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

Added ability to add, rename, move and delete selector options + option to choose selector options tint color #647

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions XLForm/XL/Cell/XLFormLeftRightSelectorCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ -(void)formDescriptorCellDidSelectedWithFormController:(XLFormViewController *)c
if (option.rightOptions){
XLFormOptionsViewController * optionsViewController = [[XLFormOptionsViewController alloc] initWithStyle:UITableViewStyleGrouped];
optionsViewController.title = option.selectorTitle;
optionsViewController.tableView.tintColor = self.rowDescriptor.selectorOptionsTintColor;
optionsViewController.rowDescriptor = self.rowDescriptor;
[controller.navigationController pushViewController:optionsViewController animated:YES];
}
Expand Down
22 changes: 19 additions & 3 deletions XLForm/XL/Cell/XLFormSelectorCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,14 @@ -(void)formDescriptorCellDidSelectedWithFormController:(XLFormViewController *)c
XLFormOptionsViewController * optionsViewController = [[XLFormOptionsViewController alloc] initWithStyle:UITableViewStyleGrouped titleHeaderSection:nil titleFooterSection:nil];
optionsViewController.rowDescriptor = self.rowDescriptor;
optionsViewController.title = self.rowDescriptor.selectorTitle;

optionsViewController.tableView.tintColor = self.rowDescriptor.selectorOptionsTintColor;
optionsViewController.editingOptionsEnabled = self.rowDescriptor.selectorOptionsEditingEnabled;
if (self.rowDescriptor.selectorOptionsEditingEnabled) {
NSAssert(![self.rowDescriptor.selectorOptionsAddNewOptionTitle isEqualToString:@""], @"selectorOptionsAddNewOptionTitle string must not be empty when selectorOptionsEditingEnabled is true");
optionsViewController.editingOptionsAddNewOptionTitle = self.rowDescriptor.selectorOptionsAddNewOptionTitle;
NSAssert(![self.rowDescriptor.selectorOptionsNewTextForOptionTitle isEqualToString:@""], @"selectorOptionsNewTextForOptionTitle string must not be empty when selectorOptionsEditingEnabled is true");
optionsViewController.editingOptionsNewTextForOptionTitle = self.rowDescriptor.selectorOptionsNewTextForOptionTitle;
}
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeSelectorPopover]) {
self.popoverController = [[UIPopoverController alloc] initWithContentViewController:optionsViewController];
self.popoverController.delegate = self;
Expand All @@ -211,11 +218,20 @@ -(void)formDescriptorCellDidSelectedWithFormController:(XLFormViewController *)c
}
else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelector] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelectorPopover])
{
NSAssert(self.rowDescriptor.selectorOptions, @"selectorOptions property shopuld not be nil");
NSAssert(self.rowDescriptor.selectorOptions, @"selectorOptions property should not be nil");
XLFormOptionsViewController * optionsViewController = [[XLFormOptionsViewController alloc] initWithStyle:UITableViewStyleGrouped titleHeaderSection:nil titleFooterSection:nil];
optionsViewController.rowDescriptor = self.rowDescriptor;
optionsViewController.title = self.rowDescriptor.selectorTitle;

optionsViewController.tableView.tintColor = self.rowDescriptor.selectorOptionsTintColor;
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelector]) {
optionsViewController.editingOptionsEnabled = self.rowDescriptor.selectorOptionsEditingEnabled;
if (self.rowDescriptor.selectorOptionsEditingEnabled) {
NSAssert(![self.rowDescriptor.selectorOptionsAddNewOptionTitle isEqualToString:@""], @"selectorOptionsAddNewOptionTitle string must not be empty when selectorOptionsEditingEnabled is true");
optionsViewController.editingOptionsAddNewOptionTitle = self.rowDescriptor.selectorOptionsAddNewOptionTitle;
NSAssert(![self.rowDescriptor.selectorOptionsNewTextForOptionTitle isEqualToString:@""], @"selectorOptionsNewTextForOptionTitle string must not be empty when selectorOptionsEditingEnabled is true");
optionsViewController.editingOptionsNewTextForOptionTitle = self.rowDescriptor.selectorOptionsNewTextForOptionTitle;
}
}
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelectorPopover]) {
self.popoverController = [[UIPopoverController alloc] initWithContentViewController:optionsViewController];
self.popoverController.delegate = self;
Expand Down
3 changes: 3 additions & 0 deletions XLForm/XL/Controllers/XLFormOptionsViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,8 @@
titleHeaderSection:(NSString *)titleHeaderSection
titleFooterSection:(NSString *)titleFooterSection;

@property (getter=isEditingEnabled, nonatomic) BOOL editingOptionsEnabled;
@property (nonatomic) NSString *editingOptionsNewTextForOptionTitle;
@property (nonatomic) NSString *editingOptionsAddNewOptionTitle;

@end
Loading