Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d5d10baa41 | |||
| 8de760e951 | |||
| 6f83343d6f | |||
| 8063c91e2d | |||
| 4fb2cb15a2 | |||
| b5b71d5ddf | |||
| 16160b431f | |||
| 2857ab3060 | |||
| 176b301087 | |||
| 51e2adc1b3 | |||
| 67daaae929 | |||
| 552624bbbf | |||
| a209c72e84 | |||
| bea831dfba |
@@ -2,7 +2,7 @@
|
||||
// AppDelegate.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// AppDelegate.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// CustomRowsViewController.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// CustomRowsViewController.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -27,11 +27,13 @@
|
||||
#import "XLFormWeekDaysCell.h"
|
||||
#import "XLFormRatingCell.h"
|
||||
#import "FloatLabeledTextFieldCell.h"
|
||||
#import "XLFormCustomCell.h"
|
||||
|
||||
static NSString * const kCustomRowFirstRatingTag = @"CustomRowFirstRatingTag";
|
||||
static NSString * const kCustomRowSecondRatingTag = @"CustomRowSecondRatingTag";
|
||||
static NSString * const kCustomRowFloatLabeledTextFieldTag = @"CustomRowFloatLabeledTextFieldTag";
|
||||
static NSString * const kCustomRowWeekdays = @"CustomRowWeekdays";
|
||||
static NSString * const kCustomRowText = @"kCustomText";
|
||||
|
||||
@implementation CustomRowsViewController
|
||||
|
||||
@@ -69,6 +71,12 @@ static NSString * const kCustomRowWeekdays = @"CustomRowWeekdays";
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:kCustomRowFloatLabeledTextFieldTag rowType:XLFormRowDescriptorTypeFloatLabeledTextField title:@"Title"];
|
||||
[section addFormRow:row];
|
||||
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:kCustomRowFloatLabeledTextFieldTag rowType:XLFormRowDescriptorTypeFloatLabeledTextField title:@"First Name"];
|
||||
[section addFormRow:row];
|
||||
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:kCustomRowFloatLabeledTextFieldTag rowType:XLFormRowDescriptorTypeFloatLabeledTextField title:@"Last Name"];
|
||||
[section addFormRow:row];
|
||||
|
||||
// Section Weekdays
|
||||
section = [XLFormSectionDescriptor formSectionWithTitle:@"Weekdays"];
|
||||
[form addFormSection:section];
|
||||
@@ -86,6 +94,15 @@ static NSString * const kCustomRowWeekdays = @"CustomRowWeekdays";
|
||||
};
|
||||
[section addFormRow:row];
|
||||
|
||||
|
||||
section = [XLFormSectionDescriptor formSection];
|
||||
[form addFormSection:section];
|
||||
|
||||
XLFormRowDescriptor *customRowDescriptor = [XLFormRowDescriptor formRowDescriptorWithTag:kCustomRowText rowType:@"XLFormRowDescriptorTypeCustom"];
|
||||
// Must set custom cell or add custom cell to cellClassesForRowDescriptorTypes dictionary before XLFormViewController loaded
|
||||
customRowDescriptor.cellClass = [XLFormCustomCell class];
|
||||
[section addFormRow:customRowDescriptor];
|
||||
|
||||
self.form = form;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// FloatLabeledTextFieldCell.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
+9
-9
@@ -1,7 +1,7 @@
|
||||
// FloatLabeledTextFieldCell.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -77,13 +77,19 @@ const static CGFloat kFloatingLabelFontSize = 11.0f;
|
||||
|
||||
self.floatLabeledTextField.attributedPlaceholder =
|
||||
[[NSAttributedString alloc] initWithString:self.rowDescriptor.title
|
||||
attributes:@{NSForegroundColorAttributeName: [UIColor darkGrayColor]}];
|
||||
attributes:@{NSForegroundColorAttributeName: [UIColor lightGrayColor]}];
|
||||
|
||||
self.floatLabeledTextField.text = self.rowDescriptor.value ? [self.rowDescriptor.value displayText] : self.rowDescriptor.noValueDisplayText;
|
||||
[self.floatLabeledTextField setEnabled:!self.rowDescriptor.disabled];
|
||||
|
||||
self.floatLabeledTextField.textColor = self.rowDescriptor.disabled ? [UIColor grayColor] : [UIColor blackColor];
|
||||
self.floatLabeledTextField.floatingLabelTextColor = [UIColor lightGrayColor];
|
||||
|
||||
[self.floatLabeledTextField setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
|
||||
}
|
||||
|
||||
-(BOOL)formDescriptorCellCanBecomeFirstResponder
|
||||
{
|
||||
return (!self.rowDescriptor.disabled);
|
||||
}
|
||||
|
||||
-(BOOL)formDescriptorCellBecomeFirstResponder
|
||||
@@ -91,12 +97,6 @@ const static CGFloat kFloatingLabelFontSize = 11.0f;
|
||||
return [self.floatLabeledTextField becomeFirstResponder];
|
||||
}
|
||||
|
||||
-(BOOL)formDescriptorCellResignFirstResponder
|
||||
{
|
||||
return [self.floatLabeledTextField resignFirstResponder];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - UITextFieldDelegate
|
||||
|
||||
- (BOOL)textFieldShouldClear:(UITextField *)textField
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// XLRatingView.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// XLRatingView.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// XLFormRatingCell.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// XLFormRatingCell.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -47,6 +47,9 @@ NSString * const XLFormRowDescriptorTypeRate = @"XLFormRowDescriptorTypeRate";
|
||||
|
||||
self.ratingView.value = [self.rowDescriptor.value floatValue];
|
||||
self.rateTitle.text = self.rowDescriptor.title;
|
||||
|
||||
[self.ratingView setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
|
||||
[self.rateTitle setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
|
||||
}
|
||||
|
||||
#pragma mark - Events
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// XLFormWeekDaysCell.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// XLFormWeekDaysCell.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -100,6 +100,14 @@ NSString *const kSaturday = @"saturday";
|
||||
self.thursdayButton.selected = [[value objectForKey:kThursday] boolValue];
|
||||
self.fridayButton.selected = [[value objectForKey:kFriday] boolValue];
|
||||
self.saturdayButton.selected = [[value objectForKey:kSaturday] boolValue];
|
||||
|
||||
[self.sundayButton setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
|
||||
[self.mondayButton setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
|
||||
[self.tuesdayButton setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
|
||||
[self.wednesdayButton setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
|
||||
[self.thursdayButton setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
|
||||
[self.fridayButton setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
|
||||
[self.saturdayButton setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
|
||||
}
|
||||
|
||||
-(NSString *)getDayFormButton:(id)sender
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// DatesFormViewController.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// DatesFormViewController.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -104,4 +104,23 @@ NSString *const kDateTime = @"dateTime";
|
||||
}
|
||||
|
||||
|
||||
-(void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
UIBarButtonItem * barButton = [[UIBarButtonItem alloc] initWithTitle:@"Disable" style:UIBarButtonItemStylePlain
|
||||
target:self
|
||||
action:@selector(disableEnable:)];
|
||||
barButton.possibleTitles = [NSSet setWithObjects:@"Disable", @"Enable", nil];
|
||||
self.navigationItem.rightBarButtonItem = barButton;
|
||||
}
|
||||
|
||||
-(void)disableEnable:(UIBarButtonItem *)button
|
||||
{
|
||||
self.form.disabled = !self.form.disabled;
|
||||
[button setTitle:(self.form.disabled ? @"Enable" : @"Disable")];
|
||||
[self.tableView endEditing:YES];
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// ExamplesFormViewController.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// ExamplesFormViewController.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -39,6 +39,9 @@ NSString * const kSelectors = @"Selectors";
|
||||
NSString * const kOthes = @"Others";
|
||||
NSString * const kDates = @"Dates";
|
||||
NSString * const kMultivalued = @"Multivalued";
|
||||
NSString * const kMultivaluedOnlyReorder = @"MultivaluedOnlyReorder";
|
||||
NSString * const kMultivaluedOnlyInsert = @"MultivaluedOnlyInsert";
|
||||
NSString * const kMultivaluedOnlyDelete = @"MultivaluedOnlyDelete";
|
||||
NSString * const kValidations= @"Validations";
|
||||
|
||||
@interface ExamplesFormViewController ()
|
||||
@@ -115,11 +118,26 @@ NSString * const kValidations= @"Validations";
|
||||
section = [XLFormSectionDescriptor formSectionWithTitle:@"Multivalued example"];
|
||||
[form addFormSection:section];
|
||||
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:kMultivalued rowType:XLFormRowDescriptorTypeButton title:@"MultiValued Sections"];
|
||||
row.action.viewControllerClass = [MultiValuedFormViewController class];
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:kMultivalued rowType:XLFormRowDescriptorTypeButton title:@"Multivalued Sections"];
|
||||
row.action.viewControllerClass = [MultivaluedFormViewController class];
|
||||
[section addFormRow:row];
|
||||
|
||||
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:kMultivaluedOnlyReorder rowType:XLFormRowDescriptorTypeButton title:@"Multivalued Only Reorder"];
|
||||
row.action.viewControllerClass = [MultivaluedOnlyReorderViewController class];
|
||||
[section addFormRow:row];
|
||||
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:kMultivaluedOnlyInsert rowType:XLFormRowDescriptorTypeButton title:@"Multivalued Only Insert"];
|
||||
row.action.viewControllerClass = [MultivaluedOnlyInserViewController class];
|
||||
[section addFormRow:row];
|
||||
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:kMultivaluedOnlyDelete rowType:XLFormRowDescriptorTypeButton title:@"Multivalued Only Delete"];
|
||||
row.action.viewControllerClass = [MultivaluedOnlyDeleteViewController class];
|
||||
[section addFormRow:row];
|
||||
|
||||
|
||||
|
||||
|
||||
section = [XLFormSectionDescriptor formSectionWithTitle:@"UI Customization"];
|
||||
[form addFormSection:section];
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// InputsFormViewController.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// InputsFormViewController.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -121,7 +121,7 @@ NSString *const kNotes = @"notes";
|
||||
}
|
||||
|
||||
|
||||
-(IBAction)savePressed:(UIBarButtonItem * __unused)button
|
||||
-(void)savePressed:(UIBarButtonItem * __unused)button
|
||||
{
|
||||
NSArray * validationErrors = [self formValidationErrors];
|
||||
if (validationErrors.count > 0){
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// MultiValuedFormViewController.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -25,6 +25,21 @@
|
||||
|
||||
#import "XLFormViewController.h"
|
||||
|
||||
@interface MultiValuedFormViewController : XLFormViewController
|
||||
@interface MultivaluedFormViewController : XLFormViewController
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface MultivaluedOnlyReorderViewController : XLFormViewController
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface MultivaluedOnlyInserViewController : XLFormViewController
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface MultivaluedOnlyDeleteViewController : XLFormViewController
|
||||
|
||||
@end
|
||||
|
||||
+192
-50
@@ -2,7 +2,7 @@
|
||||
// MultiValuedFormViewController.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -28,7 +28,7 @@
|
||||
#import "MultiValuedFormViewController.h"
|
||||
|
||||
|
||||
@implementation MultiValuedFormViewController
|
||||
@implementation MultivaluedFormViewController
|
||||
|
||||
- (id)init
|
||||
{
|
||||
@@ -36,61 +36,41 @@
|
||||
XLFormSectionDescriptor * section;
|
||||
XLFormRowDescriptor * row;
|
||||
|
||||
NSArray * nameList = @[@"family", @"male", @"female", @"client"];
|
||||
form = [XLFormDescriptor formDescriptorWithTitle:@"Multivalued Examples"];
|
||||
|
||||
|
||||
form = [XLFormDescriptor formDescriptorWithTitle:@"MultiValued Examples"];
|
||||
|
||||
// MultivaluedSection section
|
||||
section = [XLFormSectionDescriptor formSectionWithTitle:@"MultiValued TextField" multivaluedSection:YES];
|
||||
section.multiValuedTag = @"textFieldRow";
|
||||
// Multivalued section
|
||||
section = [XLFormSectionDescriptor formSectionWithTitle:@"Multivalued TextField"
|
||||
sectionOptions:XLFormSectionOptionCanReorder | XLFormSectionOptionCanInsert | XLFormSectionOptionCanDelete
|
||||
sectionInsertMode:XLFormSectionInsertModeButton];
|
||||
section.multivaluedAddButton.title = @"Add New Tag";
|
||||
section.footerTitle = @"XLFormSectionInsertModeButton sectionType adds a 'Add Item' (Add New Tag) button row as last cell.";
|
||||
// set up the row template
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeName];
|
||||
[[row cellConfig] setObject:@"Tag Name" forKey:@"textField.placeholder"];
|
||||
section.multivaluedRowTemplate = row;
|
||||
[form addFormSection:section];
|
||||
|
||||
|
||||
for (NSString * tag in nameList) {
|
||||
// add a row to the section, the row will be used to crete new rows.
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeText];
|
||||
[[row cellConfig] setObject:@"Add a new tag" forKey:@"textField.placeholder"];
|
||||
row.value = [tag copy];
|
||||
[section addFormRow:row];
|
||||
}
|
||||
// add a row to the section, the row will be used to crete new rows.
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeText];
|
||||
[[row cellConfig] setObject:@"Add a new tag" forKey:@"textField.placeholder"];
|
||||
[section addFormRow:row];
|
||||
|
||||
// Another MultivaluedSection section
|
||||
section = [XLFormSectionDescriptor formSectionWithTitle:@"MultiValued ActionSheet Selector example" multivaluedSection:YES];
|
||||
section.multiValuedTag = @"actionSheetSelector";
|
||||
// Another Multivalued section
|
||||
section = [XLFormSectionDescriptor formSectionWithTitle:@"Multivalued ActionSheet Selector example"
|
||||
sectionOptions:XLFormSectionOptionCanInsert | XLFormSectionOptionCanDelete];
|
||||
section.footerTitle = @"XLFormSectionInsertModeLastRow sectionType adds a '+' icon inside last table view cell allowing us to add a new row.";
|
||||
[form addFormSection:section];
|
||||
|
||||
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeSelectorActionSheet title:@"Tap to select.."];
|
||||
row.selectorOptions = @[[XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:@"Option 1"],
|
||||
[XLFormOptionsObject formOptionsObjectWithValue:@(1) displayText:@"Option 2"],
|
||||
[XLFormOptionsObject formOptionsObjectWithValue:@(2) displayText:@"Option 3"],
|
||||
[XLFormOptionsObject formOptionsObjectWithValue:@(3) displayText:@"Option 4"],
|
||||
[XLFormOptionsObject formOptionsObjectWithValue:@(4) displayText:@"Option 5"]
|
||||
];
|
||||
row.selectorOptions = @[@"Option 1", @"Option 2", @"Option 3", @"Option 4", @"Option 5"];
|
||||
[section addFormRow:row];
|
||||
|
||||
|
||||
|
||||
// Another one
|
||||
section = [XLFormSectionDescriptor formSectionWithTitle:@"MultiValued Push Selector example" multivaluedSection:YES];
|
||||
section.footerTitle = @"MultiValuedFormViewController.h";
|
||||
section.multiValuedTag = @"multivaluedPushSelector";
|
||||
section = [XLFormSectionDescriptor formSectionWithTitle:@"Multivalued Push Selector example"
|
||||
sectionOptions:XLFormSectionOptionCanInsert | XLFormSectionOptionCanDelete | XLFormSectionOptionCanReorder
|
||||
sectionInsertMode:XLFormSectionInsertModeButton];
|
||||
section.footerTitle = @"MultivaluedFormViewController.h";
|
||||
[form addFormSection:section];
|
||||
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeSelectorPush title:@"Tap to select ;).."];
|
||||
row.selectorOptions = @[[XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:@"Option 1"],
|
||||
[XLFormOptionsObject formOptionsObjectWithValue:@(1) displayText:@"Option 2"],
|
||||
[XLFormOptionsObject formOptionsObjectWithValue:@(2) displayText:@"Option 3"]
|
||||
];
|
||||
row.selectorOptions = @[@"Option 1", @"Option 2", @"Option 3"];
|
||||
section.multivaluedRowTemplate = [row copy];
|
||||
[section addFormRow:row];
|
||||
|
||||
|
||||
|
||||
return [super initWithForm:form];
|
||||
}
|
||||
|
||||
@@ -105,7 +85,7 @@
|
||||
|
||||
-(void)addDidTouch:(UIBarButtonItem * __unused)sender
|
||||
{
|
||||
UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Remove Last Section" otherButtonTitles:@"Add a section at the end", nil];
|
||||
UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Remove Last Section" otherButtonTitles:@"Add a section at the end", self.form.isDisabled ? @"Enable Form" : @"Disable Form", nil];
|
||||
[actionSheet showInView:self.view];
|
||||
|
||||
}
|
||||
@@ -122,15 +102,177 @@
|
||||
}
|
||||
else if ([[actionSheet buttonTitleAtIndex:buttonIndex] isEqualToString:@"Add a section at the end"]){
|
||||
// add a new section
|
||||
XLFormSectionDescriptor * newSection = [XLFormSectionDescriptor formSectionWithTitle:[NSString stringWithFormat:@"Section created at %@", [NSDateFormatter localizedStringFromDate:[NSDate new] dateStyle:NSDateFormatterShortStyle timeStyle:NSDateFormatterShortStyle]] multivaluedSection:YES];
|
||||
newSection.multiValuedTag = [NSString stringWithFormat:@"multivaluedPushSelector_%@", @(self.form.formSections.count)];
|
||||
XLFormSectionDescriptor * newSection = [XLFormSectionDescriptor formSectionWithTitle:[NSString stringWithFormat:@"Section created at %@", [NSDateFormatter localizedStringFromDate:[NSDate new] dateStyle:NSDateFormatterShortStyle timeStyle:NSDateFormatterShortStyle]] sectionOptions:XLFormSectionOptionCanInsert | XLFormSectionOptionCanDelete];
|
||||
newSection.multivaluedTag = [NSString stringWithFormat:@"multivaluedPushSelector_%@", @(self.form.formSections.count)];
|
||||
XLFormRowDescriptor * newRow = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeSelectorPush title:@"Tap to select ;).."];
|
||||
newRow.selectorOptions = @[[XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:@"Option 1"],
|
||||
[XLFormOptionsObject formOptionsObjectWithValue:@(1) displayText:@"Option 2"],
|
||||
[XLFormOptionsObject formOptionsObjectWithValue:@(2) displayText:@"Option 3"]];
|
||||
newRow.selectorOptions = @[@"Option 1", @"Option 2", @"Option 3"];
|
||||
[newSection addFormRow:newRow];
|
||||
[self.form addFormSection:newSection];
|
||||
}
|
||||
else {
|
||||
self.form.disabled = !self.form.disabled;
|
||||
[self.tableView endEditing:YES];
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation MultivaluedOnlyReorderViewController
|
||||
|
||||
- (id)init
|
||||
{
|
||||
NSTimeInterval secondsPerDay = 24 * 60 * 60;
|
||||
NSArray * list = @[@"Today", @"Yesterday", @"Before Yesterday"];
|
||||
XLFormDescriptor * form;
|
||||
XLFormSectionDescriptor * section;
|
||||
|
||||
|
||||
form = [XLFormDescriptor formDescriptorWithTitle:@"Only Reorder Examples"];
|
||||
|
||||
|
||||
// Multivalued Section with inline rows - section set up to support only reordering
|
||||
section = [XLFormSectionDescriptor formSectionWithTitle:@"Reordering Inline Rows"
|
||||
sectionOptions:XLFormSectionOptionCanReorder];
|
||||
section.footerTitle = @"XLFormRowDescriptorTypeDateInline row type";
|
||||
[form addFormSection:section];
|
||||
|
||||
[list enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||
XLFormRowDescriptor * row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeDateInline];
|
||||
row.value = [NSDate dateWithTimeIntervalSinceNow:(-secondsPerDay * idx)];
|
||||
row.title = obj;
|
||||
[section addFormRow:row];
|
||||
}];
|
||||
|
||||
|
||||
// Multivalued Section with common rows - section set up to support only reordering
|
||||
section = [XLFormSectionDescriptor formSectionWithTitle:@"Reordering Rows"
|
||||
sectionOptions:XLFormSectionOptionCanReorder];
|
||||
section.footerTitle = @"XLFormRowDescriptorTypeInfo row type";
|
||||
[form addFormSection:section];
|
||||
|
||||
|
||||
[list enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||
XLFormRowDescriptor * row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeInfo];
|
||||
row.value = [NSDateFormatter localizedStringFromDate:[NSDate dateWithTimeIntervalSinceNow:(-secondsPerDay * idx)] dateStyle:NSDateFormatterMediumStyle timeStyle:NSDateFormatterNoStyle];
|
||||
row.title = obj;
|
||||
[section addFormRow:row];
|
||||
}];
|
||||
|
||||
return [super initWithForm:form];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation MultivaluedOnlyInserViewController
|
||||
|
||||
- (id)init
|
||||
{
|
||||
XLFormDescriptor * form;
|
||||
XLFormSectionDescriptor * section;
|
||||
XLFormRowDescriptor * row;
|
||||
|
||||
NSArray * nameList = @[@"family", @"male", @"female", @"client"];
|
||||
|
||||
|
||||
form = [XLFormDescriptor formDescriptorWithTitle:@"Multivalued Only Insert"];
|
||||
|
||||
|
||||
section = [XLFormSectionDescriptor formSectionWithTitle:@"XLFormSectionInsertModeButton"
|
||||
sectionOptions:XLFormSectionOptionCanInsert
|
||||
sectionInsertMode:XLFormSectionInsertModeButton];
|
||||
[form addFormSection:section];
|
||||
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeText];
|
||||
[[row cellConfig] setObject:@"Add a new tag" forKey:@"textField.placeholder"];
|
||||
section.multivaluedRowTemplate = row;
|
||||
|
||||
|
||||
section = [XLFormSectionDescriptor formSectionWithTitle:@"XLFormSectionInsertModeButton With Inline Cells"
|
||||
sectionOptions:XLFormSectionOptionCanInsert
|
||||
sectionInsertMode:XLFormSectionInsertModeButton];
|
||||
[form addFormSection:section];
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeDateInline];
|
||||
row.value = [NSDate new];
|
||||
row.title = @"Date";
|
||||
section.multivaluedRowTemplate = row;
|
||||
|
||||
|
||||
section = [XLFormSectionDescriptor formSectionWithTitle:@"XLFormSectionInsertModeLastRow"
|
||||
sectionOptions:XLFormSectionOptionCanInsert
|
||||
sectionInsertMode:XLFormSectionInsertModeLastRow];
|
||||
[form addFormSection:section];
|
||||
for (NSString * tag in nameList) {
|
||||
// add a row to the section, the row will be used to crete new rows.
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeText];
|
||||
[[row cellConfig] setObject:@"Add a new tag" forKey:@"textField.placeholder"];
|
||||
row.value = tag;
|
||||
[section addFormRow:row];
|
||||
}
|
||||
|
||||
return [super initWithForm:form];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation MultivaluedOnlyDeleteViewController
|
||||
|
||||
- (id)init
|
||||
{
|
||||
XLFormDescriptor * form;
|
||||
XLFormSectionDescriptor * section;
|
||||
XLFormRowDescriptor * row;
|
||||
|
||||
NSArray * nameList = @[@"family", @"male", @"female", @"client"];
|
||||
|
||||
|
||||
form = [XLFormDescriptor formDescriptor];
|
||||
|
||||
// MultivaluedSection section
|
||||
section = [XLFormSectionDescriptor formSectionWithTitle:@""
|
||||
sectionOptions:XLFormSectionOptionCanDelete];
|
||||
section.footerTitle = @"you can swipe to delete when table.editing = NO (Not Editing)";
|
||||
[form addFormSection:section];
|
||||
|
||||
for (NSString * tag in nameList) {
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeText];
|
||||
[[row cellConfig] setObject:@"Add a new tag" forKey:@"textField.placeholder"];
|
||||
row.value = [tag copy];
|
||||
[section addFormRow:row];
|
||||
}
|
||||
|
||||
// Multivalued Section with inline row.
|
||||
section = [XLFormSectionDescriptor formSectionWithTitle:@""
|
||||
sectionOptions:XLFormSectionOptionCanDelete];
|
||||
section.footerTitle = @"you can swipe to delete when table.editing = NO (Not Editing)";
|
||||
[form addFormSection:section];
|
||||
for (NSUInteger i = 0; i < 4; i++) {
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeSelectorPickerViewInline];
|
||||
row.title = @"Tap to select";
|
||||
row.value = @"client";
|
||||
row.selectorOptions = nameList;
|
||||
[section addFormRow:row];
|
||||
}
|
||||
|
||||
return [super initWithForm:form];
|
||||
}
|
||||
|
||||
|
||||
-(void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Editing" style:UIBarButtonItemStylePlain target:self action:@selector(toggleEditing:)];
|
||||
}
|
||||
|
||||
|
||||
-(void)toggleEditing:(UIBarButtonItem *)barButtonItem
|
||||
{
|
||||
[self.tableView setEditing:!self.tableView.editing animated:YES];
|
||||
[barButtonItem setTitle:(self.tableView.editing ? @"Editing" : @"Not Editing")];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 5.1 MiB |
@@ -2,7 +2,7 @@
|
||||
// XLFormCustomCell.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormCustomCell.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -30,23 +30,20 @@
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self) {
|
||||
// Initialization code
|
||||
|
||||
// Initialization code
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)configure
|
||||
{
|
||||
[super configure];
|
||||
//override
|
||||
UIFont *labelFont = [UIFont preferredFontForTextStyle:UIFontTextStyleCaption1];
|
||||
UIFontDescriptor *fontDesc = [labelFont fontDescriptor];
|
||||
UIFontDescriptor *fontBoldDesc = [fontDesc fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitBold];
|
||||
self.textLabel.font = [UIFont fontWithDescriptor:fontBoldDesc size:0.0f];
|
||||
}
|
||||
|
||||
- (void)update
|
||||
{
|
||||
[super update];
|
||||
// override
|
||||
self.textLabel.text = @"Am a custom cell, select me!";
|
||||
}
|
||||
@@ -55,54 +52,9 @@
|
||||
{
|
||||
// custom code here
|
||||
// i.e new behaviour when cell has been selected
|
||||
self.textLabel.text = @"I can do any custom behaviour...";
|
||||
self.textLabel.text = [self.textLabel.text isEqualToString:@"I can do any custom behaviour..."] ? @"Am a custom cell, select me!" : @"I can do any custom behaviour...";
|
||||
self.rowDescriptor.value = self.textLabel.text;
|
||||
[self.formViewController.tableView selectRowAtIndexPath:nil animated:YES scrollPosition:UITableViewScrollPositionNone];
|
||||
}
|
||||
|
||||
/*
|
||||
+(CGFloat)formDescriptorCellHeightForRowDescriptor:(XLFormRowDescriptor *)rowDescriptor
|
||||
{
|
||||
// return custom cell size
|
||||
return 40;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
-(BOOL)formDescriptorCellBecomeFirstResponder
|
||||
{
|
||||
// custom code
|
||||
return YES;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
-(NSError *)formDescriptorCellLocalValidation
|
||||
{
|
||||
// custom error handler
|
||||
// compare with a custom property if it should return a error
|
||||
// i.e some textfield is empty etc...
|
||||
if (self.rowDescriptor.required){
|
||||
return [[NSError alloc] initWithDomain:XLFormErrorDomain code:XLFormErrorCodeRequired userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedString(@"%@ can't be empty", nil), self.rowDescriptor.title] }];
|
||||
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
-(NSString *)formDescriptorHttpParameterName
|
||||
{
|
||||
// custom code
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
// Only override drawRect: if you perform custom drawing.
|
||||
// An empty implementation adversely affects performance during animation.
|
||||
- (void)drawRect:(CGRect)rect
|
||||
{
|
||||
// Drawing code
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormImageSelectorCell.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormImageSelectorCell.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -82,7 +82,6 @@ NSString *const kFormImageSelectorCellImageRequest = @"imageRequest";
|
||||
NSLog(@"Failed to download image");
|
||||
}];
|
||||
}
|
||||
[self.textLabel setFont:[UIFont preferredFontForTextStyle:UIFontTextStyleBody]];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// OthersFormViewController.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// OthersFormViewController.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -25,7 +25,6 @@
|
||||
|
||||
#import "MapViewController.h"
|
||||
#import "OthersFormViewController.h"
|
||||
#import "XLFormCustomCell.h"
|
||||
|
||||
NSString *const kSwitchBool = @"switchBool";
|
||||
NSString *const kSwitchCheck = @"switchBool";
|
||||
@@ -97,12 +96,7 @@ NSString *const kButtonWithStoryboardId = @"buttonWithStoryboardId";
|
||||
[row.cellConfigAtConfigure setObject:@(4) forKey:@"steps"];
|
||||
[section addFormRow:row];
|
||||
|
||||
// Custom cell
|
||||
XLFormRowDescriptor *customRowDescriptor = [XLFormRowDescriptor formRowDescriptorWithTag:kCustom rowType:@"XLFormRowDescriptorTypeCustom"];
|
||||
// Must set custom cell or add custom cell to cellClassesForRowDescriptorTypes dictionary before XLFormViewController loaded
|
||||
customRowDescriptor.cellClass = [XLFormCustomCell class];
|
||||
[section addFormRow:customRowDescriptor];
|
||||
|
||||
|
||||
// Info cell
|
||||
XLFormRowDescriptor *infoRowDescriptor = [XLFormRowDescriptor formRowDescriptorWithTag:kInfo rowType:XLFormRowDescriptorTypeInfo];
|
||||
infoRowDescriptor.title = @"Version";
|
||||
@@ -172,4 +166,23 @@ NSString *const kButtonWithStoryboardId = @"buttonWithStoryboardId";
|
||||
[self deselectFormRow:sender];
|
||||
}
|
||||
|
||||
-(void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
UIBarButtonItem * barButton = [[UIBarButtonItem alloc] initWithTitle:@"Disable" style:UIBarButtonItemStylePlain
|
||||
target:self
|
||||
action:@selector(disableEnable:)];
|
||||
barButton.possibleTitles = [NSSet setWithObjects:@"Disable", @"Enable", nil];
|
||||
self.navigationItem.rightBarButtonItem = barButton;
|
||||
}
|
||||
|
||||
-(void)disableEnable:(UIBarButtonItem *)button
|
||||
{
|
||||
self.form.disabled = !self.form.disabled;
|
||||
[button setTitle:(self.form.disabled ? @"Enable" : @"Disable")];
|
||||
[self.tableView endEditing:YES];
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// NativeEventNavigationViewController.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// NativeEventNavigationViewController.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -74,13 +74,13 @@
|
||||
XLFormRowDescriptor * row;
|
||||
|
||||
form = [XLFormDescriptor formDescriptorWithTitle:@"Add Event"];
|
||||
|
||||
section = [XLFormSectionDescriptor formSection];
|
||||
[form addFormSection:section];
|
||||
|
||||
// Title
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"title" rowType:XLFormRowDescriptorTypeText];
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"Title" rowType:XLFormRowDescriptorTypeText];
|
||||
[row.cellConfigAtConfigure setObject:@"Title" forKey:@"textField.placeholder"];
|
||||
row.required = YES;
|
||||
[section addFormRow:row];
|
||||
|
||||
// Location
|
||||
@@ -241,13 +241,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
-(IBAction)cancelPressed:(UIBarButtonItem * __unused)button
|
||||
-(void)cancelPressed:(UIBarButtonItem * __unused)button
|
||||
{
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
|
||||
|
||||
-(IBAction)savePressed:(UIBarButtonItem * __unused)button
|
||||
-(void)savePressed:(UIBarButtonItem * __unused)button
|
||||
{
|
||||
NSArray * validationErrors = [self formValidationErrors];
|
||||
if (validationErrors.count > 0){
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// CustomSelectorsFormViewController.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// CustomSelectorsFormViewController.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// CLLocationValueTrasformer.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// CLLocationValueTrasformer.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// MapViewController.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// MapViewController.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// DynamicSelectorsFormViewController.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// DynamicSelectorsFormViewController.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// UsersTableViewController.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// UsersTableViewController.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// CoreDataStore.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// CoreDataStore.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// User+Additions.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// User+Additions.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// User.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// User.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// UserLocalDataLoader.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// UserLocalDataLoader.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// UserRemoteDataLoader.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// UserRemoteDataLoader.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// HTTPSessionManager.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// HTTPSessionManager.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SelectorsFormViewController.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SelectorsFormViewController.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -392,4 +392,24 @@ NSString *const kSelectorWithStoryboardId = @"selectorWithStoryboardId";
|
||||
}
|
||||
|
||||
|
||||
-(void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
UIBarButtonItem * barButton = [[UIBarButtonItem alloc] initWithTitle:@"Disable" style:UIBarButtonItemStylePlain
|
||||
target:self
|
||||
action:@selector(disableEnable:)];
|
||||
barButton.possibleTitles = [NSSet setWithObjects:@"Disable", @"Enable", nil];
|
||||
self.navigationItem.rightBarButtonItem = barButton;
|
||||
}
|
||||
|
||||
-(void)disableEnable:(UIBarButtonItem *)button
|
||||
{
|
||||
self.form.disabled = !self.form.disabled;
|
||||
[button setTitle:(self.form.disabled ? @"Enable" : @"Disable")];
|
||||
[self.tableView endEditing:YES];
|
||||
[self.tableView reloadData];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// UICustomizationFormViewController.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// UICustomizationFormViewController.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// ValidationExamplesFormViewController.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// ValidationExamplesFormViewController.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -55,8 +55,8 @@
|
||||
/* Begin PBXFileReference section */
|
||||
281E5BE719538F4A006D93C5 /* CLLocationValueTrasformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CLLocationValueTrasformer.h; path = Examples/Selectors/CustomSelectors/XLFormRowViewController/CLLocationValueTrasformer.h; sourceTree = "<group>"; };
|
||||
281E5BE819538F4A006D93C5 /* CLLocationValueTrasformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CLLocationValueTrasformer.m; path = Examples/Selectors/CustomSelectors/XLFormRowViewController/CLLocationValueTrasformer.m; sourceTree = "<group>"; };
|
||||
282EB27A1AB5FF33004A736F /* AccessoryViewFormViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AccessoryViewFormViewController.h; path = AccessoryViews/AccessoryViewFormViewController.h; sourceTree = "<group>"; };
|
||||
282EB27B1AB5FF33004A736F /* AccessoryViewFormViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AccessoryViewFormViewController.m; path = AccessoryViews/AccessoryViewFormViewController.m; sourceTree = "<group>"; };
|
||||
282EB27A1AB5FF33004A736F /* AccessoryViewFormViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AccessoryViewFormViewController.h; path = Examples/AccessoryViews/AccessoryViewFormViewController.h; sourceTree = "<group>"; };
|
||||
282EB27B1AB5FF33004A736F /* AccessoryViewFormViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AccessoryViewFormViewController.m; path = Examples/AccessoryViews/AccessoryViewFormViewController.m; sourceTree = "<group>"; };
|
||||
283B59B019532415000828CD /* MapViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MapViewController.h; path = Examples/Selectors/CustomSelectors/XLFormRowViewController/MapViewController.h; sourceTree = "<group>"; };
|
||||
283B59B119532415000828CD /* MapViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MapViewController.m; path = Examples/Selectors/CustomSelectors/XLFormRowViewController/MapViewController.m; sourceTree = "<group>"; };
|
||||
283B59B5195334AF000828CD /* CustomSelectorsFormViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CustomSelectorsFormViewController.h; path = Examples/Selectors/CustomSelectors/CustomSelectorsFormViewController.h; sourceTree = "<group>"; };
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
XLForm
|
||||
|
||||
Created by Martin Barreto on 4/4/14.
|
||||
Copyright (c) 2014 Xmartlabs. All rights reserved.
|
||||
Copyright (c) 2015 Xmartlabs. All rights reserved.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// main.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs. All rights reserved.
|
||||
// Copyright (c) 2015 Xmartlabs. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@@ -12,7 +12,7 @@ XLForm is the most flexible and powerful iOS library to create dynamic table-vie
|
||||
|
||||
XLForm provides a very powerful DSL used to create a form. It keeps track of this specification on runtime, updating the UI on the fly.
|
||||
|
||||
#####Let's see the iOS 7 Calendar Event Form created using XLForm
|
||||
#####Let's see the iOS Calendar Event Form created using XLForm
|
||||
|
||||
|
||||

|
||||
@@ -23,12 +23,14 @@ What XLForm does
|
||||
|
||||
* Loads a form based on a declarative [*form definition*](#how-to-create-a-form "form definition").
|
||||
* Keeps track of definition changes on runtime to update the form interface accordingly. Further information on [*Dynamic Forms*](#dynamic-forms---how-to-change-the-form-dynamically-at-runtime "Dynamic Forms") section of this readme.
|
||||
* Supports multivalued sections. For further details see [*Multivalued Sections*](#multivalued-sections "Multivalued Sections") section bellow.
|
||||
* Supports multivalued sections allowing us to create, delete or reorder rows. For further details see [*Multivalued Sections*](#multivalued-sections "Multivalued Sections") section bellow.
|
||||
* Supports [*custom rows definition*](#how-to-create-a-custom-row).
|
||||
* Supports custom selectors. For further details of how to define your own selectors check [*Custom selectors*](#custom-selectors---selector-row-with-a-custom-selector-view-controller "Custom Selectors") section out.
|
||||
* Provides several inline selectors such as date picker and picker inline selectors and brings a way to create custom inline selectors.
|
||||
* Validates the form data based on form definition and shows error messages.
|
||||
* Changes the firstResponder among `UITextField`s and `UITextView`s when keyboard return button is pressed.
|
||||
* Form data validation based on form definition.
|
||||
* Ability to easily navigate among rows, fully customizable. * Ability to show inputAccessoryView if needed. By default a navigation input accessory view is shown.
|
||||
* Read only mode for a particular row or the entire form.
|
||||
|
||||
|
||||
|
||||
How to create a form
|
||||
@@ -44,7 +46,7 @@ To define a form we use 3 classes:
|
||||
|
||||
A form definition is a `XLFormDescriptor` instance that contains one or more sections (`XLFormSectionDescriptor` instances) and each section contains several rows (`XLFormRowDescriptor` instance). As you may have noticed the DSL structure is analog to the structure of a `UITableView` (Table -->> Sections -- >> Rows). The resulting table-view form's structure (sections and rows order) mirrors the definition's structure.
|
||||
|
||||
#####Let's see part of the iOS 7 Calendar Event Form definition.
|
||||
#####Let's see part of the iOS Calendar Event Form definition.
|
||||
|
||||
|
||||
```objc
|
||||
@@ -92,8 +94,9 @@ How to run XLForm examples
|
||||
---------------------------------
|
||||
|
||||
1. Clone the repository `git@github.com:xmartlabs/XLForm.git`. Optionally you can fork the repository and clone it from your own github account, this approach would be better in case you want to contribute.
|
||||
2. Install cocoapod dependencies of example project. From the root folder of the cloned XLForm repository run `pod install`.
|
||||
3. Open XLForm workspace using XCode and run the project. Enjoy!
|
||||
2. Move to either the Objective-c or Swift [example folder](/Examples).
|
||||
3. Install example project cocoapod dependencies. From inside Objective-c or Swift example folder run `pod install`.
|
||||
4. Open XLForm or SwiftExample workspace using XCode and run the project. Enjoy!
|
||||
|
||||
|
||||
|
||||
@@ -210,20 +213,18 @@ static NSString *const XLFormRowDescriptorTypeMultipleSelector = @"multipleSelec
|
||||
```
|
||||
|
||||
|
||||
Normally we will have a collection of object to select (these objects should have a string to display them and a value in order to serialize them), XLForm has to be able to display these objects as well as to be able to create the object HTTP parameter properly.
|
||||
Normally we will have a collection of object to select (these objects should have a string to display them and a value in order to serialize them), XLForm has to be able to display these objects.
|
||||
|
||||
XLForm follows the following rules to display an object:
|
||||
|
||||
1. If the object is a `NSString` or `NSNumber` it uses the object `description` property.
|
||||
2. If the object conforms to protocol `XLFormOptionObject`, XLForm gets the display value from `formDisplayText` method.
|
||||
3. Otherwise it return nil. That means you should conforms the protocol `:)`.
|
||||
1. If the value of the `XLFormRowDescriptor` object is nil, XLForm uses the `noValueDisplayText` row property as display text.
|
||||
2. If the XLFormRowDescriptor instance has a `valueTransformer` property value. XLForm uses the `NSValueTransformer` to convert the selected object to a NSString.
|
||||
3. If the object is a `NSString` or `NSNumber` it uses the object `description` property.
|
||||
4. If the object conforms to protocol `XLFormOptionObject`, XLForm gets the display value from `formDisplayText` method.
|
||||
5. Otherwise it return nil. That means you should conforms the protocol `:)`.
|
||||
|
||||
|
||||
XLForm follows the following rules to get the option value:
|
||||
|
||||
1. If the object is a `NSString`, `NSNumber` or `NSDate` it uses the object itself as the option value.
|
||||
2. If the object conforms to protocol `XLFormOptionObject`, XLForm gets the option value from `formValue` method.
|
||||
3. Otherwise it return nil. That means you should conforms the protocol :).
|
||||
You may be interested in change the display text either by setting up `noValueDisplayText` or `valueTransformer` property or making the selector options objects to conform to `XLFormOptionObject` protocol.
|
||||
|
||||
|
||||
This is the protocol declaration:
|
||||
@@ -315,7 +316,7 @@ static NSString *const XLFormRowDescriptorTypeBooleanCheck = @"booleanCheck";
|
||||
static NSString *const XLFormRowDescriptorTypeBooleanSwitch = @"booleanSwitch";
|
||||
```
|
||||
|
||||
We can also simulate other types of Boolean rows using any of the Selector Row Types introduced in the Selector Rows section.
|
||||
We can also simulate other types of Boolean rows using any of the Selector Row Types introduced in the [Selector Rows section](#selector-rows).
|
||||
|
||||
|
||||
####Other Rows
|
||||
@@ -351,24 +352,44 @@ You can adjust the slider for your own interests very easily:
|
||||
|
||||
Set `steps` to `@(0)` to disable the steps functionality.
|
||||
|
||||
Multivalued Sections
|
||||
#####Info
|
||||
|
||||
Sometimes our apps needs to show data that are not editable. XLForm provides us with `XLFormRowDescriptorTypeInfo` row type to display not editable info. An example of usage would be showing the app version in the settings part of an app.
|
||||
|
||||
#####Button
|
||||
|
||||
Apart from data entry rows, not editable rows and selectors, XLForm has a button row `XLFormRowDescriptorTypeButton` that allows us to do any action when selected. It can be configured using a block (clousure), a selector, a segue identifier, segue class or specifing a view controller to be presented. ViewController specification could be done by setting up the view controller class, the view controller storyboard Id or a nib name. Nib name must match view controller class name.
|
||||
|
||||
|
||||
Multivalued Sections (Insert, Delete, Reorder rows)
|
||||
------------------------
|
||||
|
||||
Any `XLFormSectionDescriptor` could be set up to support multivalued rows. Multivalued Sections let the user enter multiple values (of the same type) for a field by adding or removing rows.
|
||||
The most interesting part of multivalued `XLFormSectionDescriptor` is that it supports all the types of rows that were shown on the [*Rows*](#rows "Rows") section.
|
||||
Any `XLFormSectionDescriptor` object can be set up to support row insertion, deletion or reodering. It is possible to enable only one of these modes, a combination or all together.
|
||||
A multivalued section is just a section that support either of these modes.
|
||||
|
||||
The most interesting part of multivalued `XLFormSectionDescriptor` is that it supports all the types of rows that were shown on the [*Rows*](#rows "Rows") section as well as custom rows.
|
||||
|
||||

|
||||
|
||||
|
||||
### How to set up a multivalued section
|
||||
|
||||
To create a multivalued section we should set `YES` to the `isMultivaluedSection` property of `XLFormSectionDescriptor`. We can also do that creating the `XLFormSectionDescriptor` instance using the this alternative constructor:
|
||||
Creating a multivalued section is as simple as use one of the following convenience `XLFormSectionDescriptor` initializer:
|
||||
|
||||
```objc
|
||||
+(id)formSectionWithTitle:(NSString *)title multivaluedSection:(BOOL)multivaluedSection;
|
||||
+(id)formSectionWithTitle:(NSString *)title
|
||||
sectionOptions:(XLFormSectionOptions)sectionOptions;
|
||||
+(id)formSectionWithTitle:(NSString *)title
|
||||
sectionOptions:(XLFormSectionOptions)sectionOptions
|
||||
sectionInsertMode:(XLFormSectionInsertMode)sectionInsertMode;
|
||||
```
|
||||
|
||||
We have also to set up the `multiValuedTag` property. `multiValuedTag` will be used to create the HTTP parameter key for the collection of values (rows added to the section).
|
||||
`sectionOptions` is a bitwise enum parameter that should be used to choose the multivalued section type/s (insert, delete, reorder). Available options are `XLFormSectionOptionCanInsert`, `XLFormSectionOptionCanDelete`, `XLFormSectionOptionCanReorder`. `XLFormSectionOptionNone` is the value used by default.
|
||||
|
||||
`sectionInsertMode` can be used to select how the insertion mode will look like. `XLform` has 2 different insertion modes out of the box: `XLFormSectionInsertModeLastRow` and `XLFormSectionInsertModeButton`. `XLFormSectionInsertModeLastRow` is the default value.
|
||||
|
||||
|
||||
**Let's see how to create a multivalued section**
|
||||
|
||||
```objc
|
||||
XLFormDescriptor * form;
|
||||
@@ -379,15 +400,17 @@ NSArray * nameList = @[@"family", @"male", @"female", @"client"];
|
||||
|
||||
form = [XLFormDescriptor formDescriptorWithTitle:@"Multivalued examples"];
|
||||
|
||||
// MultivaluedSection section
|
||||
section = [XLFormSectionDescriptor formSectionWithTitle:@"MultiValued TextField" multivaluedSection:YES];
|
||||
section.multiValuedTag = @"textFieldRow";
|
||||
// Enable Insertion, Deletion, Reordering
|
||||
section = [XLFormSectionDescriptor formSectionWithTitle:@"MultiValued TextField"
|
||||
sectionOptions:XLFormSectionOptionCanReorder | XLFormSectionOptionCanInsert | XLFormSectionOptionCanDelete];
|
||||
section.multivaluedTag = @"textFieldRow";
|
||||
[form addFormSection:section];
|
||||
|
||||
for (NSString * tag in nameList) {
|
||||
// add a row to the section, each row will represent a name of the name list array.
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeText title:nil];
|
||||
[[row cellConfig] setObject:@"Add a new tag" forKey:@"textField.placeholder"];row.value = [tag copy];
|
||||
[[row cellConfig] setObject:@"Add a new tag" forKey:@"textField.placeholder"];
|
||||
row.value = [tag copy];
|
||||
[section addFormRow:row];
|
||||
}
|
||||
// add an empty row to the section.
|
||||
@@ -397,84 +420,90 @@ row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescrip
|
||||
```
|
||||
|
||||
|
||||
|
||||
Form Values
|
||||
------------------------
|
||||
|
||||
#### formValues
|
||||
|
||||
You can get all form values invoking `-(NSDictionary *)formValues;` to either `XLFormViewController` instance or `XLFormDescriptor` instance.
|
||||
You can get all form values invoking `-(NSDictionary *)formValues;` either `XLFormViewController` instance or `XLFormDescriptor` instance.
|
||||
|
||||
The returned `NSDictionary` is created following this rules:
|
||||
|
||||
`XLForm` adds a value for each `XLFormRowDescriptor` instance not contained in a multivalued section, the dictionary key is the value of `XLFormRowDescriptor` `tag` property.
|
||||
`XLForm` adds a value for each `XLFormRowDescriptor` that belongs to a `XLFormSectionDescriptor` doesn't have a `multivaluedTag` value set up. The dictionary key is the value of `XLFormRowDescriptor` `tag` property.
|
||||
|
||||
It also adds a dictionary item for each multivalued section containing an `NSArray` with the instance values of the `XLFormRowDescriptor`s contained in the section.
|
||||
For instance, if we have a section with the tag property equal to `tags` and the following values on the contained rows: 'family', 'male', 'female', 'client', the generated value will be `tags: ['family', 'male', 'female', 'client']`
|
||||
For each section that has a `multivaluedTag` value, XLForm adds a dictionary item with a `NSArray` as a value, each value of the array is the value of each row contained in the section, and the key is the `multivaluedTag`.
|
||||
|
||||
For instance, if we have a section with the `multivaluedTag` property equal to `tags` and the following values on the contained rows: 'family', 'male', 'female', 'client', the generated value will be `tags: ['family', 'male', 'female', 'client']`
|
||||
|
||||
|
||||
#### httpParameters
|
||||
|
||||
In same cases the form value we need may differ from the value of `XLFormRowDescriptor` instance. This is usually the case of selectors row and when we need to send the form values to some endpoint, the selected value could be a core data object or any other object. In this cases XLForm need to know how to get the value and the description of the selected object.
|
||||
In same cases the form value we need may differ from the value of `XLFormRowDescriptor` instance. This is usually the case of selectors row and when we need to send the form values to some endpoint, the selected value could be a core data object or any other object. In this cases `XLForm` need to know how to get the value and the description of the selected object.
|
||||
|
||||
When using `-(NSDictionary *)httpParameters` method, `XLForm` follows the following rules to get `XLFormRowDescriptor` value:
|
||||
When using `-(NSDictionary *)httpParameters` method, XLForm follows the following rules to get `XLFormRowDescriptor` value:
|
||||
|
||||
1. If the object is a `NSString`, `NSNumber` or `NSDate`, the value is the object itself
|
||||
1. If the object is a `NSString`, `NSNumber` or `NSDate`, the value is the object itself.
|
||||
2. If the object conforms to protocol `XLFormOptionObject`, XLForm gets the value from `formValue` method.
|
||||
3. Otherwise it return nil.
|
||||
|
||||
|
||||
This is the protocol declaration:
|
||||
|
||||
```objc
|
||||
@protocol XLFormOptionObject <NSObject>
|
||||
|
||||
@required
|
||||
-(NSString *)formDisplayText;
|
||||
-(id)formValue;
|
||||
|
||||
@end
|
||||
```
|
||||
`multivaluedTag` works in the same way as in `formValues` method.
|
||||
|
||||
|
||||
How to create a Custom Row
|
||||
-------------------------------
|
||||
|
||||
To create a custom cell you should conform to @protocol `XLFormDescriptorCell` within your custom `UITableViewCell`. You can also sublass the convenience class `XLFormBaseCell` which conforms to `XLFormDescriptorCell`. In your implementation add the following required methods:
|
||||
To create a custom cell you need to create a UITableViewCell extending from `XLFormBaseCell`. `XLFormBaseCell` conforms to `XLFormDescriptorCell` protocol.
|
||||
|
||||
You may be interested in implement `XLFormDescriptorCell` methods to change the cell behaviour.
|
||||
|
||||
```objc
|
||||
@protocol XLFormDescriptorCell <NSObject>
|
||||
|
||||
@required
|
||||
|
||||
@property (nonatomic, weak) XLFormRowDescriptor * rowDescriptor;
|
||||
|
||||
// initialise all objects such as Arrays, UIControls etc...
|
||||
- (void)configure;
|
||||
|
||||
-(void)configure;
|
||||
// update cell when it about to be presented
|
||||
- (void)update;
|
||||
```
|
||||
-(void)update;
|
||||
|
||||
Add optional methods to create custom behaviour
|
||||
@optional
|
||||
|
||||
```objc
|
||||
// height of the cell
|
||||
+(CGFloat)formDescriptorCellHeightForRowDescriptor:(XLFormRowDescriptor *)rowDescriptor;
|
||||
|
||||
// called when cell wants to become active
|
||||
// called to check if cell can became first responder
|
||||
-(BOOL)formDescriptorCellCanBecomeFirstResponder;
|
||||
// called to ask cell to assign first responder to relevant UIView.
|
||||
-(BOOL)formDescriptorCellBecomeFirstResponder;
|
||||
|
||||
// called when cell requested to loss first responder
|
||||
-(BOOL)formDescriptorCellResignFirstResponder;
|
||||
|
||||
// called when cell been selected
|
||||
// called when cell is selected
|
||||
-(void)formDescriptorCellDidSelectedWithFormController:(XLFormViewController *)controller;
|
||||
|
||||
// called to validate cell, return error or nil if there no error
|
||||
-(NSError *)formDescriptorCellLocalValidation;
|
||||
|
||||
// http parameter name used for network request
|
||||
-(NSString *)formDescriptorHttpParameterName;
|
||||
|
||||
// is invoked when cell becomes firstResponder, could be used for change how the cell looks like when it's the forst responder.
|
||||
-(void)highlight;
|
||||
// is invoked when cell resign firstResponder
|
||||
-(void)unhighlight;
|
||||
|
||||
|
||||
@end
|
||||
```
|
||||
|
||||
Once custom cell has been created you have to let `XLFormRowDescriptor` know about this class either setting the cellClass property i.e `customRowDescriptor.cellClass = [XLFormCustomCell class]` or before `XLFormViewController` initialized add your custom cell to cellClassesForRowDescriptorTypes dictionary i.e `[[XLFormViewController cellClassesForRowDescriptorTypes] setObject:[MYCustomCellClass class] forKey:kMyAppCustomCellType];`
|
||||
|
||||
Once a custom cell has been created you need to let `XLForm` know about this cell by adding the row definition to `cellClassesForRowDescriptorTypes` dictionary.
|
||||
|
||||
```objc
|
||||
[[XLFormViewController cellClassesForRowDescriptorTypes] setObject:[MYCustomCellClass class] forKey:kMyAppCustomCellType];
|
||||
```
|
||||
|
||||
or, in case we have used nib file to define the `XLBaseDescriptorCell`:
|
||||
|
||||
```objc
|
||||
[[XLFormViewController cellClassesForRowDescriptorTypes] setObject:@"nibNameWithoutNibExtension" forKey:kMyAppCustomCellType];
|
||||
```
|
||||
|
||||
Doing that, XLForm will instantiate the proper cell class when kMyAppCustomCellType row type is used.
|
||||
|
||||
|
||||
Custom Selectors - Selector Row with a custom selector view controller
|
||||
@@ -494,6 +523,11 @@ Define the previous selector row is as simple as ...
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorMap rowType:XLFormRowDescriptorTypeSelectorPush title:@"Coordinate"];
|
||||
// set up the selector controller class
|
||||
row.action.viewControllerClass = [MapViewController class];
|
||||
// or
|
||||
//row.action.viewControllerStoryboardId = @"MapViewControllerStoryboardId";
|
||||
// or
|
||||
//row.action.viewControllerNibName = @"MapViewControllerNibName";
|
||||
|
||||
// Set up a NSValueTransformer to convert CLLocation to NSString, it's used to show the select value description (text).
|
||||
row.valueTransformer = [CLLocationValueTrasformer class];
|
||||
// Set up the default value
|
||||
@@ -519,8 +553,6 @@ XLForm sets up `rowDescriptor` property using the `XLFormRowDescriptor` instance
|
||||
The developer is responsible for update its views with the `rowDescriptor` value as well as set the selected value to `rowDescriptor` from within the custom selector view controller.
|
||||
|
||||
|
||||
|
||||
|
||||
#### Another example
|
||||
|
||||
|
||||
@@ -532,7 +564,7 @@ row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorUser rowType:XLForm
|
||||
row.action.viewControllerClass = [UsersTableViewController class];
|
||||
```
|
||||
|
||||
You can find the details of these examples within the example repository folder, `Examples/Selectors/CustomSelectors/` and `Examples/Selectors/DynamicSelector`.
|
||||
You can find the details of these examples within the example repository folder, [Examples/Objective-C/Examples/Selectors/CustomSelectors/](Examples/Objective-C/Examples/Selectors/CustomSelectors) and [Examples/Objective-C/Examples/Selectors/DynamicSelector](Examples/Objective-C/Examples/Selectors/DynamicSelector).
|
||||
|
||||
|
||||
|
||||
@@ -541,9 +573,9 @@ Dynamic Forms - How to change the form dynamically at runtime
|
||||
|
||||
Any change made on the `XLFormDescriptor` will be reflected on the `XLFormViewController` tableView. That means that we can add or remove sections or rows at any time and XLForm will animate the section or row accordingly.
|
||||
|
||||
We shouldn't have again to work with `NSIndexPaths` or add, remove `UITableViewCell`. `NSIndexPath` of a specific `TableViewCell` changes along the time and this makes very hard to keep track of the `NSIndexPath` of each `UITableViewCell`.
|
||||
We shouldn't have to deal with `NSIndexPaths` or add, remove `UITableViewCell` anymore. `NSIndexPath` of a specific `TableViewCell` changes along the time and this makes very hard to keep track of the `NSIndexPath` of each `UITableViewCell`.
|
||||
|
||||
On XLForm, each `XLFormRowDescriptor` has a `tag` property that is set up in its constructor. `XLFormDescriptor` has, among other helpers, an specific one to get a `XLFormRowDescriptor` from a `tag`.
|
||||
Each XLForm `XLFormRowDescriptor` row has a `tag` property that is set up in its constructor. `XLFormDescriptor` has, among other helpers, an specific one to get a `XLFormRowDescriptor` from a `tag`.
|
||||
It's much easier to manage `XLFormRowDescriptor`s using tags, the tag should be unique and it doesn't change on tableview additions modifications or deletions.
|
||||
|
||||
It's important keep in mind that all the `UITableView` form modifications have to be made using the descriptors and not making modifications directly on the `UITableView`.
|
||||
@@ -569,6 +601,7 @@ For instance if we want to show or hide a row depending on the value of another
|
||||
```objc
|
||||
-(void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
|
||||
{
|
||||
// super implmentation MUST be called
|
||||
[super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
|
||||
if ([rowDescriptor.tag isEqualToString:@"alert"]){
|
||||
if ([[rowDescriptor.value valueData] isEqualToNumber:@(0)] == NO && [[oldValue valueData] isEqualToNumber:@(0)]){
|
||||
@@ -583,79 +616,43 @@ For instance if we want to show or hide a row depending on the value of another
|
||||
}
|
||||
```
|
||||
|
||||
Open form in Popover
|
||||
Validations
|
||||
------------------------------------
|
||||
|
||||
Configure your row with `XLFormRowDescriptorTypeSelectorPopover`
|
||||
We can validate the form data using XLForm validation support.
|
||||
|
||||
Each `XLFormRowDescriptor` instance contains a list of validators. We can add validators, remove validators and validate a particular row using these methods:
|
||||
|
||||
```objc
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:rowTag rowType:XLFormRowDescriptorTypeSelectorPopover title:@"PickerForm"];
|
||||
-(void)addValidator:(id<XLFormValidatorProtocol>)validator;
|
||||
-(void)removeValidator:(id<XLFormValidatorProtocol>)validator;
|
||||
-(XLFormValidationStatus *)doValidation;
|
||||
```
|
||||
|
||||
Implement protocols `XLFormRowDescriptorViewController, XLFormRowDescriptorPopoverViewController` in your custom form class:
|
||||
We can define our own custom validators just defining a object that conforms to `XLFormValidatorProtocol`.
|
||||
|
||||
```objc
|
||||
#import "XLFormRowDescriptor.h"
|
||||
#import "XLForm.h"
|
||||
@protocol XLFormValidatorProtocol <NSObject>
|
||||
|
||||
@interface PickerForm : UITableViewController <XLFormRowDescriptorViewController,XLFormRowDescriptorPopoverViewController, UITableViewDelegate, UITableViewDataSource>
|
||||
@required
|
||||
|
||||
-(XLFormValidationStatus *)isValid:(XLFormRowDescriptor *)row;
|
||||
|
||||
@end
|
||||
```
|
||||
|
||||
Implement button to allow user to dismiss popover, synthesize popoverController:
|
||||
|
||||
```objc
|
||||
@implementation PickerForm
|
||||
|
||||
@synthesize rowDescriptor;
|
||||
@synthesize popoverController;
|
||||
[XLFormRegexValidator](XLForm/XL/Validation/XLFormRegexValidator.h) is an example of a validator we can create.
|
||||
|
||||
|
||||
-(void)viewDidLoad{
|
||||
[super viewDidLoad];
|
||||
self.navigationController.navigationBarHidden=NO;
|
||||
self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(dismiss)];
|
||||
}
|
||||
A very common validation is ensuring that a value is not empty or nil. XLFom exposes `required` XLFormRowDescriptor property to specify required rows.
|
||||
|
||||
-(void)dismiss{
|
||||
[self.popoverController dismissPopoverAnimated:YES];
|
||||
}
|
||||
```
|
||||
|
||||
```objc
|
||||
Also dismiss popover on row select:
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
||||
{
|
||||
self.rowDescriptor.value=[XLFormOptionsObject formOptionsObjectWithValue:@(indexPath.row) displayText:@""];
|
||||
[self.popoverController dismissPopoverAnimated:YES];
|
||||
}
|
||||
```
|
||||
|
||||
Validations
|
||||
------------------------------------
|
||||
|
||||
XLForm supports 2 types of app validation so far.
|
||||
|
||||
* Is Required Validation.
|
||||
* Email validation.
|
||||
|
||||
Improving XLForms validation support is in the roadmap.
|
||||
|
||||
XLForm shows one error at a time showing it as `UIAlertView`.
|
||||
|
||||
You may want to change the list of validation errors. You can do that overriding the following method of `XLFormViewController`, please make sure you call superclass implementation.
|
||||
To get all rows validation errors we can invoke the following `XLFormViewController` method:
|
||||
|
||||
```objc
|
||||
-(NSArray *)formValidationErrors;
|
||||
```
|
||||
|
||||
You can also change the way the error messages are shown overriding:
|
||||
|
||||
```objc
|
||||
-(void)showFormValidationError:(NSError *)error;
|
||||
```
|
||||
|
||||
|
||||
Additional configuration of Rows
|
||||
--------------------------------
|
||||
@@ -665,7 +662,7 @@ Additional configuration of Rows
|
||||
You may want to set up another properties of the `UITableViewCell`. To set up another properties `XLForm` makes use of [Key-Value Coding](https://developer.apple.com/LIBRARY/IOS/documentation/Cocoa/Conceptual/KeyValueCoding/Articles/KeyValueCoding.html "Key-Value Coding") allowing the developer to set the cell properties by keyPath.
|
||||
|
||||
You just have to add the properties to `cellConfig` or `cellConfigAtConfigure` dictionary property of `XLFormRowDescriptor`.
|
||||
The main difference between `cellConfig` and `cellConfigAtConfigure` is the time when the property is set up. `cellConfig` properties are set up each time before display a cell. `cellConfigAtConfigure`, on the other hand, set up the property just after the init method of the cell is called and only one time.
|
||||
The main difference between `cellConfig` and `cellConfigAtConfigure` is the time when the property is set up. `cellConfig` properties are set up each time a cell is about to be displayed. `cellConfigAtConfigure`, on the other hand, set up the property just after the init method of the cell is called and only one time.
|
||||
|
||||
|
||||
For instance if you want to set up the placeholder you can do the following:
|
||||
@@ -747,7 +744,7 @@ If you need something different, you can iterate over each row...
|
||||
[multiValuedValuesArray addObject:row.value];
|
||||
}
|
||||
}
|
||||
[result setObject:multiValuedValuesArray forKey:section.multiValuedTag];
|
||||
[result setObject:multiValuedValuesArray forKey:section.multivaluedTag];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -765,6 +762,11 @@ You can change the font or any other table view cell property using the `cellCon
|
||||
|
||||
For further details, please take a look at [UICustomizationFormViewController.m](/Examples/Objective-C/Examples/UICustomization/UICustomizationFormViewController.m) example.
|
||||
|
||||
####How to disable the entire form (read only mode).
|
||||
|
||||
`disable` XLFormDescriptor property can be used to disable the entire form. In order to make the displayed cell to take effect we should reload the visible cells ( [self.tableView reloadData] ).
|
||||
Any other row added after form `disable` property is set to `YES` will reflect the disable mode automatically (no need to reload table view).
|
||||
|
||||
|
||||
Installation
|
||||
--------------------------
|
||||
@@ -805,9 +807,34 @@ Requirements
|
||||
Release Notes
|
||||
--------------
|
||||
|
||||
Version 2.1.1 (master)
|
||||
Version 2.2.1 (master)
|
||||
|
||||
Version 2.2.0
|
||||
|
||||
* Fixed "(null)" caption when `XLFormRowDescriptorTypeSelectorLeftRight` row required error message is shown.
|
||||
* Refresh the cell content instead of recreating one, when the form get back from a selection.
|
||||
* Added XLFormRowDescriptor to validations error to easily show an error mask.
|
||||
* Use row tag in validation error message if row does not have a title. It is also possible to set up a custom message if needed
|
||||
* Added a convenience method to add a XLFormRowDescriptor instance before another one.
|
||||
* Allow nil values in cellConfig and cellConfigAtConfigure.
|
||||
* Fix constraints for textFieldCell when it is configured to be right aligned.
|
||||
* Add asterisk to required segmentedCells if needed.
|
||||
* Fail validation for empty strings and NSNull on required rows.
|
||||
* Segue support added to buttons and selectors.
|
||||
* Ability to configure a storyboardId or a viewController nibName to by used by button and selector rows as presented view controller.
|
||||
* Fix scrolling to top when status bar is tapped.
|
||||
* Fix wrong type of XLFormRowDescriptorTypeDecimal row. Now it's converted to NSNumber.
|
||||
* Fix issue: XLFormRegexValidator only checks regex validation for NSStrings, not working for number.
|
||||
* Callconfigure method from awakeFromNib on XLFormBaseCell.
|
||||
* Assign form.delegate from inside setForm: method.
|
||||
* Added custom cell, validation, reordering, can insert, can delete examples.
|
||||
* Added support for inputAccessoryView. Default input accessory view allows to navigate among rows. Fully optionally and customizable.
|
||||
* Added suport for row navigation. Fully optionally and customizable.
|
||||
* beginEditing: endEditing: methods added. These method are called each time a row gains / loses firstResponder. They bring the ability to do UI changes.
|
||||
* Read Only mode added. `disable` property added to XLFormDescriptor class.
|
||||
* Rename `label` XLFormTextViewCell property as `textLabel`.
|
||||
* fix position of multivalued section accessory view.
|
||||
* Can delete, can delete, can reorder section mode added. it's possible to enable some of them, don't need to enable all modes.
|
||||
|
||||
Version 2.1.0
|
||||
|
||||
@@ -855,12 +882,15 @@ Version 1.0.0 (cocoaPod)
|
||||
|
||||
* Initial release
|
||||
|
||||
Author
|
||||
-----------------
|
||||
|
||||
[Martin Barreto](https://www.github.com/mtnBarreto "Martin Barreto Github") ([@mtnBarreto](http://twitter.com/mtnBarreto "@mtnBarreto"))
|
||||
|
||||
|
||||
Contact
|
||||
----------------
|
||||
|
||||
Any suggestion or question? Please create a Github issue or reach us out.
|
||||
|
||||
Martin Barreto, [@mtnBarreto](http://twitter.com/mtnBarreto "@mtnBarreto")
|
||||
|
||||
[xmartlabs.com](http://xmartlabs.com).
|
||||
[@xmartlabs](http://twitter.com/xmartlabs "@xmartlabs")
|
||||
[xmartlabs.com](http://xmartlabs.com) ([@xmartlabs](http://twitter.com/xmartlabs "@xmartlabs"))
|
||||
|
||||
+1
-2
@@ -3,6 +3,5 @@ xcodeproj 'XLForm Tests'
|
||||
inhibit_all_warnings!
|
||||
|
||||
platform :ios, '7.0'
|
||||
pod 'OCMock', '~> 2.1.1'
|
||||
pod 'Expecta', '~> 0.2.1'
|
||||
pod 'Expecta', '~> 0.2.4'
|
||||
pod 'XLForm', :path => '../'
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// UITextField+Test.h
|
||||
// XLForm Tests
|
||||
//
|
||||
// Created by Gaston Borba on 3/25/15.
|
||||
//
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface UITextField (Test)
|
||||
|
||||
// This category is for simulate the change of the text
|
||||
-(void)changeText:(NSString *)string;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,58 @@
|
||||
//
|
||||
// UITextField+Test.m
|
||||
// XLForm Tests
|
||||
//
|
||||
// Created by Gaston Borba on 3/25/15.
|
||||
//
|
||||
//
|
||||
|
||||
#import "UITextField+Test.h"
|
||||
|
||||
@implementation UITextField (Test)
|
||||
|
||||
- (void)beginEditing
|
||||
{
|
||||
[self becomeFirstResponder]; // Returns NO ?
|
||||
|
||||
if ([self textFieldShouldBeginEditing]){
|
||||
if ([self.delegate respondsToSelector:@selector(textFieldDidBeginEditing:)]) {
|
||||
[self.delegate textFieldDidBeginEditing:self];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)endEditing
|
||||
{
|
||||
if ([self textFieldShouldReturn]) {
|
||||
if ([self.delegate respondsToSelector:@selector(textFieldDidEndEditing:)]) {
|
||||
[self.delegate textFieldDidEndEditing:self];
|
||||
}
|
||||
[self resignFirstResponder];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-(BOOL)textFieldShouldReturn
|
||||
{
|
||||
if ([self.delegate respondsToSelector:@selector(textFieldShouldReturn:)]) {
|
||||
return [self.delegate textFieldShouldReturn:self];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(BOOL)textFieldShouldBeginEditing
|
||||
{
|
||||
if ([self.delegate respondsToSelector:@selector(textFieldShouldBeginEditing:)]) {
|
||||
return [self.delegate textFieldShouldBeginEditing:self];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
-(void)changeText:(NSString *)string
|
||||
{
|
||||
[self beginEditing];
|
||||
[self setText:string];
|
||||
[self endEditing];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,123 @@
|
||||
//
|
||||
// XLFormViewControllerTestCase.m
|
||||
// XLForm Tests
|
||||
//
|
||||
// Created by Gaston Borba on 3/23/15.
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
#import "XLTestCase.h"
|
||||
#import <XLForm/XLFormTextFieldCell.h>
|
||||
#import "UITextField+Test.h"
|
||||
|
||||
static NSString * const kTextFieldCellTag = @"TextFieldCellTag";
|
||||
|
||||
@interface XLFormExampleTest : XCTestCase
|
||||
|
||||
@property (nonatomic, strong) XLFormViewController * formController;
|
||||
|
||||
@end
|
||||
|
||||
@implementation XLFormExampleTest
|
||||
|
||||
- (void)setUp {
|
||||
[super setUp];
|
||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||
[self buildForm]; // Build a form
|
||||
[self forceLoadingOfTheView]; // Load the view
|
||||
}
|
||||
|
||||
- (void)tearDown {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
[super tearDown];
|
||||
}
|
||||
|
||||
- (void)testTableViewLoad
|
||||
{
|
||||
// Get the tableView
|
||||
UITableView * tableView = self.formController.tableView;
|
||||
|
||||
// Check if the tableView match with the form descriptor
|
||||
expect([tableView numberOfSections]).to.equal(1);
|
||||
expect([tableView numberOfRowsInSection:0]).to.equal(1);
|
||||
|
||||
UITableViewCell * cell = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
|
||||
// Check if the cell match with the XLFormRowDescriptorTypeText
|
||||
expect(cell).to.beKindOf([XLFormTextFieldCell class]);
|
||||
XLFormTextFieldCell * textFieldCell = (XLFormTextFieldCell *)cell;
|
||||
|
||||
// Check if the title label match with the row descriptor title
|
||||
expect(textFieldCell.textLabel.text).to.equal(@"Title");
|
||||
// Check if the text field match with the row descriptor value
|
||||
expect(textFieldCell.textField.text).to.equal(@"");
|
||||
}
|
||||
|
||||
- (void)testChangeFormDynamically
|
||||
{
|
||||
// Get the tableView
|
||||
UITableView * tableView = self.formController.tableView;
|
||||
|
||||
// Add a new section in the form descriptor
|
||||
XLFormSectionDescriptor * section = [XLFormSectionDescriptor formSectionWithTitle:@"Section"];
|
||||
[self.formController.form addFormSection:section];
|
||||
|
||||
// Add a new row (switch) in the new section
|
||||
XLFormRowDescriptor * row = [XLFormRowDescriptor formRowDescriptorWithTag:XLFormRowDescriptorTypeBooleanSwitch rowType:XLFormRowDescriptorTypeBooleanSwitch title:@"Title"];
|
||||
[section addFormRow:row];
|
||||
|
||||
// Check if the tableView match with the form descriptor
|
||||
expect([tableView numberOfSections]).to.equal(2);
|
||||
expect([tableView numberOfRowsInSection:0]).to.equal(1);
|
||||
expect([tableView numberOfRowsInSection:1]).to.equal(1);
|
||||
|
||||
// Check if the cell match with the XLFormRowDescriptorTypeBooleanSwitch
|
||||
UITableViewCell * cell = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:1]];
|
||||
expect(cell).to.beKindOf([XLFormSwitchCell class]);
|
||||
}
|
||||
|
||||
- (void)testFillTextFieldCell
|
||||
{
|
||||
// Get the tableView
|
||||
UITableView * tableView = self.formController.tableView;
|
||||
|
||||
// Get the cell that correspond to the row descriptor XLFormRowDescriptorTypeText
|
||||
UITableViewCell * cell = [tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
|
||||
XLFormTextFieldCell * textFieldCell = (XLFormTextFieldCell *)cell;
|
||||
// Get the texfield in the cell
|
||||
UITextField * textField = textFieldCell.textField;
|
||||
|
||||
// Simulate that change the text on the textfield
|
||||
[textField changeText:@"Name"];
|
||||
|
||||
// Get the row descriptor XLFormRowDescriptorTypeText
|
||||
XLFormRowDescriptor * row = [self.formController.form formRowWithTag:kTextFieldCellTag];
|
||||
|
||||
// Check if the text field match with the row descriptor value
|
||||
expect(row.value).to.equal(@"Name");
|
||||
}
|
||||
|
||||
#pragma mark - Build Form
|
||||
|
||||
-(void)buildForm
|
||||
{
|
||||
self.formController = [[XLFormViewController alloc] init];
|
||||
self.formController.form = [XLFormDescriptor formDescriptor];
|
||||
|
||||
XLFormSectionDescriptor * section = [XLFormSectionDescriptor formSection];
|
||||
[self.formController.form addFormSection:section];
|
||||
|
||||
XLFormRowDescriptor * row = [XLFormRowDescriptor formRowDescriptorWithTag:kTextFieldCellTag rowType:XLFormRowDescriptorTypeText title:@"Title"];
|
||||
[section addFormRow:row];
|
||||
}
|
||||
|
||||
#pragma mark - Load View
|
||||
|
||||
- (void)forceLoadingOfTheView
|
||||
{
|
||||
// This triggers to load the view
|
||||
expect(self.formController.view).notTo.beNil();
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#define EXP_SHORTHAND YES
|
||||
#import "Expecta.h"
|
||||
#import "OCMock.h"
|
||||
|
||||
#import <XLForm/XLForm.h>
|
||||
|
||||
|
||||
+3
-3
@@ -1,14 +1,14 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'XLForm'
|
||||
s.version = '2.1.0'
|
||||
s.version = '2.2.0'
|
||||
s.license = { :type => 'MIT' }
|
||||
s.summary = 'XLForm is the most flexible and powerful iOS library to create dynamic table-view forms.'
|
||||
s.description = <<-DESC
|
||||
s.description = <<-DESC
|
||||
The goal of the library is to get the same power of hand-made forms but spending 1/10 of the time. XLForm provides a very powerful DSL used to create a form, validate & serialize the form data. It keeps track of this specification on runtime, updating the UI on the fly.
|
||||
DESC
|
||||
s.homepage = 'https://github.com/xmartlabs/XLForm'
|
||||
s.authors = { 'Martin Barreto' => 'martin@xmartlabs.com' }
|
||||
s.source = { :git => 'https://github.com/xmartlabs/XLForm.git', :tag => 'v2.1.0' }
|
||||
s.source = { :git => 'https://github.com/xmartlabs/XLForm.git', :tag => 'v2.2.0' }
|
||||
s.source_files = 'XLForm/XL/**/*.{h,m}'
|
||||
s.requires_arc = true
|
||||
s.ios.deployment_target = '7.0'
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormBaseCell.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormBaseCell.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -51,17 +51,26 @@
|
||||
{
|
||||
_rowDescriptor = rowDescriptor;
|
||||
[self update];
|
||||
[rowDescriptor.cellConfig enumerateKeysAndObjectsUsingBlock:^(NSString *keyPath, id value, BOOL * __unused stop) {
|
||||
[self setValue:(value == [NSNull null]) ? nil : value forKeyPath:keyPath];
|
||||
}];
|
||||
if (rowDescriptor.isDisabled){
|
||||
[rowDescriptor.cellConfigIfDisabled enumerateKeysAndObjectsUsingBlock:^(NSString *keyPath, id value, BOOL * __unused stop) {
|
||||
[self setValue:(value == [NSNull null]) ? nil : value forKeyPath:keyPath];
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)configure
|
||||
{
|
||||
//override
|
||||
}
|
||||
|
||||
- (void)update
|
||||
{
|
||||
// override
|
||||
self.textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
self.detailTextLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
self.textLabel.textColor = self.rowDescriptor.disabled ? [UIColor grayColor] : [UIColor blackColor];
|
||||
}
|
||||
|
||||
-(void)highlight
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormButtonCell.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormButtonCell.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -44,13 +44,12 @@
|
||||
-(void)update
|
||||
{
|
||||
[super update];
|
||||
BOOL isDisabled = self.rowDescriptor.isDisabled;
|
||||
self.textLabel.text = self.rowDescriptor.title;
|
||||
BOOL leftAligmnment = self.rowDescriptor.action.viewControllerClass || [self.rowDescriptor.action.viewControllerStoryboardId length] != 0 || [self.rowDescriptor.action.viewControllerNibName length] != 0 || [self.rowDescriptor.action.formSegueIdenfifier length] != 0 || self.rowDescriptor.action.formSegueClass;
|
||||
self.textLabel.textAlignment = leftAligmnment ? NSTextAlignmentLeft : NSTextAlignmentCenter;
|
||||
self.accessoryType = leftAligmnment ? UITableViewCellAccessoryDisclosureIndicator: UITableViewCellAccessoryNone;
|
||||
self.textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
self.textLabel.textColor = self.rowDescriptor.disabled ? [UIColor grayColor] : [UIColor blackColor];
|
||||
self.selectionStyle = self.rowDescriptor.disabled ? UITableViewCellSelectionStyleNone : UITableViewCellSelectionStyleDefault;
|
||||
self.accessoryType = !leftAligmnment || isDisabled ? UITableViewCellAccessoryNone : UITableViewCellAccessoryDisclosureIndicator;
|
||||
self.selectionStyle = isDisabled ? UITableViewCellSelectionStyleNone : UITableViewCellSelectionStyleDefault;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormCheckCell.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormCheckCell.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -40,13 +40,24 @@
|
||||
[super update];
|
||||
self.textLabel.text = self.rowDescriptor.title;
|
||||
self.accessoryType = [self.rowDescriptor.value boolValue] ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
|
||||
self.textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
CGFloat red, green, blue, alpha;
|
||||
[self.tintColor getRed:&red green:&green blue:&blue alpha:&alpha];
|
||||
self.selectionStyle = UITableViewCellSelectionStyleDefault;
|
||||
if (self.rowDescriptor.isDisabled)
|
||||
{
|
||||
[self setTintColor:[UIColor colorWithRed:red green:green blue:blue alpha:0.3]];
|
||||
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
}
|
||||
else{
|
||||
[self setTintColor:[UIColor colorWithRed:red green:green blue:blue alpha:1]];
|
||||
}
|
||||
}
|
||||
//
|
||||
|
||||
-(void)formDescriptorCellDidSelectedWithFormController:(XLFormViewController *)controller
|
||||
{
|
||||
self.rowDescriptor.value = [NSNumber numberWithBool:![self.rowDescriptor.value boolValue]];
|
||||
[self update];
|
||||
[self.formViewController updateFormRow:self.rowDescriptor];
|
||||
[controller.tableView deselectRowAtIndexPath:[controller.form indexPathOfFormRow:self.rowDescriptor] animated:YES];
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormDateCell.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormDateCell.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
- (BOOL)canBecomeFirstResponder
|
||||
{
|
||||
return (!self.rowDescriptor.disabled);
|
||||
return (!self.rowDescriptor.isDisabled);
|
||||
}
|
||||
|
||||
-(BOOL)becomeFirstResponder
|
||||
@@ -93,10 +93,12 @@
|
||||
NSIndexPath * selectedRowPath = [self.formViewController.form indexPathOfFormRow:self.rowDescriptor];
|
||||
NSIndexPath * nextRowPath = [NSIndexPath indexPathForRow:selectedRowPath.row + 1 inSection:selectedRowPath.section];
|
||||
XLFormRowDescriptor * nextFormRow = [self.formViewController.form formRowAtIndex:nextRowPath];
|
||||
BOOL result = [super resignFirstResponder];
|
||||
if ([nextFormRow.rowType isEqualToString:XLFormRowDescriptorTypeDatePicker]){
|
||||
XLFormSectionDescriptor * formSection = [self.formViewController.form.formSections objectAtIndex:nextRowPath.section];
|
||||
[formSection removeFormRow:nextFormRow];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return [super resignFirstResponder];
|
||||
}
|
||||
@@ -112,17 +114,11 @@
|
||||
-(void)update
|
||||
{
|
||||
[super update];
|
||||
|
||||
self.accessoryType = UITableViewCellAccessoryNone;
|
||||
[self.textLabel setText:self.rowDescriptor.title];
|
||||
self.textLabel.textColor = self.rowDescriptor.disabled ? [UIColor grayColor] : [UIColor blackColor];
|
||||
self.selectionStyle = self.rowDescriptor.disabled ? UITableViewCellSelectionStyleNone : UITableViewCellSelectionStyleDefault;
|
||||
|
||||
self.selectionStyle = self.rowDescriptor.isDisabled ? UITableViewCellSelectionStyleNone : UITableViewCellSelectionStyleDefault;
|
||||
self.textLabel.text = [NSString stringWithFormat:@"%@%@", self.rowDescriptor.title, self.rowDescriptor.required && self.rowDescriptor.sectionDescriptor.formDescriptor.addAsteriskToRequiredRowsTitle ? @"*" : @""];
|
||||
self.detailTextLabel.text = [self valueDisplayText];
|
||||
self.textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
self.detailTextLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
|
||||
}
|
||||
|
||||
-(void)formDescriptorCellDidSelectedWithFormController:(XLFormViewController *)controller
|
||||
@@ -147,7 +143,7 @@
|
||||
-(void)highlight
|
||||
{
|
||||
[super highlight];
|
||||
self.detailTextLabel.textColor = self.formViewController.view.tintColor;
|
||||
self.detailTextLabel.textColor = self.tintColor;
|
||||
}
|
||||
|
||||
-(void)unhighlight
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormDatePickerCell.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormDatePickerCell.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormDescriptorCell.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormInlineRowDescriptorCell.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormInlineSelectorCell.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormInlineSelectorCell.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -61,8 +61,9 @@
|
||||
NSIndexPath * nextRowPath = [NSIndexPath indexPathForRow:selectedRowPath.row + 1 inSection:selectedRowPath.section];
|
||||
XLFormRowDescriptor * nextFormRow = [self.formViewController.form formRowAtIndex:nextRowPath];
|
||||
XLFormSectionDescriptor * formSection = [self.formViewController.form.formSections objectAtIndex:nextRowPath.section];
|
||||
BOOL result = [super resignFirstResponder];
|
||||
[formSection removeFormRow:nextFormRow];
|
||||
return [super resignFirstResponder];
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,12 +79,9 @@
|
||||
[super update];
|
||||
self.accessoryType = UITableViewCellAccessoryNone;
|
||||
[self.textLabel setText:self.rowDescriptor.title];
|
||||
self.textLabel.textColor = self.rowDescriptor.disabled ? [UIColor grayColor] : [UIColor blackColor];
|
||||
self.selectionStyle = self.rowDescriptor.disabled ? UITableViewCellSelectionStyleNone : UITableViewCellSelectionStyleDefault;
|
||||
self.selectionStyle = self.rowDescriptor.isDisabled ? UITableViewCellSelectionStyleNone : UITableViewCellSelectionStyleDefault;
|
||||
self.textLabel.text = [NSString stringWithFormat:@"%@%@", self.rowDescriptor.title, self.rowDescriptor.required && self.rowDescriptor.sectionDescriptor.formDescriptor.addAsteriskToRequiredRowsTitle ? @"*" : @""];
|
||||
self.detailTextLabel.text = [self valueDisplayText];
|
||||
self.textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
self.detailTextLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
}
|
||||
|
||||
-(BOOL)formDescriptorCellCanBecomeFirstResponder
|
||||
@@ -109,7 +107,7 @@
|
||||
-(void)highlight
|
||||
{
|
||||
[super highlight];
|
||||
self.detailTextLabel.textColor = self.formViewController.view.tintColor;
|
||||
self.detailTextLabel.textColor = self.tintColor;
|
||||
}
|
||||
|
||||
-(void)unhighlight
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormLeftRightSelectorCell.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormLeftRightSelectorCell.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -109,10 +109,10 @@
|
||||
{
|
||||
[super configure];
|
||||
UIView * separatorView = [UIView autolayoutView];
|
||||
[separatorView setBackgroundColor:[UIColor colorWithWhite:0.85 alpha:1.0]];
|
||||
_constraintTextField = [UITextField autolayoutView];
|
||||
[_constraintTextField setText:@"Option"];
|
||||
[_constraintTextField setFont:[UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]];
|
||||
_constraintTextField.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
[separatorView setBackgroundColor:[UIColor colorWithWhite:0.85 alpha:1.0]];
|
||||
[self.contentView addSubview:_constraintTextField];
|
||||
[_constraintTextField setHidden:YES];
|
||||
[self.contentView addSubview:self.leftButton];
|
||||
@@ -131,15 +131,14 @@
|
||||
-(void)update
|
||||
{
|
||||
[super update];
|
||||
self.leftButton.titleLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
self.rightLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
[self.leftButton setTitle:[NSString stringWithFormat:@"%@%@", [self.rowDescriptor.leftRightSelectorLeftOptionSelected displayText], self.rowDescriptor.required && self.rowDescriptor.sectionDescriptor.formDescriptor.addAsteriskToRequiredRowsTitle ? @"*" : @""] forState:UIControlStateNormal];
|
||||
[self.rowDescriptor setTitle:[self.rowDescriptor.leftRightSelectorLeftOptionSelected displayText]];
|
||||
self.rightLabel.text = [self rightTextLabel];
|
||||
[self.leftButton setEnabled:(!self.rowDescriptor.disabled)];
|
||||
self.accessoryView = self.rowDescriptor.disabled ? nil : [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"XLForm.bundle/forwardarrow.png"]];
|
||||
self.selectionStyle = self.rowDescriptor.disabled ? UITableViewCellSelectionStyleNone : UITableViewCellSelectionStyleDefault;
|
||||
self.leftButton.titleLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
self.rightLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
_constraintTextField.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
[self.leftButton setEnabled:(!self.rowDescriptor.isDisabled)];
|
||||
self.accessoryView = self.rowDescriptor.isDisabled ? nil : [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"XLForm.bundle/forwardarrow.png"]];
|
||||
self.selectionStyle = self.rowDescriptor.isDisabled ? UITableViewCellSelectionStyleNone : UITableViewCellSelectionStyleDefault;
|
||||
}
|
||||
|
||||
|
||||
@@ -200,8 +199,7 @@
|
||||
if (![self.rowDescriptor.leftRightSelectorLeftOptionSelected isEqual:[self leftOptionForDescription:title].leftValue]){
|
||||
self.rowDescriptor.value = nil;
|
||||
self.rowDescriptor.leftRightSelectorLeftOptionSelected = [self leftOptionForDescription:title].leftValue;
|
||||
[self update];
|
||||
|
||||
[self.formViewController updateFormRow:self.rowDescriptor];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormPickerCell.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormPickerCell.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -37,7 +37,7 @@
|
||||
|
||||
-(BOOL)formDescriptorCellCanBecomeFirstResponder
|
||||
{
|
||||
return ((!self.rowDescriptor.disabled) && (self.inlineRowDescriptor == nil));
|
||||
return ((!self.rowDescriptor.isDisabled) && (self.inlineRowDescriptor == nil));
|
||||
}
|
||||
|
||||
-(BOOL)formDescriptorCellBecomeFirstResponder
|
||||
@@ -80,6 +80,9 @@
|
||||
-(void)update
|
||||
{
|
||||
[super update];
|
||||
BOOL isDisable = self.rowDescriptor.isDisabled;
|
||||
self.userInteractionEnabled = !isDisable;
|
||||
self.contentView.alpha = isDisable ? 0.5 : 1.0;
|
||||
[self.pickerView selectRow:[self selectedIndex] inComponent:0 animated:NO];
|
||||
[self.pickerView reloadAllComponents];
|
||||
|
||||
@@ -104,7 +107,7 @@
|
||||
{
|
||||
if (self.inlineRowDescriptor){
|
||||
self.inlineRowDescriptor.value = [self.inlineRowDescriptor.selectorOptions objectAtIndex:row];
|
||||
[[self.inlineRowDescriptor cellForFormController:self.formViewController] update];
|
||||
[self.formViewController updateFormRow:self.inlineRowDescriptor];
|
||||
}
|
||||
else{
|
||||
[self becomeFirstResponder];
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormSegmentedCell.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormSegmentedCell.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -57,7 +57,7 @@
|
||||
self.textLabel.text = [NSString stringWithFormat:@"%@%@", self.rowDescriptor.title, self.rowDescriptor.required && self.rowDescriptor.sectionDescriptor.formDescriptor.addAsteriskToRequiredRowsTitle ? @"*" : @""];
|
||||
[self updateSegmentedControl];
|
||||
self.segmentedControl.selectedSegmentIndex = [self selectedIndex];
|
||||
self.textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
self.segmentedControl.enabled = !self.rowDescriptor.isDisabled;
|
||||
}
|
||||
|
||||
#pragma mark - KVO
|
||||
@@ -86,7 +86,6 @@
|
||||
{
|
||||
if (_textLabel) return _textLabel;
|
||||
_textLabel = [UILabel autolayoutView];
|
||||
[_textLabel setFont:[UIFont preferredFontForTextStyle:UIFontTextStyleBody]];
|
||||
[_textLabel setContentCompressionResistancePriority:500
|
||||
forAxis:UILayoutConstraintAxisHorizontal];
|
||||
return _textLabel;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormSelectorCell.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormSelectorCell.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -72,8 +72,6 @@
|
||||
else{
|
||||
[descriptionArray addObject:[option displayText]];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
return [descriptionArray componentsJoinedByString:@", "];
|
||||
@@ -103,7 +101,7 @@
|
||||
|
||||
-(BOOL)formDescriptorCellCanBecomeFirstResponder
|
||||
{
|
||||
return ((!self.rowDescriptor.disabled) && ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeSelectorPickerView]));
|
||||
return ((!self.rowDescriptor.isDisabled) && ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeSelectorPickerView]));
|
||||
}
|
||||
|
||||
-(BOOL)formDescriptorCellBecomeFirstResponder
|
||||
@@ -141,15 +139,11 @@
|
||||
-(void)update
|
||||
{
|
||||
[super update];
|
||||
self.accessoryType = self.rowDescriptor.disabled || !([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeSelectorPush] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelector]) ? UITableViewCellAccessoryNone : UITableViewCellAccessoryDisclosureIndicator;
|
||||
self.accessoryType = self.rowDescriptor.isDisabled || !([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeSelectorPush] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelector]) ? UITableViewCellAccessoryNone : UITableViewCellAccessoryDisclosureIndicator;
|
||||
[self.textLabel setText:self.rowDescriptor.title];
|
||||
self.textLabel.textColor = self.rowDescriptor.disabled ? [UIColor grayColor] : [UIColor blackColor];
|
||||
self.selectionStyle = self.rowDescriptor.disabled || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeInfo] ? UITableViewCellSelectionStyleNone : UITableViewCellSelectionStyleDefault;
|
||||
self.selectionStyle = self.rowDescriptor.isDisabled || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeInfo] ? UITableViewCellSelectionStyleNone : UITableViewCellSelectionStyleDefault;
|
||||
self.textLabel.text = [NSString stringWithFormat:@"%@%@", self.rowDescriptor.title, self.rowDescriptor.required && self.rowDescriptor.sectionDescriptor.formDescriptor.addAsteriskToRequiredRowsTitle ? @"*" : @""];
|
||||
self.detailTextLabel.text = [self valueDisplayText];
|
||||
self.textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
self.detailTextLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
|
||||
self.detailTextLabel.text = [self valueDisplayText];
|
||||
}
|
||||
|
||||
-(void)formDescriptorCellDidSelectedWithFormController:(XLFormViewController *)controller
|
||||
@@ -177,9 +171,7 @@
|
||||
if (self.popoverController && self.popoverController.popoverVisible) {
|
||||
[self.popoverController dismissPopoverAnimated:NO];
|
||||
}
|
||||
|
||||
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:selectorViewController];
|
||||
self.popoverController = [[UIPopoverController alloc] initWithContentViewController:navigationController];
|
||||
self.popoverController = [[UIPopoverController alloc] initWithContentViewController:selectorViewController];
|
||||
self.popoverController.delegate = self;
|
||||
if ([selectorViewController conformsToProtocol:@protocol(XLFormRowDescriptorPopoverViewController)]){
|
||||
((id<XLFormRowDescriptorPopoverViewController>)selectorViewController).popoverController = self.popoverController;
|
||||
@@ -268,7 +260,7 @@
|
||||
{
|
||||
[super highlight];
|
||||
_beforeChangeColor = self.detailTextLabel.textColor;
|
||||
self.detailTextLabel.textColor = self.formViewController.view.tintColor;
|
||||
self.detailTextLabel.textColor = self.tintColor;
|
||||
}
|
||||
|
||||
-(void)unhighlight
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormSliderCell.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormSliderCell.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -28,31 +28,26 @@
|
||||
|
||||
@interface XLFormSliderCell ()
|
||||
|
||||
@property UISlider* slider;
|
||||
@property UILabel* textField;
|
||||
@property (nonatomic) UISlider * slider;
|
||||
@property (nonatomic) UILabel * textLabel;
|
||||
@property NSUInteger steps;
|
||||
|
||||
@end
|
||||
|
||||
@implementation XLFormSliderCell
|
||||
|
||||
@synthesize textLabel = _textLabel;
|
||||
|
||||
- (void)configure
|
||||
{
|
||||
|
||||
self.steps = 0;
|
||||
|
||||
self.slider = [UISlider autolayoutView];
|
||||
[self.slider addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
|
||||
[self.contentView addSubview:self.slider];
|
||||
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
|
||||
self.textField = [UILabel autolayoutView];
|
||||
[self.contentView addSubview:self.textField];
|
||||
[self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:self.textField attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1 constant:10]];
|
||||
[self.contentView addSubview:self.textLabel];
|
||||
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
[self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:self.textLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1 constant:10]];
|
||||
[self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:self.slider attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1 constant:44]];
|
||||
|
||||
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-15-[textField]-15-|" options:0 metrics:0 views:@{@"textField": self.textField}]];
|
||||
|
||||
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-15-[textLabel]-15-|" options:0 metrics:0 views:@{@"textLabel": self.textLabel}]];
|
||||
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-15-[slider]-15-|" options:0 metrics:0 views:@{@"slider": self.slider}]];
|
||||
|
||||
[self valueChanged:nil];
|
||||
@@ -61,12 +56,9 @@
|
||||
-(void)update {
|
||||
|
||||
[super update];
|
||||
self.textField.text = self.rowDescriptor.title;
|
||||
self.textField.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
self.textLabel.text = self.rowDescriptor.title;
|
||||
self.slider.value = [self.rowDescriptor.value floatValue];
|
||||
self.slider.enabled = !self.rowDescriptor.disabled;
|
||||
self.textField.textColor = self.rowDescriptor.disabled ? [UIColor grayColor] : [UIColor blackColor];
|
||||
|
||||
self.slider.enabled = !self.rowDescriptor.isDisabled;
|
||||
[self valueChanged:nil];
|
||||
}
|
||||
|
||||
@@ -81,4 +73,19 @@
|
||||
return 88;
|
||||
}
|
||||
|
||||
|
||||
-(UILabel *)textLabel
|
||||
{
|
||||
if (_textLabel) return _textLabel;
|
||||
_textLabel = [UILabel autolayoutView];
|
||||
return _textLabel;
|
||||
}
|
||||
|
||||
-(UISlider *)slider
|
||||
{
|
||||
if (_slider) return _slider;
|
||||
_slider = [UISlider autolayoutView];
|
||||
return _slider;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormStepCounterCell.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormStepCounterCell.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -29,8 +29,6 @@
|
||||
|
||||
@interface XLFormStepCounterCell ()
|
||||
|
||||
@property (strong,nonatomic) UIColor *defaultTintColor;
|
||||
|
||||
@end
|
||||
|
||||
@implementation XLFormStepCounterCell
|
||||
@@ -53,17 +51,12 @@
|
||||
0,
|
||||
0)];
|
||||
[stepperControl addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
|
||||
self.defaultTintColor = stepperControl.tintColor;
|
||||
|
||||
UILabel *currentStepValue = [[UILabel alloc] initWithFrame:CGRectMake(0,
|
||||
0,
|
||||
25,
|
||||
CGRectGetHeight(stepperControl.frame))];
|
||||
|
||||
currentStepValue.textAlignment = NSTextAlignmentCenter;
|
||||
currentStepValue.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
currentStepValue.textColor = self.defaultTintColor;
|
||||
|
||||
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,
|
||||
0,
|
||||
CGRectGetWidth(stepperControl.frame) + CGRectGetWidth(currentStepValue.frame),
|
||||
@@ -79,12 +72,20 @@
|
||||
{
|
||||
[super update];
|
||||
self.textLabel.text = self.rowDescriptor.title;
|
||||
self.textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
self.stepControl.value = [self.rowDescriptor.value doubleValue];
|
||||
self.stepControl.enabled = !self.rowDescriptor.disabled;
|
||||
[self stepControl].tintColor = self.rowDescriptor.disabled ? [UIColor grayColor] : self.defaultTintColor;
|
||||
self.textLabel.textColor = self.rowDescriptor.disabled ? [UIColor grayColor] : [UIColor blackColor];
|
||||
|
||||
[self stepControl].enabled = !self.rowDescriptor.isDisabled;
|
||||
[self currentStepValue].font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
CGFloat red, green, blue, alpha;
|
||||
[self.tintColor getRed:&red green:&green blue:&blue alpha:&alpha];
|
||||
if (self.rowDescriptor.isDisabled)
|
||||
{
|
||||
[self setTintColor:[UIColor colorWithRed:red green:green blue:blue alpha:0.3]];
|
||||
[self currentStepValue].textColor = [UIColor colorWithRed:red green:green blue:blue alpha:0.3];
|
||||
}
|
||||
else{
|
||||
[self setTintColor:[UIColor colorWithRed:red green:green blue:blue alpha:1]];
|
||||
[self currentStepValue].textColor = [UIColor colorWithRed:red green:green blue:blue alpha:1];
|
||||
}
|
||||
[self valueChanged:nil];
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormSwitchCell.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormSwitchCell.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -44,9 +44,7 @@
|
||||
[super update];
|
||||
self.textLabel.text = self.rowDescriptor.title;
|
||||
self.switchControl.on = [self.rowDescriptor.value boolValue];
|
||||
self.textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
self.textLabel.textColor = self.rowDescriptor.disabled ? [UIColor grayColor] : [UIColor blackColor];
|
||||
self.switchControl.enabled = !self.rowDescriptor.disabled;
|
||||
self.switchControl.enabled = !self.rowDescriptor.isDisabled;
|
||||
}
|
||||
|
||||
- (UISwitch *)switchControl
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormTextFieldCell.h
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// XLFormTextFieldCell.m
|
||||
// XLForm ( https://github.com/xmartlabs/XLForm )
|
||||
//
|
||||
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
|
||||
// Copyright (c) 2015 Xmartlabs ( http://xmartlabs.com )
|
||||
//
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -132,16 +132,14 @@
|
||||
self.textLabel.text = ((self.rowDescriptor.required && self.rowDescriptor.title && self.rowDescriptor.sectionDescriptor.formDescriptor.addAsteriskToRequiredRowsTitle) ? [NSString stringWithFormat:@"%@*", self.rowDescriptor.title] : self.rowDescriptor.title);
|
||||
|
||||
self.textField.text = self.rowDescriptor.value ? [self.rowDescriptor.value displayText] : self.rowDescriptor.noValueDisplayText;
|
||||
[self.textField setEnabled:!self.rowDescriptor.disabled];
|
||||
self.textLabel.textColor = self.rowDescriptor.disabled ? [UIColor grayColor] : [UIColor blackColor];
|
||||
self.textField.textColor = self.rowDescriptor.disabled ? [UIColor grayColor] : [UIColor blackColor];
|
||||
self.textLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
[self.textField setEnabled:!self.rowDescriptor.isDisabled];
|
||||
self.textField.textColor = self.rowDescriptor.isDisabled ? [UIColor grayColor] : [UIColor blackColor];
|
||||
self.textField.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
|
||||
}
|
||||
|
||||
-(BOOL)formDescriptorCellCanBecomeFirstResponder
|
||||
{
|
||||
return (!self.rowDescriptor.disabled);
|
||||
return (!self.rowDescriptor.isDisabled);
|
||||
}
|
||||
|
||||
-(BOOL)formDescriptorCellBecomeFirstResponder
|
||||
@@ -152,13 +150,13 @@
|
||||
-(void)highlight
|
||||
{
|
||||
[super highlight];
|
||||
self.textLabel.textColor = self.formViewController.view.tintColor;
|
||||
self.textLabel.textColor = self.tintColor;
|
||||
}
|
||||
|
||||
-(void)unhighlight
|
||||
{
|
||||
[super unhighlight];
|
||||
[self.formViewController reloadFormRow:self.rowDescriptor];
|
||||
[self.formViewController updateFormRow:self.rowDescriptor];
|
||||
}
|
||||
|
||||
#pragma mark - Properties
|
||||
@@ -167,7 +165,6 @@
|
||||
{
|
||||
if (_textLabel) return _textLabel;
|
||||
_textLabel = [UILabel autolayoutView];
|
||||
[_textLabel setFont:[UIFont preferredFontForTextStyle:UIFontTextStyleBody]];
|
||||
return _textLabel;
|
||||
}
|
||||
|
||||
@@ -175,7 +172,6 @@
|
||||
{
|
||||
if (_textField) return _textField;
|
||||
_textField = [UITextField autolayoutView];
|
||||
[_textField setFont:[UIFont preferredFontForTextStyle:UIFontTextStyleBody]];
|
||||
return _textField;
|
||||
}
|
||||
|
||||
@@ -186,7 +182,10 @@
|
||||
NSMutableArray * result = [[NSMutableArray alloc] init];
|
||||
[self.textLabel setContentHuggingPriority:500 forAxis:UILayoutConstraintAxisHorizontal];
|
||||
[result addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[_textLabel]-[_textField]" options:NSLayoutFormatAlignAllBaseline metrics:0 views:NSDictionaryOfVariableBindings(_textLabel, _textField)]];
|
||||
[result addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-11-[_textField]-11-|" options:NSLayoutFormatAlignAllBaseline metrics:nil views:NSDictionaryOfVariableBindings(_textField)]];
|
||||
|
||||
[result addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(>=11)-[_textField]-(>=11)-|" options:NSLayoutFormatAlignAllBaseline metrics:nil views:NSDictionaryOfVariableBindings(_textField)]];
|
||||
|
||||
[result addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(>=11)-[_textLabel]-(>=11)-|" options:NSLayoutFormatAlignAllBaseline metrics:nil views:NSDictionaryOfVariableBindings(_textLabel)]];
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user