79 Commits

Author SHA1 Message Date
Martin Barreto 307d3fb2bd v2.1.0 2014-10-16 11:58:50 -02:00
Martin Barreto be9cbf8325 Removed image row key from available keys. It should be added as a custom cell, check it out at /Examples/Others/CustomCells. 2014-10-16 11:28:30 -02:00
Martin Barreto caa91ca91b Added addAsteriskToRequiredRowsTitle property to XLFormDescriptor. 2014-10-14 17:57:04 -02:00
Martin Barreto 714290faf6 prevent deselection of selector row if row is required. 2014-10-10 20:30:02 -02:00
Martin Barreto 4ccd6b8295 Button selection can be handled using a selector or block. Added some examples. 2014-10-08 15:55:51 -02:00
Martin Barreto 392038e704 observe UIKeyboardWillShow & UIKeyboardWillHide. 2014-10-08 11:12:42 -02:00
Martin Barreto a2b284ae78 Support for Storyboard reuse identifier and nib file. 2014-10-07 21:00:53 -02:00
Miguel Revetria f05d198e8b Merge branch 'master' into intro 2014-10-07 17:41:31 -02:00
Miguel Revetria 88dc3e773f Support for custom cell from storyboard 2014-10-07 17:39:47 -02:00
Martin Barreto 721c58dded Now XLFormViewController extends from UIViewController instead of UITableViewController.
Added tableView property as a XLFormViewController IBOutlet.
2014-10-07 17:10:31 -02:00
Martin Barreto 0ef54fe703 update podfile. 2014-10-06 17:14:50 -02:00
Martin Barreto 97e840e48b Merge branch 'master' of github.com:xmartlabs/XLForm 2014-10-06 16:06:41 -02:00
Martin Barreto 030de6f779 Xcode 6 pbxproj 2014-10-06 16:06:31 -02:00
Martin Barreto 83dad3f994 Merge pull request #145 from csteynberg/travis_ci_build_fix
Resolves issue 144 by removing the branch from XLDataLoader
2014-10-06 16:03:29 -02:00
Martin Barreto 7629f5edf6 move XLFormImageSelectorCell to example group. 2014-10-06 15:36:10 -02:00
Calman Steynberg 56313bfd51 Resolves issue 144 by removing the branch from XLDataLoader 2014-09-19 07:40:28 -07:00
Martin Barreto 45eda19eab Merge pull request #135 from carlhunterroach/patch-1
Update XLFormValidationStatus.h
2014-09-16 11:15:22 -03:00
Carl Hunter Roach 1c2cfae9d8 Update XLFormValidationStatus.h
Added import to remove compile-time errors in Swift projects.
2014-09-15 13:51:21 +01:00
Martin Barreto 93a0c407ad Merge pull request #127 from robocopklaus/master
Fixed 'Expected a type' compiler error
2014-09-05 16:22:39 -03:00
Fabian Pahl 0f616b9d4e Fixed 'Expected a type' compiler error 2014-09-05 18:58:28 +02:00
Martin Barreto ea328d3466 Merge pull request #118 from MuscleRumble/master
- Fixed XLFormImageSelectorCell KVO crash bug.
2014-08-26 11:16:38 -03:00
Tobias Hagemann 14aaf8545a - Fixed XLFormImageSelectorCell KVO crash bug.
- Changed XLFormTextViewCell's value behavior so that an empty value equals nil (similar to XLFormTextFieldCell).
2014-08-25 16:29:21 +02:00
Martin Barreto c80a93392c Merge pull request #116 from xmartlabs/SwiftSupport
Swift support
2014-08-25 05:03:19 -03:00
Martin Barreto 0ea6b7526d Merge branch 'master' of github.com:xmartlabs/XLForm into SwiftSupport 2014-08-25 04:56:04 -03:00
Martin Barreto 18a68d50be Swift compatibility fixes. 2014-08-25 04:55:01 -03:00
Martin Barreto 12b5975c64 Merge pull request #115 from xmartlabs/iOS8_support
iOS 8 support.
2014-08-23 19:08:20 -03:00
Martin Barreto 1f31c6a7cd iOS 8 support. 2014-08-23 19:02:36 -03:00
Martin Barreto cea3bab421 Show accessory view for push multiple selectors. 2014-08-21 01:19:32 -03:00
Martin Barreto f7ac234135 Merge pull request #96 from wzph/UITextFieldDelegate
Expose all the UITextFieldDelegate methods.
2014-08-21 01:09:52 -03:00
Martin Barreto 56774a6dac Merge pull request #111 from flashspys/master
fixes #110 incl. comment
2014-08-21 00:55:09 -03:00
Felix Wehnert 58b0cba6d4 fixes #110 incl. comment 2014-08-21 00:41:35 +02:00
Martin Barreto 0f0b5d9ea4 Merge pull request #107 from flashspys/slider
Added Slider
2014-08-20 00:59:38 -03:00
Felix Wehnert 135479f1f7 typo 2014-08-20 01:09:01 +02:00
Felix Wehnert e7f99e7856 added Slider 2014-08-20 01:04:59 +02:00
Martin Barreto 6e0e28dfa9 Merge pull request #102 from flashspys/master
added decimalPad to input options
2014-08-18 21:11:26 -03:00
Felix Wehnert 8532bfc35b added decimalPad to input options 2014-08-18 10:31:05 +02:00
Zach Holt 7dc8dd98d8 Expose all the UITextFieldDelegate methods. 2014-08-12 16:05:50 -07:00
Martin Barreto e614300c11 Merge pull request #94 from xmartlabs/UICustomization
Ui customization
2014-08-12 00:51:16 -03:00
Martin Barreto d74bdf60fb Merge branch 'emailValidatorConvenienceMethod' 2014-08-12 00:44:28 -03:00
Martin Barreto 481f34bef9 UICustomization example added.
Update readme.
2014-08-12 00:43:36 -03:00
Martin Barreto 60878d7ef8 Merge pull request #93 from xmartlabs/emailValidatorConvenienceMethod
Email validator convenience method
2014-08-11 00:24:21 -03:00
Martin Barreto 260dcdee58 Merge branch 'master' of github.com:xmartlabs/XLForm into emailValidatorConvenienceMethod 2014-08-11 00:20:05 -03:00
Martin Barreto 4cae88e4fb Added XLFormValidator, base clase for validators, it performs XLFormValidatorProtocol.
+emailValidator convenience method added. It returns a XLFormRegexValidator instance set up accordingly. 
Email validator is shown in Text Fields example.
2014-08-11 00:19:04 -03:00
Martin Barreto 344b4e8707 Merge pull request #92 from xmartlabs/infoRow
XLFormRowDescriptorTypeInfo row added.
2014-08-11 00:09:00 -03:00
Martin Barreto cb0679703c Merge branch 'master' of github.com:xmartlabs/XLForm 2014-08-10 23:22:25 -03:00
Martin Barreto cf234ae747 XLFormRowDescriptorTypeInfo row added.
Update example app showing the new row type.
2014-08-10 23:10:19 -03:00
Martin Barreto a705b0e7d3 Merge pull request #87 from mobiquity-networks/button_disabled
buttoncell not selectable on disable
2014-08-10 21:03:43 -03:00
Alberto 6f83ccb65a buttoncell not selectable on disable 2014-08-08 17:45:40 +02:00
Martin Barreto 4fc8a0cec7 Merge pull request #85 from xmartlabs/PopoverControllerSupport
iPad popoverController selector added.
2014-08-08 02:23:07 -03:00
Martin Barreto 20a7031b27 -XLFormRowDescriptorTypeMultipleSelectorPopover, XLFormRowDescriptorTypeSelectorPopover added.
-Migrated to Universal project, now we can run the examples on an iPad. 
-Added new row types examples.
2014-08-08 02:18:35 -03:00
Martin Barreto 7a70f66b31 Merge pull request #84 from HiTask/master
Popover support implemented.
2014-08-08 01:02:38 -03:00
Martin Barreto 27f902335f Merge pull request #82 from jschmid/fix-datepicker
Fixed default date not set in date picker
2014-08-07 17:08:08 -03:00
Roman Roan 33526adf51 Popover support implemented. 2014-08-06 18:20:27 +03:00
Jonas Schmid 1a1339fe6a Fixed default date not set in date picker 2014-08-06 15:32:24 +02:00
Martin Barreto 7bd51d5615 Added travis-ci status to readme. 2014-08-05 17:41:37 -03:00
Martin Barreto ceef3ea8b0 Merge pull request #79 from xmartlabs/travis
Travis CI added.
2014-08-05 17:24:53 -03:00
Martin Barreto 8e6cc38c56 Travis CI added.
New XLForm Test project.
2014-08-05 17:13:23 -03:00
Martin Barreto 160f72509c Remove test target from XLForm project. A new test project will be added. 2014-08-05 16:58:08 -03:00
Martin Barreto 6416606991 Merge pull request #74 from bhirt-bpl/master
Minor updates to stepper cell, date cell & slider cell
2014-08-03 12:59:41 -03:00
bhirt-gf ab2fdb5842 added ability to disable stepper control. when disabled textLabel and the stepper control are grayed out 2014-07-31 11:21:47 -06:00
bhirt-gf 8d985764fe gray out text color when control is disabled, similar to the way other cells work. 2014-07-31 11:21:05 -06:00
bhirt-gf 5ef1c6d334 added support for minuteInterval/minDate/maxDate for datecell 2014-07-31 11:05:21 -06:00
Martin Barreto b86c36a278 missing files added. 2014-07-30 14:39:53 -03:00
Martin Barreto 3649279b6d Merge pull request #68 from papo2608/master
Validation improved
2014-07-28 22:49:46 -03:00
Patrick Pöll 9e31e5c1a7 changed permissons 2014-07-28 16:58:46 +02:00
Patrick Pöll e7a43a076d changed permissons 2014-07-28 16:52:19 +02:00
Patrick Pöll c89dc90723 changed permissons 2014-07-28 16:49:45 +02:00
Patrick Pöll 52202cedb1 changed permissons 2014-07-28 16:45:06 +02:00
Patrick Pöll ed26660958 changed permissons to 644 Examples dict 2014-07-28 16:40:58 +02:00
Patrick Pöll 4ceb70ce5b changed permissons to 644 2014-07-28 16:28:34 +02:00
Patrick Pöll b5e588c6c5 Changed permissions 2014-07-28 16:18:23 +02:00
papo2608 30b07e3737 Bug fix numeric fields
The value of numeric fields must also be set to nil if nothing is entered.
2014-07-24 13:50:40 +02:00
papo2608 737aaff970 Remove unnecessary method isValidAsEmail 2014-07-24 13:44:35 +02:00
Patrick Pöll 87212f421a Added FormBaseCell 2014-07-24 11:25:08 +02:00
Patrick Pöll f9e0746eec Improved validation 2014-07-24 11:22:37 +02:00
Martin Barreto 5d8b01670f Merge pull request #65 from chug2k/master
Update Step Counter value on initial load
2014-07-17 11:34:19 -03:00
chug2k a9a68529a9 Update Step Counter value on initial load
Step Counter fields were not showing their value on initial load. This didn't seem like optimal behavior, so it's just a matter of adding the `valueChanged` to `update`.
2014-07-14 18:30:13 -07:00
Martin Barreto 31e99adc26 Update keyboard types. 2014-07-02 17:00:10 -03:00
Martin Barreto d7bad2cae7 README update 2014-06-23 18:15:48 -03:00
77 changed files with 5510 additions and 1418 deletions
+2
View File
@@ -19,3 +19,5 @@ DerivedData
#CocoaPods
Pods
Tests/Pods
Tests/Podfile.lock
Executable
+7
View File
@@ -0,0 +1,7 @@
language: objective-c
before_install:
- gem install cocoapods --no-rdoc --no-ri --no-document --quiet
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet
- cd Tests && pod install && cd $TRAVIS_BUILD_DIR
script: rake test
-8
View File
@@ -23,7 +23,6 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import <AFNetworkActivityLogger/AFNetworkActivityLogger.h>
#import "CoreDataStore.h"
#import "ExamplesFormViewController.h"
#import "AppDelegate.h"
@@ -34,13 +33,6 @@
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[AFNetworkActivityLogger sharedLogger].filterPredicate = [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings) {
NSURLRequest * requestToEvaluate = (NSURLRequest *)evaluatedObject;
return [requestToEvaluate.allHTTPHeaderFields[@"Accept"] isEqualToString:@"image/*"];
}];
[[AFNetworkActivityLogger sharedLogger] startLogging];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
+1 -1
View File
@@ -39,7 +39,7 @@ NSString *const kDateTime = @"dateTime";
- (id)init
{
self = [super initWithStyle:UITableViewStyleGrouped];
self = [super init];
if (self){
XLFormDescriptor * form;
XLFormSectionDescriptor * section;
+12 -2
View File
@@ -30,6 +30,7 @@
#import "MultiValuedFormViewController.h"
#import "ExamplesFormViewController.h"
#import "NativeEventFormViewController.h"
#import "UICustomizationFormViewController.h"
NSString * const kTextFieldAndTextView = @"TextFieldAndTextView";
NSString * const kSelectors = @"Selectors";
@@ -44,9 +45,9 @@ NSString * const kMultivalued = @"Multivalued";
@implementation ExamplesFormViewController
- (id)initWithStyle:(UITableViewStyle)style
-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithStyle:style];
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self){
[self initializeForm];
}
@@ -114,6 +115,15 @@ NSString * const kMultivalued = @"Multivalued";
row.buttonViewController = [MultiValuedFormViewController class];
[section addFormRow:row];
section = [XLFormSectionDescriptor formSectionWithTitle:@"UI Customization"];
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kMultivalued rowType:XLFormRowDescriptorTypeButton title:@"UI Customization"];
row.buttonViewController = [UICustomizationFormViewController class];
[section addFormRow:row];
self.form = form;
}
@@ -32,6 +32,7 @@ NSString *const kEmail = @"email";
NSString *const kTwitter = @"twitter";
NSString *const kNumber = @"number";
NSString *const kInteger = @"integer";
NSString *const kDecimal = @"decimal";
NSString *const kPassword = @"password";
NSString *const kPhone = @"phone";
NSString *const kUrl = @"url";
@@ -61,6 +62,8 @@ NSString *const kNotes = @"notes";
// Email
row = [XLFormRowDescriptor formRowDescriptorWithTag:kEmail rowType:XLFormRowDescriptorTypeEmail title:@"Email"];
// validate the email
[row addValidator:[XLFormValidator emailValidator]];
[section addFormRow:row];
// Twitter
@@ -76,6 +79,10 @@ NSString *const kNotes = @"notes";
// Integer
row = [XLFormRowDescriptor formRowDescriptorWithTag:kInteger rowType:XLFormRowDescriptorTypeInteger title:@"Integer"];
[section addFormRow:row];
// Decimal
row = [XLFormRowDescriptor formRowDescriptorWithTag:kDecimal rowType:XLFormRowDescriptorTypeDecimal title:@"Decimal"];
[section addFormRow:row];
// Password
row = [XLFormRowDescriptor formRowDescriptorWithTag:kPassword rowType:XLFormRowDescriptorTypePassword title:@"Password"];
@@ -164,6 +164,10 @@ NSString *const kFormImageSelectorCellImageRequest = @"imageRequest";
}
}
-(void)dealloc
{
[self.textLabel removeObserver:self forKeyPath:@"text"];
}
#pragma mark - UIActionSheetDelegate
+44 -14
View File
@@ -29,9 +29,12 @@
NSString *const kSwitchBool = @"switchBool";
NSString *const kSwitchCheck = @"switchBool";
NSString *const kStepCounter = @"stepCounter";
NSString *const kSlider = @"slider";
NSString *const kSegmentedControl = @"segmentedControl";
NSString *const kCustom = @"custom";
NSString *const kInfo = @"info";
NSString *const kButton = @"button";
NSString *const kButtonLeftAligned = @"buttonLeftAligned";
@implementation OthersFormViewController
@@ -59,7 +62,7 @@ NSString *const kButton = @"button";
// check
[section addFormRow:[XLFormRowDescriptor formRowDescriptorWithTag:kSwitchCheck rowType:XLFormRowDescriptorTypeBooleanCheck title:@"Check"]];
// step counter
[section addFormRow:[XLFormRowDescriptor formRowDescriptorWithTag:kStepCounter rowType:XLFormRowDescriptorTypeStepCounter title:@"Step counter"]];
@@ -69,12 +72,27 @@ NSString *const kButton = @"button";
row.value = @"Pear";
[section addFormRow:row];
// custom cell
// Slider
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSlider rowType:XLFormRowDescriptorTypeSlider title:@"Slider"];
row.value = @(30);
[row.cellConfigAtConfigure setObject:@(100) forKey:@"slider.maximumValue"];
[row.cellConfigAtConfigure setObject:@(10) forKey:@"slider.minimumValue"];
[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";
infoRowDescriptor.value = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
[section addFormRow:infoRowDescriptor];
section = [XLFormSectionDescriptor formSectionWithTitle:@"Buttons"];
section.footerTitle = @"Button will show a message when Switch is ON";
@@ -82,24 +100,36 @@ NSString *const kButton = @"button";
// Button
XLFormRowDescriptor * buttonRow = [XLFormRowDescriptor formRowDescriptorWithTag:kButton rowType:XLFormRowDescriptorTypeButton title:@"Button"];
[buttonRow.cellConfigAtConfigure setObject:self.view.tintColor forKey:@"textLabel.textColor"];
[buttonRow.cellConfig setObject:[UIColor colorWithRed:0.0 green:122.0/255.0 blue:1.0 alpha:1.0] forKey:@"textLabel.textColor"];
buttonRow.action.formSelector = @selector(didTouchButton:);
[section addFormRow:buttonRow];
self.form = form;
}
-(void)didSelectFormRow:(XLFormRowDescriptor *)formRow
{
[super didSelectFormRow:formRow];
if ([formRow.tag isEqual:kButton]){
if ([[self.form formRowWithTag:kSwitchBool].value boolValue]){
// Left Button
XLFormRowDescriptor * buttonLeftAlignedRow = [XLFormRowDescriptor formRowDescriptorWithTag:kButtonLeftAligned rowType:XLFormRowDescriptorTypeButton title:@"Button Left"];
[buttonLeftAlignedRow.cellConfig setObject:[UIColor colorWithRed:0.0 green:122.0/255.0 blue:1.0 alpha:1.0] forKey:@"textLabel.textColor"];
[buttonLeftAlignedRow.cellConfig setObject:@(NSTextAlignmentLeft) forKey:@"textLabel.textAlignment"];
[buttonLeftAlignedRow.cellConfig setObject:@(UITableViewCellAccessoryDisclosureIndicator) forKey:@"accessoryType"];
buttonLeftAlignedRow.action.formBlock = ^(XLFormRowDescriptor * sender){
if ([[sender.sectionDescriptor.formDescriptor formRowWithTag:kSwitchBool].value boolValue]){
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Switch is ON", nil) message:@"Button has checked the switch value..." delegate:self cancelButtonTitle:NSLocalizedString(@"OK", nil) otherButtonTitles:nil];
[alertView show];
}
[self deselectFormRow:formRow];
[self deselectFormRow:sender];
};
[section addFormRow:buttonLeftAlignedRow];
self.form = form;
}
-(void)didTouchButton:(XLFormRowDescriptor *)sender
{
if ([[sender.sectionDescriptor.formDescriptor formRowWithTag:kSwitchBool].value boolValue]){
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Switch is ON", nil) message:@"Button has checked the switch value..." delegate:self cancelButtonTitle:NSLocalizedString(@"OK", nil) otherButtonTitles:nil];
[alertView show];
}
[self deselectFormRow:sender];
}
@end
@@ -30,12 +30,13 @@
#import "CustomSelectorsFormViewController.h"
NSString *const kSelectorMap = @"selectorMap";
NSString *const kSelectorMapPopover = @"selectorMapPopover";
@implementation CustomSelectorsFormViewController
-(id)initWithStyle:(UITableViewStyle)style
-(id)init
{
self = [super initWithStyle:style];
self = [super init];
if (self) {
XLFormDescriptor * form = [XLFormDescriptor formDescriptorWithTitle:@"Custom Selectors"];
XLFormSectionDescriptor * section;
@@ -54,6 +55,15 @@ NSString *const kSelectorMap = @"selectorMap";
row.value = [[CLLocation alloc] initWithLatitude:-33 longitude:-56];
[section addFormRow:row];
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad){
// Selector PopOver
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorMapPopover rowType:XLFormRowDescriptorTypeSelectorPopover title:@"Coordinate PopOver"];
row.selectorControllerClass = [MapViewController class];
row.valueTransformer = [CLLocationValueTrasformer class];
row.value = [[CLLocation alloc] initWithLatitude:-33 longitude:-56];
[section addFormRow:row];
}
self.form = form;
}
@@ -1,5 +1,5 @@
//
// DynamicSelectorsFormViewController,h
// DynamicSelectorsFormViewController.h
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
@@ -27,13 +27,14 @@
#import "DynamicSelectorsFormViewController.h"
NSString *const kSelectorUser = @"selectorUser";
NSString *const kSelectorUserPopover = @"kSelectorUserPopover";
@implementation DynamicSelectorsFormViewController
-(id)initWithStyle:(UITableViewStyle)style
-(id)init
{
self = [super initWithStyle:style];
self = [super init];
if (self) {
XLFormDescriptor * form = [XLFormDescriptor formDescriptorWithTitle:@"Selectors"];
XLFormSectionDescriptor * section;
@@ -50,6 +51,13 @@ NSString *const kSelectorUser = @"selectorUser";
row.selectorControllerClass = [UsersTableViewController class];
[section addFormRow:row];
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad){
// Selector PopOver
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorUserPopover rowType:XLFormRowDescriptorTypeSelectorPopover title:@"User Popover"];
row.selectorControllerClass = [UsersTableViewController class];
[section addFormRow:row];
}
self.form = form;
}
@@ -26,6 +26,6 @@
#import "XLFormRowDescriptor.h"
#import "XLTableViewController.h"
@interface UsersTableViewController : XLTableViewController <XLFormRowDescriptorViewController>
@interface UsersTableViewController : XLTableViewController <XLFormRowDescriptorViewController, XLFormRowDescriptorPopoverViewController>
@end
@@ -124,6 +124,7 @@
@implementation UsersTableViewController
@synthesize rowDescriptor = _rowDescriptor;
@synthesize popoverController = __popoverController;
static NSString *const kCellIdentifier = @"CellIdentifier";
@@ -160,7 +161,7 @@ static NSString *const kCellIdentifier = @"CellIdentifier";
// SearchBar
self.tableView.tableHeaderView = self.searchDisplayController.searchBar;
// register cells
[self.searchDisplayController.searchResultsTableView registerClass:[UserCell class] forCellReuseIdentifier:kCellIdentifier];
[self.tableView registerClass:[UserCell class] forCellReuseIdentifier:kCellIdentifier];
@@ -172,7 +173,7 @@ static NSString *const kCellIdentifier = @"CellIdentifier";
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UserCell *cell = (UserCell *) [tableView dequeueReusableCellWithIdentifier:kCellIdentifier forIndexPath:indexPath];;
User * user = nil;
if (tableView == self.tableView){
user = (User *)[self.localDataLoader objectAtIndexPath:indexPath];
@@ -216,8 +217,14 @@ static NSString *const kCellIdentifier = @"CellIdentifier";
user = (User *)[self.searchLocalDataLoader objectAtIndexPath:indexPath];
}
self.rowDescriptor.value = user;
[self.navigationController popViewControllerAnimated:YES];
if (self.popoverController){
[self.popoverController dismissPopoverAnimated:YES];
[self.popoverController.delegate popoverControllerDidDismissPopover:self.popoverController];
}
else if ([self.parentViewController isKindOfClass:[UINavigationController class]]){
[self.navigationController popViewControllerAnimated:YES];
}
}
@@ -228,8 +235,8 @@ static NSString *const kCellIdentifier = @"CellIdentifier";
[[self navigationItem] setTitle:@"Select a User"];
[self.tableView setBackgroundColor:[UIColor colorWithWhite:0.9 alpha:1.0]];
[self.tableView setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];
[self.tableView setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];
[self.searchDisplayController.searchResultsTableView setBackgroundColor:[UIColor colorWithWhite:0.9 alpha:1.0]];
[self.searchDisplayController.searchResultsTableView setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];
}
@@ -1,5 +1,5 @@
//
// CoreDataStore..
// CoreDataStore.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
@@ -1,5 +1,5 @@
//
// XLLocalDataLoader.h
// UserLocalDataLoader.h
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
@@ -1,5 +1,5 @@
//
// XLLocalDataLoader.m
// UserLocalDataLoader.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
@@ -1,5 +1,5 @@
//
// XLRemoteDataLoader.h
// UserRemoteDataLoader.h
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
@@ -1,5 +1,5 @@
//
// XLRemoteDataLoader.m
// UserRemoteDataLoader.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
@@ -28,6 +28,7 @@
#import "SelectorsFormViewController.h"
NSString *const kSelectorPush = @"selectorPush";
NSString *const kSelectorPopover = @"selectorPopover";
NSString *const kSelectorActionSheet = @"selectorActionSheet";
NSString *const kSelectorAlertView = @"selectorAlertView";
NSString *const kSelectorLeftRight = @"selectorLeftRight";
@@ -37,6 +38,7 @@ NSString *const kSelectorLeftRightDisabled = @"selectorLeftRightDisabled";
NSString *const kSelectorPickerView = @"selectorPickerView";
NSString *const kSelectorPickerViewInline = @"selectorPickerViewInline";
NSString *const kMultipleSelector = @"multipleSelector";
NSString *const kMultipleSelectorPopover = @"multipleSelectorPopover";
NSString *const kDynamicSelectors = @"dynamicSelectors";
NSString *const kCustomSelectors = @"customSelectors";
NSString *const kPickerView = @"pickerView";
@@ -122,23 +124,30 @@ NSString *const kPickerView = @"pickerView";
// Selector Push
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorPush rowType:XLFormRowDescriptorTypeSelectorPush title:@"Push"];
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"]
];
[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.value = [XLFormOptionsObject formOptionsObjectWithValue:@(1) displayText:@"Option 2"];
[section addFormRow:row];
// Selector Popover
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad){
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorPopover rowType:XLFormRowDescriptorTypeSelectorPopover title:@"PopOver"];
row.selectorOptions = @[@"Option 1", @"Option 2", @"Option 3", @"Option 4", @"Option 5", @"Option 6"];
row.value = @"Option 2";
[section addFormRow:row];
}
// Selector Action Sheet
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorActionSheet rowType:XLFormRowDescriptorTypeSelectorActionSheet title:@"Sheet"];
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"]
];
[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.value = [XLFormOptionsObject formOptionsObjectWithValue:@(2) displayText:@"Option 3"];
[section addFormRow:row];
@@ -148,11 +157,11 @@ NSString *const kPickerView = @"pickerView";
// Selector Alert View
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorAlertView rowType:XLFormRowDescriptorTypeSelectorAlertView title:@"Alert View"];
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"]
];
[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.value = [XLFormOptionsObject formOptionsObjectWithValue:@(2) displayText:@"Option 3"];
[section addFormRow:row];
@@ -163,11 +172,11 @@ NSString *const kPickerView = @"pickerView";
row.leftRightSelectorLeftOptionSelected = [XLFormOptionsObject formOptionsObjectWithValue:@(1) displayText:@"Option 2"];
NSArray * rightOptions = @[[XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:@"Right Option 1"],
[XLFormOptionsObject formOptionsObjectWithValue:@(1) displayText:@"Right Option 2"],
[XLFormOptionsObject formOptionsObjectWithValue:@(2) displayText:@"Right Option 3"],
[XLFormOptionsObject formOptionsObjectWithValue:@(3) displayText:@"Right Option 4"],
[XLFormOptionsObject formOptionsObjectWithValue:@(4) displayText:@"Right Option 5"]
];
[XLFormOptionsObject formOptionsObjectWithValue:@(1) displayText:@"Right Option 2"],
[XLFormOptionsObject formOptionsObjectWithValue:@(2) displayText:@"Right Option 3"],
[XLFormOptionsObject formOptionsObjectWithValue:@(3) displayText:@"Right Option 4"],
[XLFormOptionsObject formOptionsObjectWithValue:@(4) displayText:@"Right Option 5"]
];
// create right selectors
NSMutableArray * leftRightSelectorOptions = [[NSMutableArray alloc] init];
@@ -199,14 +208,14 @@ NSString *const kPickerView = @"pickerView";
row.selectorOptions = leftRightSelectorOptions;
row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(3) displayText:@"Right Option 4"];
[section addFormRow:row];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorPickerView rowType:XLFormRowDescriptorTypeSelectorPickerView title:@"Picker View"];
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"]
];
[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.value = [XLFormOptionsObject formOptionsObjectWithValue:@(3) displayText:@"Option 4"];
[section addFormRow:row];
@@ -258,6 +267,15 @@ NSString *const kPickerView = @"pickerView";
row.value = [NSLocale preferredLanguages];
[section addFormRow:row];
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad){
// Language multiple selector popover
row = [XLFormRowDescriptor formRowDescriptorWithTag:kMultipleSelectorPopover rowType:XLFormRowDescriptorTypeMultipleSelectorPopover title:@"Multiple Selector PopOver"];
row.selectorOptions = [NSLocale ISOLanguageCodes];
row.valueTransformer = [ISOLanguageCodesValueTranformer class];
row.value = [NSLocale preferredLanguages];
[section addFormRow:row];
}
// --------- Dynamic Selectors
@@ -287,7 +305,7 @@ NSString *const kPickerView = @"pickerView";
[section addFormRow:row];
// --------- Disabled Selector Action Sheet
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorActionSheetDisabled rowType:XLFormRowDescriptorTypeSelectorActionSheet title:@"Sheet"];
@@ -303,7 +321,7 @@ NSString *const kPickerView = @"pickerView";
row.disabled = YES;
[section addFormRow:row];
return [super initWithForm:form];
}
@@ -1,28 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5056" systemVersion="13C1021" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="p4n-1v-pzo">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5056" systemVersion="13F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="p4n-1v-pzo">
<dependencies>
<deployment defaultVersion="1792" identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
</dependencies>
<scenes>
<!--Examples Form View Controller - Examples-->
<scene sceneID="Qvu-go-whK">
<objects>
<tableViewController id="ATL-qw-GIU" customClass="ExamplesFormViewController" sceneMemberID="viewController">
<tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="10" sectionFooterHeight="10" id="FC2-DR-wO6">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<connections>
<outlet property="dataSource" destination="ATL-qw-GIU" id="2Gs-wa-cru"/>
<outlet property="delegate" destination="ATL-qw-GIU" id="UXJ-F6-czZ"/>
</connections>
</tableView>
<navigationItem key="navigationItem" title="Examples" id="HEK-cG-rbx"/>
</tableViewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="THE-zk-Sat" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="620" y="23"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="hSO-iI-kK3">
<objects>
@@ -34,13 +16,47 @@
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="ATL-qw-GIU" kind="relationship" relationship="rootViewController" id="Ypm-pn-idS"/>
<segue destination="cUg-F9-RF7" kind="relationship" relationship="rootViewController" id="Dli-gX-3ei"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="jqF-cF-u4f" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="94" y="23"/>
</scene>
<!--Examples Form View Controller - Examples-->
<scene sceneID="wf7-ha-lXx">
<objects>
<viewController automaticallyAdjustsScrollViewInsets="NO" id="cUg-F9-RF7" customClass="ExamplesFormViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="kOR-67-djF"/>
<viewControllerLayoutGuide type="bottom" id="0bE-2H-tqE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="PO9-pF-A7O">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="10" sectionFooterHeight="10" translatesAutoresizingMaskIntoConstraints="NO" id="Lxj-Sb-kC6">
<rect key="frame" x="0.0" y="64" width="320" height="504"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
</tableView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="Lxj-Sb-kC6" firstAttribute="top" secondItem="kOR-67-djF" secondAttribute="bottom" id="PT1-Xo-3Ql"/>
<constraint firstAttribute="trailing" secondItem="Lxj-Sb-kC6" secondAttribute="trailing" id="brq-yF-WM8"/>
<constraint firstItem="Lxj-Sb-kC6" firstAttribute="leading" secondItem="PO9-pF-A7O" secondAttribute="leading" id="d73-kq-kX4"/>
<constraint firstItem="0bE-2H-tqE" firstAttribute="top" secondItem="Lxj-Sb-kC6" secondAttribute="bottom" id="ltM-g9-Dgm"/>
</constraints>
</view>
<navigationItem key="navigationItem" title="Examples" id="sEr-D1-cU5"/>
<connections>
<outlet property="tableView" destination="Lxj-Sb-kC6" id="IS5-OZ-KBo"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="1V5-DZ-WfF" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="527" y="56"/>
</scene>
</scenes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
@@ -0,0 +1,30 @@
//
// UICustomizationFormViewController.h
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "XLFormViewController.h"
@interface UICustomizationFormViewController : XLFormViewController
@end
@@ -0,0 +1,90 @@
//
// UICustomizationFormViewController.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "XLForm.h"
#import "UICustomizationFormViewController.h"
@implementation UICustomizationFormViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
XLFormDescriptor * form = [XLFormDescriptor formDescriptorWithTitle:@"UI Customization"];
XLFormSectionDescriptor * section;
XLFormRowDescriptor * row;
// Section
section = [XLFormSectionDescriptor formSection];
[form addFormSection:section];
// Name
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"Name" rowType:XLFormRowDescriptorTypeText title:@"Name"];
// change the background color
[row.cellConfigAtConfigure setObject:[UIColor greenColor] forKey:@"backgroundColor"];
// font
[row.cellConfig setObject:[UIFont fontWithName:@"Helvetica" size:30] forKey:@"textLabel.font"];
// background color
[row.cellConfig setObject:[UIColor grayColor] forKey:@"textField.backgroundColor"];
// font
[row.cellConfig setObject:[UIFont fontWithName:@"Helvetica" size:25] forKey:@"textField.font"];
// alignment
[row.cellConfig setObject:@(NSTextAlignmentRight) forKey:@"textField.textAlignment"];
[section addFormRow:row];
// Section
section = [XLFormSectionDescriptor formSection];
[form addFormSection:section];
//Button
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"Button" rowType:XLFormRowDescriptorTypeButton title:@"Button"];
[row.cellConfigAtConfigure setObject:[UIColor purpleColor] forKey:@"backgroundColor"];
[row.cellConfig setObject:[UIColor whiteColor] forKey:@"textLabel.color"];
[row.cellConfig setObject:[UIFont fontWithName:@"Helvetica" size:40] forKey:@"textLabel.font"];
[section addFormRow:row];
self.form = form;
}
return self;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
// change cell height of a particular cell
if ([[self.form formRowAtIndex:indexPath].tag isEqualToString:@"Name"]){
return 60.0;
}
else if ([[self.form formRowAtIndex:indexPath].tag isEqualToString:@"Button"]){
return 100.0;
}
return [super tableView:tableView heightForRowAtIndexPath:indexPath];
}
@end
+2 -3
View File
@@ -1,6 +1,5 @@
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '7.0'
pod 'AFNetworking', '~> 2.0', :inhibit_warnings => true
pod 'AFNetworkActivityLogger', :inhibit_warnings => true
pod 'XLDataLoader', :git => 'https://github.com/xmartlabs/XLDataLoader.git', :branch => 'master'
pod 'MRProgress', '~> 0.2'
pod 'XLDataLoader', '~> 1.1', :inhibit_warnings => true
+15 -56
View File
@@ -1,75 +1,34 @@
PODS:
- AFNetworkActivityLogger (2.0.2):
- AFNetworking/NSURLSession (~> 2.0)
- AFNetworking (2.2.0):
- AFNetworking (2.4.1):
- AFNetworking/NSURLConnection
- AFNetworking/NSURLSession
- AFNetworking/Reachability
- AFNetworking/Security
- AFNetworking/Serialization
- AFNetworking/UIKit
- AFNetworking/NSURLConnection (2.2.0):
- AFNetworking/NSURLConnection (2.4.1):
- AFNetworking/Reachability
- AFNetworking/Security
- AFNetworking/Serialization
- AFNetworking/NSURLSession (2.2.0):
- AFNetworking/NSURLConnection
- AFNetworking/Reachability (2.2.0)
- AFNetworking/Security (2.2.0)
- AFNetworking/Serialization (2.2.0)
- AFNetworking/UIKit (2.2.0):
- AFNetworking/NSURLSession (2.4.1):
- AFNetworking/Reachability
- AFNetworking/Security
- AFNetworking/Serialization
- AFNetworking/Reachability (2.4.1)
- AFNetworking/Security (2.4.1)
- AFNetworking/Serialization (2.4.1)
- AFNetworking/UIKit (2.4.1):
- AFNetworking/NSURLConnection
- AFNetworking/NSURLSession
- MRProgress (0.4.1):
- MRProgress/ActivityIndicator
- MRProgress/Blur
- MRProgress/Circular
- MRProgress/Helper
- MRProgress/Icons
- MRProgress/MessageInterceptor
- MRProgress/NavigationBarProgress
- MRProgress/Overlay
- MRProgress/Stopable
- MRProgress/WeakProxy
- MRProgress/ActivityIndicator (0.4.1):
- MRProgress/Stopable
- MRProgress/Blur (0.4.1):
- MRProgress/Helper
- MRProgress/Circular (0.4.1):
- MRProgress/Helper
- MRProgress/Stopable
- MRProgress/Helper (0.4.1)
- MRProgress/Icons (0.4.1)
- MRProgress/MessageInterceptor (0.4.1)
- MRProgress/NavigationBarProgress (0.4.1):
- MRProgress/MessageInterceptor
- MRProgress/Overlay (0.4.1):
- MRProgress/ActivityIndicator
- MRProgress/Blur
- MRProgress/Circular
- MRProgress/Helper
- MRProgress/Icons
- MRProgress/Stopable (0.4.1):
- MRProgress/Helper
- MRProgress/WeakProxy (0.4.1)
- XLDataLoader (1.0.0):
- XLDataLoader (1.1.0):
- AFNetworking (~> 2.0)
DEPENDENCIES:
- AFNetworkActivityLogger
- AFNetworking (~> 2.0)
- MRProgress (~> 0.2)
- XLDataLoader (from `https://github.com/xmartlabs/XLDataLoader.git`, branch `master`)
EXTERNAL SOURCES:
XLDataLoader:
:branch: master
:git: https://github.com/xmartlabs/XLDataLoader.git
- XLDataLoader (~> 1.1)
SPEC CHECKSUMS:
AFNetworkActivityLogger: 45ca411593444cbdc401b12924b4c17082ad512a
AFNetworking: 5f2538aa2d150b71d4e6cca3a420d796e1e1c374
MRProgress: 209cdf239e60feab2f5b1c605d375bf9cd32c8b0
XLDataLoader: 0417b79ce5563ba135cb41af6ddd99753ae07efe
AFNetworking: 0aabc6fae66d6e5d039eeb21c315843c7aae51ab
XLDataLoader: bd783ebe782932a6390ffc7619fcd884c8600944
COCOAPODS: 0.33.1
COCOAPODS: 0.34.1
+111 -10
View File
@@ -1,6 +1,10 @@
#XMARTLABS - XLForm
XLForm
---------------
By [XMARTLABS](http://xmartlabs.com).
[![Build Status](https://travis-ci.org/xmartlabs/XLForm.svg?branch=master)](https://travis-ci.org/xmartlabs/XLForm)
Purpose
--------------
@@ -106,12 +110,12 @@ Input rows allows the user to enter text values. Basically they use `UITextField
```objc
static NSString *const XLFormRowDescriptorTypeText = @"text";
```
Will be represented by a `UITextField` with `UITextAutocorrectionTypeDefault`, `UITextAutocapitalizationTypeSentences` and `UIKeyboardTypeAlphabet`.
Will be represented by a `UITextField` with `UITextAutocorrectionTypeDefault`, `UITextAutocapitalizationTypeSentences` and `UIKeyboardTypeDefault`.
```objc
static NSString *const XLFormRowDescriptorTypeName = @"name";
```
Will be represented by a `UITextField` with `UITextAutocorrectionTypeNo`, `UITextAutocapitalizationTypeWords` and `UIKeyboardTypeAlphabet`.
Will be represented by a `UITextField` with `UITextAutocorrectionTypeNo`, `UITextAutocapitalizationTypeWords` and `UIKeyboardTypeDefault`.
```objc
static NSString *const XLFormRowDescriptorTypeURL = @"url";
@@ -126,7 +130,7 @@ Will be represented by a `UITextField` with `UITextAutocorrectionTypeNo`, `UITex
```objc
static NSString *const XLFormRowDescriptorTypePassword = @"password";
```
Will be represented by a `UITextField` with `UITextAutocorrectionTypeNo`, `UITextAutocapitalizationTypeNone` and `UIKeyboardTypeAlphabet`.
Will be represented by a `UITextField` with `UITextAutocorrectionTypeNo`, `UITextAutocapitalizationTypeNone` and `UIKeyboardTypeASCIICapable`.
This row type also set the `secureTextEntry` to `YES` in order to hide what the user types.
```objc
@@ -147,17 +151,22 @@ Will be represented by a `UITextField` with `UITextAutocorrectionTypeNo`, `UITex
```objc
static NSString *const XLFormRowDescriptorTypeAccount = @"account";
```
Will be represented by a `UITextField` with `UITextAutocorrectionTypeNo`, `UITextAutocapitalizationTypeNone` and `UIKeyboardTypeAlphabet`.
Will be represented by a `UITextField` with `UITextAutocorrectionTypeNo`, `UITextAutocapitalizationTypeNone` and `UIKeyboardTypeDefault`.
```objc
static NSString *const XLFormRowDescriptorTypeInteger = @"integer";
```
Will be represented by a `UITextField` with `UIKeyboardTypeNumberPad`.
```objc
static NSString *const XLFormRowDescriptorTypeDecimal = @"decimal";
```
Will be represented by a `UITextField` with `UIKeyboardTypeDecimalPad`.
```objc
static NSString *const XLFormRowDescriptorTypeTextView = @"textView";
```
Will be represented by a `UITextView` with `UITextAutocorrectionTypeDefault`, `UITextAutocapitalizationTypeSentences` and `UIKeyboardTypeAlphabet`.
Will be represented by a `UITextView` with `UITextAutocorrectionTypeDefault`, `UITextAutocapitalizationTypeSentences` and `UIKeyboardTypeDefault`.
@@ -309,7 +318,9 @@ 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.
####Step Counter Rows
####Other Rows
#####Stepper
XLForms supports counting using UIStepper control:
@@ -319,7 +330,26 @@ XLForms supports counting using UIStepper control:
```objc
static NSString *const XLFormRowDescriptorTypeStepCounter = @"stepCounter";
```
#####Slider
XLForms supports counting using UISlider control:
```objc
static NSString *const XLFormRowDescriptorTypeSlider = @"slider";
```
You can adjust the slider for your own interests very easily:
```objc
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSlider rowType:XLFormRowDescriptorTypeSlider title:@"Slider"];
row.value = @(30);
[row.cellConfigAtConfigure setObject:@(100) forKey:@"slider.maximumValue"];
[row.cellConfigAtConfigure setObject:@(10) forKey:@"slider.minimumValue"];
[row.cellConfigAtConfigure setObject:@(4) forKey:@"steps"];
```
Set `steps` to `@(0)` to disable the steps functionality.
Multivalued Sections
------------------------
@@ -553,8 +583,54 @@ For instance if we want to show or hide a row depending on the value of another
}
```
Open form in Popover
------------------------------------
Configure your row with `XLFormRowDescriptorTypeSelectorPopover`
```objc
row = [XLFormRowDescriptor formRowDescriptorWithTag:rowTag rowType:XLFormRowDescriptorTypeSelectorPopover title:@"PickerForm"];
```
Implement protocols `XLFormRowDescriptorViewController, XLFormRowDescriptorPopoverViewController` in your custom form class:
```objc
#import "XLFormRowDescriptor.h"
#import "XLForm.h"
@interface PickerForm : UITableViewController <XLFormRowDescriptorViewController,XLFormRowDescriptorPopoverViewController, UITableViewDelegate, UITableViewDataSource>
@end
```
Implement button to allow user to dismiss popover, synthesize popoverController:
```objc
@implementation PickerForm
@synthesize rowDescriptor;
@synthesize popoverController;
-(void)viewDidLoad{
[super viewDidLoad];
self.navigationController.navigationBarHidden=NO;
self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(dismiss)];
}
-(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
------------------------------------
@@ -676,8 +752,19 @@ If you need something different, you can iterate over each row...
}
return result;
```
#### How to change a UITableViewCell font
You can change the font or any other table view cell property using the `cellConfig` dictionary property. XLForm will set up `cellConfig` dictionary values when the table view cell is about to be displayed.
```objc
[row.cellConfig setObject:[UIColor greenColor] forKey:@"textLabel.textColor"];
[row.cellConfig setObject:[UIFont fontWithName:FONT_LATO_REGULAR size:12.0] forKey:@"textLabel.font"];
[row.cellConfig setObject:[UIFont fontWithName:FONT_LATO_REGULAR size:12.0] forKey:@"detailTextLabel.font"];
```
For further details, please take a look at [UICustomizationFormViewController.m](/Examples/UICustomization/UICustomizationFormViewController.m) example.
Installation
--------------------------
@@ -685,7 +772,7 @@ Installation
The easiest way to use XLForm in your app is via [CocoaPods](http://cocoapods.org/ "CocoaPods").
1. Add the following line in the project's Podfile file:
`pod 'XLForm', '~> 1.0.0'`.
`pod 'XLForm', '~> 2.1.0'`.
2. Run the command `pod install` from the Podfile folder directory.
XLForm **has no** dependencies over other pods.
@@ -713,7 +800,21 @@ Requirements
Release Notes
--------------
Version 2.0.0 (master)
Version 2.0.1 (master)
* Change `XLFormRowDescriptorTypeText`, `XLFormRowDescriptorTypeName` and `XLFormRowDescriptorTypeTextView` keyboard type to `UIKeyboardTypeDefault`.
* Added `XLFormRowDescriptorTypeInfo` row type and example.
* Added `XLFormRowDescriptorTypeSelectorPopover` row type and example.
* CI added. Created Test project into Tests folder and set up Travis.
* Documented how to customize UI. Added an example.
* Now XLFormViewController extends from UIViewController instead of UITableViewController.
* Added tableView property as a XLFormViewController IBOutlet.
* Added support for storyboard reuse identifier and nib file.
* Button selection can be handled using a selector or block.
* Added addAsteriskToRequiredRowsTitle property to XLFormDescriptor. NO is used as value by default.
* Image cell has been removed because it depends on AFNetworking and now needs to be implemented as a custom cell. You can find the image custom cell in Examples/Others/CustomCells.
Version 2.0.0 (cocoaPod)
* Added `XLFormRowDescriptorTypeMultipleSelector` row type and example.
* Added `XLFormRowDescriptorTypeSelectorPickerView` row type and example.
Executable
+31
View File
@@ -0,0 +1,31 @@
include FileUtils::Verbose
namespace :test do
desc "Run the XLForm Tests"
task :ios do
run_tests('XLForm Tests', 'iphonesimulator')
tests_failed unless $?.success?
end
end
task :test do
Rake::Task['test:ios'].invoke
end
task :default => 'test'
private
def run_tests(scheme, sdk)
sh("xcodebuild -workspace 'Tests/XLForm Tests.xcworkspace' -scheme '#{scheme}' -sdk '#{sdk}' -configuration Release clean test | xcpretty -c ; exit ${PIPESTATUS[0]}") rescue nil
end
def tests_failed
puts red("Unit tests failed")
exit $?.exitstatus
end
def red(string)
"\033[0;31m! #{string}"
end
Executable
+8
View File
@@ -0,0 +1,8 @@
source 'https://github.com/CocoaPods/Specs.git'
xcodeproj 'XLForm Tests'
inhibit_all_warnings!
platform :ios, '7.0'
pod 'OCMock', '~> 2.1.1'
pod 'Expecta', '~> 0.2.1'
pod 'XLForm', :path => '../'
@@ -0,0 +1,348 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
28657A3E1990879200CE8180 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28657A3D1990879200CE8180 /* XCTest.framework */; };
28657A401990879200CE8180 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28657A3F1990879200CE8180 /* Foundation.framework */; };
28657A421990879200CE8180 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28657A411990879200CE8180 /* UIKit.framework */; };
28657A481990879200CE8180 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 28657A461990879200CE8180 /* InfoPlist.strings */; };
28657A5219914F9700CE8180 /* XLTestCase.m in Sources */ = {isa = PBXBuildFile; fileRef = 28657A5119914F9700CE8180 /* XLTestCase.m */; };
28657A54199154EE00CE8180 /* XLFormValidatorsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 28657A53199154EE00CE8180 /* XLFormValidatorsTests.m */; };
803CF19E12514D00A5080A99 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CEC7E8601D7342BFAF4C4060 /* libPods.a */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
28657A3A1990879200CE8180 /* XLForm Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "XLForm Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
28657A3D1990879200CE8180 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
28657A3F1990879200CE8180 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
28657A411990879200CE8180 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
28657A451990879200CE8180 /* XLForm Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "XLForm Tests-Info.plist"; sourceTree = "<group>"; };
28657A471990879200CE8180 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
28657A4B1990879200CE8180 /* XLForm Tests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "XLForm Tests-Prefix.pch"; sourceTree = "<group>"; };
28657A5019914F9700CE8180 /* XLTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XLTestCase.h; path = Test/XLTestCase.h; sourceTree = "<group>"; };
28657A5119914F9700CE8180 /* XLTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XLTestCase.m; path = Test/XLTestCase.m; sourceTree = "<group>"; };
28657A53199154EE00CE8180 /* XLFormValidatorsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XLFormValidatorsTests.m; path = Test/XLFormValidatorsTests.m; sourceTree = "<group>"; };
B5760BA9A8114A31A245A308 /* Pods.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.xcconfig; path = Pods/Pods.xcconfig; sourceTree = "<group>"; };
CEC7E8601D7342BFAF4C4060 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
28657A371990879200CE8180 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
28657A3E1990879200CE8180 /* XCTest.framework in Frameworks */,
28657A421990879200CE8180 /* UIKit.framework in Frameworks */,
28657A401990879200CE8180 /* Foundation.framework in Frameworks */,
803CF19E12514D00A5080A99 /* libPods.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
28657A2F19907FBE00CE8180 = {
isa = PBXGroup;
children = (
28657A431990879200CE8180 /* XLForm Tests */,
28657A3C1990879200CE8180 /* Frameworks */,
28657A3B1990879200CE8180 /* Products */,
B5760BA9A8114A31A245A308 /* Pods.xcconfig */,
);
sourceTree = "<group>";
};
28657A3B1990879200CE8180 /* Products */ = {
isa = PBXGroup;
children = (
28657A3A1990879200CE8180 /* XLForm Tests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
28657A3C1990879200CE8180 /* Frameworks */ = {
isa = PBXGroup;
children = (
28657A3D1990879200CE8180 /* XCTest.framework */,
28657A3F1990879200CE8180 /* Foundation.framework */,
28657A411990879200CE8180 /* UIKit.framework */,
CEC7E8601D7342BFAF4C4060 /* libPods.a */,
);
name = Frameworks;
sourceTree = "<group>";
};
28657A431990879200CE8180 /* XLForm Tests */ = {
isa = PBXGroup;
children = (
28657A4F19914F7000CE8180 /* Tests */,
28657A441990879200CE8180 /* Supporting Files */,
);
path = "XLForm Tests";
sourceTree = "<group>";
};
28657A441990879200CE8180 /* Supporting Files */ = {
isa = PBXGroup;
children = (
28657A451990879200CE8180 /* XLForm Tests-Info.plist */,
28657A461990879200CE8180 /* InfoPlist.strings */,
28657A4B1990879200CE8180 /* XLForm Tests-Prefix.pch */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
28657A4F19914F7000CE8180 /* Tests */ = {
isa = PBXGroup;
children = (
28657A5019914F9700CE8180 /* XLTestCase.h */,
28657A5119914F9700CE8180 /* XLTestCase.m */,
28657A53199154EE00CE8180 /* XLFormValidatorsTests.m */,
);
name = Tests;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
28657A391990879200CE8180 /* XLForm Tests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 28657A4C1990879200CE8180 /* Build configuration list for PBXNativeTarget "XLForm Tests" */;
buildPhases = (
6B058765CC1143829C6943B9 /* Check Pods Manifest.lock */,
28657A361990879200CE8180 /* Sources */,
28657A371990879200CE8180 /* Frameworks */,
28657A381990879200CE8180 /* Resources */,
3E5FCF05A57F40C6AF367F6D /* Copy Pods Resources */,
);
buildRules = (
);
dependencies = (
);
name = "XLForm Tests";
productName = "XLForm Tests";
productReference = 28657A3A1990879200CE8180 /* XLForm Tests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
28657A3019907FBE00CE8180 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0510;
};
buildConfigurationList = 28657A3319907FBE00CE8180 /* Build configuration list for PBXProject "XLForm Tests" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 28657A2F19907FBE00CE8180;
productRefGroup = 28657A3B1990879200CE8180 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
28657A391990879200CE8180 /* XLForm Tests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
28657A381990879200CE8180 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
28657A481990879200CE8180 /* InfoPlist.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
3E5FCF05A57F40C6AF367F6D /* Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Pods-resources.sh\"\n";
showEnvVarsInLog = 0;
};
6B058765CC1143829C6943B9 /* Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
28657A361990879200CE8180 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
28657A54199154EE00CE8180 /* XLFormValidatorsTests.m in Sources */,
28657A5219914F9700CE8180 /* XLTestCase.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
28657A461990879200CE8180 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
28657A471990879200CE8180 /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
28657A3419907FBE00CE8180 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
};
name = Debug;
};
28657A3519907FBE00CE8180 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
};
name = Release;
};
28657A4D1990879200CE8180 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = B5760BA9A8114A31A245A308 /* Pods.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
"$(DEVELOPER_FRAMEWORKS_DIR)",
);
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "XLForm Tests/XLForm Tests-Prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "XLForm Tests/XLForm Tests-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
WRAPPER_EXTENSION = xctest;
};
name = Debug;
};
28657A4E1990879200CE8180 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = B5760BA9A8114A31A245A308 /* Pods.xcconfig */;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
"$(DEVELOPER_FRAMEWORKS_DIR)",
);
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "XLForm Tests/XLForm Tests-Prefix.pch";
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "XLForm Tests/XLForm Tests-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
WRAPPER_EXTENSION = xctest;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
28657A3319907FBE00CE8180 /* Build configuration list for PBXProject "XLForm Tests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
28657A3419907FBE00CE8180 /* Debug */,
28657A3519907FBE00CE8180 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
28657A4C1990879200CE8180 /* Build configuration list for PBXNativeTarget "XLForm Tests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
28657A4D1990879200CE8180 /* Debug */,
28657A4E1990879200CE8180 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 28657A3019907FBE00CE8180 /* Project object */;
}
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:XLForm Tests.xcodeproj">
</FileRef>
</Workspace>
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "28657A391990879200CE8180"
BuildableName = "XLForm Tests.xctest"
BlueprintName = "XLForm Tests"
ReferencedContainer = "container:XLForm Tests.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "28657A391990879200CE8180"
BuildableName = "XLForm Tests.xctest"
BlueprintName = "XLForm Tests"
ReferencedContainer = "container:XLForm Tests.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
+1
View File
@@ -0,0 +1 @@
<?xml version='1.0' encoding='UTF-8'?><Workspace version='1.0'><FileRef location='group:XLForm Tests.xcodeproj'/><FileRef location='group:Pods/Pods.xcodeproj'/></Workspace>
@@ -0,0 +1,56 @@
//
// XLFormValidatorsTests.m
// XLForm Tests
//
// Created by Martin Barreto on 8/5/14.
//
//
#import "XLTestCase.h"
#import <XCTest/XCTest.h>
@interface XLFormValidatorsTests : XLTestCase
@end
@implementation XLFormValidatorsTests
- (void)setUp
{
[super setUp];
[self buildForm];
}
- (void)tearDown
{
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testRequiredTextField
{
XLFormRowDescriptor * rowDescriptor = [self.formController.form formRowWithTag:XLFormRowDescriptorTypeText];
expect([rowDescriptor doValidation].isValid).to.beFalsy();
}
#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;
row = [XLFormRowDescriptor formRowDescriptorWithTag:XLFormRowDescriptorTypeText rowType:XLFormRowDescriptorTypeText title:@"Required XLFormRowDescriptorTypeText"];
row.required = YES;
[section addFormRow:row];
}
@end
+21
View File
@@ -0,0 +1,21 @@
//
// XLFormTestCase.h
// XLForm Tests
//
// Created by Martin Barreto on 8/5/14.
//
//
#import <XCTest/XCTest.h>
#define EXP_SHORTHAND YES
#import "Expecta.h"
#import "OCMock.h"
#import <XLForm/XLForm.h>
@interface XLTestCase : XCTestCase
@property (nonatomic, strong) XLFormViewController * formController;
@end
+13
View File
@@ -0,0 +1,13 @@
//
// XLFormTestCase.m
// XLForm Tests
//
// Created by Martin Barreto on 8/5/14.
//
//
#import "XLTestCase.h"
@implementation XLTestCase
@end
@@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.xmartlabs.XLForm.${PRODUCT_NAME:rfc1034identifier}</string>
<string>com.xmartlabs.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
@@ -0,0 +1,10 @@
//
// Prefix header
//
// The contents of this file are implicitly included at the beginning of every source file.
//
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
+2 -2
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'XLForm'
s.version = '2.0.0'
s.version = '2.1.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
@@ -8,7 +8,7 @@ Pod::Spec.new do |s|
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.0.0' }
s.source = { :git => 'https://github.com/xmartlabs/XLForm.git', :tag => 'v2.1.0' }
s.source_files = 'XLForm/XL/**/*.{h,m}'
s.requires_arc = true
s.ios.deployment_target = '7.0'
File diff suppressed because it is too large Load Diff
@@ -17,6 +17,11 @@
"idiom" : "iphone",
"filename" : "xl_appicon_120.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
}
],
"info" : {
@@ -8,6 +8,10 @@
"idiom" : "universal",
"scale" : "2x",
"filename" : "default-avatar@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
+13 -1
View File
@@ -48,12 +48,24 @@
self.textLabel.textAlignment = self.rowDescriptor.buttonViewController ? NSTextAlignmentLeft : NSTextAlignmentCenter;
self.accessoryType = self.rowDescriptor.buttonViewController ? 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;
}
-(void)formDescriptorCellDidSelectedWithFormController:(XLFormViewController *)controller
{
if (self.rowDescriptor.buttonViewController){
BOOL hasAction = self.rowDescriptor.action.formBlock || self.rowDescriptor.action.formSelector;
if (hasAction){
if (self.rowDescriptor.action.formBlock){
self.rowDescriptor.action.formBlock(self.rowDescriptor);
}
else{
[controller performFormSeletor:self.rowDescriptor.action.formSelector withObject:self.rowDescriptor];
}
}
else if (self.rowDescriptor.buttonViewController){
if (controller.navigationController == nil || [self.rowDescriptor.buttonViewController isSubclassOfClass:[UINavigationController class]] || self.rowDescriptor.buttonViewControllerPresentationMode == XLFormPresentationModePresent){
[controller presentViewController:[[self.rowDescriptor.buttonViewController alloc] init] animated:YES completion:nil];
}
+3
View File
@@ -36,5 +36,8 @@ typedef NS_ENUM(NSUInteger, XLFormDateDatePickerMode) {
@property (nonatomic) NSDateFormatter * dateFormatter;
@property (nonatomic) XLFormDateDatePickerMode formDatePickerMode;
@property (nonatomic) NSDate *minimumDate;
@property (nonatomic) NSDate *maximumDate;
@property (nonatomic) NSInteger minuteInterval;
@end
+15 -2
View File
@@ -44,6 +44,9 @@
- (UIView *)inputView
{
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeDate] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeTime] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeDateTime]){
if (self.rowDescriptor.value){
[self.datePicker setDate:self.rowDescriptor.value];
}
return self.datePicker;
}
return [super inputView];
@@ -82,12 +85,12 @@
{
[super update];
self.accessoryType = self.rowDescriptor.disabled ? UITableViewCellAccessoryNone : UITableViewCellAccessoryDisclosureIndicator;
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.textLabel.text = [NSString stringWithFormat:@"%@%@", self.rowDescriptor.title, self.rowDescriptor.required ? @"*" : @""];
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];
@@ -164,6 +167,16 @@
else{
datePicker.datePickerMode = UIDatePickerModeDateAndTime;
}
if (self.minuteInterval)
datePicker.minuteInterval = self.minuteInterval;
if (self.minimumDate)
datePicker.minimumDate = self.minimumDate;
if (self.maximumDate)
datePicker.maximumDate = self.maximumDate;
}
#pragma mark - Properties
+1 -2
View File
@@ -23,7 +23,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@class XLFormRowDescriptor;
@@ -43,7 +43,6 @@
-(BOOL)formDescriptorCellBecomeFirstResponder;
-(BOOL)formDescriptorCellResignFirstResponder;
-(void)formDescriptorCellDidSelectedWithFormController:(XLFormViewController *)controller;
-(NSError *)formDescriptorCellLocalValidation;
-(NSString *)formDescriptorHttpParameterName;
+2 -2
View File
@@ -61,11 +61,11 @@
-(void)update
{
[super update];
self.accessoryType = self.rowDescriptor.disabled ? UITableViewCellAccessoryNone : UITableViewCellAccessoryDisclosureIndicator;
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.textLabel.text = [NSString stringWithFormat:@"%@%@", self.rowDescriptor.title, self.rowDescriptor.required ? @"*" : @""];
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];
+16 -20
View File
@@ -34,6 +34,9 @@
@implementation XLFormLeftRightSelectorCell
{
UITextField * _constraintTextField;
}
@synthesize leftButton = _leftButton;
@@ -57,7 +60,6 @@
[_leftButton addSubview:separatorTop];
[_leftButton addSubview:separatorBottom];
[_leftButton addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[separatorTop(separatorBottom)][image][separatorBottom]|" options:0 metrics:0 views:@{@"image": imageView, @"separatorTop": separatorTop, @"separatorBottom": separatorBottom}]];
_leftButton.titleEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 15);
[_leftButton setTitleColor:[UIColor colorWithRed:0.0 green:0.478431 blue:1.0 alpha:1.0] forState:UIControlStateNormal];
@@ -108,31 +110,35 @@
[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]];
[self.contentView addSubview:_constraintTextField];
[_constraintTextField setHidden:YES];
[self.contentView addSubview:self.leftButton];
[self.contentView addSubview:self.rightLabel];
[self.contentView addSubview:separatorView];
NSDictionary * views = @{@"leftButton" : self.leftButton, @"rightLabel": self.rightLabel, @"separatorView": separatorView};
[self.contentView addConstraint:[self.leftButton layoutConstraintSameHeightOf:self.contentView]];
[self.contentView addConstraint:[self.rightLabel layoutConstraintSameHeightOf:self.contentView]];
NSDictionary * views = @{@"leftButton" : self.leftButton, @"rightLabel": self.rightLabel, @"separatorView": separatorView, @"constraintTextField": _constraintTextField };
[self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:self.leftButton attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterY multiplier:1.0f constant:0.0f]];
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[constraintTextField]" options:0 metrics:nil views:views]];
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-16-[leftButton]-[separatorView(1)]-[rightLabel]-14-|" options:NSLayoutFormatAlignAllCenterY metrics:nil views:views]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[rightLabel]" options:NSLayoutFormatAlignAllCenterY metrics:nil views:views]];
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-8-[separatorView]-8-|" options:0 metrics:nil views:views]];
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[separatorView(20)]" options:0 metrics:nil views:views]];
[self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-12-[constraintTextField]-12-|" options:0 metrics:0 views:views]];
}
-(void)update
{
[super update];
[self.leftButton addTarget:self action:@selector(leftButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.leftButton setTitle:[NSString stringWithFormat:@"%@%@", [self.rowDescriptor.leftRightSelectorLeftOptionSelected displayText], self.rowDescriptor.required ? @"*" : @""] forState:UIControlStateNormal];
[self.leftButton setTitle:[NSString stringWithFormat:@"%@%@", [self.rowDescriptor.leftRightSelectorLeftOptionSelected displayText], self.rowDescriptor.required && self.rowDescriptor.sectionDescriptor.formDescriptor.addAsteriskToRequiredRowsTitle ? @"*" : @""] forState:UIControlStateNormal];
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];
}
@@ -163,22 +169,12 @@
}
}
-(NSString *)formDescriptorHttpParameterName
{
XLFormLeftRightSelectorOption * option = [self leftOptionForOption:self.rowDescriptor.leftRightSelectorLeftOptionSelected];
return option.httpParameterKey;
}
-(NSError *)formDescriptorCellLocalValidation
{
if (self.rowDescriptor.required && self.rowDescriptor.value == nil){
return [[NSError alloc] initWithDomain:XLFormErrorDomain code:XLFormErrorCodeRequired userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedString(@"%@ can't be empty", nil), [self.rowDescriptor.leftRightSelectorLeftOptionSelected displayText]]}];
}
return nil;
}
#pragma mark - Actions
@@ -202,7 +198,7 @@
NSString * title = [actionSheet buttonTitleAtIndex:buttonIndex];
if (![self.rowDescriptor.leftRightSelectorLeftOptionSelected isEqual:[self leftOptionForDescription:title].leftValue]){
self.rowDescriptor.leftRightSelectorLeftOptionSelected = [self leftOptionForDescription:title].leftValue;
[self.leftButton setTitle:[NSString stringWithFormat:@"%@%@", [self.rowDescriptor.leftRightSelectorLeftOptionSelected displayText], self.rowDescriptor.required ? @"*" : @""] forState:UIControlStateNormal];
[self.leftButton setTitle:[NSString stringWithFormat:@"%@%@", [self.rowDescriptor.leftRightSelectorLeftOptionSelected displayText], self.rowDescriptor.required && self.rowDescriptor.sectionDescriptor.formDescriptor.addAsteriskToRequiredRowsTitle ? @"*" : @""] forState:UIControlStateNormal];
self.rowDescriptor.value = nil;
self.rightLabel.text = [self rightTextLabel];
}
+19 -19
View File
@@ -30,7 +30,7 @@
@interface XLFormSegmentedCell()
@property NSArray * dynamicCustomConstraints;
@property NSMutableArray * dynamicCustomConstraints;
@end
@@ -49,7 +49,6 @@ NSString * const kText = @"text";
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self.contentView addSubview:self.segmentedControl];
[self.contentView addSubview:self.textLabel];
[self.contentView addConstraints:[self layoutConstraints]];
[self.textLabel addObserver:self forKeyPath:kText options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context:0];
[self.segmentedControl addTarget:self action:@selector(valueChanged) forControlEvents:UIControlEventValueChanged];
}
@@ -69,7 +68,7 @@ NSString * const kText = @"text";
{
if (object == self.textLabel && [keyPath isEqualToString:kText]){
if ([[change objectForKey:NSKeyValueChangeKindKey] isEqualToNumber:@(NSKeyValueChangeSetting)]){
[self.contentView needsUpdateConstraints];
[self.contentView setNeedsUpdateConstraints];
}
}
}
@@ -89,7 +88,7 @@ NSString * const kText = @"text";
{
if (_textLabel) return _textLabel;
_textLabel = [UILabel autolayoutView];
[_textLabel setFont:[UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]];
[_textLabel setFont:[UIFont preferredFontForTextStyle:UIFontTextStyleBody]];
[_textLabel setContentCompressionResistancePriority:500
forAxis:UILayoutConstraintAxisHorizontal];
return _textLabel;
@@ -135,34 +134,35 @@ NSString * const kText = @"text";
#pragma mark - Layout Constraints
-(NSArray *)layoutConstraints{
NSMutableArray * result = [NSMutableArray array];
[result addObject:[NSLayoutConstraint constraintWithItem:self.segmentedControl attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]];
[result addObject:[NSLayoutConstraint constraintWithItem:self.textLabel attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]];
return result;
}
-(void)updateConstraints
{
if (self.dynamicCustomConstraints){
[self.contentView removeConstraints:self.dynamicCustomConstraints];
}
self.dynamicCustomConstraints = [NSMutableArray array];
NSDictionary * views = @{@"segmentedControl": self.segmentedControl, @"textLabel": self.textLabel};
if (self.textLabel.text.length > 0){
self.dynamicCustomConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-16-[textLabel]-16-[segmentedControl]-16-|"
[self.dynamicCustomConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-16-[textLabel]-16-[segmentedControl]-16-|"
options:NSLayoutFormatAlignAllCenterY
metrics:0
views:views]];
[self.dynamicCustomConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-12-[textLabel]-12-|"
options:0
metrics:0
views:views];
views:views]];
}
else{
self.dynamicCustomConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|-16-[segmentedControl]-16-|"
options:0
[self.dynamicCustomConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-16-[segmentedControl]-16-|"
options:NSLayoutFormatAlignAllCenterY
metrics:0
views:views];
views:views]];
[self.dynamicCustomConstraints addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-[segmentedControl]-|"
options:0
metrics:0
views:views]];
}
[self.contentView addConstraints:self.dynamicCustomConstraints];
[super updateConstraints];
+69 -10
View File
@@ -29,9 +29,10 @@
#import "XLFormSelectorCell.h"
#import "NSArray+XLFormAdditions.h"
@interface XLFormSelectorCell() <UIActionSheetDelegate, UIPickerViewDelegate, UIPickerViewDataSource>
@interface XLFormSelectorCell() <UIActionSheetDelegate, UIPickerViewDelegate, UIPickerViewDataSource, UIPopoverControllerDelegate>
@property (nonatomic) UIPickerView * pickerView;
@property (nonatomic) UIPopoverController *popoverController;
@end
@@ -41,7 +42,7 @@
-(NSString *)valueDisplayText
{
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelector]){
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelector] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelectorPopover]){
if (!self.rowDescriptor.value || [self.rowDescriptor.value count] == 0){
return self.rowDescriptor.noValueDisplayText;
}
@@ -127,11 +128,11 @@
-(void)update
{
[super update];
self.accessoryType = self.rowDescriptor.disabled ? UITableViewCellAccessoryNone : UITableViewCellAccessoryDisclosureIndicator;
self.accessoryType = self.rowDescriptor.disabled || !([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 ? UITableViewCellSelectionStyleNone : UITableViewCellSelectionStyleDefault;
self.textLabel.text = [NSString stringWithFormat:@"%@%@", self.rowDescriptor.title, self.rowDescriptor.required ? @"*" : @""];
self.selectionStyle = self.rowDescriptor.disabled || [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];
@@ -140,28 +141,79 @@
-(void)formDescriptorCellDidSelectedWithFormController:(XLFormViewController *)controller
{
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeSelectorPush]){
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeSelectorPush] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeSelectorPopover]){
if (self.rowDescriptor.selectorOptions){
XLFormOptionsViewController * optionsViewController = [[XLFormOptionsViewController alloc] initWithOptions:self.rowDescriptor.selectorOptions style:UITableViewStyleGrouped titleHeaderSection:nil titleFooterSection:nil];
optionsViewController.rowDescriptor = self.rowDescriptor;
optionsViewController.title = self.rowDescriptor.selectorTitle;
[controller.navigationController pushViewController:optionsViewController animated:YES];
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeSelectorPopover]) {
self.popoverController = [[UIPopoverController alloc] initWithContentViewController:optionsViewController];
self.popoverController.delegate = self;
optionsViewController.popoverController = self.popoverController;
if (self.detailTextLabel.window){
[self.popoverController presentPopoverFromRect:CGRectMake(0, 0, self.detailTextLabel.frame.size.width, self.detailTextLabel.frame.size.height) inView:self.detailTextLabel permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
else{
[self.popoverController presentPopoverFromRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height) inView:self permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
[controller.tableView deselectRowAtIndexPath:[controller.tableView indexPathForCell:self] animated:YES];
} else {
[controller.navigationController pushViewController:optionsViewController animated:YES];
}
}
else{
Class selectorClass = self.rowDescriptor.selectorControllerClass;
UIViewController<XLFormRowDescriptorViewController> *selectorViewController = [[selectorClass alloc] init];
selectorViewController.rowDescriptor = self.rowDescriptor;
selectorViewController.title = self.rowDescriptor.selectorTitle;
[controller.navigationController pushViewController:selectorViewController animated:YES];
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeSelectorPopover]) {
if (self.popoverController && self.popoverController.popoverVisible) {
[self.popoverController dismissPopoverAnimated:NO];
}
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:selectorViewController];
self.popoverController = [[UIPopoverController alloc] initWithContentViewController:navigationController];
self.popoverController.delegate = self;
if ([selectorViewController conformsToProtocol:@protocol(XLFormRowDescriptorPopoverViewController)]){
((id<XLFormRowDescriptorPopoverViewController>)selectorViewController).popoverController = self.popoverController;
}
if (self.detailTextLabel.window){
[self.popoverController presentPopoverFromRect:CGRectMake(0, 0, self.detailTextLabel.frame.size.width, self.detailTextLabel.frame.size.height) inView:self.detailTextLabel permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
else{
[self.popoverController presentPopoverFromRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height) inView:self permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
[controller.tableView deselectRowAtIndexPath:[controller.tableView indexPathForCell:self] animated:YES];
}
else {
[controller.navigationController pushViewController:selectorViewController animated:YES];
}
}
}
else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelector])
else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelector] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelectorPopover])
{
NSAssert(self.rowDescriptor.selectorOptions, @"selectorOptions property shopuld not be nil");
XLFormOptionsViewController * optionsViewController = [[XLFormOptionsViewController alloc] initWithOptions:self.rowDescriptor.selectorOptions style:UITableViewStyleGrouped titleHeaderSection:nil titleFooterSection:nil];
optionsViewController.rowDescriptor = self.rowDescriptor;
optionsViewController.title = self.rowDescriptor.selectorTitle;
[controller.navigationController pushViewController:optionsViewController animated:YES];
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelectorPopover]) {
self.popoverController = [[UIPopoverController alloc] initWithContentViewController:optionsViewController];
self.popoverController.delegate = self;
optionsViewController.popoverController = self.popoverController;
if (self.detailTextLabel.window){
[self.popoverController presentPopoverFromRect:CGRectMake(0, 0, self.detailTextLabel.frame.size.width, self.detailTextLabel.frame.size.height) inView:self.detailTextLabel permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
else{
[self.popoverController presentPopoverFromRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height) inView:self permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
[controller.tableView deselectRowAtIndexPath:[controller.tableView indexPathForCell:self] animated:YES];
} else {
[controller.navigationController pushViewController:optionsViewController animated:YES];
}
}
else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeSelectorActionSheet]){
UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle:self.rowDescriptor.selectorTitle delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
@@ -280,4 +332,11 @@
}
#pragma mark - UIPopoverControllerDelegate
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{
[self.formViewController.tableView reloadData];
}
@end
+30
View File
@@ -0,0 +1,30 @@
//
// XLFormSliderCell.h
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "XLForm.h"
@interface XLFormSliderCell : XLFormBaseCell
@end
+84
View File
@@ -0,0 +1,84 @@
//
// XLFormSliderCell.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "XLFormSliderCell.h"
#import "UIView+XLFormAdditions.h"
@interface XLFormSliderCell ()
@property UISlider* slider;
@property UILabel* textField;
@property NSUInteger steps;
@end
@implementation XLFormSliderCell
- (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 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-[slider]-15-|" options:0 metrics:0 views:@{@"slider": self.slider}]];
[self valueChanged:nil];
}
-(void)update {
[super update];
self.textField.text = self.rowDescriptor.title;
self.textField.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
self.slider.value = [self.rowDescriptor.value floatValue];
self.slider.enabled = !self.rowDescriptor.disabled;
self.textField.textColor = self.rowDescriptor.disabled ? [UIColor grayColor] : [UIColor blackColor];
[self valueChanged:nil];
}
-(void)valueChanged:(UISlider*)_slider {
if(self.steps != 0) {
self.slider.value = roundf((self.slider.value-self.slider.minimumValue)/(self.slider.maximumValue-self.slider.minimumValue)*self.steps)*(self.slider.maximumValue-self.slider.minimumValue)/self.steps + self.slider.minimumValue;
}
self.rowDescriptor.value = @(self.slider.value);
}
+(CGFloat)formDescriptorCellHeightForRowDescriptor:(XLFormRowDescriptor *)rowDescriptor {
return 88;
}
@end
+13 -1
View File
@@ -27,6 +27,12 @@
#import "XLFormStepCounterCell.h"
#import "XLFormRowDescriptor.h"
@interface XLFormStepCounterCell ()
@property (strong,nonatomic) UIColor *defaultTintColor;
@end
@implementation XLFormStepCounterCell
#pragma mark - XLFormStepCounterCell
@@ -47,6 +53,7 @@
0,
0)];
[stepperControl addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
self.defaultTintColor = stepperControl.tintColor;
UILabel *currentStepValue = [[UILabel alloc] initWithFrame:CGRectMake(0,
0,
@@ -55,7 +62,7 @@
currentStepValue.textAlignment = NSTextAlignmentCenter;
currentStepValue.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
currentStepValue.textColor = stepperControl.tintColor;
currentStepValue.textColor = self.defaultTintColor;
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0,
0,
@@ -74,6 +81,11 @@
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 valueChanged:nil];
}
- (UIStepper *)stepControl
+1
View File
@@ -45,6 +45,7 @@
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;
}
+43 -40
View File
@@ -46,7 +46,7 @@
{
if ((object == self.textLabel && [keyPath isEqualToString:@"text"]) || (object == self.imageView && [keyPath isEqualToString:@"image"])){
if ([[change objectForKey:NSKeyValueChangeKindKey] isEqualToNumber:@(NSKeyValueChangeSetting)]){
[self.contentView needsUpdateConstraints];
[self.contentView setNeedsUpdateConstraints];
}
}
}
@@ -80,12 +80,12 @@
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeText]){
self.textField.autocorrectionType = UITextAutocorrectionTypeDefault;
self.textField.autocapitalizationType = UITextAutocapitalizationTypeSentences;
self.textField.keyboardType = UIKeyboardTypeAlphabet;
self.textField.keyboardType = UIKeyboardTypeDefault;
}
else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeName]){
self.textField.autocorrectionType = UITextAutocorrectionTypeNo;
self.textField.autocapitalizationType = UITextAutocapitalizationTypeWords;
self.textField.keyboardType = UIKeyboardTypeAlphabet;
self.textField.keyboardType = UIKeyboardTypeDefault;
}
else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeEmail]){
self.textField.keyboardType = UIKeyboardTypeEmailAddress;
@@ -100,10 +100,13 @@
else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeInteger]){
self.textField.keyboardType = UIKeyboardTypeNumberPad;
}
else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeDecimal]){
self.textField.keyboardType = UIKeyboardTypeDecimalPad;
}
else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypePassword]){
self.textField.autocorrectionType = UITextAutocorrectionTypeNo;
self.textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
self.textField.keyboardType = UIKeyboardTypeAlphabet;
self.textField.keyboardType = UIKeyboardTypeASCIICapable;
self.textField.secureTextEntry = YES;
}
else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypePhone]){
@@ -120,14 +123,14 @@
self.textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
}
else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeAccount]){
self.textField.keyboardType = UIKeyboardTypeAlphabet;
self.textField.keyboardType = UIKeyboardTypeASCIICapable;
self.textField.autocorrectionType = UITextAutocorrectionTypeNo;
self.textField.autocapitalizationType = UITextAutocapitalizationTypeNone;
}
self.textLabel.text = ((self.rowDescriptor.required && self.rowDescriptor.title) ? [NSString stringWithFormat:@"%@*", self.rowDescriptor.title] : self.rowDescriptor.title);
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.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];
@@ -145,32 +148,13 @@
return [self.textField resignFirstResponder];
}
-(NSError *)formDescriptorCellLocalValidation
{
if (self.rowDescriptor.required && (self.textField.text == nil || [self.textField.text isEqualToString:@""])){
return [[NSError alloc] initWithDomain:XLFormErrorDomain code:XLFormErrorCodeRequired userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedString(@"%@ can't be empty", nil), self.rowDescriptor.title] }];
}
else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeEmail] && self.textField.text.length > 0 && ![self isValidAsEmail:self.textField.text]){
return [[NSError alloc] initWithDomain:XLFormErrorDomain code:XLFormErrorCodeInvalidEmailAddress userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedString(@"\"%@\" is not an email", nil), self.textField.text] }];
}
return nil;
}
-(BOOL)isValidAsEmail:(NSString *)emailString
{
NSString *regexForEmailAddress = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
NSPredicate *emailValidation = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regexForEmailAddress];
return [emailValidation evaluateWithObject:emailString];
}
#pragma mark - Properties
-(UILabel *)textLabel
{
if (_textLabel) return _textLabel;
_textLabel = [UILabel autolayoutView];
[_textLabel setFont:[UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]];
[_textLabel setFont:[UIFont preferredFontForTextStyle:UIFontTextStyleBody]];
return _textLabel;
}
@@ -178,7 +162,7 @@
{
if (_textField) return _textField;
_textField = [UITextField autolayoutView];
[_textField setFont:[UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline]];
[_textField setFont:[UIFont preferredFontForTextStyle:UIFontTextStyleBody]];
return _textField;
}
@@ -188,10 +172,8 @@
{
NSMutableArray * result = [[NSMutableArray alloc] init];
[self.textLabel setContentHuggingPriority:500 forAxis:UILayoutConstraintAxisHorizontal];
[result addObject:[NSLayoutConstraint constraintWithItem:self.textLabel attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeHeight multiplier:1 constant:0]];
[result addObject:[NSLayoutConstraint constraintWithItem:self.textField attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeHeight multiplier:1 constant:0]];
[result addObject:[NSLayoutConstraint constraintWithItem:self.textField attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]];
[result addObject:[NSLayoutConstraint constraintWithItem:self.textLabel attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]];
[result addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[_textLabel]-[_textField]" options:NSLayoutFormatAlignAllBaseline metrics:0 views:NSDictionaryOfVariableBindings(_textLabel, _textField)]];
[result addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-12-[_textField]-12-|" options:NSLayoutFormatAlignAllBaseline metrics:nil views:NSDictionaryOfVariableBindings(_textField)]];
return result;
}
@@ -234,6 +216,25 @@
return [self.formViewController textFieldShouldReturn:textField];
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
return [self.formViewController textFieldShouldBeginEditing:textField];
}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
return [self.formViewController textFieldShouldEndEditing:textField];
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
return [self.formViewController textField:textField shouldChangeCharactersInRange:range replacementString:string];
}
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
[self.formViewController textFieldDidBeginEditing:textField];
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
[self textFieldDidChange:textField];
@@ -244,14 +245,16 @@
#pragma mark - Helper
- (void)textFieldDidChange:(UITextField *)textField{
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeNumber]){
self.rowDescriptor.value = @([self.textField.text doubleValue]);
}
else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeInteger]){
self.rowDescriptor.value = @([self.textField.text integerValue]);
}
else{
self.rowDescriptor.value = self.textField.text;
if([self.textField.text length] > 0) {
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeNumber]){
self.rowDescriptor.value = @([self.textField.text doubleValue]);
} else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeInteger]){
self.rowDescriptor.value = @([self.textField.text integerValue]);
} else {
self.rowDescriptor.value = self.textField.text;
}
} else {
self.rowDescriptor.value = nil;
}
}
+12 -13
View File
@@ -98,12 +98,12 @@ NSString *const kFormTextViewCellPlaceholder = @"placeholder";
self.label.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
self.textView.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
self.textView.placeHolderLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
self.textView.keyboardType = UIKeyboardTypeAlphabet;
self.textView.keyboardType = UIKeyboardTypeDefault;
self.textView.text = self.rowDescriptor.value;
[self.textView setEditable:!self.rowDescriptor.disabled];
self.textView.textColor = self.rowDescriptor.disabled ? [UIColor grayColor] : [UIColor blackColor];
self.label.textColor = self.rowDescriptor.disabled ? [UIColor grayColor] : [UIColor blackColor];
self.label.text = ((self.rowDescriptor.required && self.rowDescriptor.title) ? [NSString stringWithFormat:@"%@*", self.rowDescriptor.title]: self.rowDescriptor.title);
self.label.text = ((self.rowDescriptor.required && self.rowDescriptor.title && self.rowDescriptor.sectionDescriptor.formDescriptor.addAsteriskToRequiredRowsTitle) ? [NSString stringWithFormat:@"%@*", self.rowDescriptor.title]: self.rowDescriptor.title);
}
+(CGFloat)formDescriptorCellHeightForRowDescriptor:(XLFormRowDescriptor *)rowDescriptor
@@ -111,15 +111,6 @@ NSString *const kFormTextViewCellPlaceholder = @"placeholder";
return 110.f;
}
-(NSError *)formDescriptorCellLocalValidation
{
if (self.rowDescriptor.required && (self.textView.text == nil || [self.textView.text isEqualToString:@""])){
return [[NSError alloc] initWithDomain:XLFormErrorDomain code:XLFormErrorCodeRequired userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:NSLocalizedString(@"%@ can't be empty", nil), self.rowDescriptor.title] }];
}
return nil;
}
-(BOOL)formDescriptorCellBecomeFirstResponder
{
return [self.textView becomeFirstResponder];
@@ -151,12 +142,20 @@ NSString *const kFormTextViewCellPlaceholder = @"placeholder";
#pragma mark - UITextViewDelegate
-(void)textViewDidEndEditing:(UITextView *)textView{
self.rowDescriptor.value = self.textView.text;
if([self.textView.text length] > 0) {
self.rowDescriptor.value = self.textView.text;
} else {
self.rowDescriptor.value = nil;
}
[self.formViewController textViewDidEndEditing:textView];
}
-(void)textViewDidChange:(UITextView *)textView{
self.rowDescriptor.value = self.textView.text;
if([self.textView.text length] > 0) {
self.rowDescriptor.value = self.textView.text;
} else {
self.rowDescriptor.value = nil;
}
}
@end
@@ -28,7 +28,7 @@
#import "XLFormRowDescriptorViewController.h"
#import "XLFormRowDescriptor.h"
@interface XLFormOptionsViewController : UITableViewController<XLFormRowDescriptorViewController>
@interface XLFormOptionsViewController : UITableViewController<XLFormRowDescriptorViewController, XLFormRowDescriptorPopoverViewController>
- (id)initWithOptions:(NSArray *)options style:(UITableViewStyle)style;
@@ -45,6 +45,7 @@
@synthesize titleHeaderSection = _titleHeaderSection;
@synthesize titleFooterSection = _titleFooterSection;
@synthesize rowDescriptor = _rowDescriptor;
@synthesize popoverController = __popoverController;
@synthesize options = _options;
- (id)initWithOptions:(NSArray *)options style:(UITableViewStyle)style
@@ -68,7 +69,6 @@
[super viewDidLoad];
// register option cell
[self.tableView registerClass:[XLFormRightDetailCell class] forCellReuseIdentifier:CELL_REUSE_IDENTIFIER];
//self.tableView.allowsMultipleSelection = [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelector];
}
@@ -84,7 +84,7 @@
XLFormRightDetailCell * cell = [tableView dequeueReusableCellWithIdentifier:CELL_REUSE_IDENTIFIER forIndexPath:indexPath];
id cellObject = [self.options objectAtIndex:indexPath.row];
cell.textLabel.text = [self valueDisplayTextForOption:cellObject];
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelector]){
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelector] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelectorPopover]){
cell.accessoryType = ([self selectedValuesContainsOption:cellObject] ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone);
}
else{
@@ -116,7 +116,7 @@
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
id cellObject = [self.options objectAtIndex:indexPath.row];
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelector]){
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelector] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelectorPopover]){
if ([self selectedValuesContainsOption:cellObject]){
self.rowDescriptor.value = [self selectedValuesRemoveOption:cellObject];
cell.accessoryType = UITableViewCellAccessoryNone;
@@ -128,7 +128,9 @@
}
else{
if ([[self.rowDescriptor.value valueData] isEqual:[cellObject valueData]]){
self.rowDescriptor.value = nil;
if (!self.rowDescriptor.required){
self.rowDescriptor.value = nil;
}
cell.accessoryType = UITableViewCellAccessoryNone;
}
else{
@@ -143,7 +145,13 @@
self.rowDescriptor.value = cellObject;
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
[self.navigationController popViewControllerAnimated:YES];
if (self.popoverController){
[self.popoverController dismissPopoverAnimated:YES];
[self.popoverController.delegate popoverControllerDidDismissPopover:self.popoverController];
}
else if ([self.parentViewController isKindOfClass:[UINavigationController class]]){
[self.navigationController popViewControllerAnimated:YES];
}
}
[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}
@@ -176,7 +184,7 @@
return self.selectedValues;
}
-(NSMutableArray *)selectedValuesAddOption:(id)option
-(NSMutableArray *)selectedValuesAddOption:(id)option
{
NSAssert([self.selectedValues formIndexForItem:option] == NSNotFound, @"XLFormRowDescriptor value must not contain the option");
NSMutableArray * result = self.selectedValues;
@@ -34,3 +34,10 @@
@end
@protocol XLFormRowDescriptorPopoverViewController <NSObject>
@required
@property (nonatomic) UIPopoverController * popoverController;
@end
+5 -1
View File
@@ -58,12 +58,16 @@
@end
@interface XLFormViewController : UITableViewController<XLFormDescriptorDelegate, UITextFieldDelegate, UITextViewDelegate, UIActionSheetDelegate, XLFormViewControllerDelegate>
@interface XLFormViewController : UIViewController<UITableViewDataSource, UITableViewDelegate, XLFormDescriptorDelegate, UITextFieldDelegate, UITextViewDelegate, UIActionSheetDelegate, XLFormViewControllerDelegate>
@property XLFormDescriptor * form;
@property IBOutlet UITableView * tableView;
-(id)initWithForm:(XLFormDescriptor *)form;
-(id)initWithForm:(XLFormDescriptor *)form style:(UITableViewStyle)style;
+(NSMutableDictionary *)cellClassesForRowDescriptorTypes;
+(NSMutableDictionary *)inlineRowDescriptorTypesForRowDescriptorTypes;
-(void)performFormSeletor:(SEL)selector withObject:(id)sender;
@end
+129 -29
View File
@@ -23,6 +23,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "UIView+XLFormAdditions.h"
#import "NSObject+XLFormAdditions.h"
#import "XLFormViewController.h"
#import "UIView+XLFormAdditions.h"
@@ -35,28 +36,19 @@
@end
@implementation XLFormViewController
-(id)init
{
return [self initWithStyle:UITableViewStyleGrouped];
}
-(id)initWithForm:(XLFormDescriptor *)form
{
self = [self initWithStyle:UITableViewStyleGrouped];
if (self){
self.form = form;
}
return self;
return [self initWithForm:form style:UITableViewStyleGrouped];
}
- (id)initWithStyle:(UITableViewStyle)style
-(id)initWithForm:(XLFormDescriptor *)form style:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
self = [self initWithNibName:nil bundle:nil];
if (self){
_tableViewStyle = style;
_form = form;
}
return self;
}
@@ -70,8 +62,6 @@
return self;
}
-(id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
@@ -90,13 +80,30 @@
- (void)viewDidLoad
{
[super viewDidLoad];
if (!self.tableView){
self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds
style:self.tableViewStyle];
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}
if (!self.tableView.superview){
[self.view addSubview:self.tableView];;
}
if (!self.tableView.delegate){
self.tableView.delegate = self;
}
if (!self.tableView.dataSource){
self.tableView.dataSource = self;
}
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")){
self.tableView.rowHeight = UITableViewAutomaticDimension;
self.tableView.estimatedRowHeight = 44.0;
}
if (self.form.title){
self.title = self.form.title;
}
[self.tableView setEditing:YES animated:NO];
self.tableView.allowsSelectionDuringEditing = YES;
self.form.delegate = self;
self.clearsSelectionOnViewWillAppear = NO;
}
-(void)viewWillAppear:(BOOL)animated
@@ -112,6 +119,15 @@
selector:@selector(contentSizeCategoryChanged:)
name:UIContentSizeCategoryDidChangeNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];
}
-(void)viewDidDisappear:(BOOL)animated
@@ -120,6 +136,15 @@
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIContentSizeCategoryDidChangeNotification
object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UIKeyboardWillHideNotification
object:nil];
}
- (void)viewDidAppear:(BOOL)animated
@@ -154,15 +179,19 @@
XLFormRowDescriptorTypePassword: [XLFormTextFieldCell class],
XLFormRowDescriptorTypeNumber: [XLFormTextFieldCell class],
XLFormRowDescriptorTypeInteger: [XLFormTextFieldCell class],
XLFormRowDescriptorTypeDecimal: [XLFormTextFieldCell class],
XLFormRowDescriptorTypeSelectorPush: [XLFormSelectorCell class],
XLFormRowDescriptorTypeSelectorPopover: [XLFormSelectorCell class],
XLFormRowDescriptorTypeSelectorActionSheet: [XLFormSelectorCell class],
XLFormRowDescriptorTypeSelectorAlertView: [XLFormSelectorCell class],
XLFormRowDescriptorTypeSelectorPickerView: [XLFormSelectorCell class],
XLFormRowDescriptorTypeSelectorPickerViewInline: [XLFormInlineSelectorCell class],
XLFormRowDescriptorTypeSelectorSegmentedControl: [XLFormSegmentedCell class],
XLFormRowDescriptorTypeMultipleSelector: [XLFormSelectorCell class],
XLFormRowDescriptorTypeMultipleSelectorPopover: [XLFormSelectorCell class],
XLFormRowDescriptorTypeTextView: [XLFormTextViewCell class],
XLFormRowDescriptorTypeButton: [XLFormButtonCell class],
XLFormRowDescriptorTypeInfo: [XLFormSelectorCell class],
XLFormRowDescriptorTypeBooleanSwitch : [XLFormSwitchCell class],
XLFormRowDescriptorTypeBooleanCheck : [XLFormCheckCell class],
XLFormRowDescriptorTypeDate: [XLFormDateCell class],
@@ -173,6 +202,7 @@
XLFormRowDescriptorTypeDateTimeInline: [XLFormDateCell class],
XLFormRowDescriptorTypeDatePicker : [XLFormDatePickerCell class],
XLFormRowDescriptorTypePicker : [XLFormPickerCell class],
XLFormRowDescriptorTypeSlider : [XLFormSliderCell class],
XLFormRowDescriptorTypeSelectorLeftRight : [XLFormLeftRightSelectorCell class],
XLFormRowDescriptorTypeStepCounter: [XLFormStepCounterCell class]
} mutableCopy];
@@ -240,7 +270,7 @@
-(void)didSelectFormRow:(XLFormRowDescriptor *)formRow
{
if ([[formRow cellForFormController:self] respondsToSelector:@selector(formDescriptorCellDidSelectedWithFormController:)]){
if ([[formRow cellForFormController:self] respondsToSelector:@selector(formDescriptorCellDidSelectedWithFormController:)]){
[[formRow cellForFormController:self] formDescriptorCellDidSelectedWithFormController:self];
}
}
@@ -281,6 +311,18 @@
[alertView show];
}
-(void)performFormSeletor:(SEL)selector withObject:(id)sender
{
UIResponder * responder = [self targetForAction:selector withSender:sender];;
if (responder) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warc-performSelector-leaks"
[responder performSelector:selector withObject:sender];
#pragma GCC diagnostic pop
}
}
#pragma mark - Private
- (void)contentSizeCategoryChanged:(NSNotification *)notification
@@ -288,6 +330,50 @@
[self.tableView reloadData];
}
- (void)keyboardWillShow:(NSNotification *)notification
{
UIView * firstResponderView = [self.tableView findFirstResponder];
UITableViewCell<XLFormDescriptorCell> * cell = [firstResponderView formDescriptorCell];
if (cell){
NSDictionary *keyboardInfo = [notification userInfo];
CGRect keyboardFrame = [self.tableView.window convertRect:[keyboardInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue] toView:self.tableView.superview];
CGFloat newBottomInset = self.tableView.frame.origin.y + self.tableView.frame.size.height - keyboardFrame.origin.y;
if (newBottomInset > 0){
UIEdgeInsets tableContentInset = self.tableView.contentInset;
UIEdgeInsets tableScrollIndicatorInsets = self.tableView.scrollIndicatorInsets;
tableContentInset.bottom = newBottomInset;
tableScrollIndicatorInsets.bottom = tableContentInset.bottom;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:[keyboardInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]];
[UIView setAnimationCurve:[keyboardInfo[UIKeyboardAnimationCurveUserInfoKey] intValue]];
self.tableView.contentInset = tableContentInset;
self.tableView.scrollIndicatorInsets = tableScrollIndicatorInsets;
NSIndexPath *selectedRow = [self.tableView indexPathForCell:cell];
[self.tableView scrollToRowAtIndexPath:selectedRow atScrollPosition:UITableViewScrollPositionNone animated:NO];
[UIView commitAnimations];
}
}
}
- (void)keyboardWillHide:(NSNotification *)notification
{
UIView * firstResponderView = [self.tableView findFirstResponder];
UITableViewCell<XLFormDescriptorCell> * cell = [firstResponderView formDescriptorCell];
if (cell){
NSDictionary *keyboardInfo = [notification userInfo];
UIEdgeInsets tableContentInset = self.tableView.contentInset;
UIEdgeInsets tableScrollIndicatorInsets = self.tableView.scrollIndicatorInsets;
tableContentInset.bottom = 0;
tableScrollIndicatorInsets.bottom = tableContentInset.bottom;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:[keyboardInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue]];
[UIView setAnimationCurve:[keyboardInfo[UIKeyboardAnimationCurveUserInfoKey] intValue]];
self.tableView.contentInset = tableContentInset;
self.tableView.scrollIndicatorInsets = tableScrollIndicatorInsets;
[UIView commitAnimations];
}
}
#pragma mark - Helpers
-(void)deselectFormRow:(XLFormRowDescriptor *)formRow
@@ -340,19 +426,16 @@
{
XLFormRowDescriptor * rowDescriptor = [self.form formRowAtIndex:indexPath];
UITableViewCell<XLFormDescriptorCell> * formDescriptorCell = [rowDescriptor cellForFormController:self];
((UITableViewCell<XLFormDescriptorCell> *)formDescriptorCell).rowDescriptor = rowDescriptor;
[rowDescriptor.cellConfig enumerateKeysAndObjectsUsingBlock:^(NSString *keyPath, id value, BOOL * __unused stop) {
[formDescriptorCell setValue:value forKeyPath:keyPath];
}];
[formDescriptorCell setNeedsLayout];
return formDescriptorCell;
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
XLFormRowDescriptor * rowDescriptor = [self.form formRowAtIndex:indexPath];
((UITableViewCell<XLFormDescriptorCell> *)cell).rowDescriptor = rowDescriptor;
[rowDescriptor.cellConfig enumerateKeysAndObjectsUsingBlock:^(NSString *keyPath, id value, BOOL *stop) {
[cell setValue:value forKeyPath:keyPath];
}];
[cell setNeedsUpdateConstraints];
[cell setNeedsLayout];
}
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
@@ -400,7 +483,7 @@
if ([cellClass respondsToSelector:@selector(formDescriptorCellHeightForRowDescriptor:)]){
return [cellClass formDescriptorCellHeightForRowDescriptor:rowDescriptor];
}
return [super tableView:tableView heightForRowAtIndexPath:indexPath];
return self.tableView.rowHeight;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
@@ -453,6 +536,23 @@
return YES;
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
return YES;
}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
return YES;
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
return YES;
}
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
}
-(void)textFieldDidEndEditing:(UITextField *)textField
{
+3 -3
View File
@@ -32,9 +32,8 @@ NSString * const XLFormErrorDomain;
typedef NS_ENUM(NSInteger, XLFormErrorCode)
{
XLFormErrorCodeRequired = -999,
XLFormErrorCodePasswordsMustMatch = -998,
XLFormErrorCodeInvalidEmailAddress = -997
XLFormErrorCodeGen = -999,
XLFormErrorCodeRequired = -1000
};
@class XLFormSectionDescriptor;
@@ -44,6 +43,7 @@ typedef NS_ENUM(NSInteger, XLFormErrorCode)
@property (readonly, nonatomic) NSMutableArray * formSections;
@property (readonly) NSString * title;
@property (nonatomic) BOOL assignFirstResponderOnShow;
@property (nonatomic) BOOL addAsteriskToRequiredRowsTitle;
@property (weak) id<XLFormDescriptorDelegate> delegate;
+14 -7
View File
@@ -38,12 +38,18 @@ NSString * const XLFormErrorDomain = @"XLFormErrorDomain";
@implementation XLFormDescriptor
-(id)init
{
return [self initWithTitle:nil];
}
-(id)initWithTitle:(NSString *)title;
{
self = [super init];
if (self){
_formSections = [NSMutableArray array];
_title = title;
_addAsteriskToRequiredRowsTitle = NO;
[self addObserver:self forKeyPath:@"formSections" options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld) context:0];
}
return self;
@@ -200,7 +206,7 @@ NSString * const XLFormErrorDomain = @"XLFormErrorDomain";
}
}
return result;
}
-(NSDictionary *)httpParameters:(XLFormViewController *)formViewController
@@ -241,23 +247,24 @@ NSString * const XLFormErrorDomain = @"XLFormErrorDomain";
return nil;
}
-(NSArray *)localValidationErrors:(XLFormViewController *)formViewController
{
-(NSArray *)localValidationErrors:(XLFormViewController *)formViewController {
NSMutableArray * result = [NSMutableArray array];
for (XLFormSectionDescriptor * section in self.formSections) {
for (XLFormRowDescriptor * row in section.formRows) {
UITableViewCell<XLFormDescriptorCell> * cell = [row cellForFormController:formViewController];
if ([cell respondsToSelector:@selector(formDescriptorCellLocalValidation)]){
NSError * error = cell.formDescriptorCellLocalValidation;
XLFormValidationStatus* status = [row doValidation];
if (status != nil && (![status isValid])) {
NSError * error = [[NSError alloc] initWithDomain:XLFormErrorDomain code:XLFormErrorCodeGen userInfo:@{ NSLocalizedDescriptionKey:status.msg }];
if (error){
[result addObject:error];
}
}
}
}
return result;
}
- (void)setFirstResponder:(XLFormViewController *)formViewController
{
for (XLFormSectionDescriptor * formSection in self.formSections) {
@@ -303,7 +310,7 @@ NSString * const XLFormErrorDomain = @"XLFormErrorDomain";
NSUInteger sectionIndex = [self.formSections indexOfObject:object];
[self.delegate formRowHasBeenRemoved:removedRow atIndexPath:[NSIndexPath indexPathForRow:indexSet.firstIndex inSection:sectionIndex]];
}
}
}
+20 -5
View File
@@ -24,12 +24,15 @@
// THE SOFTWARE.
#import "XLFormBaseCell.h"
#import <Foundation/Foundation.h>
#import "XLFormBaseCell.h"
#import "XLFormValidatorProtocol.h"
#import "XLFormValidationStatus.h"
@class XLFormViewController;
@class XLFormSectionDescriptor;
@protocol XLFormValidatorProtocol;
@class XLFormAction;
typedef NS_ENUM(NSUInteger, XLFormPresentationMode) {
XLFormPresentationModeDefault = 0,
@@ -39,7 +42,7 @@ typedef NS_ENUM(NSUInteger, XLFormPresentationMode) {
@interface XLFormRowDescriptor : NSObject
@property Class cellClass;
@property id cellClass;
@property (readwrite) NSString *tag;
@property (readonly) NSString *rowType;
@property NSString *title;
@@ -52,6 +55,8 @@ typedef NS_ENUM(NSUInteger, XLFormPresentationMode) {
@property BOOL disabled;
@property BOOL required;
@property (readonly) XLFormAction * action;
@property (weak) XLFormSectionDescriptor * sectionDescriptor;
-(id)initWithTag:(NSString *)tag rowType:(NSString *)rowType title:(NSString *)title;
@@ -60,6 +65,11 @@ typedef NS_ENUM(NSUInteger, XLFormPresentationMode) {
-(UITableViewCell<XLFormDescriptorCell> *)cellForFormController:(XLFormViewController *)formController;
@property NSString *requireMsg;
-(void) addValidator: (id<XLFormValidatorProtocol>) validator;
-(void) removeValidator: (id<XLFormValidatorProtocol>) validator;
-(XLFormValidationStatus *) doValidation;
// ================================
// properties for Button
// =================================
@@ -99,8 +109,8 @@ typedef NS_ENUM(NSUInteger, XLFormPresentationMode) {
+(XLFormLeftRightSelectorOption *)formLeftRightSelectorOptionWithLeftValue:(id)leftValue
httpParameterKey:(NSString *)httpParameterKey
rightOptions:(NSArray *)rightOptions;
httpParameterKey:(NSString *)httpParameterKey
rightOptions:(NSArray *)rightOptions;
@end
@@ -116,5 +126,10 @@ typedef NS_ENUM(NSUInteger, XLFormPresentationMode) {
@end
@interface XLFormAction : NSObject
@property (nonatomic, strong) void (^formBlock)(XLFormRowDescriptor * sender);
@property (nonatomic) SEL formSelector;
@end
+118 -6
View File
@@ -23,28 +23,34 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "XLForm.h"
#import "XLFormViewController.h"
#import "XLFormRowDescriptor.h"
@interface XLFormRowDescriptor() <NSCopying>
@property UITableViewCell<XLFormDescriptorCell> * cell;
@property (nonatomic) NSMutableArray *validators;
@end
@implementation XLFormRowDescriptor
@synthesize action = _action;
-(id)initWithTag:(NSString *)tag rowType:(NSString *)rowType title:(NSString *)title;
{
self = [self init];
if (self){
NSAssert(((![rowType isEqualToString:XLFormRowDescriptorTypeSelectorPopover] && ![rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelectorPopover]) || (([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) && ([rowType isEqualToString:XLFormRowDescriptorTypeSelectorPopover] || [rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelectorPopover]))), @"You must be running under UIUserInterfaceIdiomPad to use either XLFormRowDescriptorTypeSelectorPopover or XLFormRowDescriptorTypeMultipleSelectorPopover rows.");
_tag = tag;
_disabled = NO;
_rowType = rowType;
_title = title;
_buttonViewControllerPresentationMode = XLFormPresentationModeDefault;
_cellStype = UITableViewCellStyleValue1;
_validators = [NSMutableArray new];
}
return self;
}
@@ -62,13 +68,31 @@
-(UITableViewCell<XLFormDescriptorCell> *)cellForFormController:(XLFormViewController *)formController
{
if (_cell) return _cell;
NSAssert(self.cellClass || [XLFormViewController cellClassesForRowDescriptorTypes][self.rowType], @"Not defined XLFormRowDescriptorType");
_cell = self.cellClass ? [[self.cellClass alloc] initWithStyle:self.cellStype reuseIdentifier:nil] : [[[XLFormViewController cellClassesForRowDescriptorTypes][self.rowType] alloc] initWithStyle:self.cellStype reuseIdentifier:nil];
id cellClass = self.cellClass ?: [XLFormViewController cellClassesForRowDescriptorTypes][self.rowType];
NSAssert(cellClass, @"Not defined XLFormRowDescriptorType");
if ([cellClass isKindOfClass:[NSString class]]) {
UITableViewCell<XLFormDescriptorCell> * reuseCell = [formController.tableView dequeueReusableCellWithIdentifier:cellClass];
if (reuseCell){
_cell = reuseCell;
[self configureCellAtCreationTime];
}
else if (!_cell && [[NSBundle mainBundle] pathForResource:cellClass ofType:@"nib"]){
_cell = [[[NSBundle mainBundle] loadNibNamed:cellClass owner:nil options:nil] firstObject];
[self configureCellAtCreationTime];
}
} else if (!_cell) {
_cell = [[cellClass alloc] initWithStyle:self.cellStype reuseIdentifier:nil];
[self configureCellAtCreationTime];
}
NSAssert([_cell isKindOfClass:[UITableViewCell class]] && [_cell conformsToProtocol:@protocol(XLFormDescriptorCell)], @"Can not get a UITableViewCell form cellClass");
return _cell;
}
- (void) configureCellAtCreationTime
{
[self.cellConfigAtConfigure enumerateKeysAndObjectsUsingBlock:^(NSString *keyPath, id value, __unused BOOL *stop) {
[_cell setValue:value forKeyPath:keyPath];
}];
return _cell;
}
-(NSMutableDictionary *)cellConfig
@@ -90,6 +114,14 @@
return [NSString stringWithFormat:@"%@ - %@ (%@)", [super description], self.tag, self.rowType];
}
-(XLFormAction *)action
{
if (!_action){
_action = [[XLFormAction alloc] init];
}
return _action;
}
// In the implementation
-(id)copyWithZone:(NSZone *)zone
{
@@ -100,9 +132,9 @@
rowDescriptorCopy.disabled = self.disabled;
rowDescriptorCopy.required = self.required;
// ================================
// =====================
// properties for Button
// =================================
// =====================
rowDescriptorCopy.buttonViewController = [self.buttonViewController copy];
rowDescriptorCopy.buttonViewControllerPresentationMode = self.buttonViewControllerPresentationMode;
@@ -123,6 +155,68 @@
}
#pragma mark - validation
-(void) addValidator: (id<XLFormValidatorProtocol>) validator {
if (validator == nil || ![validator conformsToProtocol:@protocol(XLFormValidatorProtocol)])
return;
if(![self.validators containsObject:validator]) {
[self.validators addObject:validator];
}
}
-(void) removeValidator: (id<XLFormValidatorProtocol>) validator {
if (validator == nil|| ![validator conformsToProtocol:@protocol(XLFormValidatorProtocol)])
return;
if ([self.validators containsObject:validator]) {
[self.validators removeObject:validator];
}
}
-(XLFormValidationStatus *) doValidation {
XLFormValidationStatus *valStatus = [XLFormValidationStatus formValidationStatusWithMsg:@"" status:YES];
if (self.required) {
// do required validation here
if (self.value == nil) { // || value.length() == 0
valStatus.isValid = NO;
NSString *msg = nil;
if (self.requireMsg != nil) {
msg = self.requireMsg;
} else {
// default message for required msg
msg = NSLocalizedString(@"%@ can't be empty", nil);
}
valStatus.msg = [NSString stringWithFormat:msg, self.title];
return valStatus;
}
} else {
// if user has not enter anything, we dun display the valid icon
if (self.value == nil) {// || value.length() == 0
valStatus = nil; // optional field, we will mark this validation as optional by passing null
}
}
// custom validator
for(id<XLFormValidatorProtocol> v in self.validators) {
if ([v conformsToProtocol:@protocol(XLFormValidatorProtocol)]) {
XLFormValidationStatus *vStatus = [v isValid:self];
// fail validation
if (vStatus != nil && !vStatus.isValid) {
return vStatus;
}
valStatus = vStatus;
} else {
valStatus = nil;
}
}
return valStatus;
}
@end
@@ -155,3 +249,21 @@
@end
@implementation XLFormAction
-(void)setFormSelector:(SEL)formSelector
{
_formBlock = nil;
_formSelector = formSelector;
}
-(void)setFormBlock:(void (^)(XLFormRowDescriptor *))formBlock
{
_formSelector = nil;
_formBlock = formBlock;
}
@end
@@ -33,14 +33,25 @@
@implementation XLFormSectionDescriptor
-(id)init
{
self = [super init];
if (self){
_formRows = [NSMutableArray array];
_isMultivaluedSection = NO;
_title = nil;
_footerTitle = nil;
}
return self;
}
-(id)initWithTitle:(NSString *)title multivaluedSection:(BOOL)multivaluedSection
{
self = [self init];
if (self){
_formRows = [NSMutableArray array];
_isMultivaluedSection = multivaluedSection;
_title = title;
_footerTitle = nil;
}
return self;
}
-6
View File
@@ -26,12 +26,6 @@
#import "XLFormTextView.h"
@interface XLFormTextView()
//
//@property (nonatomic, retain) UILabel *placeHolderLabel;
@end
@implementation XLFormTextView
- (void)dealloc
@@ -0,0 +1,38 @@
//
// XLFormRegexValidator.h
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "XLFormValidatorProtocol.h"
#import "XLFormValidationStatus.h"
#import "XLFormValidator.h"
@interface XLFormRegexValidator : XLFormValidator
@property NSString *msg;
@property NSString *regex;
- (id)initWithMsg:(NSString*)msg andRegexString:(NSString*)regex;
+ (XLFormRegexValidator *)formRegexValidatorWithMsg:(NSString *)msg regex:(NSString *)regex;
@end
@@ -0,0 +1,59 @@
//
// XLFormRegexValidator.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "XLFormRegexValidator.h"
@implementation XLFormRegexValidator
-(id)initWithMsg:(NSString*)msg andRegexString:(NSString*)regex {
self = [super init];
if (self) {
self.msg = msg;
self.regex = regex;
}
return self;
}
-(XLFormValidationStatus *)isValid: (XLFormRowDescriptor *)row {
if (row != nil && row.value != nil && [row.value isKindOfClass:[NSString class]]) {
// we only validate if there is a value
// assumption: required validation is already triggered
// if this field is optional, we only validate if there is a value
if (row.value != nil && [row.value length] > 0) {
BOOL isValid = [[NSPredicate predicateWithFormat:@"SELF MATCHES %@",self.regex] evaluateWithObject:[row.value stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]];
return [XLFormValidationStatus formValidationStatusWithMsg:self.msg status:isValid];
}
}
return nil;
};
+(XLFormRegexValidator *)formRegexValidatorWithMsg:(NSString *)msg regex:(NSString *)regex {
return [[XLFormRegexValidator alloc] initWithMsg:msg andRegexString:regex];
}
@end
@@ -0,0 +1,36 @@
//
// XLFormValidationStatus.h
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import <Foundation/Foundation.h>
@interface XLFormValidationStatus : NSObject
@property NSString *msg;
@property BOOL isValid;
-(id)initWithMsg:(NSString*)msg andStatus:(BOOL)isValid;
+(XLFormValidationStatus *)formValidationStatusWithMsg:(NSString *)msg status:(BOOL)status;
@end
@@ -0,0 +1,44 @@
//
// XLFormValidationStatus.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "XLFormValidationStatus.h"
@implementation XLFormValidationStatus
-(id)initWithMsg:(NSString*)msg andStatus:(BOOL)isValid {
self = [super init];
if (self) {
self.msg = msg;
self.isValid = isValid;
}
return self;
}
+(XLFormValidationStatus *)formValidationStatusWithMsg:(NSString *)msg status:(BOOL)status {
return [[XLFormValidationStatus alloc] initWithMsg:msg andStatus:status];
}
@end
+33
View File
@@ -0,0 +1,33 @@
//
// XLFormValidator.h
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "XLFormValidatorProtocol.h"
@interface XLFormValidator : NSObject<XLFormValidatorProtocol>
+(XLFormValidator *)emailValidator;
@end
+46
View File
@@ -0,0 +1,46 @@
//
// XLFormValidator.h
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "XLFormValidationStatus.h"
#import "XLFormRegexValidator.h"
#import "XLFormValidator.h"
@implementation XLFormValidator
-(XLFormValidationStatus *)isValid:(XLFormRowDescriptor *)row
{
return [XLFormValidationStatus formValidationStatusWithMsg:nil status:YES];
}
#pragma mark - Validators
+(XLFormValidator *)emailValidator
{
return [XLFormRegexValidator formRegexValidatorWithMsg:NSLocalizedString(@"Invalid email address", nil) regex:@"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}"];
}
@end
@@ -0,0 +1,36 @@
//
// XLFormValidatorProtocol.h
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "XLFormRowDescriptor.h"
@class XLFormValidationStatus;
@protocol XLFormValidatorProtocol <NSObject>
@required
-(XLFormValidationStatus *)isValid:(XLFormRowDescriptor *)row;
@end
+48 -32
View File
@@ -61,38 +61,54 @@
#import "XLFormDateCell.h"
#import "XLFormStepCounterCell.h"
#import "XLFormSegmentedCell.h"
#import "XLFormSliderCell.h"
//Validation
#import "XLFormRegexValidator.h"
static NSString *const XLFormRowDescriptorTypeText = @"text";
static NSString *const XLFormRowDescriptorTypeName = @"name";
static NSString *const XLFormRowDescriptorTypeURL = @"url";
static NSString *const XLFormRowDescriptorTypeEmail = @"email";
static NSString *const XLFormRowDescriptorTypePassword = @"password";
static NSString *const XLFormRowDescriptorTypeNumber = @"number";
static NSString *const XLFormRowDescriptorTypePhone = @"phone";
static NSString *const XLFormRowDescriptorTypeTwitter = @"twitter";
static NSString *const XLFormRowDescriptorTypeAccount = @"account";
static NSString *const XLFormRowDescriptorTypeInteger = @"integer";
static NSString *const XLFormRowDescriptorTypeTextView = @"textView";
static NSString *const XLFormRowDescriptorTypeSelectorPush = @"selectorPush";
static NSString *const XLFormRowDescriptorTypeSelectorActionSheet = @"selectorActionSheet";
static NSString *const XLFormRowDescriptorTypeSelectorAlertView = @"selectorAlertView";
static NSString *const XLFormRowDescriptorTypeSelectorPickerView = @"selectorPickerView";
static NSString *const XLFormRowDescriptorTypeSelectorPickerViewInline = @"selectorPickerViewInline";
static NSString *const XLFormRowDescriptorTypeMultipleSelector = @"multipleSelector";
static NSString *const XLFormRowDescriptorTypeSelectorLeftRight = @"selectorLeftRight";
static NSString *const XLFormRowDescriptorTypeSelectorSegmentedControl = @"selectorSegmentedControl";
static NSString *const XLFormRowDescriptorTypeDateInline = @"dateInline";
static NSString *const XLFormRowDescriptorTypeDateTimeInline = @"datetimeInline";
static NSString *const XLFormRowDescriptorTypeTimeInline = @"timeInline";
static NSString *const XLFormRowDescriptorTypeDate = @"date";
static NSString *const XLFormRowDescriptorTypeDateTime = @"datetime";
static NSString *const XLFormRowDescriptorTypeTime = @"time";
static NSString *const XLFormRowDescriptorTypeDatePicker = @"datePicker";
static NSString *const XLFormRowDescriptorTypePicker = @"picker";
static NSString *const XLFormRowDescriptorTypeBooleanCheck = @"booleanCheck";
static NSString *const XLFormRowDescriptorTypeBooleanSwitch = @"booleanSwitch";
static NSString *const XLFormRowDescriptorTypeButton = @"button";
static NSString *const XLFormRowDescriptorTypeImage = @"image";
static NSString *const XLFormRowDescriptorTypeStepCounter = @"stepCounter";
extern NSString *const XLFormRowDescriptorTypeText;
extern NSString *const XLFormRowDescriptorTypeName;
extern NSString *const XLFormRowDescriptorTypeURL;
extern NSString *const XLFormRowDescriptorTypeEmail;
extern NSString *const XLFormRowDescriptorTypePassword;
extern NSString *const XLFormRowDescriptorTypeNumber;
extern NSString *const XLFormRowDescriptorTypePhone;
extern NSString *const XLFormRowDescriptorTypeTwitter;
extern NSString *const XLFormRowDescriptorTypeAccount;
extern NSString *const XLFormRowDescriptorTypeInteger;
extern NSString *const XLFormRowDescriptorTypeDecimal;
extern NSString *const XLFormRowDescriptorTypeTextView;
extern NSString *const XLFormRowDescriptorTypeSelectorPush;
extern NSString *const XLFormRowDescriptorTypeSelectorPopover;
extern NSString *const XLFormRowDescriptorTypeSelectorActionSheet;
extern NSString *const XLFormRowDescriptorTypeSelectorAlertView;
extern NSString *const XLFormRowDescriptorTypeSelectorPickerView;
extern NSString *const XLFormRowDescriptorTypeSelectorPickerViewInline;
extern NSString *const XLFormRowDescriptorTypeMultipleSelector;
extern NSString *const XLFormRowDescriptorTypeMultipleSelectorPopover;
extern NSString *const XLFormRowDescriptorTypeSelectorLeftRight;
extern NSString *const XLFormRowDescriptorTypeSelectorSegmentedControl;
extern NSString *const XLFormRowDescriptorTypeDateInline;
extern NSString *const XLFormRowDescriptorTypeDateTimeInline;
extern NSString *const XLFormRowDescriptorTypeTimeInline;
extern NSString *const XLFormRowDescriptorTypeDate;
extern NSString *const XLFormRowDescriptorTypeDateTime;
extern NSString *const XLFormRowDescriptorTypeTime;
extern NSString *const XLFormRowDescriptorTypeDatePicker;
extern NSString *const XLFormRowDescriptorTypePicker;
extern NSString *const XLFormRowDescriptorTypeSlider;
extern NSString *const XLFormRowDescriptorTypeBooleanCheck;
extern NSString *const XLFormRowDescriptorTypeBooleanSwitch;
extern NSString *const XLFormRowDescriptorTypeButton;
extern NSString *const XLFormRowDescriptorTypeInfo;
extern NSString *const XLFormRowDescriptorTypeStepCounter;
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending
+65
View File
@@ -0,0 +1,65 @@
//
// XLForm.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014 Xmartlabs ( http://xmartlabs.com )
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import "XLForm.h"
NSString * const XLFormRowDescriptorTypeText = @"text";
NSString *const XLFormRowDescriptorTypeName = @"name";
NSString *const XLFormRowDescriptorTypeURL = @"url";
NSString *const XLFormRowDescriptorTypeEmail = @"email";
NSString *const XLFormRowDescriptorTypePassword = @"password";
NSString *const XLFormRowDescriptorTypeNumber = @"number";
NSString *const XLFormRowDescriptorTypePhone = @"phone";
NSString *const XLFormRowDescriptorTypeTwitter = @"twitter";
NSString *const XLFormRowDescriptorTypeAccount = @"account";
NSString *const XLFormRowDescriptorTypeInteger = @"integer";
NSString *const XLFormRowDescriptorTypeDecimal = @"decimal";
NSString *const XLFormRowDescriptorTypeTextView = @"textView";
NSString *const XLFormRowDescriptorTypeSelectorPush = @"selectorPush";
NSString *const XLFormRowDescriptorTypeSelectorPopover = @"selectorPopover";
NSString *const XLFormRowDescriptorTypeSelectorActionSheet = @"selectorActionSheet";
NSString *const XLFormRowDescriptorTypeSelectorAlertView = @"selectorAlertView";
NSString *const XLFormRowDescriptorTypeSelectorPickerView = @"selectorPickerView";
NSString *const XLFormRowDescriptorTypeSelectorPickerViewInline = @"selectorPickerViewInline";
NSString *const XLFormRowDescriptorTypeMultipleSelector = @"multipleSelector";
NSString *const XLFormRowDescriptorTypeMultipleSelectorPopover = @"multipleSelectorPopover";
NSString *const XLFormRowDescriptorTypeSelectorLeftRight = @"selectorLeftRight";
NSString *const XLFormRowDescriptorTypeSelectorSegmentedControl = @"selectorSegmentedControl";
NSString *const XLFormRowDescriptorTypeDateInline = @"dateInline";
NSString *const XLFormRowDescriptorTypeDateTimeInline = @"datetimeInline";
NSString *const XLFormRowDescriptorTypeTimeInline = @"timeInline";
NSString *const XLFormRowDescriptorTypeDate = @"date";
NSString *const XLFormRowDescriptorTypeDateTime = @"datetime";
NSString *const XLFormRowDescriptorTypeTime = @"time";
NSString *const XLFormRowDescriptorTypeDatePicker = @"datePicker";
NSString *const XLFormRowDescriptorTypePicker = @"picker";
NSString *const XLFormRowDescriptorTypeSlider = @"slider";
NSString *const XLFormRowDescriptorTypeBooleanCheck = @"booleanCheck";
NSString *const XLFormRowDescriptorTypeBooleanSwitch = @"booleanSwitch";
NSString *const XLFormRowDescriptorTypeButton = @"button";
NSString *const XLFormRowDescriptorTypeInfo = @"info";
NSString *const XLFormRowDescriptorTypeStepCounter = @"stepCounter";
+2 -2
View File
@@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.1</string>
<string>2.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0.1</string>
<string>2.0.1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
-33
View File
@@ -1,33 +0,0 @@
//
// XLFormTests.m
// XLForm ( https://github.com/xmartlabs/XLForm )Tests
//
// Copyright (c) 2014 Xmartlabs. All rights reserved.
//
#import <XCTest/XCTest.h>
@interface XLFormTests : XCTestCase
@end
@implementation XLFormTests
- (void)setUp
{
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
}
- (void)tearDown
{
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void)testExample
{
XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__);
}
@end