Skip to content

Commit

Permalink
Merge pull request #785 from xmartlabs/fix/buttonDisabled
Browse files Browse the repository at this point in the history
fix button cell disabled state.
  • Loading branch information
mats-claassen committed May 24, 2016
2 parents 2b55aea + c036d7a commit c32e28f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions XLForm/XL/Cell/XLFormButtonCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,18 @@ -(void)update
[super update];
BOOL isDisabled = self.rowDescriptor.isDisabled;
self.textLabel.text = self.rowDescriptor.title;
BOOL notASimpleAction = self.rowDescriptor.action.viewControllerClass || [self.rowDescriptor.action.viewControllerStoryboardId length] != 0 || [self.rowDescriptor.action.viewControllerNibName length] != 0 || [self.rowDescriptor.action.formSegueIdentifier length] != 0 || self.rowDescriptor.action.formSegueClass;
self.textLabel.textAlignment = notASimpleAction ? NSTextAlignmentNatural : NSTextAlignmentCenter;
self.accessoryType = !notASimpleAction || isDisabled ? UITableViewCellAccessoryNone : UITableViewCellAccessoryDisclosureIndicator;
BOOL simpleAction = !(self.rowDescriptor.action.viewControllerClass || [self.rowDescriptor.action.viewControllerStoryboardId length] != 0 || [self.rowDescriptor.action.viewControllerNibName length] != 0 || [self.rowDescriptor.action.formSegueIdentifier length] != 0 || self.rowDescriptor.action.formSegueClass);
self.textLabel.textAlignment = !simpleAction ? NSTextAlignmentNatural : NSTextAlignmentCenter;
self.accessoryType = simpleAction || isDisabled ? UITableViewCellAccessoryNone : UITableViewCellAccessoryDisclosureIndicator;
self.editingAccessoryType = self.accessoryType;
self.selectionStyle = isDisabled ? UITableViewCellSelectionStyleNone : UITableViewCellSelectionStyleDefault;

if (!notASimpleAction){
if (simpleAction){
CGFloat red, green, blue, alpha;
[self.tintColor getRed:&red green:&green blue:&blue alpha:&alpha];
self.textLabel.textColor = [UIColor colorWithRed:red green:green blue:blue alpha:(isDisabled ? 0.3 : 1.0)];
}
else{
self.textLabel.textColor = nil;
}

self.detailTextLabel.text = self.rowDescriptor.value;
}

Expand Down

0 comments on commit c32e28f

Please sign in to comment.