Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REActionBar Friendly advice #163

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion RETableViewManager/Cells/RETableViewCreditCardCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ static inline RECreditCardType RECreditCardTypeFromNumber(NSString *creditCardNu
return RECreditCardTypeUnknown;
}

+ (BOOL)canFocus
+ (BOOL)canFocusWithItem:(RETableViewItem *)item
{
return YES;
}
Expand Down
26 changes: 23 additions & 3 deletions RETableViewManager/Cells/RETableViewDateTimeCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,27 @@ - (void)cellWillAppear
{
self.textLabel.text = self.item.title.length == 0 ? @" " : self.item.title;
self.textField.inputView = self.datePicker;
self.datePicker.date = self.item.value ? self.item.value : (self.item.pickerStartDate ? self.item.pickerStartDate : [NSDate date]);
if (self.item.value || self.item.pickerStartDate)
{
if (self.item.value)
{
self.datePicker.date = self.item.value;
}
else if (self.item.pickerStartDate)
{
self.datePicker.date = self.item.pickerStartDate;
}
}
self.datePicker.datePickerMode = self.item.datePickerMode;
self.datePicker.locale = self.item.locale;
self.datePicker.calendar = self.item.calendar;
self.datePicker.timeZone = self.item.timeZone;
if (self.item.calendar)
{
self.datePicker.calendar = self.item.calendar;
}
if (self.item.timeZone)
{
self.datePicker.timeZone = self.item.timeZone;
}
self.datePicker.minimumDate = self.item.minimumDate;
self.datePicker.maximumDate = self.item.maximumDate;
self.datePicker.minuteInterval = self.item.minuteInterval;
Expand Down Expand Up @@ -149,7 +165,9 @@ - (void)setSelected:(BOOL)selected animated:(BOOL)animated
}
self.item.inlinePickerItem = [REInlineDatePickerItem itemWithDateTimeItem:self.item];
[self.section insertItem:self.item.inlinePickerItem atIndex:self.item.indexPath.row + 1];
[self.tableViewManager.tableView beginUpdates];
[self.tableViewManager.tableView insertRowsAtIndexPaths:@[self.item.inlinePickerItem.indexPath] withRowAnimation:UITableViewRowAnimationFade];
[self.tableViewManager.tableView endUpdates];
} else {
if (selected && self.item.inlineDatePicker && self.item.inlinePickerItem) {
[self setSelected:NO animated:NO];
Expand All @@ -158,7 +176,9 @@ - (void)setSelected:(BOOL)selected animated:(BOOL)animated
NSIndexPath *indexPath = [self.item.inlinePickerItem.indexPath copy];
[self.section removeItemAtIndex:self.item.inlinePickerItem.indexPath.row];
self.item.inlinePickerItem = nil;
[self.tableViewManager.tableView beginUpdates];
[self.tableViewManager.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
[self.tableViewManager.tableView endUpdates];
}
}
}
Expand Down
1 change: 1 addition & 0 deletions RETableViewManager/Cells/RETableViewLongTextCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ - (void)setSelected:(BOOL)selected animated:(BOOL)animated
- (void)cellWillAppear
{
[super cellWillAppear];
self.textLabel.text = @"";
self.selectionStyle = UITableViewCellSelectionStyleNone;

self.textView.editable = self.item.editable;
Expand Down
6 changes: 4 additions & 2 deletions RETableViewManager/Cells/RETableViewPickerCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,14 @@ - (void)cellDidLoad
[self.contentView addSubview:self.placeholderLabel];

self.pickerView = [[UIPickerView alloc] init];
self.pickerView.delegate = self;
self.pickerView.dataSource = self;
}

- (void)cellWillAppear
{
//TODO: i don't know why,but it's work.
//FIXME: later fix
self.pickerView.delegate = self;
self.pickerView.dataSource = self;
self.textLabel.text = self.item.title.length == 0 ? @" " : self.item.title;
self.imageView.image = self.item.image;
self.imageView.highlightedImage = self.item.highlightedImage;
Expand Down
4 changes: 2 additions & 2 deletions RETableViewManager/Cells/RETableViewSegmentedCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ - (void)cellWillAppear

if (self.item.segmentedControlTitles.count > 0) {
[self.item.segmentedControlTitles enumerateObjectsUsingBlock:^(NSString *title, NSUInteger idx, BOOL *stop) {
[self.segmentedControl insertSegmentWithTitle:title atIndex:idx animated:NO];
[myself.segmentedControl insertSegmentWithTitle:title atIndex:idx animated:NO];
}];
} else if (self.item.segmentedControlImages.count > 0) {
[self.item.segmentedControlImages enumerateObjectsUsingBlock:^(UIImage *image, NSUInteger idx, BOOL *stop) {
[self.segmentedControl insertSegmentWithImage:image atIndex:idx animated:NO];
[myself.segmentedControl insertSegmentWithImage:image atIndex:idx animated:NO];
}];
}
self.segmentedControl.tintColor = self.item.tintColor;
Expand Down
21 changes: 17 additions & 4 deletions RETableViewManager/RETableViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ @interface RETableViewCell ()

@implementation RETableViewCell

#pragma mark
#pragma mark Lazy Load

-(REActionBar *)actionBar
{
if (nil == _actionBar)
{
_actionBar = [[REActionBar alloc] initWithDelegate:self];
}
return _actionBar;
}

+ (BOOL)canFocusWithItem:(RETableViewItem *)item
{
return NO;
Expand Down Expand Up @@ -79,7 +91,6 @@ - (void)addSelectedBackgroundImage
- (void)cellDidLoad
{
self.loaded = YES;
self.actionBar = [[REActionBar alloc] initWithDelegate:self];
self.selectionStyle = self.tableViewManager.style.defaultCellSelectionStyle;

if ([self.tableViewManager.style hasCustomBackgroundImage]) {
Expand All @@ -93,7 +104,10 @@ - (void)cellDidLoad

- (void)cellWillAppear
{
[self updateActionBarNavigationControl];
if ([[self class] canFocusWithItem:self.item])
{
[self updateActionBarNavigationControl];
}
self.selectionStyle = self.section.style.defaultCellSelectionStyle;

if ([self.item isKindOfClass:[NSString class]]) {
Expand Down Expand Up @@ -292,10 +306,9 @@ - (void)actionBar:(REActionBar *)actionBar navigationControlValueChanged:(UISegm

- (void)actionBar:(REActionBar *)actionBar doneButtonPressed:(UIBarButtonItem *)doneButtonItem
{
[self endEditing:YES];
if (self.item.actionBarDoneButtonTapHandler)
self.item.actionBarDoneButtonTapHandler(self.item);

[self endEditing:YES];
}

@end