34 Commits

Author SHA1 Message Date
Martin Barreto 49e30831fe Removed XLDataLoader dependency from swift example project. 2015-06-18 19:22:44 -03:00
Martin Barreto a025671a7c minor fix. 2015-06-18 19:09:01 -03:00
Martin Barreto d938ae2ff2 #384 fix. 2015-06-17 10:52:42 -05:00
Martin Barreto ec32aa367f Merge pull request #400 from Babylonpartners/bugfix/long-text-value-fix
title labels should be always visible
2015-06-17 07:45:42 -05:00
Tim Preuß 10d97e6521 title labels should be always visible, even if the entered text is very long 2015-06-17 09:59:33 +01:00
Martin Barreto 73a2d52754 Merge pull request #383 from haaakon/master
Clearify how to install with cocoapods when use_frameworks is set
2015-06-09 09:00:17 -07:00
Håkon Bogen 9805fdca06 Clearify how to install with cocoapods when use_frameworks is set
Also updating the title, there is no such thing as a "Swift project", there is Swift files and Objective-C files, you can use both in any project.
2015-06-07 17:47:05 +02:00
Martin Barreto ef057d9276 Merge pull request #371 from bojan/master
The Swift example was not compilable
2015-05-29 02:49:02 -03:00
Bojan Dimovski 12f0666a01 Add a missing local variable in the Swift example, that was making the code uncompilable. 2015-05-28 10:13:02 +02:00
Bojan Dimovski fde42a24c9 Fix a typo in the perform selector method name. 2015-05-28 10:11:21 +02:00
Martin Barreto 395ad92609 Merge pull request #364 from xmartlabs/examples/swift
Swift Examples added.
2015-05-22 11:27:22 -03:00
Martin Barreto 8583c62371 Merge branch 'examples/swift' of github.com:xmartlabs/XLForm into examples/swift 2015-05-21 22:17:35 -03:00
Martin Barreto f1da656aed minor fix. 2015-05-21 22:16:28 -03:00
Martin Barreto f02bcf92c5 Merge pull request #362 from ericcgu/examples/swift
Swift Update to Enum + If Statement to Switch
2015-05-21 17:46:01 -03:00
Eric Gu (@ericguuu) c0e9260930 Update to Swift Enum 2015-05-21 16:30:40 -04:00
Eric Gu (@ericguuu) 69b70c657d Use Swift Enum + If Statement to Switch Statement 2015-05-21 16:29:07 -04:00
Eric Gu (@ericguuu) 9589061a0d Merge pull request #2 from xmartlabs/examples/swift
Examples/swift
2015-05-21 16:12:06 -04:00
Martin Barreto f4044f6259 Merge pull request #360 from ericcgu/patch-1
Add Swift to README
2015-05-21 15:37:20 -03:00
Eric Gu (@ericguuu) ff2f0283ff Add Swift to README 2015-05-21 13:06:15 -04:00
Martin Barreto 9fada5f4f9 swift examples added. 2015-05-21 12:46:38 -03:00
Martin Barreto 3b54dee1fe delete unnecessary XLFormRowDescriptor initializer and disabled selector example. 2015-05-21 12:42:40 -03:00
Martin Barreto 514807c473 clean up code. 2015-04-27 11:20:19 -03:00
Martin Barreto 2702ca48c6 Merge branch 'master' of github.com:xmartlabs/XLForm 2015-04-25 18:43:47 -03:00
Martin Barreto f329a71340 FloatLabeledTextFieldCell minor fix 2015-04-25 18:42:50 -03:00
mats-claassen 9e9289801b Merge pull request #339 from xmartlabs/ios_7_compatibility_fix
Fixed error with function that was not available on iOS 7 and before.
2015-04-24 15:29:01 -03:00
Mathias Claassen 1169554708 Fixed error with function that was not available on iOS 7 and before. 2015-04-24 15:28:15 -03:00
Martin Barreto f2408e86a5 merge 2015-04-24 01:39:12 -03:00
Martin Barreto b085dcb325 minor fixes. 2015-04-24 01:35:03 -03:00
mats-claassen d67eb7f762 Merge pull request #332 from xmartlabs/countdown_issue_fix
Fixed issue #330 with countdown timer. It did not check the first change...
2015-04-22 14:58:34 -03:00
Mathias Claassen 8bbbef613b Fixed issue #330 with countdown timer. It did not check the first change. 2015-04-22 14:57:18 -03:00
mats-claassen 6a7040e531 Merge pull request #331 from xmartlabs/readme_update_FAQ
Added FAQ question for issue #329
2015-04-22 12:36:09 -03:00
Mathias Claassen 73abfd53c2 Added FAQ question for issue #329 2015-04-22 12:33:23 -03:00
mats-claassen 6e5427d7a4 Merge pull request #328 from xmartlabs/textFieldLayoutFix
Fixed issue with layout in iOS v7.1 (#324).
2015-04-21 12:17:44 -03:00
Mathias Claassen 23c315b479 Fixed issue with layout in iOS v7.1 (#324). 2015-04-21 12:16:34 -03:00
144 changed files with 10030 additions and 317 deletions
+2 -1
View File
@@ -21,4 +21,5 @@ DerivedData
Pods
Tests/Pods
Tests/Podfile.lock
Examples/Objective-C/Podfile.lock
Examples/Objective-C/Podfile.lock
Examples/Swift/Podfile.lock
@@ -132,8 +132,7 @@ NSString * kAccessoryViewNotes = @"notes";
// Basic Information - Section
section = [XLFormSectionDescriptor formSectionWithTitle:@"TextField Types"];
section.footerTitle = @"This is a long text that will appear on section footer";
section = [XLFormSectionDescriptor formSection];
[formDescriptor addFormSection:section];
// Name
@@ -173,7 +172,7 @@ NSString * kAccessoryViewNotes = @"notes";
row = [XLFormRowDescriptor formRowDescriptorWithTag:kAccessoryViewCheck rowType:XLFormRowDescriptorTypeBooleanCheck title:@"Ckeck"];
[section addFormRow:row];
section = [XLFormSectionDescriptor formSectionWithTitle:@"TextView With Label Example"];
section = [XLFormSectionDescriptor formSection];
[formDescriptor addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kAccessoryViewNotes rowType:XLFormRowDescriptorTypeTextView title:@"Notes"];
[section addFormRow:row];
@@ -80,7 +80,7 @@ const static CGFloat kFloatingLabelFontSize = 11.0f;
attributes:@{NSForegroundColorAttributeName: [UIColor lightGrayColor]}];
self.floatLabeledTextField.text = self.rowDescriptor.value ? [self.rowDescriptor.value displayText] : self.rowDescriptor.noValueDisplayText;
[self.floatLabeledTextField setEnabled:!self.rowDescriptor.disabled];
[self.floatLabeledTextField setEnabled:!self.rowDescriptor.isDisabled];
self.floatLabeledTextField.floatingLabelTextColor = [UIColor lightGrayColor];
@@ -89,7 +89,7 @@ const static CGFloat kFloatingLabelFontSize = 11.0f;
-(BOOL)formDescriptorCellCanBecomeFirstResponder
{
return (!self.rowDescriptor.disabled);
return !self.rowDescriptor.isDisabled;
}
-(BOOL)formDescriptorCellBecomeFirstResponder
@@ -55,11 +55,8 @@
- (void)customize
{
UIColor * grayColor = [UIColor colorWithRed:(205/255.0) green:(201/255.0) blue:(201/255.0) alpha:1];
self.baseColor = grayColor;
UIColor * goldColor = [UIColor colorWithRed:(255/255.0) green:(215/255.0) blue:0 alpha:1];
self.highlightColor = goldColor;
self.baseColor = [UIColor colorWithRed:(205/255.0) green:(201/255.0) blue:(201/255.0) alpha:1];
self.highlightColor = [UIColor colorWithRed:(255/255.0) green:(215/255.0) blue:0 alpha:1];
self.markFont = [UIFont systemFontOfSize:23.0f];
self.translatesAutoresizingMaskIntoConstraints = NO;
self.stepInterval = 1.0f;
@@ -28,6 +28,7 @@
extern NSString * const XLFormRowDescriptorTypeRate;
@interface XLFormRatingCell : XLFormBaseCell
@property (weak, nonatomic) IBOutlet UILabel *rateTitle;
@property (weak, nonatomic) IBOutlet XLRatingView *ratingView;
@@ -102,12 +102,12 @@ NSString *const kSaturday = @"saturday";
self.saturdayButton.selected = [[value objectForKey:kSaturday] boolValue];
[self.sundayButton setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
[self.mondayButton setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
[self.tuesdayButton setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
[self.wednesdayButton setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
[self.thursdayButton setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
[self.fridayButton setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
[self.saturdayButton setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
[self.mondayButton setAlpha:self.sundayButton.alpha];
[self.tuesdayButton setAlpha:self.sundayButton.alpha];
[self.wednesdayButton setAlpha:self.sundayButton.alpha];
[self.thursdayButton setAlpha:self.sundayButton.alpha];
[self.fridayButton setAlpha:self.sundayButton.alpha];
[self.saturdayButton setAlpha:self.sundayButton.alpha];
}
-(NSString *)getDayFormButton:(id)sender
@@ -71,7 +71,13 @@ NSString *const kCountDownTimer = @"countDownTimer";
// CountDownTimer
row = [XLFormRowDescriptor formRowDescriptorWithTag:kCountDownTimerInline rowType:XLFormRowDescriptorTypeCountDownTimerInline title:@"Countdown Timer"];
row.value = [NSDate new];
NSDateComponents * dateComp = [NSDateComponents new];
dateComp.hour = 0;
dateComp.minute = 7;
dateComp.timeZone = [NSTimeZone systemTimeZone];
NSCalendar * calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
row.value = [calendar dateFromComponents:dateComp];
[section addFormRow:row];
@@ -98,7 +104,7 @@ NSString *const kCountDownTimer = @"countDownTimer";
// CountDownTimer
row = [XLFormRowDescriptor formRowDescriptorWithTag:kCountDownTimerInline rowType:XLFormRowDescriptorTypeCountDownTimer title:@"Countdown Timer"];
row.value = [NSDate new];
row.value = [calendar dateFromComponents:dateComp];
[section addFormRow:row];
section = [XLFormSectionDescriptor formSectionWithTitle:@"Disabled Dates"];
@@ -148,6 +154,8 @@ NSString *const kCountDownTimer = @"countDownTimer";
-(void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)formRow oldValue:(id)oldValue newValue:(id)newValue
{
// super implementation must be called
[super formRowDescriptorValueHasChanged:formRow oldValue:oldValue newValue:newValue];
if([formRow.tag isEqualToString:kDatePicker])
{
UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"DatePicker"
@@ -120,12 +120,14 @@ NSString *const kButtonWithStoryboardId = @"buttonWithStoryboardId";
[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"];
__typeof(self) __weak weakSelf = self;
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];
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Switch is ON", nil) message:@"Button has checked the switch value..." delegate:weakSelf cancelButtonTitle:NSLocalizedString(@"OK", nil) otherButtonTitles:nil];
[alertView show];
}
[self deselectFormRow:sender];
[weakSelf deselectFormRow:sender];
};
[section addFormRow:buttonLeftAlignedRow];
@@ -31,11 +31,8 @@ NSString *const kFilm = @"films1";
NSString *const kFilm2 = @"films2";
NSString *const kMusic = @"music";
@interface BlogExampleViewController ()
@end
@implementation BlogExampleViewController
- (instancetype)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
@@ -74,7 +71,7 @@ NSString *const kMusic = @"music";
[section addFormRow:hobbyRow];
section = [XLFormSectionDescriptor formSectionWithTitle:@"Some more questions"];
section.hidden = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"$%@.value.@count = 0", hobbyRow]];
section.hidden = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"$%@.value.@count == 0", hobbyRow]];
section.footerTitle = @"BlogExampleViewController.m";
[form addFormSection:section];
@@ -215,17 +215,17 @@
[dateStartCell setFormDatePickerMode:XLFormDateDatePickerModeDateTime];
[dateEndCell setFormDatePickerMode:XLFormDateDatePickerModeDateTime];
}
[dateStartCell update];
[dateEndCell update];
[self updateFormRow:startDateDescriptor];
[self updateFormRow:endDateDescriptor];
}
else if ([rowDescriptor.tag isEqualToString:@"starts"]){
XLFormRowDescriptor * startDateDescriptor = [self.form formRowWithTag:@"starts"];
XLFormRowDescriptor * endDateDescriptor = [self.form formRowWithTag:@"ends"];
XLFormDateCell * dateEndCell = (XLFormDateCell *)[endDateDescriptor cellForFormController:self];
if ([startDateDescriptor.value compare:endDateDescriptor.value] == NSOrderedDescending) {
// startDateDescriptor is later than endDateDescriptor
endDateDescriptor.value = [[NSDate alloc] initWithTimeInterval:(60*60*24) sinceDate:startDateDescriptor.value];
[dateEndCell update];
[endDateDescriptor.cellConfig removeObjectForKey:@"detailTextLabel.attributedText"];
[self updateFormRow:endDateDescriptor];
}
}
else if ([rowDescriptor.tag isEqualToString:@"ends"]){
@@ -234,10 +234,16 @@
XLFormDateCell * dateEndCell = (XLFormDateCell *)[endDateDescriptor cellForFormController:self];
if ([startDateDescriptor.value compare:endDateDescriptor.value] == NSOrderedDescending) {
// startDateDescriptor is later than endDateDescriptor
[dateEndCell update]; // force detailTextLabel update
NSDictionary *strikeThroughAttribute = [NSDictionary dictionaryWithObject:@1
forKey:NSStrikethroughStyleAttributeName];
NSAttributedString* strikeThroughText = [[NSAttributedString alloc] initWithString:dateEndCell.detailTextLabel.text attributes:strikeThroughAttribute];
dateEndCell.detailTextLabel.attributedText = strikeThroughText;
[endDateDescriptor.cellConfig setObject:strikeThroughText forKey:@"detailTextLabel.attributedText"];
[self updateFormRow:endDateDescriptor];
}
else{
[endDateDescriptor.cellConfig removeObjectForKey:@"detailTextLabel.attributedText"];
[self updateFormRow:endDateDescriptor];
}
}
}
@@ -1,13 +0,0 @@
//
// UIFormViewCotroller+NativeEvetFormViewController.h
// XLForm
//
// Created by Martin Barreto on 4/2/14.
// Copyright (c) 2014 Xmartlabs. All rights reserved.
//
@interface UIFormViewCotroller (NativeEventFormViewController)
@end
@@ -50,4 +50,4 @@
+(instancetype)insert:(NSManagedObjectContext *)context;
@end
@end
@@ -317,34 +317,6 @@ NSString *const kSelectorWithStoryboardId = @"selectorWithStoryboardId";
row.action.viewControllerClass = [CustomSelectorsFormViewController class];
[section addFormRow:row];
section = [XLFormSectionDescriptor formSectionWithTitle:@"Disabled & Required Selectors"];
[form addFormSection:section];
// Disabled Selector Push
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorPushDisabled rowType:XLFormRowDescriptorTypeSelectorPush title:@"Push"];
row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(1) displayText:@"Option 2"];
row.disabled = @YES;
[section addFormRow:row];
// --------- Disabled Selector Action Sheet
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorActionSheetDisabled rowType:XLFormRowDescriptorTypeSelectorActionSheet title:@"Sheet"];
row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(2) displayText:@"Option 3"];
row.disabled = @YES;
[section addFormRow:row];
// --------- Disabled Selector Left Right
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorLeftRightDisabled rowType:XLFormRowDescriptorTypeSelectorLeftRight title:@"Left Right"];
row.leftRightSelectorLeftOptionSelected = [XLFormOptionsObject formOptionsObjectWithValue:@(1) displayText:@"Option 2"];
row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(3) displayText:@"Right Option 4"];
row.disabled = @YES;
[section addFormRow:row];
// --------- Selector definition types
@@ -360,7 +332,7 @@ NSString *const kSelectorWithStoryboardId = @"selectorWithStoryboardId";
[section addFormRow:row];
// selector with SegueId
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorWithSegueClass rowType:XLFormRowDescriptorTypeSelectorPush title:@"Selector with Segue Idenfifier"];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorWithSegueId rowType:XLFormRowDescriptorTypeSelectorPush title:@"Selector with Segue Idenfifier"];
row.action.formSegueIdenfifier = @"MapViewControllerSegue";
row.valueTransformer = [CLLocationValueTrasformer class];
row.value = [[CLLocation alloc] initWithLatitude:-33 longitude:-56];
@@ -32,10 +32,11 @@
<viewControllerLayoutGuide type="bottom" id="HPb-Nx-E1G"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="wpr-wE-9nj">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="504"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<extendedEdge key="edgesForExtendedLayout" bottom="YES"/>
<navigationItem key="navigationItem" id="Hf0-cB-ORN"/>
<connections>
<segue destination="WMh-VN-FWi" kind="push" identifier="MapViewControllerSegue" id="wAD-tS-AFZ"/>
@@ -129,10 +130,11 @@
<viewControllerLayoutGuide type="bottom" id="scM-da-Sg0"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="hrV-fb-58s">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="504"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<extendedEdge key="edgesForExtendedLayout" bottom="YES"/>
<navigationItem key="navigationItem" id="RJB-cz-SnF"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Fvo-wr-5Ca" userLabel="First Responder" sceneMemberID="firstResponder"/>
@@ -184,10 +186,11 @@
<viewControllerLayoutGuide type="bottom" id="Lsg-dH-McH"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="6EZ-O7-FjX">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="504"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<extendedEdge key="edgesForExtendedLayout" bottom="YES"/>
<navigationItem key="navigationItem" id="Lsd-xH-7IN"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="rZL-10-YZn" userLabel="First Responder" sceneMemberID="firstResponder"/>
@@ -203,10 +206,11 @@
<viewControllerLayoutGuide type="bottom" id="CTu-Y5-7Qw"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="bNj-SD-83w">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="504"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<extendedEdge key="edgesForExtendedLayout" bottom="YES"/>
<navigationItem key="navigationItem" id="Buo-Af-6Q1"/>
<connections>
<segue destination="WMh-VN-FWi" kind="push" identifier="MapViewControllerSegue" id="Mtw-x2-E0b"/>
@@ -225,10 +229,11 @@
<viewControllerLayoutGuide type="bottom" id="cgQ-Vs-ICN"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="JjC-E5-SyY">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="504"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<extendedEdge key="edgesForExtendedLayout" bottom="YES"/>
<navigationItem key="navigationItem" id="BjG-Bq-0lD"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="LmS-YR-mFY" userLabel="First Responder" sceneMemberID="firstResponder"/>
@@ -262,10 +267,11 @@
<viewControllerLayoutGuide type="bottom" id="2b4-gN-85p"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="NZg-t1-g19">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<rect key="frame" x="0.0" y="0.0" width="320" height="504"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<extendedEdge key="edgesForExtendedLayout" bottom="YES"/>
<navigationItem key="navigationItem" id="1lh-jZ-lIV"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Tlw-q2-pcu" userLabel="First Responder" sceneMemberID="firstResponder"/>
@@ -26,10 +26,6 @@
#import "XLForm.h"
#import "ValidationExamplesFormViewController.h"
@interface ValidationExamplesFormViewController ()
@end
@implementation ValidationExamplesFormViewController
NSString * const kValidationName = @"kName";
@@ -0,0 +1,250 @@
//
// AccessoryViewFormViewController.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "AccessoryViewFormViewController.h"
//This macro defines if we use predicates to hide rows or do it manually the old way.
//Just comment out if you want it to run without predicates.
#define USE_PREDICATES_FOR_HIDING
@interface AccessoryViewFormViewController ()
@end
@implementation AccessoryViewFormViewController
{
#ifndef USE_PREDICATES_FOR_HIDING
XLFormRowDescriptor * _rowShowAccessoryView;
XLFormRowDescriptor * _rowStopDisableRow;
XLFormRowDescriptor * _rowStopInlineRow;
XLFormRowDescriptor * _rowSkipCanNotBecomeFirstResponderRow;
#endif
}
NSString * kAccessoryViewRowNavigationEnabled = @"kRowNavigationEnabled";
NSString * kAccessoryViewRowNavigationShowAccessoryView = @"kRowNavigationShowAccessoryView";
NSString * kAccessoryViewRowNavigationStopDisableRow = @"rowNavigationStopDisableRow";
NSString * kAccessoryViewRowNavigationSkipCanNotBecomeFirstResponderRow = @"rowNavigationSkipCanNotBecomeFirstResponderRow";
NSString * kAccessoryViewRowNavigationStopInlineRow = @"rowNavigationStopInlineRow";
NSString * kAccessoryViewName = @"name";
NSString * kAccessoryViewEmail = @"email";
NSString * kAccessoryViewTwitter = @"twitter";
NSString * kAccessoryViewUrl = @"url";
NSString * kAccessoryViewDate = @"date";
NSString * kAccessoryViewTextView = @"textView";
NSString * kAccessoryViewCheck = @"check";
NSString * kAccessoryViewNotes = @"notes";
-(id)init
{
self = [super init];
if (self) {
[self initializeForm];
}
return self;
}
-(void)initializeForm
{
XLFormDescriptor * formDescriptor = [XLFormDescriptor formDescriptorWithTitle:@"Accessory View"];
formDescriptor.rowNavigationOptions = XLFormRowNavigationOptionEnabled;
XLFormSectionDescriptor * section;
XLFormRowDescriptor * row;
XLFormRowDescriptor * switchRow;
// Configuration section
section = [XLFormSectionDescriptor formSectionWithTitle:@"Row Navigation Settings"];
section.footerTitle = @"Changing the Settings values you will navigate differently";
[formDescriptor addFormSection:section];
// RowNavigationEnabled
switchRow = [XLFormRowDescriptor formRowDescriptorWithTag:kAccessoryViewRowNavigationEnabled rowType:XLFormRowDescriptorTypeBooleanSwitch title:@"Row Navigation Enabled?"];
switchRow.value = @YES;
[section addFormRow:switchRow];
// RowNavigationShowAccessoryView
row = [XLFormRowDescriptor formRowDescriptorWithTag:kAccessoryViewRowNavigationShowAccessoryView rowType:XLFormRowDescriptorTypeBooleanCheck title:@"Show input accessory row?"];
row.value = @((formDescriptor.rowNavigationOptions & XLFormRowNavigationOptionEnabled) == XLFormRowNavigationOptionEnabled);
[section addFormRow:row];
#ifdef USE_PREDICATES_FOR_HIDING
row.hidden = [NSString stringWithFormat:@"$%@ == 0", switchRow];
#else
_rowShowAccessoryView = row;
#endif
// RowNavigationStopDisableRow
row = [XLFormRowDescriptor formRowDescriptorWithTag:kAccessoryViewRowNavigationStopDisableRow rowType:XLFormRowDescriptorTypeBooleanCheck title:@"Stop when reach disabled row?"];
row.value = @((formDescriptor.rowNavigationOptions & XLFormRowNavigationOptionStopDisableRow) == XLFormRowNavigationOptionStopDisableRow);
[section addFormRow:row];
#ifdef USE_PREDICATES_FOR_HIDING
row.hidden = [NSString stringWithFormat:@"$%@ == 0", switchRow];
#else
_rowStopDisableRow = row;
#endif
// RowNavigationStopInlineRow
row = [XLFormRowDescriptor formRowDescriptorWithTag:kAccessoryViewRowNavigationStopInlineRow rowType:XLFormRowDescriptorTypeBooleanCheck title:@"Stop when reach inline row?"];
row.value = @((formDescriptor.rowNavigationOptions & XLFormRowNavigationOptionStopInlineRow) == XLFormRowNavigationOptionStopInlineRow);
[section addFormRow:row];
#ifdef USE_PREDICATES_FOR_HIDING
row.hidden = [NSString stringWithFormat:@"$%@ == 0", switchRow];
#else
_rowStopInlineRow = row;
#endif
// RowNavigationSkipCanNotBecomeFirstResponderRow
row = [XLFormRowDescriptor formRowDescriptorWithTag:kAccessoryViewRowNavigationSkipCanNotBecomeFirstResponderRow rowType:XLFormRowDescriptorTypeBooleanCheck title:@"Skip Can Not Become First Responder Row?"];
row.value = @((formDescriptor.rowNavigationOptions & XLFormRowNavigationOptionSkipCanNotBecomeFirstResponderRow) == XLFormRowNavigationOptionSkipCanNotBecomeFirstResponderRow);
[section addFormRow:row];
#ifdef USE_PREDICATES_FOR_HIDING
row.hidden = [NSString stringWithFormat:@"$%@ == 0", switchRow];
#else
_rowSkipCanNotBecomeFirstResponderRow = row;
#endif
// Basic Information - Section
section = [XLFormSectionDescriptor formSectionWithTitle:@"TextField Types"];
section.footerTitle = @"This is a long text that will appear on section footer";
[formDescriptor addFormSection:section];
// Name
row = [XLFormRowDescriptor formRowDescriptorWithTag:kAccessoryViewName rowType:XLFormRowDescriptorTypeText title:@"Name"];
row.required = YES;
[section addFormRow:row];
// Email
row = [XLFormRowDescriptor formRowDescriptorWithTag:kAccessoryViewEmail rowType:XLFormRowDescriptorTypeEmail title:@"Email"];
// validate the email
[row addValidator:[XLFormValidator emailValidator]];
[section addFormRow:row];
// Twitter
row = [XLFormRowDescriptor formRowDescriptorWithTag:kAccessoryViewTwitter rowType:XLFormRowDescriptorTypeTwitter title:@"Twitter"];
row.disabled = @YES;
row.value = @"@no_editable";
[section addFormRow:row];
// Url
row = [XLFormRowDescriptor formRowDescriptorWithTag:kAccessoryViewUrl rowType:XLFormRowDescriptorTypeURL title:@"Url"];
[section addFormRow:row];
// Url
row = [XLFormRowDescriptor formRowDescriptorWithTag:kAccessoryViewDate rowType:XLFormRowDescriptorTypeDateInline title:@"Date Inline"];
row.value = [NSDate new];
[section addFormRow:row];
section = [XLFormSectionDescriptor formSection];
[formDescriptor addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kAccessoryViewTextView rowType:XLFormRowDescriptorTypeTextView];
[row.cellConfigAtConfigure setObject:@"TEXT VIEW EXAMPLE" forKey:@"textView.placeholder"];
[section addFormRow:row];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kAccessoryViewCheck rowType:XLFormRowDescriptorTypeBooleanCheck title:@"Ckeck"];
[section addFormRow:row];
section = [XLFormSectionDescriptor formSectionWithTitle:@"TextView With Label Example"];
[formDescriptor addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kAccessoryViewNotes rowType:XLFormRowDescriptorTypeTextView title:@"Notes"];
[section addFormRow:row];
self.form = formDescriptor;
}
#pragma mark - XLFormDescriptorDelegate
-(void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
{
[super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
#ifndef USE_PREDICATES_FOR_HIDING
NSString * kRowNavigationEnabled = @"kRowNavigationEnabled";
if ([rowDescriptor.tag isEqualToString:kRowNavigationEnabled]){
if ([[rowDescriptor.value valueData] isEqual:@NO]){
self.form.rowNavigationOptions = XLFormRowNavigationOptionNone;
[self.form removeFormRowWithTag:kAccessoryViewRowNavigationShowAccessoryView];
[self.form removeFormRowWithTag:kAccessoryViewRowNavigationStopDisableRow];
[self.form removeFormRowWithTag:kAccessoryViewRowNavigationStopInlineRow];
[self.form removeFormRowWithTag:kAccessoryViewRowNavigationSkipCanNotBecomeFirstResponderRow];
}
else{
self.form.rowNavigationOptions = XLFormRowNavigationOptionEnabled;
_rowShowAccessoryView.value = @YES;
_rowStopDisableRow.value = @NO;
_rowStopInlineRow.value = @NO;
_rowSkipCanNotBecomeFirstResponderRow.value = @NO;
[self.form addFormRow:_rowShowAccessoryView afterRow:rowDescriptor];
[self.form addFormRow:_rowStopDisableRow afterRow:_rowShowAccessoryView];
[self.form addFormRow:_rowStopInlineRow afterRow:_rowStopDisableRow];
[self.form addFormRow:_rowSkipCanNotBecomeFirstResponderRow afterRow:_rowStopInlineRow];
}
}
else
#endif
if ([rowDescriptor.tag isEqualToString:kAccessoryViewRowNavigationStopDisableRow]){
if ([[rowDescriptor.value valueData] isEqual:@(YES)]){
self.form.rowNavigationOptions = self.form.rowNavigationOptions | XLFormRowNavigationOptionStopDisableRow;
}
else{
self.form.rowNavigationOptions = self.form.rowNavigationOptions & (~XLFormRowNavigationOptionStopDisableRow);
}
}
else if ([rowDescriptor.tag isEqualToString:kAccessoryViewRowNavigationStopInlineRow]){
if ([[rowDescriptor.value valueData] isEqual:@(YES)]){
self.form.rowNavigationOptions = self.form.rowNavigationOptions | XLFormRowNavigationOptionStopInlineRow;
}
else{
self.form.rowNavigationOptions = self.form.rowNavigationOptions & (~XLFormRowNavigationOptionStopInlineRow);
}
}
else if ([rowDescriptor.tag isEqualToString:kAccessoryViewRowNavigationSkipCanNotBecomeFirstResponderRow]){
if ([[rowDescriptor.value valueData] isEqual:@(YES)]){
self.form.rowNavigationOptions = self.form.rowNavigationOptions | XLFormRowNavigationOptionSkipCanNotBecomeFirstResponderRow;
}
else{
self.form.rowNavigationOptions = self.form.rowNavigationOptions & (~XLFormRowNavigationOptionSkipCanNotBecomeFirstResponderRow);
}
}
}
-(UIView *)inputAccessoryViewForRowDescriptor:(XLFormRowDescriptor *)rowDescriptor
{
if ([[[self.form formRowWithTag:kAccessoryViewRowNavigationShowAccessoryView].value valueData] isEqual:@NO]){
return nil;
}
return [super inputAccessoryViewForRowDescriptor:rowDescriptor];
}
@end
@@ -0,0 +1,109 @@
// CustomRowsViewController.swift
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014-2015 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.
class CustomRowsViewController : XLFormViewController {
private enum Tags : String {
case CustomRowFirstRatingTag = "CustomRowFirstRatingTag"
case CustomRowSecondRatingTag = "CustomRowSecondRatingTag"
case CustomRowFloatLabeledTextFieldTag = "CustomRowFloatLabeledTextFieldTag"
case CustomRowWeekdays = "CustomRowWeekdays"
case CustomRowText = "CustomText"
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
self.initializeForm()
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.initializeForm()
}
func initializeForm() {
let form : XLFormDescriptor
var section : XLFormSectionDescriptor
var row : XLFormRowDescriptor
form = XLFormDescriptor(title: "Custom Rows")
section = XLFormSectionDescriptor()
section.title = "Ratings"
form.addFormSection(section)
row = XLFormRowDescriptor(tag: Tags.CustomRowFirstRatingTag.rawValue, rowType: XLFormRowDescriptorTypeRate, title: "First Rating")
row.value = 3
section.addFormRow(row)
row = XLFormRowDescriptor(tag: Tags.CustomRowSecondRatingTag.rawValue, rowType: XLFormRowDescriptorTypeRate, title: "First Rating")
row.value = 1
section.addFormRow(row)
// Section Float Labeled Text Field
section = XLFormSectionDescriptor.formSectionWithTitle("Float Labeled Text Field")
form.addFormSection(section)
row = XLFormRowDescriptor(tag: Tags.CustomRowFloatLabeledTextFieldTag.rawValue, rowType: XLFormRowDescriptorTypeFloatLabeledTextField, title: "Title")
section.addFormRow(row)
row = XLFormRowDescriptor(tag: Tags.CustomRowFloatLabeledTextFieldTag.rawValue, rowType: XLFormRowDescriptorTypeFloatLabeledTextField, title: "First Name")
section.addFormRow(row)
row = XLFormRowDescriptor(tag: Tags.CustomRowFloatLabeledTextFieldTag.rawValue, rowType: XLFormRowDescriptorTypeFloatLabeledTextField, title: "Last Name")
section.addFormRow(row)
section = XLFormSectionDescriptor.formSectionWithTitle("Weekdays")
form.addFormSection(section)
// WeekDays
row = XLFormRowDescriptor(tag: Tags.CustomRowWeekdays.rawValue, rowType: XLFormRowDescriptorTypeWeekDays, title: nil)
row.value = [
XLFormWeekDaysCell.kWeekDay.Sunday.description(): false,
XLFormWeekDaysCell.kWeekDay.Monday.description(): true,
XLFormWeekDaysCell.kWeekDay.Tuesday.description(): true,
XLFormWeekDaysCell.kWeekDay.Wednesday.description(): false,
XLFormWeekDaysCell.kWeekDay.Thursday.description(): false,
XLFormWeekDaysCell.kWeekDay.Friday.description(): false,
XLFormWeekDaysCell.kWeekDay.Saturday.description(): false
]
section.addFormRow(row)
section = XLFormSectionDescriptor()
form.addFormSection(section)
row = XLFormRowDescriptor(tag: Tags.CustomRowText.rawValue, rowType: XLFormRowDescriptorTypeCustom)
// Must set custom cell or add custom cell to cellClassesForRowDescriptorTypes dictionary before XLFormViewController loaded
row.cellClass = XLFormCustomCell.self
section.addFormRow(row)
self.form = form
}
}
@@ -0,0 +1,140 @@
// FloatLabeledTextFieldCell.swift
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014-2015 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.
//
let XLFormRowDescriptorTypeFloatLabeledTextField = "XLFormRowDescriptorTypeFloatLabeledTextField"
class FloatLabeledTextFieldCell : XLFormBaseCell, UITextFieldDelegate {
static let kFontSize : CGFloat = 16.0
lazy var floatLabeledTextField: JVFloatLabeledTextField = {
let result = JVFloatLabeledTextField(frame: CGRect.zeroRect)
result.setTranslatesAutoresizingMaskIntoConstraints(false)
result.font = UIFont.systemFontOfSize(kFontSize)
result.floatingLabel.font = UIFont.boldSystemFontOfSize(kFontSize)
result.clearButtonMode = UITextFieldViewMode.WhileEditing
return result
}()
//Mark: - XLFormDescriptorCell
override func configure() {
super.configure()
self.selectionStyle = UITableViewCellSelectionStyle.None
self.contentView.addSubview(self.floatLabeledTextField)
self.floatLabeledTextField.delegate = self
self.contentView.addConstraints(self.layoutConstraints())
}
override func update() {
super.update()
self.floatLabeledTextField.attributedPlaceholder = NSAttributedString(string: self.rowDescriptor.title, attributes: [NSForegroundColorAttributeName: UIColor.lightGrayColor()])
if let value: AnyObject = self.rowDescriptor.value {
self.floatLabeledTextField.text = value.displayText()
}
else {
self.floatLabeledTextField.text = self.rowDescriptor.noValueDisplayText
}
self.floatLabeledTextField.enabled = !self.rowDescriptor.isDisabled()
self.floatLabeledTextField.floatingLabelTextColor = UIColor.lightGrayColor()
self.floatLabeledTextField.alpha = self.rowDescriptor.isDisabled() ? 0.6 : 1.0
}
override func formDescriptorCellCanBecomeFirstResponder() -> Bool {
return !self.rowDescriptor.isDisabled()
}
override func formDescriptorCellBecomeFirstResponder() -> Bool {
return self.floatLabeledTextField.becomeFirstResponder()
}
override static func formDescriptorCellHeightForRowDescriptor(rowDescriptor: XLFormRowDescriptor!) -> CGFloat {
return 55.0
}
//MARK: Helpers
func layoutConstraints() -> [AnyObject]{
let views = ["floatLabeledTextField" : self.floatLabeledTextField]
let metrics = ["hMargin": 15.0, "vMargin": 8.0]
var result = NSLayoutConstraint.constraintsWithVisualFormat("H:|-(hMargin)-[floatLabeledTextField]-(hMargin)-|", options:NSLayoutFormatOptions.AlignAllCenterY, metrics:metrics, views:views)
result += NSLayoutConstraint.constraintsWithVisualFormat("V:|-(vMargin)-[floatLabeledTextField]-(vMargin)-|", options:NSLayoutFormatOptions.AlignAllCenterX, metrics:metrics, views:views)
return result
}
func textFieldDidChange(textField : UITextField) {
if self.floatLabeledTextField == textField {
if self.floatLabeledTextField.text.isEmpty == false {
self.rowDescriptor.value = self.floatLabeledTextField.text
} else {
self.rowDescriptor.value = nil
}
}
}
//Mark: UITextFieldDelegate
func textFieldShouldClear(textField: UITextField) -> Bool {
return self.formViewController().textFieldShouldClear(textField)
}
func textFieldShouldReturn(textField: UITextField) -> Bool {
return self.formViewController().textFieldShouldReturn(textField)
}
func textFieldShouldBeginEditing(textField: UITextField) -> Bool {
return self.formViewController().textFieldShouldBeginEditing(textField)
}
func textFieldShouldEndEditing(textField: UITextField) -> Bool {
return self.formViewController().textFieldShouldEndEditing(textField)
}
func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
return self.formViewController().textField(textField, shouldChangeCharactersInRange: range, replacementString: string)
}
func textFieldDidBeginEditing(textField: UITextField) {
self.formViewController().textFieldDidBeginEditing(textField)
}
func textFieldDidEndEditing(textField: UITextField) {
self.textFieldDidChange(textField)
self.formViewController().textFieldDidEndEditing(textField)
}
}
@@ -0,0 +1,48 @@
// XLRatingView.swift
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014-2015 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.
class XLRatingView : AXRatingView {
override init(frame: CGRect) {
super.init(frame: frame)
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
func customize() {
self.baseColor = UIColor(red: (205/255.0), green: (201/255.0), blue: (201/255.0), alpha: 1)
self.highlightColor = UIColor(red: (255/255.0), green: (215/255.0), blue: 0, alpha: 1)
self.markFont = UIFont.systemFontOfSize(23.0)
self.setTranslatesAutoresizingMaskIntoConstraints(false)
self.stepInterval = 1.0
}
}
@@ -0,0 +1,56 @@
// XLFormRatingCell.swift
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014-2015 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.
let XLFormRowDescriptorTypeRate = "XLFormRowDescriptorTypeRate"
@objc
class XLFormRatingCell : XLFormBaseCell {
@IBOutlet weak var rateTitle: UILabel!
@IBOutlet weak var ratingView: XLRatingView!
override func configure() {
super.configure()
self.selectionStyle = UITableViewCellSelectionStyle.None
self.ratingView.addTarget(self, action: "rateChanged:", forControlEvents:UIControlEvents.ValueChanged)
}
override func update() {
super.update()
self.ratingView.value = self.rowDescriptor.value.floatValue
self.rateTitle.text = self.rowDescriptor.title
self.ratingView.alpha = self.rowDescriptor.isDisabled() ? 0.6 : 1
self.rateTitle.alpha = self.rowDescriptor.isDisabled() ? 0.6 : 1
}
//MARK: Events
func rateChanged(ratingView : XLRatingView){
self.rowDescriptor.value = ratingView.value
}
}
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7531" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="OGo-4x-YLf" customClass="XLFormRatingCell" customModule="SwiftExample" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="478" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="OGo-4x-YLf" id="hV6-xt-6pq">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="yhI-dj-sRk" customClass="XLRatingView" customModule="SwiftExample" customModuleProvider="target">
<rect key="frame" x="353" y="11" width="115" height="22"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="22" id="85e-Ov-qM7"/>
<constraint firstAttribute="width" constant="115" id="kOb-W4-HPs"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Rate" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Vxp-gw-YTt">
<rect key="frame" x="15" y="11" width="338" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="IK4-8e-SFs"/>
<constraint firstAttribute="width" constant="150" id="hNG-F9-1wj"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
<variation key="default">
<mask key="constraints">
<exclude reference="hNG-F9-1wj"/>
</mask>
</variation>
</label>
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="Vxp-gw-YTt" secondAttribute="bottom" constant="11" id="0Qz-iR-Tzb"/>
<constraint firstAttribute="centerY" secondItem="Vxp-gw-YTt" secondAttribute="centerY" id="4Vh-2e-m2p"/>
<constraint firstAttribute="trailing" secondItem="yhI-dj-sRk" secondAttribute="trailing" constant="10" id="NPC-r7-JFl"/>
<constraint firstAttribute="centerY" secondItem="yhI-dj-sRk" secondAttribute="centerY" id="Vw4-h8-wId"/>
<constraint firstItem="Vxp-gw-YTt" firstAttribute="leading" secondItem="hV6-xt-6pq" secondAttribute="leading" constant="15" id="Xgq-Cy-zLQ"/>
<constraint firstItem="Vxp-gw-YTt" firstAttribute="top" secondItem="hV6-xt-6pq" secondAttribute="top" constant="11" id="bgO-t8-Rjz"/>
<constraint firstItem="yhI-dj-sRk" firstAttribute="leading" secondItem="Vxp-gw-YTt" secondAttribute="trailing" id="n0B-tg-Pik"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="rateTitle" destination="Vxp-gw-YTt" id="0Qh-NC-yq5"/>
<outlet property="ratingView" destination="yhI-dj-sRk" id="BKM-pX-m9F"/>
</connections>
<point key="canvasLocation" x="301" y="260"/>
</tableViewCell>
</objects>
</document>
@@ -0,0 +1,177 @@
// XLFormWeekDaysCell.swift
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014-2015 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.
let XLFormRowDescriptorTypeWeekDays = "XLFormRowDescriptorTypeWeekDays"
class XLFormWeekDaysCell : XLFormBaseCell {
enum kWeekDay: Int {
case
Sunday = 1,
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday
func description() -> String {
switch self {
case .Sunday:
return "Sunday"
case .Monday:
return "Monday"
case .Tuesday:
return "Tuesday"
case .Wednesday:
return "Wednesday"
case .Thursday:
return "Thursday"
case .Friday:
return "Friday"
case .Saturday:
return "Saturday"
}
}
//Add Custom Functions
//Allows for iteration as needed (for in ...)
static let allValues = [Sunday,
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday]
}
@IBOutlet weak var sundayButton: UIButton!
@IBOutlet weak var mondayButton: UIButton!
@IBOutlet weak var tuesdayButton: UIButton!
@IBOutlet weak var wednesdayButton: UIButton!
@IBOutlet weak var thursdayButton: UIButton!
@IBOutlet weak var fridayButton: UIButton!
@IBOutlet weak var saturdayButton: UIButton!
//MARK: - XLFormDescriptorCell
override func configure() {
super.configure()
selectionStyle = UITableViewCellSelectionStyle.None
configureButtons()
}
override func update() {
super.update()
updateButtons()
}
override static func formDescriptorCellHeightForRowDescriptor(rowDescriptor: XLFormRowDescriptor!) -> CGFloat {
return 60
}
//MARK: - Action
@IBAction func dayTapped(sender: UIButton) {
let day = getDayFormButton(sender)
sender.selected = !sender.selected
var newValue = rowDescriptor.value as! Dictionary<String, Bool>
newValue[day] = sender.selected
rowDescriptor.value = newValue
}
//MARK: - Helpers
func configureButtons() {
for subview in contentView.subviews {
if let button : UIButton = subview as? UIButton {
button.setImage(UIImage(named: "uncheckedDay"), forState: UIControlState.Normal)
button.setImage(UIImage(named: "checkedDay"), forState: UIControlState.Selected)
button.adjustsImageWhenHighlighted = false
imageTopTitleBottom(button)
}
}
}
func updateButtons() {
var value = rowDescriptor.value as! Dictionary<String, Bool>
sundayButton.selected = value[XLFormWeekDaysCell.kWeekDay.Sunday.description()]!
mondayButton.selected = value[XLFormWeekDaysCell.kWeekDay.Monday.description()]!
tuesdayButton.selected = value[XLFormWeekDaysCell.kWeekDay.Tuesday.description()]!
wednesdayButton.selected = value[XLFormWeekDaysCell.kWeekDay.Wednesday.description()]!
thursdayButton.selected = value[XLFormWeekDaysCell.kWeekDay.Thursday.description()]!
fridayButton.selected = value[XLFormWeekDaysCell.kWeekDay.Friday.description()]!
saturdayButton.selected = value[XLFormWeekDaysCell.kWeekDay.Saturday.description()]!
sundayButton.alpha = rowDescriptor.isDisabled() ? 0.6 : 1
mondayButton.alpha = mondayButton.alpha
tuesdayButton.alpha = mondayButton.alpha
wednesdayButton.alpha = mondayButton.alpha
thursdayButton.alpha = mondayButton.alpha
fridayButton.alpha = mondayButton.alpha
saturdayButton.alpha = mondayButton.alpha
}
func imageTopTitleBottom(button: UIButton) {
// the space between the image and text
let spacing : CGFloat = 3.0
// lower the text and push it left so it appears centered
// below the image
let imageSize : CGSize = button.imageView!.image!.size
button.titleEdgeInsets = UIEdgeInsets(top: 0.0, left: -imageSize.width, bottom: -(imageSize.height + spacing), right: 0.0)
// raise the image and push it right so it appears centered
// above the text
let titleSize : CGSize = (button.titleLabel!.text! as NSString).sizeWithAttributes([NSFontAttributeName: button.titleLabel!.font])
button.imageEdgeInsets = UIEdgeInsetsMake(-(titleSize.height + spacing), 0.0, 0.0, -titleSize.width)
}
func getDayFormButton(button: UIButton) -> String {
switch button {
case sundayButton:
return XLFormWeekDaysCell.kWeekDay.Sunday.description()
case mondayButton:
return XLFormWeekDaysCell.kWeekDay.Monday.description()
case tuesdayButton:
return XLFormWeekDaysCell.kWeekDay.Tuesday.description()
case wednesdayButton:
return XLFormWeekDaysCell.kWeekDay.Wednesday.description()
case thursdayButton:
return XLFormWeekDaysCell.kWeekDay.Thursday.description()
case fridayButton:
return XLFormWeekDaysCell.kWeekDay.Friday.description()
default:
return XLFormWeekDaysCell.kWeekDay.Saturday.description()
}
}
}
@@ -0,0 +1,249 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7531" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="60" id="piA-L5-eiN" customClass="XLFormWeekDaysCell" customModule="SwiftExample" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="382" height="50"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="piA-L5-eiN" id="Yr6-3E-keb">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ZAg-Me-yKR">
<rect key="frame" x="5" y="0.0" width="53" height="49"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="S">
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="selected">
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
</state>
<connections>
<action selector="dayTapped:" destination="piA-L5-eiN" eventType="touchUpInside" id="K4V-Xd-Bak"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="UjQ-Cw-7wH" userLabel="separator 1">
<rect key="frame" x="58" y="10" width="1" height="29"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="K3N-3h-MZr"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="N3w-qP-kRZ">
<rect key="frame" x="58" y="0.0" width="53" height="49"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="M">
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="dayTapped:" destination="piA-L5-eiN" eventType="touchUpInside" id="FaQ-oB-Nkl"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kwc-0w-V51" userLabel="separator 2">
<rect key="frame" x="111" y="10" width="1" height="29"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="3mE-sT-ql1"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="cPl-47-rS8">
<rect key="frame" x="111" y="0.0" width="53" height="49"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="T">
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="dayTapped:" destination="piA-L5-eiN" eventType="touchUpInside" id="4vk-5n-jge"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="EiN-2p-Oig" userLabel="separator 3">
<rect key="frame" x="164" y="10" width="1" height="29"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="JyW-GC-0A7"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="6iC-Cl-RyI">
<rect key="frame" x="164" y="0.0" width="54" height="49"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="W">
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="dayTapped:" destination="piA-L5-eiN" eventType="touchUpInside" id="oO1-zj-XRv"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bRc-5e-QAH" userLabel="separator 4">
<rect key="frame" x="218" y="10" width="1" height="29"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="W9F-iR-Leh"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="eTo-Ip-reh">
<rect key="frame" x="218" y="0.0" width="53" height="49"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="T">
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="dayTapped:" destination="piA-L5-eiN" eventType="touchUpInside" id="SkQ-0a-9Fy"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dHj-rj-mjh" userLabel="separator 5">
<rect key="frame" x="271" y="10" width="1" height="29"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="h5U-x0-9nJ"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Wjb-tu-QEo">
<rect key="frame" x="271" y="0.0" width="53" height="49"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="F">
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="dayTapped:" destination="piA-L5-eiN" eventType="touchUpInside" id="9A8-9a-SGG"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="L7g-lu-boa" userLabel="separator 6">
<rect key="frame" x="324" y="10" width="1" height="29"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="81t-Xh-wZT"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="LNf-b4-GYP">
<rect key="frame" x="324" y="0.0" width="53" height="49"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="S">
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="dayTapped:" destination="piA-L5-eiN" eventType="touchUpInside" id="I4k-Ho-KxE"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="ZAg-Me-yKR" firstAttribute="leading" secondItem="Yr6-3E-keb" secondAttribute="leading" constant="5" id="0EB-cP-ogn"/>
<constraint firstItem="6iC-Cl-RyI" firstAttribute="width" secondItem="cPl-47-rS8" secondAttribute="width" id="1ZI-HN-9ew"/>
<constraint firstItem="cPl-47-rS8" firstAttribute="leading" secondItem="N3w-qP-kRZ" secondAttribute="trailing" id="1pQ-h0-SEG"/>
<constraint firstItem="eTo-Ip-reh" firstAttribute="leading" secondItem="6iC-Cl-RyI" secondAttribute="trailing" constant="1" id="2UA-Ao-KZF"/>
<constraint firstItem="dHj-rj-mjh" firstAttribute="height" secondItem="L7g-lu-boa" secondAttribute="height" id="4dj-Xx-ksP"/>
<constraint firstAttribute="bottom" secondItem="EiN-2p-Oig" secondAttribute="bottom" constant="10" id="5eK-Bu-wpU"/>
<constraint firstItem="N3w-qP-kRZ" firstAttribute="leading" secondItem="ZAg-Me-yKR" secondAttribute="trailing" id="67F-sV-r6W"/>
<constraint firstItem="Wjb-tu-QEo" firstAttribute="leading" secondItem="dHj-rj-mjh" secondAttribute="trailing" id="6ZX-Ub-2vw"/>
<constraint firstItem="EiN-2p-Oig" firstAttribute="height" secondItem="bRc-5e-QAH" secondAttribute="height" id="7Um-cV-f7p"/>
<constraint firstItem="LNf-b4-GYP" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" id="7YT-x4-m88"/>
<constraint firstItem="6iC-Cl-RyI" firstAttribute="trailing" secondItem="bRc-5e-QAH" secondAttribute="leading" id="ABd-MQ-9sp"/>
<constraint firstAttribute="bottom" secondItem="UjQ-Cw-7wH" secondAttribute="bottom" constant="10" id="ASC-xR-Yxa"/>
<constraint firstAttribute="bottom" secondItem="dHj-rj-mjh" secondAttribute="bottom" constant="10" id="ASP-um-b8o"/>
<constraint firstItem="6iC-Cl-RyI" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" id="Aac-10-vTs"/>
<constraint firstItem="eTo-Ip-reh" firstAttribute="leading" secondItem="6iC-Cl-RyI" secondAttribute="trailing" id="BL5-PL-pac"/>
<constraint firstAttribute="bottom" secondItem="ZAg-Me-yKR" secondAttribute="bottom" id="BeZ-ar-qMN"/>
<constraint firstItem="dHj-rj-mjh" firstAttribute="height" secondItem="bRc-5e-QAH" secondAttribute="height" id="DYn-Cd-g5H"/>
<constraint firstAttribute="bottom" secondItem="kwc-0w-V51" secondAttribute="bottom" constant="10" id="EXu-BP-ftM"/>
<constraint firstAttribute="bottom" secondItem="LNf-b4-GYP" secondAttribute="bottom" id="EYe-ne-rqO"/>
<constraint firstItem="cPl-47-rS8" firstAttribute="leading" secondItem="N3w-qP-kRZ" secondAttribute="trailing" id="Fo8-Tp-bkn"/>
<constraint firstItem="dHj-rj-mjh" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" constant="10" id="GYq-pf-vR0"/>
<constraint firstItem="cPl-47-rS8" firstAttribute="leading" secondItem="UjQ-Cw-7wH" secondAttribute="trailing" constant="72" id="HQ2-jA-X9g"/>
<constraint firstItem="Wjb-tu-QEo" firstAttribute="leading" secondItem="eTo-Ip-reh" secondAttribute="trailing" id="I0s-Ze-pwV"/>
<constraint firstAttribute="bottom" secondItem="bRc-5e-QAH" secondAttribute="bottom" constant="10" id="InL-Hk-twg"/>
<constraint firstItem="UjQ-Cw-7wH" firstAttribute="leading" secondItem="ZAg-Me-yKR" secondAttribute="trailing" id="Jj4-jg-rdr"/>
<constraint firstItem="6iC-Cl-RyI" firstAttribute="leading" secondItem="cPl-47-rS8" secondAttribute="trailing" id="KQe-Ei-8jY"/>
<constraint firstItem="cPl-47-rS8" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" id="Kw5-3R-qXs"/>
<constraint firstItem="bRc-5e-QAH" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" constant="10" id="MXG-vB-U8F"/>
<constraint firstItem="ZAg-Me-yKR" firstAttribute="width" secondItem="N3w-qP-kRZ" secondAttribute="width" id="Mem-UJ-5Js"/>
<constraint firstItem="L7g-lu-boa" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" constant="10" id="OVT-GJ-zq8"/>
<constraint firstItem="kwc-0w-V51" firstAttribute="leading" secondItem="cPl-47-rS8" secondAttribute="trailing" constant="25" id="OYQ-8o-3j8"/>
<constraint firstItem="N3w-qP-kRZ" firstAttribute="width" secondItem="cPl-47-rS8" secondAttribute="width" id="Pl6-Xd-Krq"/>
<constraint firstItem="Wjb-tu-QEo" firstAttribute="width" secondItem="LNf-b4-GYP" secondAttribute="width" id="Pro-fg-wBA"/>
<constraint firstAttribute="bottom" secondItem="6iC-Cl-RyI" secondAttribute="bottom" id="Q5M-8N-hIh"/>
<constraint firstItem="UjQ-Cw-7wH" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" constant="10" id="RGn-ja-FRD"/>
<constraint firstAttribute="trailing" secondItem="LNf-b4-GYP" secondAttribute="trailing" constant="5" id="RlS-d5-rIx"/>
<constraint firstItem="kwc-0w-V51" firstAttribute="trailing" secondItem="cPl-47-rS8" secondAttribute="leading" id="Rs4-Pl-R8X"/>
<constraint firstItem="eTo-Ip-reh" firstAttribute="leading" secondItem="bRc-5e-QAH" secondAttribute="trailing" id="SO9-U6-cVO"/>
<constraint firstAttribute="bottom" secondItem="N3w-qP-kRZ" secondAttribute="bottom" id="STf-aE-Y2E"/>
<constraint firstAttribute="bottom" secondItem="kwc-0w-V51" secondAttribute="bottom" constant="10" id="SWG-oy-aZJ"/>
<constraint firstItem="kwc-0w-V51" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" constant="10" id="TAb-IV-m7A"/>
<constraint firstAttribute="bottom" secondItem="cPl-47-rS8" secondAttribute="bottom" id="Tmp-md-564"/>
<constraint firstItem="kwc-0w-V51" firstAttribute="height" secondItem="UjQ-Cw-7wH" secondAttribute="height" id="Uli-Qb-6Om"/>
<constraint firstItem="6iC-Cl-RyI" firstAttribute="leading" secondItem="cPl-47-rS8" secondAttribute="trailing" id="VcV-kz-XBb"/>
<constraint firstItem="eTo-Ip-reh" firstAttribute="width" secondItem="6iC-Cl-RyI" secondAttribute="width" id="X0k-jG-o63"/>
<constraint firstItem="Wjb-tu-QEo" firstAttribute="leading" secondItem="eTo-Ip-reh" secondAttribute="trailing" id="cOc-P1-ZhU"/>
<constraint firstItem="LNf-b4-GYP" firstAttribute="leading" secondItem="Wjb-tu-QEo" secondAttribute="trailing" id="dSr-cr-ebR"/>
<constraint firstItem="EiN-2p-Oig" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" constant="10" id="fgT-6k-CaP"/>
<constraint firstItem="LNf-b4-GYP" firstAttribute="leading" secondItem="Wjb-tu-QEo" secondAttribute="trailing" id="gNl-wJ-ujY"/>
<constraint firstItem="ZAg-Me-yKR" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" id="glN-lT-q1z"/>
<constraint firstItem="eTo-Ip-reh" firstAttribute="width" secondItem="Wjb-tu-QEo" secondAttribute="width" id="hEH-9C-pGZ"/>
<constraint firstItem="EiN-2p-Oig" firstAttribute="height" secondItem="kwc-0w-V51" secondAttribute="height" id="hOI-fd-H7m"/>
<constraint firstItem="eTo-Ip-reh" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" id="i5C-wG-rRN"/>
<constraint firstItem="eTo-Ip-reh" firstAttribute="trailing" secondItem="dHj-rj-mjh" secondAttribute="leading" id="jsw-H6-2gQ"/>
<constraint firstItem="kwc-0w-V51" firstAttribute="leading" secondItem="cPl-47-rS8" secondAttribute="trailing" id="lQE-r9-9JT"/>
<constraint firstAttribute="bottom" secondItem="L7g-lu-boa" secondAttribute="bottom" constant="10" id="lv1-xB-0zR"/>
<constraint firstItem="kwc-0w-V51" firstAttribute="leading" secondItem="N3w-qP-kRZ" secondAttribute="trailing" id="oQe-Qf-9ZO"/>
<constraint firstItem="Wjb-tu-QEo" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" id="pn7-s8-fDj"/>
<constraint firstItem="EiN-2p-Oig" firstAttribute="leading" secondItem="cPl-47-rS8" secondAttribute="trailing" id="qIf-aB-2ZY"/>
<constraint firstItem="6iC-Cl-RyI" firstAttribute="leading" secondItem="EiN-2p-Oig" secondAttribute="trailing" id="sAE-Nl-Puc"/>
<constraint firstItem="LNf-b4-GYP" firstAttribute="leading" secondItem="L7g-lu-boa" secondAttribute="trailing" id="t1q-Nc-vbg"/>
<constraint firstItem="kwc-0w-V51" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" constant="10" id="tVL-uj-6Ma"/>
<constraint firstItem="Wjb-tu-QEo" firstAttribute="trailing" secondItem="L7g-lu-boa" secondAttribute="leading" id="u3Q-pF-E3A"/>
<constraint firstAttribute="bottom" secondItem="Wjb-tu-QEo" secondAttribute="bottom" id="uh4-LM-Ieo"/>
<constraint firstItem="kwc-0w-V51" firstAttribute="leading" secondItem="cPl-47-rS8" secondAttribute="trailing" constant="25" id="vrx-0B-GOB"/>
<constraint firstAttribute="bottom" secondItem="eTo-Ip-reh" secondAttribute="bottom" id="xIu-Vy-Nff"/>
<constraint firstItem="N3w-qP-kRZ" firstAttribute="leading" secondItem="UjQ-Cw-7wH" secondAttribute="trailing" id="xWy-Uf-QEm"/>
<constraint firstItem="N3w-qP-kRZ" firstAttribute="leading" secondItem="ZAg-Me-yKR" secondAttribute="trailing" id="xsx-BM-yQ5"/>
<constraint firstItem="N3w-qP-kRZ" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" id="yEX-Wv-CZQ"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="67F-sV-r6W"/>
<exclude reference="xWy-Uf-QEm"/>
<exclude reference="1pQ-h0-SEG"/>
<exclude reference="HQ2-jA-X9g"/>
<exclude reference="OYQ-8o-3j8"/>
<exclude reference="Rs4-Pl-R8X"/>
<exclude reference="SWG-oy-aZJ"/>
<exclude reference="TAb-IV-m7A"/>
<exclude reference="Uli-Qb-6Om"/>
<exclude reference="lQE-r9-9JT"/>
<exclude reference="vrx-0B-GOB"/>
<exclude reference="KQe-Ei-8jY"/>
<exclude reference="sAE-Nl-Puc"/>
<exclude reference="7Um-cV-f7p"/>
<exclude reference="hOI-fd-H7m"/>
<exclude reference="2UA-Ao-KZF"/>
<exclude reference="SO9-U6-cVO"/>
<exclude reference="6ZX-Ub-2vw"/>
<exclude reference="cOc-P1-ZhU"/>
<exclude reference="4dj-Xx-ksP"/>
<exclude reference="DYn-Cd-g5H"/>
<exclude reference="dSr-cr-ebR"/>
<exclude reference="t1q-Nc-vbg"/>
</mask>
</variation>
</tableViewCellContentView>
<connections>
<outlet property="fridayButton" destination="Wjb-tu-QEo" id="AcP-Qg-i9P"/>
<outlet property="mondayButton" destination="N3w-qP-kRZ" id="u3A-mt-EKd"/>
<outlet property="saturdayButton" destination="LNf-b4-GYP" id="TeM-3b-B1Z"/>
<outlet property="sundayButton" destination="ZAg-Me-yKR" id="GUI-ry-Hm1"/>
<outlet property="thursdayButton" destination="eTo-Ip-reh" id="Dxi-hi-oBK"/>
<outlet property="tuesdayButton" destination="cPl-47-rS8" id="wIn-mO-cUx"/>
<outlet property="wednesdayButton" destination="6iC-Cl-RyI" id="GQe-Oy-pcd"/>
</connections>
<point key="canvasLocation" x="296" y="222"/>
</tableViewCell>
</objects>
</document>
@@ -0,0 +1,78 @@
//
// DateAndTimeValueTransformer.swift
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014-2015 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.
class DateValueTrasformer : NSValueTransformer {
override class func transformedValueClass() -> AnyClass {
return NSString.self
}
override class func allowsReverseTransformation() -> Bool {
return false
}
override func transformedValue(value: AnyObject?) -> AnyObject? {
if let valueData: AnyObject = value {
if valueData.isKindOfClass(NSDate) {
let date = valueData as! NSDate
let dateFormatter = NSDateFormatter()
dateFormatter.dateStyle = NSDateFormatterStyle.FullStyle
dateFormatter.timeStyle = NSDateFormatterStyle.NoStyle
return dateFormatter.stringFromDate(date)
}
}
return nil
}
}
class DateTimeValueTrasformer: NSValueTransformer {
override class func transformedValueClass() -> AnyClass {
return NSString.self
}
override class func allowsReverseTransformation() -> Bool {
return false
}
override func transformedValue(value: AnyObject?) -> AnyObject? {
if let valueData: AnyObject = value {
if valueData.isKindOfClass(NSDate) {
let date = valueData as! NSDate
let dateFormatter = NSDateFormatter()
dateFormatter.dateStyle = NSDateFormatterStyle.MediumStyle
dateFormatter.timeStyle = NSDateFormatterStyle.ShortStyle
return dateFormatter.stringFromDate(date)
}
}
return nil
}
}
@@ -26,46 +26,138 @@
class DatesFormViewController: XLFormViewController {
struct tag {
static let dateTime = "dateTime"
static let date = "date"
static let time = "time"
private enum Tags : String {
case DateInline = "dateInline"
case TimeInline = "timeInline"
case DateTimeInline = "dateTimeInline"
case CountDownTimerInline = "countDownTimerInline"
case DatePicker = "datePicker"
case Date = "date"
case Time = "time"
case DateTime = "dateTime"
case CountDownTimer = "countDownTimer"
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
self.initializeForm()
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder);
super.init(coder: aDecoder)
self.initializeForm()
}
override func viewDidLoad() {
super.viewDidLoad()
let barButton = UIBarButtonItem(title: "Disable", style: UIBarButtonItemStyle.Plain, target: self, action: "disableEnable:")
barButton.possibleTitles = Set(["Disable", "Enable"])
self.navigationItem.rightBarButtonItem = barButton
}
func disableEnable(button : UIBarButtonItem)
{
self.form.disabled = !self.form.disabled
button.title = self.form.disabled ? "Enable" : "Disable"
self.tableView.endEditing(true)
self.tableView.reloadData()
}
func initializeForm() {
var form : XLFormDescriptor
let form : XLFormDescriptor
var section : XLFormSectionDescriptor
var row : XLFormRowDescriptor
form = XLFormDescriptor.formDescriptorWithTitle("Dates") as XLFormDescriptor
form = XLFormDescriptor(title: "Date & Time")
section = XLFormSectionDescriptor.formSectionWithTitle("Inline Dates") as XLFormSectionDescriptor
section = XLFormSectionDescriptor.formSectionWithTitle("Inline Dates")
form.addFormSection(section)
// Date
row = XLFormRowDescriptor(tag: tag.date, rowType: XLFormRowDescriptorTypeDateInline, title:"Date")
row = XLFormRowDescriptor(tag: Tags.DateInline.rawValue, rowType: XLFormRowDescriptorTypeDateInline, title:"Date")
row.value = NSDate()
section.addFormRow(row)
// Time
row = XLFormRowDescriptor(tag: tag.time, rowType: XLFormRowDescriptorTypeTimeInline, title: "Time")
row = XLFormRowDescriptor(tag: Tags.TimeInline.rawValue, rowType: XLFormRowDescriptorTypeTimeInline, title: "Time")
row.value = NSDate()
section.addFormRow(row)
// DateTime
row = XLFormRowDescriptor(tag: tag.dateTime, rowType: XLFormRowDescriptorTypeDateTimeInline, title: "Date Time")
row = XLFormRowDescriptor(tag: Tags.DateTimeInline.rawValue, rowType: XLFormRowDescriptorTypeDateTimeInline, title: "Date Time")
row.value = NSDate()
section.addFormRow(row)
self.form = form;
// CountDownTimer
row = XLFormRowDescriptor(tag: Tags.CountDownTimerInline.rawValue, rowType:XLFormRowDescriptorTypeCountDownTimerInline, title:"Countdown Timer")
row.value = NSDate()
section.addFormRow(row)
section = XLFormSectionDescriptor.formSectionWithTitle("Dates") //
form.addFormSection(section)
// Date
row = XLFormRowDescriptor(tag: Tags.Date.rawValue, rowType:XLFormRowDescriptorTypeDate, title:"Date")
row.value = NSDate()
row.cellConfigAtConfigure["minimumDate"] = NSDate()
row.cellConfigAtConfigure["maximumDate"] = NSDate(timeIntervalSinceNow: 60*60*24*3)
section.addFormRow(row)
// Time
row = XLFormRowDescriptor(tag: Tags.Time.rawValue, rowType: XLFormRowDescriptorTypeTime, title: "Time")
row.cellConfigAtConfigure["minuteInterval"] = 10
row.value = NSDate()
section.addFormRow(row)
// DateTime
row = XLFormRowDescriptor(tag: Tags.DateTime.rawValue, rowType: XLFormRowDescriptorTypeDateTime, title: "Date Time")
row.value = NSDate()
section.addFormRow(row)
// CountDownTimer
row = XLFormRowDescriptor(tag: Tags.CountDownTimer.rawValue, rowType: XLFormRowDescriptorTypeCountDownTimer, title: "Countdown Timer")
row.value = NSDate()
section.addFormRow(row)
section = XLFormSectionDescriptor.formSectionWithTitle("Disabled Dates")
section.footerTitle = "DatesFormViewController.swift"
form.addFormSection(section)
// Date
row = XLFormRowDescriptor(tag: nil, rowType: XLFormRowDescriptorTypeDate, title: "Date")
row.disabled = NSNumber(bool: true)
row.required = true
row.value = NSDate()
section.addFormRow(row)
section = XLFormSectionDescriptor.formSectionWithTitle("DatePicker")
form.addFormSection(section)
// DatePicker
row = XLFormRowDescriptor(tag: Tags.DatePicker.rawValue, rowType:XLFormRowDescriptorTypeDatePicker)
row.cellConfigAtConfigure["datePicker.datePickerMode"] = UIDatePickerMode.Date.rawValue
row.value = NSDate()
section.addFormRow(row)
self.form = form
}
// MARK: - XLFormDescriptorDelegate
override func formRowDescriptorValueHasChanged(formRow: XLFormRowDescriptor!, oldValue: AnyObject!, newValue: AnyObject!) {
super.formRowDescriptorValueHasChanged(formRow, oldValue: oldValue, newValue: newValue)
if formRow.tag == Tags.DatePicker.rawValue {
let alertView = UIAlertView(title: "DatePicker", message: "Value Has changed!", delegate: self, cancelButtonTitle: "OK")
alertView.show()
}
}
}
@@ -0,0 +1,193 @@
//
// ExamplesFormViewController.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "InputsFormViewController.h"
#import "SelectorsFormViewController.h"
#import "OthersFormViewController.h"
#import "DatesFormViewController.h"
#import "MultiValuedFormViewController.h"
#import "ExamplesFormViewController.h"
#import "NativeEventFormViewController.h"
#import "UICustomizationFormViewController.h"
#import "CustomRowsViewController.h"
#import "AccessoryViewFormViewController.h"
#import "PredicateFormViewController.h"
NSString * const kTextFieldAndTextView = @"TextFieldAndTextView";
NSString * const kSelectors = @"Selectors";
NSString * const kOthes = @"Others";
NSString * const kDates = @"Dates";
NSString * const kPredicates = @"BasicPredicates";
NSString * const kBlogExample = @"BlogPredicates";
NSString * const kMultivalued = @"Multivalued";
NSString * const kMultivaluedOnlyReorder = @"MultivaluedOnlyReorder";
NSString * const kMultivaluedOnlyInsert = @"MultivaluedOnlyInsert";
NSString * const kMultivaluedOnlyDelete = @"MultivaluedOnlyDelete";
NSString * const kValidations= @"Validations";
@interface ExamplesFormViewController ()
@end
@implementation ExamplesFormViewController
-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self){
[self initializeForm];
}
return self;
}
-(id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self){
[self initializeForm];
}
return self;
}
#pragma mark - Helper
-(void)initializeForm
{
XLFormDescriptor * form;
XLFormSectionDescriptor * section;
XLFormRowDescriptor * row;
form = [XLFormDescriptor formDescriptor];
section = [XLFormSectionDescriptor formSectionWithTitle:@"Real examples"];
[form addFormSection:section];
// NativeEventFormViewController
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"realExamples" rowType:XLFormRowDescriptorTypeButton title:@"iOS Calendar Event Form"];
row.action.formSegueIdenfifier = @"NativeEventNavigationViewControllerSegue";
[section addFormRow:row];
section = [XLFormSectionDescriptor formSectionWithTitle:@"This form is actually an example"];
section.footerTitle = @"ExamplesFormViewController.h, Select an option to view another example";
[form addFormSection:section];
// TextFieldAndTextView
row = [XLFormRowDescriptor formRowDescriptorWithTag:kTextFieldAndTextView rowType:XLFormRowDescriptorTypeButton title:@"Text Fields"];
row.action.viewControllerClass = [InputsFormViewController class];
[section addFormRow:row];
// Selectors
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectors rowType:XLFormRowDescriptorTypeButton title:@"Selectors"];
row.action.formSegueIdenfifier = @"SelectorsFormViewControllerSegue";
[section addFormRow:row];
// Dates
row = [XLFormRowDescriptor formRowDescriptorWithTag:kDates rowType:XLFormRowDescriptorTypeButton title:@"Date & Time"];
row.action.viewControllerClass = [DatesFormViewController class];
[section addFormRow:row];
// Others
row = [XLFormRowDescriptor formRowDescriptorWithTag:kOthes rowType:XLFormRowDescriptorTypeButton title:@"Other Rows"];
row.action.formSegueIdenfifier = @"OthersFormViewControllerSegue";
[section addFormRow:row];
section = [XLFormSectionDescriptor formSectionWithTitle:@"Multivalued example"];
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kMultivalued rowType:XLFormRowDescriptorTypeButton title:@"Multivalued Sections"];
row.action.viewControllerClass = [MultivaluedFormViewController class];
[section addFormRow:row];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kMultivaluedOnlyReorder rowType:XLFormRowDescriptorTypeButton title:@"Multivalued Only Reorder"];
row.action.viewControllerClass = [MultivaluedOnlyReorderViewController class];
[section addFormRow:row];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kMultivaluedOnlyInsert rowType:XLFormRowDescriptorTypeButton title:@"Multivalued Only Insert"];
row.action.viewControllerClass = [MultivaluedOnlyInserViewController class];
[section addFormRow:row];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kMultivaluedOnlyDelete rowType:XLFormRowDescriptorTypeButton title:@"Multivalued Only Delete"];
row.action.viewControllerClass = [MultivaluedOnlyDeleteViewController class];
[section addFormRow:row];
section = [XLFormSectionDescriptor formSectionWithTitle:@"UI Customization"];
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kMultivalued rowType:XLFormRowDescriptorTypeButton title:@"UI Customization"];
row.action.viewControllerClass = [UICustomizationFormViewController class];
[section addFormRow:row];
section = [XLFormSectionDescriptor formSectionWithTitle:@"Custom Rows"];
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kMultivalued rowType:XLFormRowDescriptorTypeButton title:@"Custom Rows"];
row.action.viewControllerClass = [CustomRowsViewController class];
[section addFormRow:row];
section = [XLFormSectionDescriptor formSectionWithTitle:@"Accessory View"];
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kMultivalued rowType:XLFormRowDescriptorTypeButton title:@"Accessory Views"];
row.action.viewControllerClass = [AccessoryViewFormViewController class];
[section addFormRow:row];
section = [XLFormSectionDescriptor formSectionWithTitle:@"Validation Examples"];
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kValidations rowType:XLFormRowDescriptorTypeButton title:@"Validation Examples"];
row.action.formSegueIdenfifier = @"ValidationExamplesFormViewControllerSegue";
[section addFormRow:row];
section = [XLFormSectionDescriptor formSectionWithTitle:@"Using Predicates"];
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kPredicates rowType:XLFormRowDescriptorTypeButton title:@"Very basic predicates"];
row.action.formSegueIdenfifier = @"BasicPredicateViewControllerSegue";
[section addFormRow:row];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kPredicates rowType:XLFormRowDescriptorTypeButton title:@"Blog Example Hide predicates"];
row.action.formSegueIdenfifier = @"BlogExampleViewSegue";
[section addFormRow:row];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kPredicates rowType:XLFormRowDescriptorTypeButton title:@"Another example"];
row.action.formSegueIdenfifier = @"PredicateFormViewControllerSegue";
[section addFormRow:row];
self.form = form;
}
@end
@@ -0,0 +1,148 @@
//
// InputsFormViewController.swift
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014-2015 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.
class InputsFormViewController : XLFormViewController {
private enum Tags : String {
case Name = "name"
case Email = "email"
case Twitter = "twitter"
case Number = "number"
case Integer = "integer"
case Decimal = "decimal"
case Password = "password"
case Phone = "phone"
case Url = "url"
case TextView = "textView"
case Notes = "notes"
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
self.initializeForm()
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.initializeForm()
}
func initializeForm() {
let form : XLFormDescriptor
var section : XLFormSectionDescriptor
var row : XLFormRowDescriptor
form = XLFormDescriptor(title: "Text Fields")
form.assignFirstResponderOnShow = true
section = XLFormSectionDescriptor.formSectionWithTitle("TextField Types")
section.footerTitle = "This is a long text that will appear on section footer"
form.addFormSection(section)
// Name
row = XLFormRowDescriptor(tag: Tags.Name.rawValue, rowType: XLFormRowDescriptorTypeText, title: "Name")
row.required = true
section.addFormRow(row)
// Email
row = XLFormRowDescriptor(tag: Tags.Email.rawValue, rowType: XLFormRowDescriptorTypeEmail, title: "Email")
// validate the email
row.addValidator(XLFormValidator.emailValidator())
section.addFormRow(row)
// Twitter
row = XLFormRowDescriptor(tag: Tags.Name.rawValue, rowType: XLFormRowDescriptorTypeTwitter, title: "Twitter")
row.disabled = NSNumber(bool: true)
row.value = "@no_editable"
section.addFormRow(row)
// Number
row = XLFormRowDescriptor(tag: Tags.Number.rawValue, rowType: XLFormRowDescriptorTypeNumber, title: "Number")
section.addFormRow(row)
// Integer
row = XLFormRowDescriptor(tag: Tags.Integer.rawValue, rowType: XLFormRowDescriptorTypeInteger, title: "Integer")
section.addFormRow(row)
// Decimal
row = XLFormRowDescriptor(tag: Tags.Decimal.rawValue, rowType: XLFormRowDescriptorTypeDecimal, title: "Decimal")
section.addFormRow(row)
// Password
row = XLFormRowDescriptor(tag: Tags.Password.rawValue, rowType: XLFormRowDescriptorTypePassword, title: "Password")
section.addFormRow(row)
// Phone
row = XLFormRowDescriptor(tag: Tags.Phone.rawValue, rowType: XLFormRowDescriptorTypePhone, title: "Phone")
section.addFormRow(row)
// Url
row = XLFormRowDescriptor(tag: Tags.Url.rawValue, rowType: XLFormRowDescriptorTypeURL, title: "Url")
section.addFormRow(row)
section = XLFormSectionDescriptor.formSection()
form.addFormSection(section)
// TextView
row = XLFormRowDescriptor(tag: Tags.TextView.rawValue, rowType: XLFormRowDescriptorTypeTextView)
row.cellConfigAtConfigure["textView.placeholder"] = "TEXT VIEW EXAMPLE"
section.addFormRow(row)
section = XLFormSectionDescriptor.formSectionWithTitle("TextView With Label Example")
form.addFormSection(section)
row = XLFormRowDescriptor(tag: Tags.Number.rawValue, rowType: XLFormRowDescriptorTypeTextView, title: "Notes")
section.addFormRow(row)
self.form = form
}
override func viewDidLoad()
{
super.viewDidLoad()
self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Save, target: self, action: "savePressed:")
}
func savePressed(button: UIBarButtonItem)
{
let validationErrors : Array<NSError> = self.formValidationErrors() as! Array<NSError>
if (validationErrors.count > 0){
self.showFormValidationError(validationErrors.first)
return
}
self.tableView.endEditing(true)
let alertView = UIAlertView(title: "Valid Form", message: "No errors found", delegate: self, cancelButtonTitle: "OK")
alertView.show()
}
}
@@ -0,0 +1,278 @@
//
// MultiValuedFormViewController.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "SelectorsFormViewController.h"
#import "MultiValuedFormViewController.h"
@implementation MultivaluedFormViewController
- (id)init
{
XLFormDescriptor * form;
XLFormSectionDescriptor * section;
XLFormRowDescriptor * row;
form = [XLFormDescriptor formDescriptorWithTitle:@"Multivalued Examples"];
// Multivalued section
section = [XLFormSectionDescriptor formSectionWithTitle:@"Multivalued TextField"
sectionOptions:XLFormSectionOptionCanReorder | XLFormSectionOptionCanInsert | XLFormSectionOptionCanDelete
sectionInsertMode:XLFormSectionInsertModeButton];
section.multivaluedAddButton.title = @"Add New Tag";
section.footerTitle = @"XLFormSectionInsertModeButton sectionType adds a 'Add Item' (Add New Tag) button row as last cell.";
// set up the row template
row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeName];
[[row cellConfig] setObject:@"Tag Name" forKey:@"textField.placeholder"];
section.multivaluedRowTemplate = row;
[form addFormSection:section];
// Another Multivalued section
section = [XLFormSectionDescriptor formSectionWithTitle:@"Multivalued ActionSheet Selector example"
sectionOptions:XLFormSectionOptionCanInsert | XLFormSectionOptionCanDelete];
section.footerTitle = @"XLFormSectionInsertModeLastRow sectionType adds a '+' icon inside last table view cell allowing us to add a new row.";
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeSelectorActionSheet title:@"Tap to select.."];
row.selectorOptions = @[@"Option 1", @"Option 2", @"Option 3", @"Option 4", @"Option 5"];
[section addFormRow:row];
// Another one
section = [XLFormSectionDescriptor formSectionWithTitle:@"Multivalued Push Selector example"
sectionOptions:XLFormSectionOptionCanInsert | XLFormSectionOptionCanDelete | XLFormSectionOptionCanReorder
sectionInsertMode:XLFormSectionInsertModeButton];
section.footerTitle = @"MultivaluedFormViewController.h";
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeSelectorPush title:@"Tap to select ;).."];
row.selectorOptions = @[@"Option 1", @"Option 2", @"Option 3"];
section.multivaluedRowTemplate = [row copy];
[section addFormRow:row];
return [super initWithForm:form];
}
-(void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(addDidTouch:)];
}
#pragma mark - Actions
-(void)addDidTouch:(UIBarButtonItem * __unused)sender
{
UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Remove Last Section" otherButtonTitles:@"Add a section at the end", self.form.isDisabled ? @"Enable Form" : @"Disable Form", nil];
[actionSheet showInView:self.view];
}
#pragma mark - UIActionSheetDelegate
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if ([actionSheet destructiveButtonIndex] == buttonIndex){
if (self.form.formSections.count > 0){
// remove last section
[self.form removeFormSectionAtIndex:(self.form.formSections.count - 1)];
}
}
else if ([[actionSheet buttonTitleAtIndex:buttonIndex] isEqualToString:@"Add a section at the end"]){
// add a new section
XLFormSectionDescriptor * newSection = [XLFormSectionDescriptor formSectionWithTitle:[NSString stringWithFormat:@"Section created at %@", [NSDateFormatter localizedStringFromDate:[NSDate new] dateStyle:NSDateFormatterShortStyle timeStyle:NSDateFormatterShortStyle]] sectionOptions:XLFormSectionOptionCanInsert | XLFormSectionOptionCanDelete];
newSection.multivaluedTag = [NSString stringWithFormat:@"multivaluedPushSelector_%@", @(self.form.formSections.count)];
XLFormRowDescriptor * newRow = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeSelectorPush title:@"Tap to select ;).."];
newRow.selectorOptions = @[@"Option 1", @"Option 2", @"Option 3"];
[newSection addFormRow:newRow];
[self.form addFormSection:newSection];
}
else {
self.form.disabled = !self.form.disabled;
[self.tableView endEditing:YES];
[self.tableView reloadData];
}
}
@end
@implementation MultivaluedOnlyReorderViewController
- (id)init
{
NSTimeInterval secondsPerDay = 24 * 60 * 60;
NSArray * list = @[@"Today", @"Yesterday", @"Before Yesterday"];
XLFormDescriptor * form;
XLFormSectionDescriptor * section;
form = [XLFormDescriptor formDescriptorWithTitle:@"Only Reorder Examples"];
// Multivalued Section with inline rows - section set up to support only reordering
section = [XLFormSectionDescriptor formSectionWithTitle:@"Reordering Inline Rows"
sectionOptions:XLFormSectionOptionCanReorder];
section.footerTitle = @"XLFormRowDescriptorTypeDateInline row type";
[form addFormSection:section];
[list enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
XLFormRowDescriptor * row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeDateInline];
row.value = [NSDate dateWithTimeIntervalSinceNow:(-secondsPerDay * idx)];
row.title = obj;
[section addFormRow:row];
}];
// Multivalued Section with common rows - section set up to support only reordering
section = [XLFormSectionDescriptor formSectionWithTitle:@"Reordering Rows"
sectionOptions:XLFormSectionOptionCanReorder];
section.footerTitle = @"XLFormRowDescriptorTypeInfo row type";
[form addFormSection:section];
[list enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
XLFormRowDescriptor * row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeInfo];
row.value = [NSDateFormatter localizedStringFromDate:[NSDate dateWithTimeIntervalSinceNow:(-secondsPerDay * idx)] dateStyle:NSDateFormatterMediumStyle timeStyle:NSDateFormatterNoStyle];
row.title = obj;
[section addFormRow:row];
}];
return [super initWithForm:form];
}
@end
@implementation MultivaluedOnlyInserViewController
- (id)init
{
XLFormDescriptor * form;
XLFormSectionDescriptor * section;
XLFormRowDescriptor * row;
NSArray * nameList = @[@"family", @"male", @"female", @"client"];
form = [XLFormDescriptor formDescriptorWithTitle:@"Multivalued Only Insert"];
section = [XLFormSectionDescriptor formSectionWithTitle:@"XLFormSectionInsertModeButton"
sectionOptions:XLFormSectionOptionCanInsert
sectionInsertMode:XLFormSectionInsertModeButton];
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeText];
[[row cellConfig] setObject:@"Add a new tag" forKey:@"textField.placeholder"];
section.multivaluedRowTemplate = row;
section = [XLFormSectionDescriptor formSectionWithTitle:@"XLFormSectionInsertModeButton With Inline Cells"
sectionOptions:XLFormSectionOptionCanInsert
sectionInsertMode:XLFormSectionInsertModeButton];
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeDateInline];
row.value = [NSDate new];
row.title = @"Date";
section.multivaluedRowTemplate = row;
section = [XLFormSectionDescriptor formSectionWithTitle:@"XLFormSectionInsertModeLastRow"
sectionOptions:XLFormSectionOptionCanInsert
sectionInsertMode:XLFormSectionInsertModeLastRow];
[form addFormSection:section];
for (NSString * tag in nameList) {
// add a row to the section, the row will be used to crete new rows.
row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeText];
[[row cellConfig] setObject:@"Add a new tag" forKey:@"textField.placeholder"];
row.value = tag;
[section addFormRow:row];
}
return [super initWithForm:form];
}
@end
@implementation MultivaluedOnlyDeleteViewController
- (id)init
{
XLFormDescriptor * form;
XLFormSectionDescriptor * section;
XLFormRowDescriptor * row;
NSArray * nameList = @[@"family", @"male", @"female", @"client"];
form = [XLFormDescriptor formDescriptor];
// MultivaluedSection section
section = [XLFormSectionDescriptor formSectionWithTitle:@""
sectionOptions:XLFormSectionOptionCanDelete];
section.footerTitle = @"you can swipe to delete when table.editing = NO (Not Editing)";
[form addFormSection:section];
for (NSString * tag in nameList) {
row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeText];
[[row cellConfig] setObject:@"Add a new tag" forKey:@"textField.placeholder"];
row.value = [tag copy];
[section addFormRow:row];
}
// Multivalued Section with inline row.
section = [XLFormSectionDescriptor formSectionWithTitle:@""
sectionOptions:XLFormSectionOptionCanDelete];
section.footerTitle = @"you can swipe to delete when table.editing = NO (Not Editing)";
[form addFormSection:section];
for (NSUInteger i = 0; i < 4; i++) {
row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeSelectorPickerViewInline];
row.title = @"Tap to select";
row.value = @"client";
row.selectorOptions = nameList;
[section addFormRow:row];
}
return [super initWithForm:form];
}
-(void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Editing" style:UIBarButtonItemStylePlain target:self action:@selector(toggleEditing:)];
}
-(void)toggleEditing:(UIBarButtonItem *)barButtonItem
{
[self.tableView setEditing:!self.tableView.editing animated:YES];
[barButtonItem setTitle:(self.tableView.editing ? @"Editing" : @"Not Editing")];
}
@end
@@ -0,0 +1,60 @@
//
// XLFormCustomCell.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "XLFormCustomCell.h"
@implementation XLFormCustomCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)configure
{
[super configure];
//override
}
- (void)update
{
[super update];
// override
self.textLabel.text = @"Am a custom cell, select me!";
}
-(void)formDescriptorCellDidSelectedWithFormController:(XLFormViewController *)controller
{
// custom code here
// i.e new behaviour when cell has been selected
self.textLabel.text = [self.textLabel.text isEqualToString:@"I can do any custom behaviour..."] ? @"Am a custom cell, select me!" : @"I can do any custom behaviour...";
self.rowDescriptor.value = self.textLabel.text;
[self.formViewController.tableView selectRowAtIndexPath:nil animated:YES scrollPosition:UITableViewScrollPositionNone];
}
@end
@@ -0,0 +1,188 @@
//
// OthersFormViewController.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "MapViewController.h"
#import "OthersFormViewController.h"
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";
NSString *const kButtonWithSegueId = @"buttonWithSegueId";
NSString *const kButtonWithSegueClass = @"buttonWithSegueClass";
NSString *const kButtonWithNibName = @"buttonWithNibName";
NSString *const kButtonWithStoryboardId = @"buttonWithStoryboardId";
@implementation OthersFormViewController
- (instancetype)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self) {
[self initializeForm];
}
return self;
}
- (id)init
{
self = [super init];
if (self){
[self initializeForm];
}
return self;
}
-(void)initializeForm
{
XLFormDescriptor * form = [XLFormDescriptor formDescriptorWithTitle:@"Other Cells"];
XLFormSectionDescriptor * section;
// Basic Information
section = [XLFormSectionDescriptor formSectionWithTitle:@"Other Cells"];
section.footerTitle = @"OthersFormViewController.h";
[form addFormSection:section];
// Switch
[section addFormRow:[XLFormRowDescriptor formRowDescriptorWithTag:kSwitchBool rowType:XLFormRowDescriptorTypeBooleanSwitch title:@"Switch"]];
// check
[section addFormRow:[XLFormRowDescriptor formRowDescriptorWithTag:kSwitchCheck rowType:XLFormRowDescriptorTypeBooleanCheck title:@"Check"]];
// step counter
[section addFormRow:[XLFormRowDescriptor formRowDescriptorWithTag:kStepCounter rowType:XLFormRowDescriptorTypeStepCounter title:@"Step counter"]];
// Segmented Control
XLFormRowDescriptor * row = [XLFormRowDescriptor formRowDescriptorWithTag:kSegmentedControl rowType:XLFormRowDescriptorTypeSelectorSegmentedControl title:@"Fruits"];
row.selectorOptions = @[@"Apple", @"Orange", @"Pear"];
row.value = @"Pear";
[section addFormRow:row];
// 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];
// 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 = @"Blue buttons will show a message when Switch is ON";
[form addFormSection:section];
// Button
XLFormRowDescriptor * buttonRow = [XLFormRowDescriptor formRowDescriptorWithTag:kButton rowType:XLFormRowDescriptorTypeButton title:@"Button"];
[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];
// Left Button
XLFormRowDescriptor * buttonLeftAlignedRow = [XLFormRowDescriptor formRowDescriptorWithTag:kButtonLeftAligned rowType:XLFormRowDescriptorTypeButton title:@"Button with Block"];
[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:sender];
};
[section addFormRow:buttonLeftAlignedRow];
// Another Left Button with segue
XLFormRowDescriptor * buttonLeftAlignedWithSegueRow = [XLFormRowDescriptor formRowDescriptorWithTag:kButtonWithSegueClass rowType:XLFormRowDescriptorTypeButton title:@"Button with Segue Class"];
buttonLeftAlignedWithSegueRow.action.formSegueClass = NSClassFromString(@"UIStoryboardPushSegue");
buttonLeftAlignedWithSegueRow.action.viewControllerClass = [MapViewController class];
[section addFormRow:buttonLeftAlignedWithSegueRow];
// Button with SegueId
XLFormRowDescriptor * buttonWithSegueId = [XLFormRowDescriptor formRowDescriptorWithTag:kButtonWithSegueClass rowType:XLFormRowDescriptorTypeButton title:@"Button with Segue Idenfifier"];
buttonWithSegueId.action.formSegueIdenfifier = @"MapViewControllerSegue";
[section addFormRow:buttonWithSegueId];
// Another Button using Segue
XLFormRowDescriptor * buttonWithStoryboardId = [XLFormRowDescriptor formRowDescriptorWithTag:kButtonWithStoryboardId rowType:XLFormRowDescriptorTypeButton title:@"Button with StoryboardId"];
buttonWithStoryboardId.action.viewControllerStoryboardId = @"MapViewController";
[section addFormRow:buttonWithStoryboardId];
// Another Left Button with segue
XLFormRowDescriptor * buttonWithNibName = [XLFormRowDescriptor formRowDescriptorWithTag:kButtonWithNibName
rowType:XLFormRowDescriptorTypeButton
title:@"Button with NibName"];
buttonWithNibName.action.viewControllerNibName = @"MapViewController";
[section addFormRow:buttonWithNibName];
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];
}
-(void)viewDidLoad
{
[super viewDidLoad];
UIBarButtonItem * barButton = [[UIBarButtonItem alloc] initWithTitle:@"Disable" style:UIBarButtonItemStylePlain
target:self
action:@selector(disableEnable:)];
barButton.possibleTitles = [NSSet setWithObjects:@"Disable", @"Enable", nil];
self.navigationItem.rightBarButtonItem = barButton;
}
-(void)disableEnable:(UIBarButtonItem *)button
{
self.form.disabled = !self.form.disabled;
[button setTitle:(self.form.disabled ? @"Enable" : @"Disable")];
[self.tableView endEditing:YES];
[self.tableView reloadData];
}
@end
@@ -0,0 +1,84 @@
//
// BasicPredicateViewController.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "BasicPredicateViewController.h"
NSString *const khiderow = @"tag1";
NSString *const khidesection = @"tag2";
NSString *const ktext = @"tag3";
@implementation BasicPredicateViewController
- (instancetype)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self) {
[self initializeForm];
}
return self;
}
- (instancetype)init
{
self = [super init];
if (self) {
[self initializeForm];
}
return self;
}
- (void)initializeForm
{
XLFormDescriptor * form;
XLFormSectionDescriptor * section;
XLFormRowDescriptor * row;
form = [XLFormDescriptor formDescriptorWithTitle:@"Basic Predicates"];
section = [XLFormSectionDescriptor formSectionWithTitle:@"A Section"];
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:khiderow rowType:XLFormRowDescriptorTypeBooleanSwitch title:@"Show next row"];
row.value = @0;
[section addFormRow:row];
row = [XLFormRowDescriptor formRowDescriptorWithTag:khidesection rowType:XLFormRowDescriptorTypeBooleanSwitch title:@"Show B Section"];
row.hidden = [NSString stringWithFormat:@"$%@==0", khiderow];
row.value = @0;
[section addFormRow:row];
section = [XLFormSectionDescriptor formSectionWithTitle:@"B Section"];
section.footerTitle = @"BasicPredicateViewController";
section.hidden = [NSString stringWithFormat:@"$%@==0", khidesection];
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:ktext rowType:XLFormRowDescriptorTypeText title:@""];
[row.cellConfigAtConfigure setObject:@"Gonna disappear soon!!" forKey:@"textField.placeholder"];
[section addFormRow:row];
self.form = form;
}
@end
@@ -0,0 +1,92 @@
//
// BlogExampleViewController.swift
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014-2015 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.
class BlogExampleViewController : XLFormViewController {
private enum Tags : String {
case Hobbies = "hobbies"
case Sport = "sport"
case Film = "films1"
case Film2 = "films2"
case Music = "music"
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
self.initializeForm()
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.initializeForm()
}
func initializeForm() {
let form : XLFormDescriptor
var section : XLFormSectionDescriptor
var row : XLFormRowDescriptor
form = XLFormDescriptor(title: "Blog Example: Hobbies")
section = XLFormSectionDescriptor()
section.title = "Hobbies"
form.addFormSection(section)
row = XLFormRowDescriptor(tag: Tags.Hobbies.rawValue, rowType: XLFormRowDescriptorTypeMultipleSelector, title:"Select Hobbies")
row.selectorOptions = ["Sport", "Music", "Films"]
row.value = []
section.addFormRow(row)
section = XLFormSectionDescriptor()
section.title = "Some more questions"
section.hidden = NSPredicate(format: "$\(row.description).value.@count == 0")
section.footerTitle = "BlogExampleViewController.swift"
form.addFormSection(section)
row = XLFormRowDescriptor(tag: Tags.Sport.rawValue, rowType: XLFormRowDescriptorTypeTextView, title:"Your favourite sportsman?")
row.hidden = "NOT $\(Tags.Hobbies.rawValue).value contains 'Sport'"
section.addFormRow(row)
row = XLFormRowDescriptor(tag: Tags.Film.rawValue, rowType:XLFormRowDescriptorTypeTextView, title: "Your favourite film?")
row.hidden = "NOT $\(Tags.Hobbies.rawValue) contains 'Films'"
section.addFormRow(row)
row = XLFormRowDescriptor(tag: Tags.Film2.rawValue, rowType:XLFormRowDescriptorTypeTextView, title:"Your favourite actor?")
row.hidden = "NOT $\(Tags.Hobbies.rawValue) contains 'Films'"
section.addFormRow(row)
row = XLFormRowDescriptor(tag: Tags.Music.rawValue, rowType:XLFormRowDescriptorTypeTextView, title:"Your favourite singer?")
row.hidden = "NOT $\(Tags.Hobbies.rawValue) contains 'Music'"
section.addFormRow(row)
self.form = form
}
}
@@ -0,0 +1,112 @@
//
// PredicateFormViewController.swift
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014-2015 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.
class PredicateFormViewController : XLFormViewController {
private enum Tags : String {
case Text = "text"
case Integer = "integer"
case Switch = "switch"
case Date = "date"
case Account = "account"
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
self.initializeForm()
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.initializeForm()
}
func initializeForm() {
let form : XLFormDescriptor
var section : XLFormSectionDescriptor
var row : XLFormRowDescriptor
form = XLFormDescriptor(title: "Predicates example")
section = XLFormSectionDescriptor()
section.title = "Independent rows"
form.addFormSection(section)
row = XLFormRowDescriptor(tag: Tags.Text.rawValue, rowType: XLFormRowDescriptorTypeAccount, title:"Text")
row.cellConfigAtConfigure["textField.placeholder"] = "Type disable"
section.addFormRow(row)
row = XLFormRowDescriptor(tag: Tags.Integer.rawValue, rowType: XLFormRowDescriptorTypeInteger, title:"Integer")
row.hidden = NSPredicate(format: "$\(Tags.Switch.rawValue).value==0")
section.addFormRow(row)
row = XLFormRowDescriptor(tag: Tags.Switch.rawValue, rowType: XLFormRowDescriptorTypeBooleanSwitch, title:"Boolean")
row.value = true
section.addFormRow(row)
form.addFormSection(section)
section = XLFormSectionDescriptor()
section.title = "Dependent section"
section.footerTitle = "Type disable in the textfield, a number between 18 and 60 in the integer field or use the switch to disable the last row. By doing all three the last section will hide.\nThe integer field hides when the boolean switch is set to 0."
form.addFormSection(section)
// Predicate Disabling
row = XLFormRowDescriptor(tag: Tags.Date.rawValue, rowType: XLFormRowDescriptorTypeDateInline, title:"Disabled")
row.value = NSDate.new()
section.addFormRow(row)
row.disabled = NSPredicate(format: "$\(Tags.Text.rawValue).value contains[c] 'disable' OR ($\(Tags.Integer.rawValue).value between {18, 60}) OR ($\(Tags.Switch.rawValue).value == 0)")
section.hidden = NSPredicate(format: "($\(Tags.Text.rawValue).value contains[c] 'disable') AND ($\(Tags.Integer.rawValue).value between {18, 60}) AND ($\(Tags.Switch.rawValue).value == 0)")
section = XLFormSectionDescriptor()
section.title = "More predicates..."
section.footerTitle = "This row hides when the row of the previous section is disabled and the textfield in the first section contains \"out\"\n\nPredicateFormViewController.swift"
form.addFormSection(section)
row = XLFormRowDescriptor(tag: "thirds", rowType:XLFormRowDescriptorTypeAccount, title:"Account")
section.addFormRow(row)
row.hidden = NSPredicate(format: "$\(Tags.Date.rawValue).isDisabled == 1 AND $\(Tags.Text.rawValue).value contains[c] 'Out'")
self.form = form
}
}
@@ -0,0 +1,263 @@
//
// NativeEventNavigationViewController.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "DateAndTimeValueTrasformer.h"
#import "NativeEventFormViewController.h"
@implementation NativeEventNavigationViewController
-(id)init
{
self = [super initWithRootViewController:[[NativeEventFormViewController alloc] init]];
return self;
}
-(void)viewDidLoad
{
[super viewDidLoad];
[self.view setTintColor:[UIColor redColor]];
}
@end
@interface NativeEventFormViewController ()
@end
@implementation NativeEventFormViewController
- (instancetype)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self) {
[self initializeForm];
}
return self;
}
- (instancetype)init
{
self = [super init];
if (self) {
[self initializeForm];
}
return self;
}
- (void)initializeForm
{
XLFormDescriptor * form;
XLFormSectionDescriptor * section;
XLFormRowDescriptor * row;
form = [XLFormDescriptor formDescriptorWithTitle:@"Add Event"];
section = [XLFormSectionDescriptor formSection];
[form addFormSection:section];
// Title
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"Title" rowType:XLFormRowDescriptorTypeText];
[row.cellConfigAtConfigure setObject:@"Title" forKey:@"textField.placeholder"];
row.required = YES;
[section addFormRow:row];
// Location
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"location" rowType:XLFormRowDescriptorTypeText];
[row.cellConfigAtConfigure setObject:@"Location" forKey:@"textField.placeholder"];
[section addFormRow:row];
section = [XLFormSectionDescriptor formSection];
[form addFormSection:section];
// All-day
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"all-day" rowType:XLFormRowDescriptorTypeBooleanSwitch title:@"All-day"];
[section addFormRow:row];
// Starts
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"starts" rowType:XLFormRowDescriptorTypeDateTimeInline title:@"Starts"];
row.value = [NSDate dateWithTimeIntervalSinceNow:60*60*24];
[section addFormRow:row];
// Ends
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"ends" rowType:XLFormRowDescriptorTypeDateTimeInline title:@"Ends"];
row.value = [NSDate dateWithTimeIntervalSinceNow:60*60*25];
[section addFormRow:row];
section = [XLFormSectionDescriptor formSection];
[form addFormSection:section];
// Repeat
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"repeat" rowType:XLFormRowDescriptorTypeSelectorPush title:@"Repeat"];
row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:@"Never"];
row.selectorTitle = @"Repeat";
row.selectorOptions = @[[XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:@"Never"],
[XLFormOptionsObject formOptionsObjectWithValue:@(1) displayText:@"Every Day"],
[XLFormOptionsObject formOptionsObjectWithValue:@(2) displayText:@"Every Week"],
[XLFormOptionsObject formOptionsObjectWithValue:@(3) displayText:@"Every 2 Weeks"],
[XLFormOptionsObject formOptionsObjectWithValue:@(4) displayText:@"Every Month"],
[XLFormOptionsObject formOptionsObjectWithValue:@(5) displayText:@"Every Year"],
];
[section addFormRow:row];
section = [XLFormSectionDescriptor formSection];
[form addFormSection:section];
// Alert
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"alert" rowType:XLFormRowDescriptorTypeSelectorPush title:@"Alert"];
row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:@"None"];
row.selectorTitle = @"Event Alert";
row.selectorOptions = @[[XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:@"None"],
[XLFormOptionsObject formOptionsObjectWithValue:@(1) displayText:@"At time of event"],
[XLFormOptionsObject formOptionsObjectWithValue:@(2) displayText:@"5 minutes before"],
[XLFormOptionsObject formOptionsObjectWithValue:@(3) displayText:@"15 minutes before"],
[XLFormOptionsObject formOptionsObjectWithValue:@(4) displayText:@"30 minutes before"],
[XLFormOptionsObject formOptionsObjectWithValue:@(5) displayText:@"1 hour before"],
[XLFormOptionsObject formOptionsObjectWithValue:@(6) displayText:@"2 hours before"],
[XLFormOptionsObject formOptionsObjectWithValue:@(7) displayText:@"1 day before"],
[XLFormOptionsObject formOptionsObjectWithValue:@(8) displayText:@"2 days before"],
];
[section addFormRow:row];
section = [XLFormSectionDescriptor formSection];
[form addFormSection:section];
// Show As
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"showAs" rowType:XLFormRowDescriptorTypeSelectorPush title:@"Show As"];
row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:@"Busy"];
row.selectorTitle = @"Show As";
row.selectorOptions = @[[XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:@"Busy"],
[XLFormOptionsObject formOptionsObjectWithValue:@(1) displayText:@"Free"]];
[section addFormRow:row];
section = [XLFormSectionDescriptor formSection];
[form addFormSection:section];
// URL
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"url" rowType:XLFormRowDescriptorTypeURL];
[row.cellConfigAtConfigure setObject:@"URL" forKey:@"textField.placeholder"];
[section addFormRow:row];
// Notes
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"notes" rowType:XLFormRowDescriptorTypeTextView];
[row.cellConfigAtConfigure setObject:@"Notes" forKey:@"textView.placeholder"];
[section addFormRow:row];
self.form = form;
}
-(void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelPressed:)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(savePressed:)];
}
#pragma mark - XLFormDescriptorDelegate
-(void)formRowDescriptorValueHasChanged:(XLFormRowDescriptor *)rowDescriptor oldValue:(id)oldValue newValue:(id)newValue
{
[super formRowDescriptorValueHasChanged:rowDescriptor oldValue:oldValue newValue:newValue];
if ([rowDescriptor.tag isEqualToString:@"alert"]){
if ([[rowDescriptor.value valueData] isEqualToNumber:@(0)] == NO && [[oldValue valueData] isEqualToNumber:@(0)]){
XLFormRowDescriptor * newRow = [rowDescriptor copy];
newRow.tag = @"secondAlert";
newRow.title = @"Second Alert";
[self.form addFormRow:newRow afterRow:rowDescriptor];
}
else if ([[oldValue valueData] isEqualToNumber:@(0)] == NO && [[newValue valueData] isEqualToNumber:@(0)]){
[self.form removeFormRowWithTag:@"secondAlert"];
}
}
else if ([rowDescriptor.tag isEqualToString:@"all-day"]){
XLFormRowDescriptor * startDateDescriptor = [self.form formRowWithTag:@"starts"];
XLFormRowDescriptor * endDateDescriptor = [self.form formRowWithTag:@"ends"];
XLFormDateCell * dateStartCell = (XLFormDateCell *)[[self.form formRowWithTag:@"starts"] cellForFormController:self];
XLFormDateCell * dateEndCell = (XLFormDateCell *)[[self.form formRowWithTag:@"ends"] cellForFormController:self];
if ([[rowDescriptor.value valueData] boolValue] == YES){
startDateDescriptor.valueTransformer = [DateValueTrasformer class];
endDateDescriptor.valueTransformer = [DateValueTrasformer class];
[dateStartCell setFormDatePickerMode:XLFormDateDatePickerModeDate];
[dateEndCell setFormDatePickerMode:XLFormDateDatePickerModeDate];
}
else{
startDateDescriptor.valueTransformer = [DateTimeValueTrasformer class];
endDateDescriptor.valueTransformer = [DateTimeValueTrasformer class];
[dateStartCell setFormDatePickerMode:XLFormDateDatePickerModeDateTime];
[dateEndCell setFormDatePickerMode:XLFormDateDatePickerModeDateTime];
}
[dateStartCell update];
[dateEndCell update];
}
else if ([rowDescriptor.tag isEqualToString:@"starts"]){
XLFormRowDescriptor * startDateDescriptor = [self.form formRowWithTag:@"starts"];
XLFormRowDescriptor * endDateDescriptor = [self.form formRowWithTag:@"ends"];
XLFormDateCell * dateEndCell = (XLFormDateCell *)[endDateDescriptor cellForFormController:self];
if ([startDateDescriptor.value compare:endDateDescriptor.value] == NSOrderedDescending) {
// startDateDescriptor is later than endDateDescriptor
endDateDescriptor.value = [[NSDate alloc] initWithTimeInterval:(60*60*24) sinceDate:startDateDescriptor.value];
[dateEndCell update];
}
}
else if ([rowDescriptor.tag isEqualToString:@"ends"]){
XLFormRowDescriptor * startDateDescriptor = [self.form formRowWithTag:@"starts"];
XLFormRowDescriptor * endDateDescriptor = [self.form formRowWithTag:@"ends"];
XLFormDateCell * dateEndCell = (XLFormDateCell *)[endDateDescriptor cellForFormController:self];
if ([startDateDescriptor.value compare:endDateDescriptor.value] == NSOrderedDescending) {
// startDateDescriptor is later than endDateDescriptor
NSDictionary *strikeThroughAttribute = [NSDictionary dictionaryWithObject:@1
forKey:NSStrikethroughStyleAttributeName];
NSAttributedString* strikeThroughText = [[NSAttributedString alloc] initWithString:dateEndCell.detailTextLabel.text attributes:strikeThroughAttribute];
dateEndCell.detailTextLabel.attributedText = strikeThroughText;
}
}
}
-(void)cancelPressed:(UIBarButtonItem * __unused)button
{
[self dismissViewControllerAnimated:YES completion:nil];
}
-(void)savePressed:(UIBarButtonItem * __unused)button
{
NSArray * validationErrors = [self formValidationErrors];
if (validationErrors.count > 0){
[self showFormValidationError:[validationErrors firstObject]];
return;
}
[self.tableView endEditing:YES];
}
@end
@@ -0,0 +1,73 @@
//
// CustomSelectorsFormViewController.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 <MapKit/MapKit.h>
#import "CLLocationValueTrasformer.h"
#import "MapViewController.h"
#import "CustomSelectorsFormViewController.h"
NSString *const kSelectorMap = @"selectorMap";
NSString *const kSelectorMapPopover = @"selectorMapPopover";
@implementation CustomSelectorsFormViewController
-(id)init
{
self = [super init];
if (self) {
XLFormDescriptor * form = [XLFormDescriptor formDescriptorWithTitle:@"Custom Selectors"];
XLFormSectionDescriptor * section;
XLFormRowDescriptor * row;
// Basic Information
section = [XLFormSectionDescriptor formSection];
section.footerTitle = @"CustomSelectorsFormViewController.h";
[form addFormSection:section];
// Selector Push
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorMap rowType:XLFormRowDescriptorTypeSelectorPush title:@"Coordinate"];
row.action.viewControllerClass = [MapViewController class];
row.valueTransformer = [CLLocationValueTrasformer class];
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.action.viewControllerClass = [MapViewController class];
row.valueTransformer = [CLLocationValueTrasformer class];
row.value = [[CLLocation alloc] initWithLatitude:-33 longitude:-56];
[section addFormRow:row];
}
self.form = form;
}
return self;
}
@end
@@ -0,0 +1,48 @@
//
// CLLocationValueTrasformer.h
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 <MapKit/MapKit.h>
#import "CLLocationValueTrasformer.h"
@implementation CLLocationValueTrasformer
+ (Class)transformedValueClass
{
return [NSString class];
}
+ (BOOL)allowsReverseTransformation
{
return NO;
}
- (id)transformedValue:(id)value
{
if (!value) return nil;
CLLocation * location = (CLLocation *)value;
return [NSString stringWithFormat:@"%0.4f, %0.4f", location.coordinate.latitude, location.coordinate.longitude];
}
@end
@@ -0,0 +1,108 @@
//
// MapViewController.h
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "UIView+XLFormAdditions.h"
#import <MapKit/MapKit.h>
#import "MapViewController.h"
@interface MapAnnotation : NSObject <MKAnnotation>
@end
@implementation MapAnnotation
@synthesize coordinate = _coordinate;
-(void)setCoordinate:(CLLocationCoordinate2D)newCoordinate
{
_coordinate = newCoordinate;
}
@end
@interface MapViewController () <MKMapViewDelegate>
@property (nonatomic) MKMapView * mapView;
@end
@implementation MapViewController
@synthesize rowDescriptor = _rowDescriptor;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
[self.view addSubview:self.mapView];
self.mapView.delegate = self;
if (self.rowDescriptor.value){
[self.mapView setCenterCoordinate:((CLLocation *)self.rowDescriptor.value).coordinate];
self.title = [NSString stringWithFormat:@"%0.4f, %0.4f", self.mapView.centerCoordinate.latitude, self.mapView.centerCoordinate.longitude];
MapAnnotation *annotation = [[MapAnnotation alloc] init];
annotation.coordinate = self.mapView.centerCoordinate;
[self.mapView addAnnotation:annotation];
}
}
-(MKMapView *)mapView
{
if (_mapView) return _mapView;
_mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];
_mapView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
return _mapView;
}
#pragma mark - MKMapViewDelegate
- (MKAnnotationView *)mapView:(MKMapView *)mapView
viewForAnnotation:(id <MKAnnotation>)annotation {
MKPinAnnotationView *pinAnnotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation
reuseIdentifier:@"annotation"];
pinAnnotationView.pinColor = MKPinAnnotationColorRed;
pinAnnotationView.draggable = YES;
pinAnnotationView.animatesDrop = YES;
return pinAnnotationView;
}
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view didChangeDragState:(MKAnnotationViewDragState)newState
fromOldState:(MKAnnotationViewDragState)oldState
{
if (newState == MKAnnotationViewDragStateEnding){
self.rowDescriptor.value = [[CLLocation alloc] initWithLatitude:view.annotation.coordinate.latitude longitude:view.annotation.coordinate.longitude];
self.title = [NSString stringWithFormat:@"%0.4f, %0.4f", view.annotation.coordinate.latitude, view.annotation.coordinate.longitude];
}
}
@end
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6254" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6247"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MapViewController">
<connections>
<outlet property="view" destination="iN0-l3-epB" id="O5R-PM-tsI"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</objects>
</document>
@@ -0,0 +1,66 @@
//
// DynamicSelectorsFormViewController.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "UsersTableViewController.h"
#import "DynamicSelectorsFormViewController.h"
NSString *const kSelectorUser = @"selectorUser";
NSString *const kSelectorUserPopover = @"kSelectorUserPopover";
@implementation DynamicSelectorsFormViewController
-(id)init
{
self = [super init];
if (self) {
XLFormDescriptor * form = [XLFormDescriptor formDescriptorWithTitle:@"Selectors"];
XLFormSectionDescriptor * section;
XLFormRowDescriptor * row;
// Basic Information
section = [XLFormSectionDescriptor formSectionWithTitle:@"Dynamic Selectors"];
section.footerTitle = @"DynamicSelectorsFormViewController.h";
[form addFormSection:section];
// Selector Push
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorUser rowType:XLFormRowDescriptorTypeSelectorPush title:@"User"];
row.action.viewControllerClass = [UsersTableViewController class];
[section addFormRow:row];
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad){
// Selector PopOver
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorUserPopover rowType:XLFormRowDescriptorTypeSelectorPopover title:@"User Popover"];
row.action.viewControllerClass = [UsersTableViewController class];
[section addFormRow:row];
}
self.form = form;
}
return self;
}
@end
@@ -0,0 +1,204 @@
//
// UsersTableViewController.swift
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014-2015 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.
class UserCell : UITableViewCell {
lazy var userImage : UIImageView = {
let tempUserImage = UIImageView()
tempUserImage.setTranslatesAutoresizingMaskIntoConstraints(false)
tempUserImage.layer.masksToBounds = true
tempUserImage.layer.cornerRadius = 10.0
return tempUserImage
}()
lazy var userName : UILabel = {
let tempUserName = UILabel()
tempUserName.setTranslatesAutoresizingMaskIntoConstraints(false)
tempUserName.font = UIFont.systemFontOfSize(15.0)
return tempUserName
}()
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
// Initialization code
self.contentView.addSubview(self.userImage)
self.contentView.addSubview(self.userName)
self.contentView.addConstraints(self.layoutConstraints())
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func setSelected(selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
// MARK: - Layout Constraints
func layoutConstraints() -> [AnyObject]{
let views = ["image": self.userImage, "name": self.userName ]
let metrics = [ "imgSize": 50.0, "margin": 12.0]
var result = NSLayoutConstraint.constraintsWithVisualFormat("H:|-(margin)-[image(imgSize)]-[name]", options:NSLayoutFormatOptions.AlignAllTop, metrics: metrics, views: views)
result += NSLayoutConstraint.constraintsWithVisualFormat("V:|-(margin)-[image(imgSize)]", options:NSLayoutFormatOptions.allZeros, metrics:metrics, views: views)
return result
}
}
private let _UsersJSONSerializationSharedInstance = UsersJSONSerialization()
class UsersJSONSerialization {
lazy var userData : Array<AnyObject>? = {
let dataString =
"[" +
"{\"id\":1,\"name\":\"Apu Nahasapeemapetilon\",\"imageName\":\"Apu_Nahasapeemapetilon.png\"}," +
"{\"id\":7,\"name\":\"Bart Simpsons\",\"imageName\":\"Bart_Simpsons.png\"}," +
"{\"id\":8,\"name\":\"Homer Simpsons\",\"imageName\":\"Homer_Simpsons.png\"}," +
"{\"id\":9,\"name\":\"Lisa Simpsons\",\"imageName\":\"Lisa_Simpsons.png\"}," +
"{\"id\":2,\"name\":\"Maggie Simpsons\",\"imageName\":\"Maggie_Simpsons.png\"}," +
"{\"id\":3,\"name\":\"Marge Simpsons\",\"imageName\":\"Marge_Simpsons.png\"}," +
"{\"id\":4,\"name\":\"Montgomery Burns\",\"imageName\":\"Montgomery_Burns.png\"}," +
"{\"id\":5,\"name\":\"Ned Flanders\",\"imageName\":\"Ned_Flanders.png\"}," +
"{\"id\":6,\"name\":\"Otto Mann\",\"imageName\":\"Otto_Mann.png\"}]"
let jsonData = dataString.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true)
return NSJSONSerialization.JSONObjectWithData(jsonData!, options: NSJSONReadingOptions.allZeros, error: nil) as! Array<AnyObject>?
}()
class var sharedInstance: UsersJSONSerialization {
return _UsersJSONSerializationSharedInstance
}
}
class User: NSObject, XLFormOptionObject {
let userId: Int
let userName : String
let userImage: String
init(userId: Int, userName: String, userImage: String){
self.userId = userId
self.userImage = userImage
self.userName = userName
}
func formDisplayText() -> String! {
return self.userName
}
func formValue() -> AnyObject! {
return self.userId
}
}
class UsersTableViewController : UITableViewController, XLFormRowDescriptorViewController, XLFormRowDescriptorPopoverViewController {
var rowDescriptor : XLFormRowDescriptor?
var popoverController : UIPopoverController?
var userCell : UserCell?
private let kUserCellIdentifier = "UserCell"
override init(style: UITableViewStyle) {
super.init(style: style);
}
override init!(nibName nibNameOrNil: String!, bundle nibBundleOrNil: NSBundle!) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.registerClass(UserCell.self, forCellReuseIdentifier: self.kUserCellIdentifier)
self.tableView.tableFooterView = UIView(frame: CGRect.zeroRect)
}
// MARK: UITableViewDataSource
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return UsersJSONSerialization.sharedInstance.userData!.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: UserCell = tableView.dequeueReusableCellWithIdentifier(self.kUserCellIdentifier, forIndexPath: indexPath) as! UserCell
let usersData = UsersJSONSerialization.sharedInstance.userData! as! Array<Dictionary<String, AnyObject>>
let userData = usersData[indexPath.row] as Dictionary<String, AnyObject>
let userId = userData["id"] as! Int
cell.userName.text = userData["name"] as? String
cell.userImage.image = UIImage(named: (userData["imageName"] as? String)!)
if self.rowDescriptor?.value != nil {
cell.accessoryType = self.rowDescriptor!.value.formValue().isEqual(userId) ? UITableViewCellAccessoryType.Checkmark : UITableViewCellAccessoryType.None
}
return cell;
}
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 73.0
}
//MARK: UITableViewDelegate
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
let usersData = UsersJSONSerialization.sharedInstance.userData! as! Array<Dictionary<String, AnyObject>>
let userData = usersData[indexPath.row] as Dictionary<String, AnyObject>
let user = User(userId: (userData["id"] as! Int), userName: userData["name"] as! String, userImage: userData["imageName"] as! String)
self.rowDescriptor!.value = user;
if let porpOver = self.popoverController {
porpOver.dismissPopoverAnimated(true)
porpOver.delegate?.popoverControllerDidDismissPopover!(porpOver)
}
else if self.parentViewController is UINavigationController {
self.navigationController?.popViewControllerAnimated(true)
}
}
}
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="5064" systemVersion="13C1021" minimumToolsVersion="Xcode 4.3" macOSVersion="Automatic" iOSVersion="Automatic">
<entity name="User" representedClassName="User" syncable="YES">
<attribute name="userId" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
<attribute name="userImageURL" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="userName" optional="YES" attributeType="String" syncable="YES"/>
</entity>
<elements>
<element name="User" positionX="-63" positionY="-18" width="128" height="88"/>
</elements>
</model>
@@ -0,0 +1,53 @@
//
// CoreDataStore.h
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 <CoreData/CoreData.h>
#import <Foundation/Foundation.h>
@interface CoreDataStore : NSObject
+(id)defaultStore;
+ (NSManagedObjectContext *)mainQueueContext;
+ (NSManagedObjectContext *)privateQueueContext;
+ (void)savePrivateQueueContext;
+ (void)saveMainQueueContext;
+ (NSManagedObjectID *)managedObjectIDFromString:(NSString *)managedObjectIDString;
@end
@interface NSManagedObject (Additions)
+(instancetype)findFirstByAttribute:(NSString *)attribute withValue:(id)value inContext:(NSManagedObjectContext *)context;
+(NSFetchRequest*)fetchRequest;
+(instancetype)insert:(NSManagedObjectContext *)context;
@end
@@ -0,0 +1,227 @@
//
// CoreDataStore.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "CoreDataStore.h"
static NSString *const TBCoreDataModelFileName = @"Model";
@interface CoreDataStore ()
@property (strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
@property (strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (strong, nonatomic) NSManagedObjectContext *mainQueueContext;
@property (strong, nonatomic) NSManagedObjectContext *privateQueueContext;
@end
@implementation CoreDataStore
+ (instancetype)defaultStore {
static CoreDataStore *_defaultStore = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_defaultStore = [[self alloc] init];
});
return _defaultStore;
}
#pragma mark - Singleton Access
+ (NSManagedObjectContext *)mainQueueContext
{
return [[self defaultStore] mainQueueContext];
}
+ (NSManagedObjectContext *)privateQueueContext
{
return [[self defaultStore] privateQueueContext];
}
+(void)savePrivateQueueContext
{
NSError * error;
[[self privateQueueContext] save:&error];
NSAssert(!error, [error localizedDescription]);
}
+ (void)saveMainQueueContext
{
NSError * error;
[[self mainQueueContext] save:&error];
NSAssert(!error, [error localizedDescription]);
}
+ (NSManagedObjectID *)managedObjectIDFromString:(NSString *)managedObjectIDString
{
return [[[self defaultStore] persistentStoreCoordinator] managedObjectIDForURIRepresentation:[NSURL URLWithString:managedObjectIDString]];
}
#pragma mark - Lifecycle
- (id)init
{
self = [super init];
if (self) {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contextDidSavePrivateQueueContext:)name:NSManagedObjectContextDidSaveNotification object:[self privateQueueContext]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(contextDidSaveMainQueueContext:) name:NSManagedObjectContextDidSaveNotification object:[self mainQueueContext]];
}
return self;
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
#pragma mark - Notifications
- (void)contextDidSavePrivateQueueContext:(NSNotification *)notification
{
@synchronized(self) {
[self.mainQueueContext performBlock:^{
for(NSManagedObject *object in [[notification userInfo] objectForKey:NSUpdatedObjectsKey]) {
[[self.mainQueueContext objectWithID:[object objectID]] willAccessValueForKey:nil];
}
[self.mainQueueContext mergeChangesFromContextDidSaveNotification:notification];
}];
}
}
- (void)contextDidSaveMainQueueContext:(NSNotification *)notification
{
@synchronized(self) {
[self.privateQueueContext performBlock:^{
[self.privateQueueContext mergeChangesFromContextDidSaveNotification:notification];
}];
}
}
#pragma mark - Getters
- (NSManagedObjectContext *)mainQueueContext
{
if (!_mainQueueContext) {
_mainQueueContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSMainQueueConcurrencyType];
_mainQueueContext.persistentStoreCoordinator = self.persistentStoreCoordinator;
}
return _mainQueueContext;
}
- (NSManagedObjectContext *)privateQueueContext
{
if (!_privateQueueContext) {
_privateQueueContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
_privateQueueContext.persistentStoreCoordinator = self.persistentStoreCoordinator;
}
return _privateQueueContext;
}
#pragma mark - Stack Setup
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
if (!_persistentStoreCoordinator) {
_persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:self.managedObjectModel];
NSError *error = nil;
if (![_persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:[self persistentStoreURL] options:[self persistentStoreOptions] error:&error]) {
NSLog(@"Error adding persistent store. %@, %@", error, error.userInfo);
}
}
return _persistentStoreCoordinator;
}
- (NSManagedObjectModel *)managedObjectModel
{
if (!_managedObjectModel) {
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:TBCoreDataModelFileName withExtension:@"momd"];
_managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
}
return _managedObjectModel;
}
- (NSURL *)persistentStoreURL
{
return [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"Model.sqlite"];
}
- (NSDictionary *)persistentStoreOptions
{
return @{NSInferMappingModelAutomaticallyOption: @YES, NSMigratePersistentStoresAutomaticallyOption: @YES, NSSQLitePragmasOption: @{@"synchronous": @"OFF"}};
}
#pragma mark - Application's Documents directory
// Returns the URL to the application's Documents directory.
- (NSURL *)applicationDocumentsDirectory
{
return [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
}
@end
@implementation NSManagedObject (Additions)
+(instancetype)findFirstByAttribute:(NSString *)attribute withValue:(id)value inContext:(NSManagedObjectContext *)context
{
NSString * predicateStr = [NSString stringWithFormat:@"%@ = %%@", attribute];
NSPredicate * searchByAttValue = [NSPredicate predicateWithFormat:predicateStr argumentArray:@[value]];
NSFetchRequest * fetchRequest = [self fetchRequest];
fetchRequest.predicate = searchByAttValue;
fetchRequest.fetchLimit = 1;
NSArray *result = [context executeFetchRequest:fetchRequest error:nil];
return [result lastObject];
}
+(NSFetchRequest*)fetchRequest
{
return [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass(self)];
}
+(NSEntityDescription*)entityDescriptor:(NSManagedObjectContext *)context
{
return [NSEntityDescription entityForName:NSStringFromClass(self) inManagedObjectContext:context];
}
+(instancetype)insert:(NSManagedObjectContext *)context
{
return [[NSManagedObject alloc] initWithEntity:[self entityDescriptor:context] insertIntoManagedObjectContext:context];
}
@end
@@ -0,0 +1,41 @@
//
// User+Additions.h
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "User.h"
@interface User (Additions) <XLFormOptionObject>
+ (User *)createOrUpdateWithServiceResult:(NSDictionary *)data inContext:(NSManagedObjectContext *)context;
+ (UIImage *)defaultProfileImage;
+ (NSPredicate *)getPredicateBySearchInput:(NSString *)search;
+ (NSFetchRequest *)getFetchRequest;
+ (NSFetchRequest *)getFetchRequestBySearchInput:(NSString *)search;
@end
@@ -0,0 +1,87 @@
//
// User+Additions.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "CoreDataStore.h"
#import "User+Additions.h"
#define USER_ID @"id"
#define USER_IMAGE_URL @"imageURL"
#define USER_NAME @"name"
@implementation User (Additions)
+ (User *)createOrUpdateWithServiceResult:(NSDictionary *)data inContext:(NSManagedObjectContext *)context;
{
User *user = [User findFirstByAttribute:@"userId" withValue:data[USER_ID] inContext:context];
if (!user)
{
user = [User insert:context];
}
user.userId = data[USER_ID];
user.userImageURL = data[USER_IMAGE_URL] ;
user.userName = data[USER_NAME];
return user;
}
+ (UIImage *)defaultProfileImage
{
return [UIImage imageNamed:@"default-avatar"];
}
+ (NSPredicate *)getPredicateBySearchInput:(NSString *)search {
if (search && ![search isEqualToString:@""]) {
return [NSPredicate predicateWithFormat:@"userName CONTAINS[cd] %@" , search];
}
return nil;
}
+ (NSFetchRequest *)getFetchRequest {
return [User getFetchRequestBySearchInput:nil];
}
+ (NSFetchRequest *)getFetchRequestBySearchInput:(NSString *)search {
NSFetchRequest * fetchRequest = [User fetchRequest];
fetchRequest.predicate = [User getPredicateBySearchInput:search];
fetchRequest.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"userName" ascending:YES selector:@selector(caseInsensitiveCompare:)]];
return fetchRequest;
}
#pragma mark - XLFormOptionObject
-(NSString *)formDisplayText
{
return self.userName;
}
-(id)formValue
{
return self.userId;
}
@end
@@ -0,0 +1,36 @@
//
// User.h
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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>
#import <CoreData/CoreData.h>
@interface User : NSManagedObject
@property (nonatomic, retain) NSNumber * userId;
@property (nonatomic, retain) NSString * userName;
@property (nonatomic, retain) NSString * userImageURL;
@end
@@ -0,0 +1,35 @@
//
// User.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "User.h"
@implementation User
@dynamic userId;
@dynamic userName;
@dynamic userImageURL;
@end
@@ -0,0 +1,30 @@
//
// UserLocalDataLoader.h
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "XLLocalDataLoader.h"
@interface UserLocalDataLoader : XLLocalDataLoader
@end
@@ -0,0 +1,60 @@
//
// UserLocalDataLoader.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "UserLocalDataLoader.h"
#import "User+Additions.h"
#import "CoreDataStore.h"
@implementation UserLocalDataLoader
{
NSString *_searchString;
}
- (id)init {
self = [super init];
if (self) {
NSFetchedResultsController * fetchResultController = [[NSFetchedResultsController alloc] initWithFetchRequest:[User getFetchRequest]
managedObjectContext:[CoreDataStore mainQueueContext]
sectionNameKeyPath:nil
cacheName:nil];
[self setFetchedResultsController:fetchResultController];
}
return self;
}
-(void)changeSearchString:(NSString *)searchString
{
_searchString = searchString;
[self refreshPredicate];
}
- (void)refreshPredicate
{
[self setPredicate:[User getPredicateBySearchInput:_searchString]];
}
@end
@@ -0,0 +1,30 @@
//
// UserRemoteDataLoader.h
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "XLRemoteDataLoader.h"
@interface UserRemoteDataLoader : XLRemoteDataLoader
@end
@@ -0,0 +1,107 @@
//
// UserRemoteDataLoader.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "UserRemoteDataLoader.h"
#import "HTTPSessionManager.h"
#import "CoreDataStore.h"
#import "User+Additions.h"
@implementation UserRemoteDataLoader
-(NSString *)URLString
{
return @"/mobile/users.json";
}
-(NSDictionary *)parameters
{
NSString *filterParam = self.searchString ?: @"";
return @{@"filter" : filterParam,
@"offset" : @(self.offset),
@"limit" : @(self.limit)};
}
-(AFHTTPSessionManager *)sessionManager
{
return [HTTPSessionManager sharedClient];
}
-(void)successulDataLoad {
// change flags
// [self fetchedData] contains the data coming from the server
NSArray * itemsArray = [[self fetchedData] objectForKey:kXLRemoteDataLoaderDefaultKeyForNonDictionaryResponse];
// This flag indicates if there is more data to load
_hasMoreToLoad = !((itemsArray.count == 0) || (itemsArray.count < _limit && itemsArray.count != 0));
[[CoreDataStore privateQueueContext] performBlock:^{
for (NSDictionary *item in itemsArray) {
// Creates or updates the User and the user who created it with the data that came from the server
[User createOrUpdateWithServiceResult:item[@"user"] inContext:[CoreDataStore privateQueueContext]];
}
[self removeOutdatedData:itemsArray inContext:[CoreDataStore privateQueueContext]];
[CoreDataStore savePrivateQueueContext];
}];
[super successulDataLoad];
}
#pragma mark - Auxiliary Functions
- (void)removeOutdatedData:(NSArray *)data inContext:(NSManagedObjectContext *)context
{
// First, remove older data
NSFetchRequest * fetchRequest = [User getFetchRequestBySearchInput:self.searchString];
fetchRequest.fetchLimit = self.limit;
fetchRequest.fetchOffset = self.offset;
NSError *error;
NSArray * oldObjects = [context executeFetchRequest:fetchRequest error:&error];
NSArray * arrayToIterate = [oldObjects copy];
if (error) {
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Error"
message:error.localizedFailureReason ?: error.localizedDescription
delegate:nil
cancelButtonTitle:NSLocalizedString(@"OK", nil) otherButtonTitles:nil, nil];
[alertView show];
});
return;
}
for (User *user in arrayToIterate)
{
NSArray *filteredArray = [data filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"user.id == %@" argumentArray:@[user.userId]]];
if (filteredArray.count == 0) {
// This User no longer exists
[context deleteObject:user];
}
}
}
@end
@@ -0,0 +1,32 @@
//
// HTTPSessionManager.h
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "AFHTTPSessionManager.h"
@interface HTTPSessionManager : AFHTTPSessionManager
+ (HTTPSessionManager *)sharedClient;
@end
@@ -0,0 +1,45 @@
//
// HTTPSessionManager.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "HTTPSessionManager.h"
@implementation HTTPSessionManager
// Server Base URL
static NSString * const APIBaseURLString = @"http://obscure-refuge-3149.herokuapp.com";
+ (instancetype)sharedClient {
static HTTPSessionManager *_sharedClient = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedClient = [[HTTPSessionManager alloc] initWithBaseURL:[NSURL URLWithString:APIBaseURLString]];
[_sharedClient.reachabilityManager startMonitoring];
_sharedClient.securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
});
return _sharedClient;
}
@end
@@ -0,0 +1,415 @@
//
// SelectorsFormViewController.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 <MapKit/MapKit.h>
#import "CLLocationValueTrasformer.h"
#import "MapViewController.h"
#import "CustomSelectorsFormViewController.h"
#import "DynamicSelectorsFormViewController.h"
#import "SelectorsFormViewController.h"
NSString *const kSelectorPush = @"selectorPush";
NSString *const kSelectorPopover = @"selectorPopover";
NSString *const kSelectorActionSheet = @"selectorActionSheet";
NSString *const kSelectorAlertView = @"selectorAlertView";
NSString *const kSelectorLeftRight = @"selectorLeftRight";
NSString *const kSelectorPushDisabled = @"selectorPushDisabled";
NSString *const kSelectorActionSheetDisabled = @"selectorActionSheetDisabled";
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";
NSString *const kSelectorWithSegueId = @"selectorWithSegueId";
NSString *const kSelectorWithSegueClass = @"selectorWithSegueClass";
NSString *const kSelectorWithNibName = @"selectorWithNibName";
NSString *const kSelectorWithStoryboardId = @"selectorWithStoryboardId";
#pragma mark - NSValueTransformer
@interface NSArrayValueTrasformer : NSValueTransformer
@end
@implementation NSArrayValueTrasformer
+ (Class)transformedValueClass
{
return [NSString class];
}
+ (BOOL)allowsReverseTransformation
{
return NO;
}
- (id)transformedValue:(id)value
{
if (!value) return nil;
if ([value isKindOfClass:[NSArray class]]){
NSArray * array = (NSArray *)value;
return [NSString stringWithFormat:@"%@ Item%@", @(array.count), array.count > 1 ? @"s" : @""];
}
if ([value isKindOfClass:[NSString class]])
{
return [NSString stringWithFormat:@"%@ - ;) - Transformed", value];
}
return nil;
}
@end
@interface ISOLanguageCodesValueTranformer : NSValueTransformer
@end
@implementation ISOLanguageCodesValueTranformer
+ (Class)transformedValueClass
{
return [NSString class];
}
+ (BOOL)allowsReverseTransformation
{
return NO;
}
- (id)transformedValue:(id)value
{
if (!value) return nil;
if ([value isKindOfClass:[NSString class]]){
return [[NSLocale currentLocale] displayNameForKey:NSLocaleLanguageCode value:value];
}
return nil;
}
@end
#pragma mark - SelectorsFormViewController
@implementation SelectorsFormViewController
- (instancetype)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self) {
[self initializeForm];
}
return self;
}
- (instancetype)init
{
self = [super init];
if (self) {
[self initializeForm];
}
return self;
}
- (void)initializeForm
{
XLFormDescriptor * form = [XLFormDescriptor formDescriptorWithTitle:@"Selectors"];
XLFormSectionDescriptor * section;
XLFormRowDescriptor * row;
// Basic Information
section = [XLFormSectionDescriptor formSectionWithTitle:@"Selectors"];
section.footerTitle = @"SelectorsFormViewController.h";
[form addFormSection:section];
// 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"]
];
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"]
];
row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(2) displayText:@"Option 3"];
[section addFormRow:row];
// 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"]
];
row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(2) displayText:@"Option 3"];
[section addFormRow:row];
// Selector Left Right
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorLeftRight rowType:XLFormRowDescriptorTypeSelectorLeftRight title:@"Left Right"];
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"]
];
// create right selectors
NSMutableArray * leftRightSelectorOptions = [[NSMutableArray alloc] init];
NSMutableArray * mutableRightOptions = [rightOptions mutableCopy];
[mutableRightOptions removeObjectAtIndex:0];
XLFormLeftRightSelectorOption * leftRightSelectorOption = [XLFormLeftRightSelectorOption formLeftRightSelectorOptionWithLeftValue:[XLFormOptionsObject formOptionsObjectWithValue:@(0) displayText:@"Option 1"] httpParameterKey:@"option_1" rightOptions:mutableRightOptions];
[leftRightSelectorOptions addObject:leftRightSelectorOption];
mutableRightOptions = [rightOptions mutableCopy];
[mutableRightOptions removeObjectAtIndex:1];
leftRightSelectorOption = [XLFormLeftRightSelectorOption formLeftRightSelectorOptionWithLeftValue:[XLFormOptionsObject formOptionsObjectWithValue:@(1) displayText:@"Option 2"] httpParameterKey:@"option_2" rightOptions:mutableRightOptions];
[leftRightSelectorOptions addObject:leftRightSelectorOption];
mutableRightOptions = [rightOptions mutableCopy];
[mutableRightOptions removeObjectAtIndex:2];
leftRightSelectorOption = [XLFormLeftRightSelectorOption formLeftRightSelectorOptionWithLeftValue:[XLFormOptionsObject formOptionsObjectWithValue:@(2) displayText:@"Option 3"] httpParameterKey:@"option_3" rightOptions:mutableRightOptions];
[leftRightSelectorOptions addObject:leftRightSelectorOption];
mutableRightOptions = [rightOptions mutableCopy];
[mutableRightOptions removeObjectAtIndex:3];
leftRightSelectorOption = [XLFormLeftRightSelectorOption formLeftRightSelectorOptionWithLeftValue:[XLFormOptionsObject formOptionsObjectWithValue:@(3) displayText:@"Option 4"] httpParameterKey:@"option_4" rightOptions:mutableRightOptions];
[leftRightSelectorOptions addObject:leftRightSelectorOption];
mutableRightOptions = [rightOptions mutableCopy];
[mutableRightOptions removeObjectAtIndex:4];
leftRightSelectorOption = [XLFormLeftRightSelectorOption formLeftRightSelectorOptionWithLeftValue:[XLFormOptionsObject formOptionsObjectWithValue:@(4) displayText:@"Option 5"] httpParameterKey:@"option_5" rightOptions:mutableRightOptions];
[leftRightSelectorOptions addObject:leftRightSelectorOption];
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"]
];
row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(3) displayText:@"Option 4"];
[section addFormRow:row];
// --------- Fixed Controls
section = [XLFormSectionDescriptor formSectionWithTitle:@"Fixed Controls"];
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kPickerView rowType:XLFormRowDescriptorTypePicker];
row.selectorOptions = @[@"Option 1", @"Option 2", @"Option 3", @"Option 4", @"Option 5", @"Option 6"];
row.value = @"Option 1";
[section addFormRow:row];
// --------- Inline Selectors
section = [XLFormSectionDescriptor formSectionWithTitle:@"Inline Selectors"];
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kMultipleSelector rowType:XLFormRowDescriptorTypeSelectorPickerViewInline title:@"Inline Picker View"];
row.selectorOptions = @[@"Option 1", @"Option 2", @"Option 3", @"Option 4", @"Option 5", @"Option 6"];
row.value = @"Option 6";
[section addFormRow:row];
// --------- MultipleSelector
section = [XLFormSectionDescriptor formSectionWithTitle:@"Multiple Selectors"];
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kMultipleSelector rowType:XLFormRowDescriptorTypeMultipleSelector title:@"Multiple Selector"];
row.selectorOptions = @[@"Option 1", @"Option 2", @"Option 3", @"Option 4", @"Option 5", @"Option 6"];
row.value = @[@"Option 1", @"Option 3", @"Option 4", @"Option 5", @"Option 6"];
[section addFormRow:row];
// Multiple selector with value tranformer
row = [XLFormRowDescriptor formRowDescriptorWithTag:kMultipleSelector rowType:XLFormRowDescriptorTypeMultipleSelector title:@"Multiple Selector"];
row.selectorOptions = @[@"Option 1", @"Option 2", @"Option 3", @"Option 4", @"Option 5", @"Option 6"];
row.value = @[@"Option 1", @"Option 3", @"Option 4", @"Option 5", @"Option 6"];
row.valueTransformer = [NSArrayValueTrasformer class];
[section addFormRow:row];
// Language multiple selector
row = [XLFormRowDescriptor formRowDescriptorWithTag:kMultipleSelector rowType:XLFormRowDescriptorTypeMultipleSelector title:@"Multiple Selector"];
row.selectorOptions = [NSLocale ISOLanguageCodes];
row.selectorTitle = @"Languages";
row.valueTransformer = [ISOLanguageCodesValueTranformer class];
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
section = [XLFormSectionDescriptor formSectionWithTitle:@"Dynamic Selectors"];
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kDynamicSelectors rowType:XLFormRowDescriptorTypeButton title:@"Dynamic Selectors"];
row.action.viewControllerClass = [DynamicSelectorsFormViewController class];
[section addFormRow:row];
// --------- Custom Selectors
section = [XLFormSectionDescriptor formSectionWithTitle:@"Custom Selectors"];
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kCustomSelectors rowType:XLFormRowDescriptorTypeButton title:@"Custom Selectors"];
row.action.viewControllerClass = [CustomSelectorsFormViewController class];
[section addFormRow:row];
section = [XLFormSectionDescriptor formSectionWithTitle:@"Disabled & Required Selectors"];
[form addFormSection:section];
// Disabled Selector Push
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorPushDisabled rowType:XLFormRowDescriptorTypeSelectorPush title:@"Push"];
row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(1) displayText:@"Option 2"];
row.disabled = @YES;
[section addFormRow:row];
// --------- Disabled Selector Action Sheet
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorActionSheetDisabled rowType:XLFormRowDescriptorTypeSelectorActionSheet title:@"Sheet"];
row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(2) displayText:@"Option 3"];
row.disabled = @YES;
[section addFormRow:row];
// --------- Disabled Selector Left Right
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorLeftRightDisabled rowType:XLFormRowDescriptorTypeSelectorLeftRight title:@"Left Right"];
row.leftRightSelectorLeftOptionSelected = [XLFormOptionsObject formOptionsObjectWithValue:@(1) displayText:@"Option 2"];
row.value = [XLFormOptionsObject formOptionsObjectWithValue:@(3) displayText:@"Right Option 4"];
row.disabled = @YES;
[section addFormRow:row];
// --------- Selector definition types
section = [XLFormSectionDescriptor formSectionWithTitle:@"Selectors"];
[form addFormSection:section];
// selector with segue class
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorWithSegueClass rowType:XLFormRowDescriptorTypeSelectorPush title:@"Selector with Segue Class"];
row.action.formSegueClass = NSClassFromString(@"UIStoryboardPushSegue");
row.action.viewControllerClass = [MapViewController class];
row.valueTransformer = [CLLocationValueTrasformer class];
row.value = [[CLLocation alloc] initWithLatitude:-33 longitude:-56];
[section addFormRow:row];
// selector with SegueId
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorWithSegueClass rowType:XLFormRowDescriptorTypeSelectorPush title:@"Selector with Segue Idenfifier"];
row.action.formSegueIdenfifier = @"MapViewControllerSegue";
row.valueTransformer = [CLLocationValueTrasformer class];
row.value = [[CLLocation alloc] initWithLatitude:-33 longitude:-56];
[section addFormRow:row];
// selector using StoryboardId
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorWithStoryboardId rowType:XLFormRowDescriptorTypeSelectorPush title:@"Selector with StoryboardId"];
row.action.viewControllerStoryboardId = @"MapViewController";
row.valueTransformer = [CLLocationValueTrasformer class];
row.value = [[CLLocation alloc] initWithLatitude:-33 longitude:-56];
[section addFormRow:row];
// selector with NibName
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorWithNibName rowType:XLFormRowDescriptorTypeSelectorPush title:@"Selector with NibName"];
row.action.viewControllerNibName = @"MapViewController";
row.valueTransformer = [CLLocationValueTrasformer class];
row.value = [[CLLocation alloc] initWithLatitude:-33 longitude:-56];
[section addFormRow:row];
self.form = form;
}
-(UIStoryboard *)storyboardForRow:(XLFormRowDescriptor *)formRow
{
return [UIStoryboard storyboardWithName:@"iPhoneStoryboard" bundle:nil];
}
-(void)viewDidLoad
{
[super viewDidLoad];
UIBarButtonItem * barButton = [[UIBarButtonItem alloc] initWithTitle:@"Disable" style:UIBarButtonItemStylePlain
target:self
action:@selector(disableEnable:)];
barButton.possibleTitles = [NSSet setWithObjects:@"Disable", @"Enable", nil];
self.navigationItem.rightBarButtonItem = barButton;
}
-(void)disableEnable:(UIBarButtonItem *)button
{
self.form.disabled = !self.form.disabled;
[button setTitle:(self.form.disabled ? @"Enable" : @"Disable")];
[self.tableView endEditing:YES];
[self.tableView reloadData];
}
@end
@@ -0,0 +1,284 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7531" systemVersion="14D131" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="p4n-1v-pzo">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/>
</dependencies>
<scenes>
<!--Navigation Controller-->
<scene sceneID="hSO-iI-kK3">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="p4n-1v-pzo" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="SNt-hk-N3V">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<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="117" y="56"/>
</scene>
<!--Others Form View Controller-->
<scene sceneID="dyJ-7m-RaD">
<objects>
<viewController storyboardIdentifier="OthersFormViewController" id="oQO-1z-ESS" customClass="OthersFormViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="oOp-1u-3hE"/>
<viewControllerLayoutGuide type="bottom" id="HPb-Nx-E1G"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="wpr-wE-9nj">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<navigationItem key="navigationItem" id="Hf0-cB-ORN"/>
<connections>
<segue destination="WMh-VN-FWi" kind="push" identifier="MapViewControllerSegue" id="wAD-tS-AFZ"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="7YZ-ZR-X81" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1533" y="-233"/>
</scene>
<!--Native Event Form View Controller-->
<scene sceneID="EjT-rm-U3h">
<objects>
<viewController id="vx5-lN-WwK" customClass="NativeEventFormViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Fbw-im-bwR"/>
<viewControllerLayoutGuide type="bottom" id="QuR-kY-o5R"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="tun-QW-CGC">
<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="JY7-WL-SnH">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
</tableView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="JY7-WL-SnH" firstAttribute="leading" secondItem="tun-QW-CGC" secondAttribute="leading" id="bSe-SV-rx6"/>
<constraint firstAttribute="trailing" secondItem="JY7-WL-SnH" secondAttribute="trailing" id="jLI-68-pSq"/>
<constraint firstItem="QuR-kY-o5R" firstAttribute="top" secondItem="JY7-WL-SnH" secondAttribute="bottom" id="lUW-qG-LqV"/>
<constraint firstItem="JY7-WL-SnH" firstAttribute="top" secondItem="tun-QW-CGC" secondAttribute="top" id="tu2-ah-L2P"/>
</constraints>
</view>
<navigationItem key="navigationItem" id="Xti-ay-J1u"/>
<connections>
<outlet property="tableView" destination="JY7-WL-SnH" id="kPy-NX-IyW"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="zV0-mq-irv" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1120" y="-635"/>
</scene>
<!--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"/>
<segue destination="oQO-1z-ESS" kind="push" identifier="OthersFormViewControllerSegue" id="ulP-FP-rk3"/>
<segue destination="G68-Ra-1fb" kind="push" identifier="SelectorsFormViewControllerSegue" id="vhA-cV-A02"/>
<segue destination="K9D-4c-9eZ" kind="modal" identifier="NativeEventNavigationViewControllerSegue" id="Iie-Js-Izx"/>
<segue destination="Kiw-nF-jv7" kind="push" identifier="ValidationExamplesFormViewControllerSegue" id="VKe-Ir-Fiu"/>
<segue destination="OG6-Tc-1SC" kind="push" identifier="PredicateFormViewControllerSegue" id="Wwg-e9-gLq"/>
<segue destination="pO0-sS-Tes" kind="push" identifier="BlogExampleViewSegue" id="a28-Gm-Iku"/>
<segue destination="JL7-uU-kWK" kind="push" identifier="BasicPredicateViewControllerSegue" id="SGg-Ve-bng"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="1V5-DZ-WfF" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="527" y="56"/>
</scene>
<!--Blog Example View Controller-->
<scene sceneID="Vn0-9y-5bc">
<objects>
<viewController id="pO0-sS-Tes" customClass="BlogExampleViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="gjZ-Jv-Awa"/>
<viewControllerLayoutGuide type="bottom" id="scM-da-Sg0"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="hrV-fb-58s">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<navigationItem key="navigationItem" id="RJB-cz-SnF"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Fvo-wr-5Ca" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="167" y="1151"/>
</scene>
<!--Validation Examples-->
<scene sceneID="z2I-Nk-y9W">
<objects>
<viewController id="Kiw-nF-jv7" customClass="ValidationExamplesFormViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="AG9-N9-2qp"/>
<viewControllerLayoutGuide type="bottom" id="xtJ-Wo-mhU"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="1Ol-Ra-Ysg">
<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="Fty-3j-BeF">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
</tableView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="xtJ-Wo-mhU" firstAttribute="top" secondItem="Fty-3j-BeF" secondAttribute="bottom" id="CbV-4f-RzP"/>
<constraint firstItem="Fty-3j-BeF" firstAttribute="top" secondItem="AG9-N9-2qp" secondAttribute="bottom" constant="-64" id="Pdw-VG-qcc"/>
<constraint firstAttribute="trailing" secondItem="Fty-3j-BeF" secondAttribute="trailing" id="nPd-m1-CWF"/>
<constraint firstItem="Fty-3j-BeF" firstAttribute="leading" secondItem="1Ol-Ra-Ysg" secondAttribute="leading" id="qUB-l2-4IG"/>
</constraints>
</view>
<navigationItem key="navigationItem" title="Validation Examples" id="apf-4a-VpV">
<barButtonItem key="rightBarButtonItem" title="Validate" id="Thm-OY-hsk"/>
</navigationItem>
<connections>
<outlet property="tableView" destination="Fty-3j-BeF" id="Rck-sk-OHi"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="VFT-Og-STO" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="566" y="938"/>
</scene>
<!--Predicate Form View Controller-->
<scene sceneID="a9p-C8-g8y">
<objects>
<viewController id="OG6-Tc-1SC" customClass="PredicateFormViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="2YH-dK-JXQ"/>
<viewControllerLayoutGuide type="bottom" id="Lsg-dH-McH"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="6EZ-O7-FjX">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<navigationItem key="navigationItem" id="Lsd-xH-7IN"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="rZL-10-YZn" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="956" y="924"/>
</scene>
<!--Selectors Form View Controller-->
<scene sceneID="KYK-TX-8rm">
<objects>
<viewController id="G68-Ra-1fb" customClass="SelectorsFormViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Z21-Qr-DQ8"/>
<viewControllerLayoutGuide type="bottom" id="CTu-Y5-7Qw"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="bNj-SD-83w">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<navigationItem key="navigationItem" id="Buo-Af-6Q1"/>
<connections>
<segue destination="WMh-VN-FWi" kind="push" identifier="MapViewControllerSegue" id="Mtw-x2-E0b"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="8fu-YK-6qz" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1346" y="533"/>
</scene>
<!--Map View Controller-->
<scene sceneID="tAS-lK-35t">
<objects>
<viewController storyboardIdentifier="MapViewController" id="WMh-VN-FWi" customClass="MapViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="9jO-04-Lp1"/>
<viewControllerLayoutGuide type="bottom" id="cgQ-Vs-ICN"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="JjC-E5-SyY">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<navigationItem key="navigationItem" id="BjG-Bq-0lD"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="LmS-YR-mFY" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1789" y="533"/>
</scene>
<!--Native Event Navigation View Controller-->
<scene sceneID="mNb-be-ApA">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="K9D-4c-9eZ" customClass="NativeEventNavigationViewController" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="fO3-V7-XXu">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="vx5-lN-WwK" kind="relationship" relationship="rootViewController" id="gie-et-cUW"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="eqB-vl-BzH" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="588" y="-635"/>
</scene>
<!--Basic Predicate View Controller-->
<scene sceneID="pD4-sm-x3a">
<objects>
<viewController id="JL7-uU-kWK" customClass="BasicPredicateViewController" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="OQP-pW-kNp"/>
<viewControllerLayoutGuide type="bottom" id="2b4-gN-85p"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="NZg-t1-g19">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
<navigationItem key="navigationItem" id="1lh-jZ-lIV"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Tlw-q2-pcu" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="-159" y="1151"/>
</scene>
</scenes>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
<simulatedScreenMetrics key="destination" type="retina4"/>
</simulatedMetricsContainer>
<inferredMetricsTieBreakers>
<segue reference="wAD-tS-AFZ"/>
</inferredMetricsTieBreakers>
</document>
@@ -0,0 +1,90 @@
//
// UICustomizationFormViewController.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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
@@ -0,0 +1,164 @@
//
// ValidationExamplesFormViewController.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "ValidationExamplesFormViewController.h"
@interface ValidationExamplesFormViewController ()
@end
@implementation ValidationExamplesFormViewController
NSString * const kValidationName = @"kName";
NSString * const kValidationEmail = @"kEmail";
NSString * const kValidationPassword = @"kPassword";
NSString * const kValidationInteger = @"kInteger";
- (instancetype)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self) {
[self initializeForm];
}
return self;
}
-(void)initializeForm
{
XLFormDescriptor * formDescriptor = [XLFormDescriptor formDescriptorWithTitle:@"Text Fields"];
XLFormSectionDescriptor * section;
XLFormRowDescriptor * row;
// Name Section
section = [XLFormSectionDescriptor formSectionWithTitle:@"Validation Required"];
[formDescriptor addFormSection:section];
// Name
row = [XLFormRowDescriptor formRowDescriptorWithTag:kValidationName rowType:XLFormRowDescriptorTypeText title:@"Name"];
[row.cellConfigAtConfigure setObject:@"Required..." forKey:@"textField.placeholder"];
[row.cellConfigAtConfigure setObject:@(NSTextAlignmentRight) forKey:@"textField.textAlignment"];
row.required = YES;
row.value = @"Martin";
[section addFormRow:row];
// Email Section
section = [XLFormSectionDescriptor formSectionWithTitle:@"Validation Email"];
[formDescriptor addFormSection:section];
// Email
row = [XLFormRowDescriptor formRowDescriptorWithTag:kValidationEmail rowType:XLFormRowDescriptorTypeText title:@"Email"];
[row.cellConfigAtConfigure setObject:@(NSTextAlignmentRight) forKey:@"textField.textAlignment"];
row.required = NO;
row.value = @"not valid email";
[row addValidator:[XLFormValidator emailValidator]];
[section addFormRow:row];
// password Section
section = [XLFormSectionDescriptor formSectionWithTitle:@"Validation Password"];
section.footerTitle = @"between 6 and 32 charachers, 1 alphanumeric and 1 numeric";
[formDescriptor addFormSection:section];
// Password
row = [XLFormRowDescriptor formRowDescriptorWithTag:kValidationPassword rowType:XLFormRowDescriptorTypePassword title:@"Password"];
[row.cellConfigAtConfigure setObject:@"Required..." forKey:@"textField.placeholder"];
[row.cellConfigAtConfigure setObject:@(NSTextAlignmentRight) forKey:@"textField.textAlignment"];
row.required = YES;
[row addValidator:[XLFormRegexValidator formRegexValidatorWithMsg:@"At least 6, max 32 characters" regex:@"^(?=.*\\d)(?=.*[A-Za-z]).{6,32}$"]];
[section addFormRow:row];
// number Section
section = [XLFormSectionDescriptor formSectionWithTitle:@"Validation Numbers"];
section.footerTitle = @"grather than 50 and less than 100";
[formDescriptor addFormSection:section];
// Integer
row = [XLFormRowDescriptor formRowDescriptorWithTag:kValidationInteger rowType:XLFormRowDescriptorTypeInteger title:@"Integer"];
[row.cellConfigAtConfigure setObject:@"Required..." forKey:@"textField.placeholder"];
[row.cellConfigAtConfigure setObject:@(NSTextAlignmentRight) forKey:@"textField.textAlignment"];
row.required = YES;
[row addValidator:[XLFormRegexValidator formRegexValidatorWithMsg:@"grather than 50 and less than 100" regex:@"^([5-9][0-9]|100)$"]];
[section addFormRow:row];
self.form = formDescriptor;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self.navigationItem.rightBarButtonItem setTarget:self];
[self.navigationItem.rightBarButtonItem setAction:@selector(validateForm:)];
}
#pragma mark - actions
-(void)validateForm:(UIBarButtonItem *)buttonItem
{
NSArray * array = [self formValidationErrors];
[array enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
XLFormValidationStatus * validationStatus = [[obj userInfo] objectForKey:XLValidationStatusErrorKey];
if ([validationStatus.rowDescriptor.tag isEqualToString:kValidationName]){
UITableViewCell * cell = [self.tableView cellForRowAtIndexPath:[self.form indexPathOfFormRow:validationStatus.rowDescriptor]];
cell.backgroundColor = [UIColor orangeColor];
[UIView animateWithDuration:0.3 animations:^{
cell.backgroundColor = [UIColor whiteColor];
}];
}
else if ([validationStatus.rowDescriptor.tag isEqualToString:kValidationEmail]){
UITableViewCell * cell = [self.tableView cellForRowAtIndexPath:[self.form indexPathOfFormRow:validationStatus.rowDescriptor]];
[self animateCell:cell];
}
else if ([validationStatus.rowDescriptor.tag isEqualToString:kValidationPassword]){
UITableViewCell * cell = [self.tableView cellForRowAtIndexPath:[self.form indexPathOfFormRow:validationStatus.rowDescriptor]];
[self animateCell:cell];
}
else if ([validationStatus.rowDescriptor.tag isEqualToString:kValidationInteger]){
UITableViewCell * cell = [self.tableView cellForRowAtIndexPath:[self.form indexPathOfFormRow:validationStatus.rowDescriptor]];
[self animateCell:cell];
}
}];
}
#pragma mark - Helper
-(void)animateCell:(UITableViewCell *)cell
{
CAKeyframeAnimation *animation = [CAKeyframeAnimation animation];
animation.keyPath = @"position.x";
animation.values = @[ @0, @20, @-20, @10, @0];
animation.keyTimes = @[@0, @(1 / 6.0), @(3 / 6.0), @(5 / 6.0), @1];
animation.duration = 0.3;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
animation.additive = YES;
[cell.layer addAnimation:animation forKey:@"shake"];
}
@end
+3 -1
View File
@@ -2,6 +2,8 @@ platform :ios, '8.0'
target 'SwiftExample' do
pod 'XLForm', :path => '../../'
pod 'XLForm', :path => '../../'
pod 'JVFloatLabeledTextField', '1.0.2', :inhibit_warnings => true
pod 'AXRatingView', '1.0.3', :inhibit_warnings => true
end
@@ -7,26 +7,78 @@
objects = {
/* Begin PBXBuildFile section */
2724071466166BFA1E54E659 /* libPods-SwiftExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 854F8DF43072D7C59CBECB68 /* libPods-SwiftExample.a */; };
2847A6A41AAF2679000A2ABE /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2847A6A31AAF2679000A2ABE /* AppDelegate.swift */; };
2847A6A91AAF2679000A2ABE /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 2847A6A71AAF2679000A2ABE /* Main.storyboard */; };
2847A6AB1AAF2679000A2ABE /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2847A6AA1AAF2679000A2ABE /* Images.xcassets */; };
2847A6AE1AAF2679000A2ABE /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2847A6AC1AAF2679000A2ABE /* LaunchScreen.xib */; };
2860673E1AEDBD4A002F1E04 /* CustomRowsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 286067321AEDBD4A002F1E04 /* CustomRowsViewController.swift */; };
2860673F1AEDBD4A002F1E04 /* FloatLabeledTextFieldCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 286067341AEDBD4A002F1E04 /* FloatLabeledTextFieldCell.swift */; };
286067411AEDBD4A002F1E04 /* XLFormRatingCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 286067391AEDBD4A002F1E04 /* XLFormRatingCell.swift */; };
286067421AEDBD4A002F1E04 /* XLFormRatingCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2860673A1AEDBD4A002F1E04 /* XLFormRatingCell.xib */; };
286067431AEDBD4A002F1E04 /* XLFormWeekDaysCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2860673C1AEDBD4A002F1E04 /* XLFormWeekDaysCell.swift */; };
286067441AEDBD4A002F1E04 /* XLFormWeekDaysCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2860673D1AEDBD4A002F1E04 /* XLFormWeekDaysCell.xib */; };
286067461AEDC3D7002F1E04 /* XLRatingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 286067451AEDC3D7002F1E04 /* XLRatingView.swift */; };
286E8B751AE809EF00F2767A /* DynamicSelectorsFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 286E8B731AE809EF00F2767A /* DynamicSelectorsFormViewController.swift */; };
286E8B781AE80C4300F2767A /* UsersTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 286E8B771AE80C4300F2767A /* UsersTableViewController.swift */; };
286E8B7E1AE86C8900F2767A /* XLFormCustomCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 286E8B7C1AE86C8900F2767A /* XLFormCustomCell.swift */; };
286E8B7F1AE86C8900F2767A /* OthersFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 286E8B7D1AE86C8900F2767A /* OthersFormViewController.swift */; };
286E8B861AE9286B00F2767A /* CustomSelectorsFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 286E8B811AE9286B00F2767A /* CustomSelectorsFormViewController.swift */; };
286E8B871AE9286B00F2767A /* CLLocationValueTrasformer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 286E8B831AE9286B00F2767A /* CLLocationValueTrasformer.swift */; };
286E8B881AE9286B00F2767A /* MapViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 286E8B841AE9286B00F2767A /* MapViewController.swift */; };
286E8B891AE9286B00F2767A /* MapViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 286E8B851AE9286B00F2767A /* MapViewController.xib */; };
286E8B8C1AE9993F00F2767A /* MultivaluedFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 286E8B8B1AE9993F00F2767A /* MultivaluedFormViewController.swift */; };
288646151AE59474007A8B9B /* ExamplesFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 288646141AE59474007A8B9B /* ExamplesFormViewController.swift */; };
288646181AE5C7EA007A8B9B /* iPhoneStoryboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 288646171AE5C7EA007A8B9B /* iPhoneStoryboard.storyboard */; };
2886461C1AE5C958007A8B9B /* NativeEventFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2886461A1AE5C958007A8B9B /* NativeEventFormViewController.swift */; };
2886461F1AE5FEB5007A8B9B /* DateAndTimeValueTrasformer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2886461E1AE5FEB5007A8B9B /* DateAndTimeValueTrasformer.swift */; };
28B920751AE6F02F00BD6382 /* InputsFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28B920741AE6F02F00BD6382 /* InputsFormViewController.swift */; };
28B920781AE73AA600BD6382 /* SelectorsFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28B920771AE73AA600BD6382 /* SelectorsFormViewController.swift */; };
28D832571AEBC4A7009E3B3F /* AccessoryViewFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28D832561AEBC4A7009E3B3F /* AccessoryViewFormViewController.swift */; };
28D832631AEBE4E4009E3B3F /* BasicPredicateViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28D832601AEBE4E4009E3B3F /* BasicPredicateViewController.swift */; };
28D832671AEBEAA0009E3B3F /* BlogExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28D832661AEBEAA0009E3B3F /* BlogExampleViewController.swift */; };
28D832691AEBFE9F009E3B3F /* PredicateFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28D832681AEBFE9F009E3B3F /* PredicateFormViewController.swift */; };
28D8326C1AEC177E009E3B3F /* ValidationExamplesFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28D8326B1AEC177E009E3B3F /* ValidationExamplesFormViewController.swift */; };
28D8326F1AEC2D1B009E3B3F /* UICustomizationFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28D8326E1AEC2D1B009E3B3F /* UICustomizationFormViewController.swift */; };
28F490221AAFBBC600C8E0CC /* DatesFormViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28F490211AAFBBC600C8E0CC /* DatesFormViewController.swift */; };
DD7B43598E698717584375E9 /* libPods-SwiftExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 9CFB9BA3A82D5F6FE7CCE5A5 /* libPods-SwiftExample.a */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
2847A69E1AAF2679000A2ABE /* SwiftExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
2847A6A21AAF2679000A2ABE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
2847A6A31AAF2679000A2ABE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
2847A6A81AAF2679000A2ABE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
2847A6A31AAF2679000A2ABE /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = AppDelegate.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
2847A6AA1AAF2679000A2ABE /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
2847A6AD1AAF2679000A2ABE /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = "<group>"; };
2847A6C31AAF2B14000A2ABE /* SwiftExample-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SwiftExample-Bridging-Header.h"; sourceTree = "<group>"; };
28F490211AAFBBC600C8E0CC /* DatesFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DatesFormViewController.swift; sourceTree = "<group>"; };
286067321AEDBD4A002F1E04 /* CustomRowsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = CustomRowsViewController.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
286067341AEDBD4A002F1E04 /* FloatLabeledTextFieldCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FloatLabeledTextFieldCell.swift; sourceTree = "<group>"; };
286067391AEDBD4A002F1E04 /* XLFormRatingCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XLFormRatingCell.swift; sourceTree = "<group>"; };
2860673A1AEDBD4A002F1E04 /* XLFormRatingCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = XLFormRatingCell.xib; sourceTree = "<group>"; };
2860673C1AEDBD4A002F1E04 /* XLFormWeekDaysCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XLFormWeekDaysCell.swift; sourceTree = "<group>"; };
2860673D1AEDBD4A002F1E04 /* XLFormWeekDaysCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = XLFormWeekDaysCell.xib; sourceTree = "<group>"; };
286067451AEDC3D7002F1E04 /* XLRatingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XLRatingView.swift; sourceTree = "<group>"; };
286E8B731AE809EF00F2767A /* DynamicSelectorsFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = DynamicSelectorsFormViewController.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
286E8B771AE80C4300F2767A /* UsersTableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UsersTableViewController.swift; path = Examples/Selectors/DynamicSelector/UsersTableViewController.swift; sourceTree = SOURCE_ROOT; };
286E8B7C1AE86C8900F2767A /* XLFormCustomCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XLFormCustomCell.swift; sourceTree = "<group>"; };
286E8B7D1AE86C8900F2767A /* OthersFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = OthersFormViewController.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
286E8B811AE9286B00F2767A /* CustomSelectorsFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = CustomSelectorsFormViewController.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
286E8B831AE9286B00F2767A /* CLLocationValueTrasformer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = CLLocationValueTrasformer.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
286E8B841AE9286B00F2767A /* MapViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MapViewController.swift; sourceTree = "<group>"; };
286E8B851AE9286B00F2767A /* MapViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MapViewController.xib; sourceTree = "<group>"; };
286E8B8B1AE9993F00F2767A /* MultivaluedFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = MultivaluedFormViewController.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
288646141AE59474007A8B9B /* ExamplesFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = ExamplesFormViewController.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
288646171AE5C7EA007A8B9B /* iPhoneStoryboard.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = iPhoneStoryboard.storyboard; sourceTree = "<group>"; };
2886461A1AE5C958007A8B9B /* NativeEventFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = NativeEventFormViewController.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
2886461E1AE5FEB5007A8B9B /* DateAndTimeValueTrasformer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DateAndTimeValueTrasformer.swift; sourceTree = "<group>"; };
28B920741AE6F02F00BD6382 /* InputsFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; name = InputsFormViewController.swift; path = Examples/Inputs/InputsFormViewController.swift; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
28B920771AE73AA600BD6382 /* SelectorsFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SelectorsFormViewController.swift; sourceTree = "<group>"; };
28D832561AEBC4A7009E3B3F /* AccessoryViewFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = AccessoryViewFormViewController.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
28D832601AEBE4E4009E3B3F /* BasicPredicateViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BasicPredicateViewController.swift; sourceTree = "<group>"; };
28D832661AEBEAA0009E3B3F /* BlogExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BlogExampleViewController.swift; path = Examples/PredicateExamples/BlogExampleViewController.swift; sourceTree = SOURCE_ROOT; };
28D832681AEBFE9F009E3B3F /* PredicateFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PredicateFormViewController.swift; path = Examples/PredicateExamples/PredicateFormViewController.swift; sourceTree = SOURCE_ROOT; };
28D8326B1AEC177E009E3B3F /* ValidationExamplesFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValidationExamplesFormViewController.swift; sourceTree = "<group>"; };
28D8326E1AEC2D1B009E3B3F /* UICustomizationFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UICustomizationFormViewController.swift; sourceTree = "<group>"; };
28F490211AAFBBC600C8E0CC /* DatesFormViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = DatesFormViewController.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
2EB9C638FC2450A0B9786D1E /* Pods-SwiftExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftExample.release.xcconfig"; path = "Pods/Target Support Files/Pods-SwiftExample/Pods-SwiftExample.release.xcconfig"; sourceTree = "<group>"; };
420D9BAB7B0D2AF9487DD060 /* Pods-SwiftExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftExample.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SwiftExample/Pods-SwiftExample.debug.xcconfig"; sourceTree = "<group>"; };
854F8DF43072D7C59CBECB68 /* libPods-SwiftExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SwiftExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
9CFB9BA3A82D5F6FE7CCE5A5 /* libPods-SwiftExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SwiftExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -34,7 +86,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
2724071466166BFA1E54E659 /* libPods-SwiftExample.a in Frameworks */,
DD7B43598E698717584375E9 /* libPods-SwiftExample.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -62,11 +114,20 @@
2847A6A01AAF2679000A2ABE /* SwiftExample */ = {
isa = PBXGroup;
children = (
286067311AEDBD4A002F1E04 /* CustomRows */,
28D8326D1AEC2D1B009E3B3F /* UICustomization */,
28D8326A1AEC177E009E3B3F /* Validations */,
28D8325F1AEBE4E4009E3B3F /* PredicateExamples */,
28D832551AEBC4A7009E3B3F /* AccessoryViews */,
286E8B8A1AE9993F00F2767A /* MultiValuedSections */,
286E8B7A1AE86C8900F2767A /* Others */,
28B920761AE7378400BD6382 /* Selectors */,
28B920711AE6EB6100BD6382 /* Inputs */,
288646191AE5C958007A8B9B /* RealExamples */,
288646161AE5C7EA007A8B9B /* StoryboardExample */,
288646141AE59474007A8B9B /* ExamplesFormViewController.swift */,
28F490201AAFBBC600C8E0CC /* Dates */,
2847A6A31AAF2679000A2ABE /* AppDelegate.swift */,
2847A6A71AAF2679000A2ABE /* Main.storyboard */,
2847A6AA1AAF2679000A2ABE /* Images.xcassets */,
2847A6AC1AAF2679000A2ABE /* LaunchScreen.xib */,
2847A6A11AAF2679000A2ABE /* Supporting Files */,
);
path = SwiftExample;
@@ -75,15 +136,185 @@
2847A6A11AAF2679000A2ABE /* Supporting Files */ = {
isa = PBXGroup;
children = (
2847A6AA1AAF2679000A2ABE /* Images.xcassets */,
2847A6A21AAF2679000A2ABE /* Info.plist */,
2847A6C31AAF2B14000A2ABE /* SwiftExample-Bridging-Header.h */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
286067311AEDBD4A002F1E04 /* CustomRows */ = {
isa = PBXGroup;
children = (
286067321AEDBD4A002F1E04 /* CustomRowsViewController.swift */,
286067331AEDBD4A002F1E04 /* FloatLabeledTextField */,
286067351AEDBD4A002F1E04 /* Rating */,
2860673B1AEDBD4A002F1E04 /* Weekdays */,
);
name = CustomRows;
path = Examples/CustomRows;
sourceTree = SOURCE_ROOT;
};
286067331AEDBD4A002F1E04 /* FloatLabeledTextField */ = {
isa = PBXGroup;
children = (
286067341AEDBD4A002F1E04 /* FloatLabeledTextFieldCell.swift */,
);
path = FloatLabeledTextField;
sourceTree = "<group>";
};
286067351AEDBD4A002F1E04 /* Rating */ = {
isa = PBXGroup;
children = (
286067361AEDBD4A002F1E04 /* RatingView */,
286067391AEDBD4A002F1E04 /* XLFormRatingCell.swift */,
2860673A1AEDBD4A002F1E04 /* XLFormRatingCell.xib */,
);
path = Rating;
sourceTree = "<group>";
};
286067361AEDBD4A002F1E04 /* RatingView */ = {
isa = PBXGroup;
children = (
286067451AEDC3D7002F1E04 /* XLRatingView.swift */,
);
path = RatingView;
sourceTree = "<group>";
};
2860673B1AEDBD4A002F1E04 /* Weekdays */ = {
isa = PBXGroup;
children = (
2860673C1AEDBD4A002F1E04 /* XLFormWeekDaysCell.swift */,
2860673D1AEDBD4A002F1E04 /* XLFormWeekDaysCell.xib */,
);
path = Weekdays;
sourceTree = "<group>";
};
286E8B6C1AE8099F00F2767A /* DynamicSelector */ = {
isa = PBXGroup;
children = (
286E8B771AE80C4300F2767A /* UsersTableViewController.swift */,
286E8B731AE809EF00F2767A /* DynamicSelectorsFormViewController.swift */,
);
path = DynamicSelector;
sourceTree = "<group>";
};
286E8B7A1AE86C8900F2767A /* Others */ = {
isa = PBXGroup;
children = (
286E8B7B1AE86C8900F2767A /* CustomCells */,
286E8B7D1AE86C8900F2767A /* OthersFormViewController.swift */,
);
path = Others;
sourceTree = "<group>";
};
286E8B7B1AE86C8900F2767A /* CustomCells */ = {
isa = PBXGroup;
children = (
286E8B7C1AE86C8900F2767A /* XLFormCustomCell.swift */,
);
path = CustomCells;
sourceTree = "<group>";
};
286E8B801AE9286B00F2767A /* CustomSelectors */ = {
isa = PBXGroup;
children = (
286E8B811AE9286B00F2767A /* CustomSelectorsFormViewController.swift */,
286E8B821AE9286B00F2767A /* XLFormRowViewController */,
);
path = CustomSelectors;
sourceTree = "<group>";
};
286E8B821AE9286B00F2767A /* XLFormRowViewController */ = {
isa = PBXGroup;
children = (
286E8B831AE9286B00F2767A /* CLLocationValueTrasformer.swift */,
286E8B841AE9286B00F2767A /* MapViewController.swift */,
286E8B851AE9286B00F2767A /* MapViewController.xib */,
);
path = XLFormRowViewController;
sourceTree = "<group>";
};
286E8B8A1AE9993F00F2767A /* MultiValuedSections */ = {
isa = PBXGroup;
children = (
286E8B8B1AE9993F00F2767A /* MultivaluedFormViewController.swift */,
);
path = MultiValuedSections;
sourceTree = "<group>";
};
288646161AE5C7EA007A8B9B /* StoryboardExample */ = {
isa = PBXGroup;
children = (
288646171AE5C7EA007A8B9B /* iPhoneStoryboard.storyboard */,
);
path = StoryboardExample;
sourceTree = "<group>";
};
288646191AE5C958007A8B9B /* RealExamples */ = {
isa = PBXGroup;
children = (
2886461A1AE5C958007A8B9B /* NativeEventFormViewController.swift */,
);
path = RealExamples;
sourceTree = "<group>";
};
28B920711AE6EB6100BD6382 /* Inputs */ = {
isa = PBXGroup;
children = (
28B920741AE6F02F00BD6382 /* InputsFormViewController.swift */,
);
path = Inputs;
sourceTree = "<group>";
};
28B920761AE7378400BD6382 /* Selectors */ = {
isa = PBXGroup;
children = (
286E8B801AE9286B00F2767A /* CustomSelectors */,
286E8B6C1AE8099F00F2767A /* DynamicSelector */,
28B920771AE73AA600BD6382 /* SelectorsFormViewController.swift */,
);
name = Selectors;
sourceTree = "<group>";
};
28D832551AEBC4A7009E3B3F /* AccessoryViews */ = {
isa = PBXGroup;
children = (
28D832561AEBC4A7009E3B3F /* AccessoryViewFormViewController.swift */,
);
path = AccessoryViews;
sourceTree = "<group>";
};
28D8325F1AEBE4E4009E3B3F /* PredicateExamples */ = {
isa = PBXGroup;
children = (
28D832681AEBFE9F009E3B3F /* PredicateFormViewController.swift */,
28D832601AEBE4E4009E3B3F /* BasicPredicateViewController.swift */,
28D832661AEBEAA0009E3B3F /* BlogExampleViewController.swift */,
);
path = PredicateExamples;
sourceTree = "<group>";
};
28D8326A1AEC177E009E3B3F /* Validations */ = {
isa = PBXGroup;
children = (
28D8326B1AEC177E009E3B3F /* ValidationExamplesFormViewController.swift */,
);
path = Validations;
sourceTree = "<group>";
};
28D8326D1AEC2D1B009E3B3F /* UICustomization */ = {
isa = PBXGroup;
children = (
28D8326E1AEC2D1B009E3B3F /* UICustomizationFormViewController.swift */,
);
path = UICustomization;
sourceTree = "<group>";
};
28F490201AAFBBC600C8E0CC /* Dates */ = {
isa = PBXGroup;
children = (
2886461E1AE5FEB5007A8B9B /* DateAndTimeValueTrasformer.swift */,
28F490211AAFBBC600C8E0CC /* DatesFormViewController.swift */,
);
name = Dates;
@@ -93,7 +324,7 @@
402AE3EC1FACD058DCF0A2D3 /* Frameworks */ = {
isa = PBXGroup;
children = (
854F8DF43072D7C59CBECB68 /* libPods-SwiftExample.a */,
9CFB9BA3A82D5F6FE7CCE5A5 /* libPods-SwiftExample.a */,
);
name = Frameworks;
sourceTree = "<group>";
@@ -166,8 +397,10 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2847A6A91AAF2679000A2ABE /* Main.storyboard in Resources */,
2847A6AE1AAF2679000A2ABE /* LaunchScreen.xib in Resources */,
288646181AE5C7EA007A8B9B /* iPhoneStoryboard.storyboard in Resources */,
286E8B891AE9286B00F2767A /* MapViewController.xib in Resources */,
286067441AEDBD4A002F1E04 /* XLFormWeekDaysCell.xib in Resources */,
286067421AEDBD4A002F1E04 /* XLFormRatingCell.xib in Resources */,
2847A6AB1AAF2679000A2ABE /* Images.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -212,32 +445,37 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
28B920781AE73AA600BD6382 /* SelectorsFormViewController.swift in Sources */,
28D832671AEBEAA0009E3B3F /* BlogExampleViewController.swift in Sources */,
28D8326C1AEC177E009E3B3F /* ValidationExamplesFormViewController.swift in Sources */,
286067411AEDBD4A002F1E04 /* XLFormRatingCell.swift in Sources */,
28F490221AAFBBC600C8E0CC /* DatesFormViewController.swift in Sources */,
286E8B8C1AE9993F00F2767A /* MultivaluedFormViewController.swift in Sources */,
28D8326F1AEC2D1B009E3B3F /* UICustomizationFormViewController.swift in Sources */,
2860673E1AEDBD4A002F1E04 /* CustomRowsViewController.swift in Sources */,
286E8B781AE80C4300F2767A /* UsersTableViewController.swift in Sources */,
286067461AEDC3D7002F1E04 /* XLRatingView.swift in Sources */,
288646151AE59474007A8B9B /* ExamplesFormViewController.swift in Sources */,
286067431AEDBD4A002F1E04 /* XLFormWeekDaysCell.swift in Sources */,
2860673F1AEDBD4A002F1E04 /* FloatLabeledTextFieldCell.swift in Sources */,
286E8B7E1AE86C8900F2767A /* XLFormCustomCell.swift in Sources */,
286E8B871AE9286B00F2767A /* CLLocationValueTrasformer.swift in Sources */,
2886461C1AE5C958007A8B9B /* NativeEventFormViewController.swift in Sources */,
286E8B7F1AE86C8900F2767A /* OthersFormViewController.swift in Sources */,
2847A6A41AAF2679000A2ABE /* AppDelegate.swift in Sources */,
28D832691AEBFE9F009E3B3F /* PredicateFormViewController.swift in Sources */,
28D832571AEBC4A7009E3B3F /* AccessoryViewFormViewController.swift in Sources */,
286E8B861AE9286B00F2767A /* CustomSelectorsFormViewController.swift in Sources */,
2886461F1AE5FEB5007A8B9B /* DateAndTimeValueTrasformer.swift in Sources */,
28B920751AE6F02F00BD6382 /* InputsFormViewController.swift in Sources */,
28D832631AEBE4E4009E3B3F /* BasicPredicateViewController.swift in Sources */,
286E8B751AE809EF00F2767A /* DynamicSelectorsFormViewController.swift in Sources */,
286E8B881AE9286B00F2767A /* MapViewController.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
2847A6A71AAF2679000A2ABE /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
2847A6A81AAF2679000A2ABE /* Base */,
);
name = Main.storyboard;
sourceTree = "<group>";
};
2847A6AC1AAF2679000A2ABE /* LaunchScreen.xib */ = {
isa = PBXVariantGroup;
children = (
2847A6AD1AAF2679000A2ABE /* Base */,
);
name = LaunchScreen.xib;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
2847A6BB1AAF2679000A2ABE /* Debug */ = {
isa = XCBuildConfiguration;
@@ -323,6 +561,7 @@
baseConfigurationReference = 420D9BAB7B0D2AF9487DD060 /* Pods-SwiftExample.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
INFOPLIST_FILE = SwiftExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -335,6 +574,7 @@
baseConfigurationReference = 2EB9C638FC2450A0B9786D1E /* Pods-SwiftExample.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
INFOPLIST_FILE = SwiftExample/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -0,0 +1,197 @@
//
// AccessoryViewFormViewController.swift
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014-2015 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.
class AccessoryViewFormViewController : XLFormViewController {
private enum Tags : String {
case AccessoryViewRowNavigationEnabled = "RowNavigationEnabled"
case AccessoryViewRowNavigationShowAccessoryView = "RowNavigationShowAccessoryView"
case AccessoryViewRowNavigationStopDisableRow = "rowNavigationStopDisableRow"
case AccessoryViewRowNavigationSkipCanNotBecomeFirstResponderRow = "rowNavigationSkipCanNotBecomeFirstResponderRow"
case AccessoryViewRowNavigationStopInlineRow = "rowNavigationStopInlineRow"
case AccessoryViewName = "name"
case AccessoryViewEmail = "email"
case AccessoryViewTwitter = "twitter"
case AccessoryViewUrl = "url"
case AccessoryViewDate = "date"
case AccessoryViewTextView = "textView"
case AccessoryViewCheck = "check"
case AccessoryViewNotes = "notes"
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
self.initializeForm()
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.initializeForm()
}
func initializeForm() {
let form : XLFormDescriptor
var section : XLFormSectionDescriptor
var row : XLFormRowDescriptor
form = XLFormDescriptor(title: "Accessory View")
form.rowNavigationOptions = XLFormRowNavigationOptions.Enabled
// Configuration section
section = XLFormSectionDescriptor()
section.title = "Row Navigation Settings"
section.footerTitle = "Changing the Settings values you will navigate differently"
form.addFormSection(section)
// RowNavigationEnabled
row = XLFormRowDescriptor(tag: Tags.AccessoryViewRowNavigationEnabled.rawValue, rowType: XLFormRowDescriptorTypeBooleanSwitch, title: "Row Navigation Enabled?")
row.value = true
section.addFormRow(row)
// RowNavigationShowAccessoryView
row = XLFormRowDescriptor(tag: Tags.AccessoryViewRowNavigationShowAccessoryView.rawValue, rowType:XLFormRowDescriptorTypeBooleanCheck, title:"Show input accessory row?")
row.value = (form.rowNavigationOptions & XLFormRowNavigationOptions.Enabled) == XLFormRowNavigationOptions.Enabled
row.hidden = "$\(Tags.AccessoryViewRowNavigationEnabled.rawValue) == 0"
section.addFormRow(row)
// RowNavigationStopDisableRow
row = XLFormRowDescriptor(tag: Tags.AccessoryViewRowNavigationStopDisableRow.rawValue, rowType: XLFormRowDescriptorTypeBooleanCheck, title:"Stop when reach disabled row?")
row.value = (form.rowNavigationOptions & XLFormRowNavigationOptions.StopDisableRow) == XLFormRowNavigationOptions.StopDisableRow
row.hidden = "$\(Tags.AccessoryViewRowNavigationEnabled.rawValue) == 0"
section.addFormRow(row)
// RowNavigationStopInlineRow
row = XLFormRowDescriptor(tag: Tags.AccessoryViewRowNavigationStopInlineRow.rawValue, rowType: XLFormRowDescriptorTypeBooleanCheck, title: "Stop when reach inline row?")
row.value = (form.rowNavigationOptions & XLFormRowNavigationOptions.StopInlineRow) == XLFormRowNavigationOptions.StopInlineRow
row.hidden = "$\(Tags.AccessoryViewRowNavigationEnabled.rawValue) == 0"
section.addFormRow(row)
// RowNavigationSkipCanNotBecomeFirstResponderRow
row = XLFormRowDescriptor(tag: Tags.AccessoryViewRowNavigationSkipCanNotBecomeFirstResponderRow.rawValue, rowType:XLFormRowDescriptorTypeBooleanCheck, title:"Skip Can Not Become First Responder Row?")
row.value = (form.rowNavigationOptions & XLFormRowNavigationOptions.SkipCanNotBecomeFirstResponderRow) == XLFormRowNavigationOptions.SkipCanNotBecomeFirstResponderRow
row.hidden = "$\(Tags.AccessoryViewRowNavigationEnabled.rawValue) == 0"
section.addFormRow(row)
section = XLFormSectionDescriptor()
form.addFormSection(section)
// Name
row = XLFormRowDescriptor(tag: Tags.AccessoryViewName.rawValue, rowType: XLFormRowDescriptorTypeText, title: "Name")
row.required = true
section.addFormRow(row)
// Email
row = XLFormRowDescriptor(tag: Tags.AccessoryViewEmail.rawValue, rowType: XLFormRowDescriptorTypeEmail, title: "Email")
// validate the email
row.addValidator(XLFormValidator.emailValidator())
section.addFormRow(row)
// Twitter
row = XLFormRowDescriptor(tag: Tags.AccessoryViewTwitter.rawValue, rowType: XLFormRowDescriptorTypeTwitter, title: "Twitter")
row.disabled = NSNumber(bool: true)
row.value = "@no_editable"
section.addFormRow(row)
// Url
row = XLFormRowDescriptor(tag: Tags.AccessoryViewUrl.rawValue, rowType: XLFormRowDescriptorTypeURL, title: "Url")
section.addFormRow(row)
// Date
row = XLFormRowDescriptor(tag: Tags.AccessoryViewDate.rawValue, rowType:XLFormRowDescriptorTypeDateInline, title:"Date Inline")
row.value = NSDate.new()
section.addFormRow(row)
section = XLFormSectionDescriptor()
form.addFormSection(section)
row = XLFormRowDescriptor(tag: Tags.AccessoryViewTextView.rawValue, rowType:XLFormRowDescriptorTypeTextView, title: nil)
row.cellConfigAtConfigure["textView.placeholder"] = "TEXT VIEW EXAMPLE"
section.addFormRow(row)
row = XLFormRowDescriptor(tag: Tags.AccessoryViewCheck.rawValue, rowType:XLFormRowDescriptorTypeBooleanCheck, title:"Ckeck")
section.addFormRow(row)
section = XLFormSectionDescriptor()
form.addFormSection(section)
row = XLFormRowDescriptor(tag: Tags.AccessoryViewNotes.rawValue, rowType:XLFormRowDescriptorTypeTextView, title:"Notes")
section.addFormRow(row)
self.form = form
}
override func inputAccessoryViewForRowDescriptor(rowDescriptor: XLFormRowDescriptor!) -> UIView! {
if self.form.formRowWithTag(Tags.AccessoryViewRowNavigationShowAccessoryView.rawValue)!.value!.boolValue == false {
return nil
}
return super.inputAccessoryViewForRowDescriptor(rowDescriptor)
}
//MARK: XLFormDescriptorDelegate
override func formRowDescriptorValueHasChanged(formRow: XLFormRowDescriptor!, oldValue: AnyObject!, newValue: AnyObject!) {
super.formRowDescriptorValueHasChanged(formRow, oldValue: oldValue, newValue: newValue)
if formRow.tag == Tags.AccessoryViewRowNavigationStopDisableRow.rawValue {
if formRow.value.boolValue == true {
self.form.rowNavigationOptions = self.form.rowNavigationOptions | XLFormRowNavigationOptions.StopDisableRow
}
else{
self.form.rowNavigationOptions = self.form.rowNavigationOptions & (~XLFormRowNavigationOptions.StopDisableRow)
}
}
else if formRow.tag == Tags.AccessoryViewRowNavigationStopInlineRow.rawValue {
if formRow.value.boolValue == true {
self.form.rowNavigationOptions = self.form.rowNavigationOptions | XLFormRowNavigationOptions.StopInlineRow
}
else{
self.form.rowNavigationOptions = self.form.rowNavigationOptions & (~XLFormRowNavigationOptions.StopInlineRow)
}
}
else if formRow.tag == Tags.AccessoryViewRowNavigationSkipCanNotBecomeFirstResponderRow.rawValue {
if formRow.value.boolValue == true {
self.form.rowNavigationOptions = self.form.rowNavigationOptions | XLFormRowNavigationOptions.SkipCanNotBecomeFirstResponderRow
}
else{
self.form.rowNavigationOptions = self.form.rowNavigationOptions & (~XLFormRowNavigationOptions.SkipCanNotBecomeFirstResponderRow)
}
}
}
}
+16 -2
View File
@@ -3,7 +3,7 @@
// SwiftExample
//
// Created by Martin Barreto on 3/10/15.
// Copyright (c) 2015 Xmartlabs. All rights reserved.
// Copyright (c) 2014-2015 Xmartlabs. All rights reserved.
//
import UIKit
@@ -15,7 +15,21 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Declare custom rows
XLFormViewController.cellClassesForRowDescriptorTypes()[XLFormRowDescriptorTypeRate] = "XLFormRatingCell"
XLFormViewController.cellClassesForRowDescriptorTypes()[XLFormRowDescriptorTypeFloatLabeledTextField] = FloatLabeledTextFieldCell.self
XLFormViewController.cellClassesForRowDescriptorTypes()[XLFormRowDescriptorTypeWeekDays] = "XLFormWeekDaysCell"
// Override point for customization after application launch.
self.window = UIWindow.init(frame: UIScreen.mainScreen().bounds)
// Override point for customization after application launch.
self.window!.backgroundColor = UIColor.whiteColor()
// load the initial form form Storybiard
let storyboard = UIStoryboard.init(name:"iPhoneStoryboard", bundle:nil)
self.window!.rootViewController = storyboard.instantiateInitialViewController() as? UIViewController
self.window!.makeKeyAndVisible()
return true
}
@@ -30,7 +44,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
// Called as part of the transition from the background to the inactive state here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(application: UIApplication) {
@@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6214" systemVersion="14A314h" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6207"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2015 Xmartlabs. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
<rect key="frame" x="20" y="439" width="441" height="21"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="SwiftExample" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/>
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/>
<constraint firstAttribute="bottom" secondItem="8ie-xW-0ye" secondAttribute="bottom" constant="20" id="Kzo-t9-V3l"/>
<constraint firstItem="8ie-xW-0ye" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="MfP-vx-nX0"/>
<constraint firstAttribute="centerX" secondItem="8ie-xW-0ye" secondAttribute="centerX" id="ZEH-qu-HZ9"/>
<constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g"/>
</constraints>
<nil key="simulatedStatusBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="548" y="455"/>
</view>
</objects>
</document>
@@ -1,82 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="6751" systemVersion="14C109" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="Qcv-79-vVI">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6736"/>
</dependencies>
<scenes>
<!--Dates-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="DatesFormViewController" customModule="SwiftExample" customModuleProvider="target" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<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="2sg-5P-kgQ">
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
</tableView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="2sg-5P-kgQ" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="3Yn-bA-w0I"/>
<constraint firstAttribute="trailing" secondItem="2sg-5P-kgQ" secondAttribute="trailing" id="73f-7i-5tC"/>
<constraint firstItem="wfy-db-euE" firstAttribute="top" secondItem="2sg-5P-kgQ" secondAttribute="bottom" id="j8D-ZK-VSm"/>
<constraint firstItem="2sg-5P-kgQ" firstAttribute="top" secondItem="8bC-Xf-vdC" secondAttribute="top" id="u4s-WS-f87"/>
</constraints>
<variation key="default">
<mask key="subviews">
<exclude reference="2sg-5P-kgQ"/>
</mask>
<mask key="constraints">
<exclude reference="3Yn-bA-w0I"/>
<exclude reference="73f-7i-5tC"/>
<exclude reference="u4s-WS-f87"/>
<exclude reference="j8D-ZK-VSm"/>
</mask>
</variation>
<variation key="widthClass=compact">
<mask key="subviews">
<include reference="2sg-5P-kgQ"/>
</mask>
<mask key="constraints">
<include reference="3Yn-bA-w0I"/>
<include reference="73f-7i-5tC"/>
<include reference="u4s-WS-f87"/>
<include reference="j8D-ZK-VSm"/>
</mask>
</variation>
</view>
<navigationItem key="navigationItem" title="Dates" id="9ob-1y-Xxj"/>
<connections>
<outlet property="tableView" destination="2sg-5P-kgQ" id="8ra-Jh-FFN"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="1699.5" y="227"/>
</scene>
<!--Navigation Controller-->
<scene sceneID="Rqn-ai-pbu">
<objects>
<navigationController automaticallyAdjustsScrollViewInsets="NO" id="Qcv-79-vVI" sceneMemberID="viewController">
<toolbarItems/>
<navigationBar key="navigationBar" contentMode="scaleToFill" id="DYY-3j-vkq">
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
</navigationBar>
<nil name="viewControllers"/>
<connections>
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="PVw-tk-bDX"/>
</connections>
</navigationController>
<placeholder placeholderIdentifier="IBFirstResponder" id="2NC-vw-Oo6" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="936" y="227"/>
</scene>
</scenes>
</document>
@@ -0,0 +1,109 @@
// CustomRowsViewController.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "CustomRowsViewController.h"
#import "XLForm.h"
#import "XLFormWeekDaysCell.h"
#import "XLFormRatingCell.h"
#import "FloatLabeledTextFieldCell.h"
#import "XLFormCustomCell.h"
static NSString * const kCustomRowFirstRatingTag = @"CustomRowFirstRatingTag";
static NSString * const kCustomRowSecondRatingTag = @"CustomRowSecondRatingTag";
static NSString * const kCustomRowFloatLabeledTextFieldTag = @"CustomRowFloatLabeledTextFieldTag";
static NSString * const kCustomRowWeekdays = @"CustomRowWeekdays";
static NSString * const kCustomRowText = @"kCustomText";
@implementation CustomRowsViewController
-(id)init
{
self = [super init];
if (self) {
[self initializeForm];
}
return self;
}
-(void)initializeForm
{
XLFormDescriptor * form = [XLFormDescriptor formDescriptorWithTitle:@"Custom Rows"];
XLFormSectionDescriptor * section;
XLFormRowDescriptor * row;
// Section Ratings
section = [XLFormSectionDescriptor formSectionWithTitle:@"Ratings"];
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kCustomRowFirstRatingTag rowType:XLFormRowDescriptorTypeRate title:@"First Rating"];
row.value = @(3);
[section addFormRow:row];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kCustomRowSecondRatingTag rowType:XLFormRowDescriptorTypeRate title:@"Second Rating"];
row.value = @(1);
[section addFormRow:row];
// Section Float Labeled Text Field
section = [XLFormSectionDescriptor formSectionWithTitle:@"Float Labeled Text Field"];
[form addFormSection:section];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kCustomRowFloatLabeledTextFieldTag rowType:XLFormRowDescriptorTypeFloatLabeledTextField title:@"Title"];
[section addFormRow:row];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kCustomRowFloatLabeledTextFieldTag rowType:XLFormRowDescriptorTypeFloatLabeledTextField title:@"First Name"];
[section addFormRow:row];
row = [XLFormRowDescriptor formRowDescriptorWithTag:kCustomRowFloatLabeledTextFieldTag rowType:XLFormRowDescriptorTypeFloatLabeledTextField title:@"Last Name"];
[section addFormRow:row];
// Section Weekdays
section = [XLFormSectionDescriptor formSectionWithTitle:@"Weekdays"];
[form addFormSection:section];
// WeekDays
row = [XLFormRowDescriptor formRowDescriptorWithTag:kCustomRowWeekdays rowType:XLFormRowDescriptorTypeWeekDays];
row.value = @{
kSunday: @(NO),
kMonday: @(YES),
kTuesday: @(YES),
kWednesday: @(NO),
kThursday: @(NO),
kFriday: @(NO),
kSaturday: @(NO)
};
[section addFormRow:row];
section = [XLFormSectionDescriptor formSection];
[form addFormSection:section];
XLFormRowDescriptor *customRowDescriptor = [XLFormRowDescriptor formRowDescriptorWithTag:kCustomRowText rowType:@"XLFormRowDescriptorTypeCustom"];
// Must set custom cell or add custom cell to cellClassesForRowDescriptorTypes dictionary before XLFormViewController loaded
customRowDescriptor.cellClass = [XLFormCustomCell class];
[section addFormRow:customRowDescriptor];
self.form = form;
}
@end
@@ -0,0 +1,187 @@
// FloatLabeledTextFieldCell.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "FloatLabeledTextFieldCell.h"
#import "UIView+XLFormAdditions.h"
#import "JVFloatLabeledTextField.h"
#import "NSObject+XLFormAdditions.h"
#import <JVFloatLabeledTextField/JVFloatLabeledTextField.h>
NSString * const XLFormRowDescriptorTypeFloatLabeledTextField = @"XLFormRowDescriptorTypeFloatLabeledTextField";
const static CGFloat kHMargin = 15.0f;
const static CGFloat kVMargin = 8.0f;
const static CGFloat kFloatingLabelFontSize = 11.0f;
@interface FloatLabeledTextFieldCell () <UITextFieldDelegate>
@property (nonatomic) JVFloatLabeledTextField * floatLabeledTextField;
@end
@implementation FloatLabeledTextFieldCell
@synthesize floatLabeledTextField =_floatLabeledTextField;
+(void)load
{
[XLFormViewController.cellClassesForRowDescriptorTypes setObject:[FloatLabeledTextFieldCell class] forKey:XLFormRowDescriptorTypeFloatLabeledTextField];
}
-(JVFloatLabeledTextField *)floatLabeledTextField
{
if (_floatLabeledTextField) return _floatLabeledTextField;
_floatLabeledTextField = [JVFloatLabeledTextField autolayoutView];
_floatLabeledTextField.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
_floatLabeledTextField.floatingLabel.font = [UIFont boldSystemFontOfSize:kFloatingLabelFontSize];
_floatLabeledTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
return _floatLabeledTextField;
}
#pragma mark - XLFormDescriptorCell
-(void)configure
{
[super configure];
[self setSelectionStyle:UITableViewCellSelectionStyleNone];
[self.contentView addSubview:self.floatLabeledTextField];
[self.floatLabeledTextField setDelegate:self];
[self.contentView addConstraints:[self layoutConstraints]];
}
-(void)update
{
[super update];
self.floatLabeledTextField.attributedPlaceholder =
[[NSAttributedString alloc] initWithString:self.rowDescriptor.title
attributes:@{NSForegroundColorAttributeName: [UIColor lightGrayColor]}];
self.floatLabeledTextField.text = self.rowDescriptor.value ? [self.rowDescriptor.value displayText] : self.rowDescriptor.noValueDisplayText;
[self.floatLabeledTextField setEnabled:!self.rowDescriptor.isDisabled];
self.floatLabeledTextField.floatingLabelTextColor = [UIColor lightGrayColor];
[self.floatLabeledTextField setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
}
-(BOOL)formDescriptorCellCanBecomeFirstResponder
{
return !self.rowDescriptor.isDisabled;
}
-(BOOL)formDescriptorCellBecomeFirstResponder
{
return [self.floatLabeledTextField becomeFirstResponder];
}
#pragma mark - UITextFieldDelegate
- (BOOL)textFieldShouldClear:(UITextField *)textField
{
return [self.formViewController textFieldShouldClear:textField];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
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];
[self.formViewController textFieldDidEndEditing:textField];
}
-(void)setReturnKeyType:(UIReturnKeyType)returnKeyType
{
self.floatLabeledTextField.returnKeyType = returnKeyType;
}
-(UIReturnKeyType)returnKeyType
{
return self.floatLabeledTextField.returnKeyType;
}
+(CGFloat)formDescriptorCellHeightForRowDescriptor:(XLFormRowDescriptor *)rowDescriptor {
return 55;
}
-(NSArray *)layoutConstraints
{
NSMutableArray * result = [[NSMutableArray alloc] init];
NSDictionary * views = @{@"floatLabeledTextField": self.floatLabeledTextField};
NSDictionary *metrics = @{@"hMargin":@(kHMargin),
@"vMargin":@(kVMargin)};
[result addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-(hMargin)-[floatLabeledTextField]-(hMargin)-|"
options:0
metrics:metrics
views:views]];
[result addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(vMargin)-[floatLabeledTextField]-(vMargin)-|"
options:0
metrics:metrics
views:views]];
return result;
}
#pragma mark - Helpers
- (void)textFieldDidChange:(UITextField *)textField
{
if (self.floatLabeledTextField == textField) {
if ([self.floatLabeledTextField.text length] > 0) {
self.rowDescriptor.value = self.floatLabeledTextField.text;
} else {
self.rowDescriptor.value = nil;
}
}
}
@end
@@ -0,0 +1,29 @@
// XLRatingView.h
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 <AXRatingView/AXRatingView.h>
@interface XLRatingView : AXRatingView
@end
@@ -0,0 +1,69 @@
// XLRatingView.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "XLRatingView.h"
@implementation XLRatingView
- (instancetype)init
{
self = [super init];
if (self) {
[self customize];
}
return self;
}
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self customize];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
[self customize];
}
return self;
}
- (void)customize
{
UIColor * grayColor = [UIColor colorWithRed:(205/255.0) green:(201/255.0) blue:(201/255.0) alpha:1];
self.baseColor = grayColor;
UIColor * goldColor = [UIColor colorWithRed:(255/255.0) green:(215/255.0) blue:0 alpha:1];
self.highlightColor = goldColor;
self.markFont = [UIFont systemFontOfSize:23.0f];
self.translatesAutoresizingMaskIntoConstraints = NO;
self.stepInterval = 1.0f;
}
@end
@@ -0,0 +1,62 @@
// XLFormRatingCell.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "XLFormRatingCell.h"
NSString * const XLFormRowDescriptorTypeRate = @"XLFormRowDescriptorTypeRate";
@implementation XLFormRatingCell
+(void)load
{
[XLFormViewController.cellClassesForRowDescriptorTypes setObject:NSStringFromClass([XLFormRatingCell class]) forKey:XLFormRowDescriptorTypeRate];
}
- (void)configure
{
[super configure];
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self.ratingView addTarget:self action:@selector(rateChanged:) forControlEvents:UIControlEventValueChanged];
}
- (void)update
{
[super update];
self.ratingView.value = [self.rowDescriptor.value floatValue];
self.rateTitle.text = self.rowDescriptor.title;
[self.ratingView setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
[self.rateTitle setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
}
#pragma mark - Events
-(void)rateChanged:(AXRatingView *)ratingView
{
self.rowDescriptor.value = [NSNumber numberWithFloat:ratingView.value];
}
@end
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6250" systemVersion="14A389" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" id="OGo-4x-YLf" customClass="XLFormRatingCell">
<rect key="frame" x="0.0" y="0.0" width="478" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="OGo-4x-YLf" id="hV6-xt-6pq">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="yhI-dj-sRk" customClass="XLRatingView">
<rect key="frame" x="353" y="11" width="115" height="22"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" constant="22" id="85e-Ov-qM7"/>
<constraint firstAttribute="width" constant="115" id="kOb-W4-HPs"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Rate" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Vxp-gw-YTt">
<rect key="frame" x="15" y="11" width="338" height="21"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="IK4-8e-SFs"/>
<constraint firstAttribute="width" constant="150" id="hNG-F9-1wj"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
<variation key="default">
<mask key="constraints">
<exclude reference="hNG-F9-1wj"/>
</mask>
</variation>
</label>
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="Vxp-gw-YTt" secondAttribute="bottom" constant="11" id="0Qz-iR-Tzb"/>
<constraint firstAttribute="centerY" secondItem="Vxp-gw-YTt" secondAttribute="centerY" id="4Vh-2e-m2p"/>
<constraint firstAttribute="trailing" secondItem="yhI-dj-sRk" secondAttribute="trailing" constant="10" id="NPC-r7-JFl"/>
<constraint firstAttribute="centerY" secondItem="yhI-dj-sRk" secondAttribute="centerY" id="Vw4-h8-wId"/>
<constraint firstItem="Vxp-gw-YTt" firstAttribute="leading" secondItem="hV6-xt-6pq" secondAttribute="leading" constant="15" id="Xgq-Cy-zLQ"/>
<constraint firstItem="Vxp-gw-YTt" firstAttribute="top" secondItem="hV6-xt-6pq" secondAttribute="top" constant="11" id="bgO-t8-Rjz"/>
<constraint firstItem="yhI-dj-sRk" firstAttribute="leading" secondItem="Vxp-gw-YTt" secondAttribute="trailing" id="n0B-tg-Pik"/>
</constraints>
</tableViewCellContentView>
<connections>
<outlet property="rateTitle" destination="Vxp-gw-YTt" id="KRL-Lg-C7F"/>
<outlet property="ratingView" destination="yhI-dj-sRk" id="QBD-SA-AlI"/>
</connections>
<point key="canvasLocation" x="301" y="260"/>
</tableViewCell>
</objects>
</document>
@@ -0,0 +1,154 @@
// XLFormWeekDaysCell.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "XLFormWeekDaysCell.h"
NSString * const XLFormRowDescriptorTypeWeekDays = @"XLFormRowDescriptorTypeWeekDays";
NSString *const kSunday= @"sunday";
NSString *const kMonday = @"monday";
NSString *const kTuesday = @"tuesday";
NSString *const kWednesday = @"wednesday";
NSString *const kThursday = @"thursday";
NSString *const kFriday = @"friday";
NSString *const kSaturday = @"saturday";
@interface XLFormWeekDaysCell()
@property (weak, nonatomic) IBOutlet UIButton *sundayButton;
@property (weak, nonatomic) IBOutlet UIButton *mondayButton;
@property (weak, nonatomic) IBOutlet UIButton *tuesdayButton;
@property (weak, nonatomic) IBOutlet UIButton *wednesdayButton;
@property (weak, nonatomic) IBOutlet UIButton *thursdayButton;
@property (weak, nonatomic) IBOutlet UIButton *fridayButton;
@property (weak, nonatomic) IBOutlet UIButton *saturdayButton;
@end
@implementation XLFormWeekDaysCell
+(void)load
{
[XLFormViewController.cellClassesForRowDescriptorTypes setObject:NSStringFromClass([XLFormWeekDaysCell class]) forKey:XLFormRowDescriptorTypeWeekDays];
}
#pragma mark - XLFormDescriptorCell
- (void)configure
{
[super configure];
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self configureButtons];
}
-(void)update
{
[super update];
[self updateButtons];
}
#pragma mark - Action
- (IBAction)dayTapped:(id)sender {
[self dayTapped:sender day:[self getDayFormButton:sender]];
}
#pragma mark - Helpers
-(void)configureButtons
{
for (UIView *subview in self.contentView.subviews)
{
if ([subview isKindOfClass:[UIButton class]])
{
UIButton * button = (UIButton *)subview;
[button setImage:[UIImage imageNamed:@"uncheckedDay"] forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:@"checkedDay"] forState:UIControlStateSelected];
button.adjustsImageWhenHighlighted = NO;
[self imageTopTitleBottom:button];
}
}
}
-(void)updateButtons
{
NSDictionary * value = self.rowDescriptor.value;
self.sundayButton.selected = [[value objectForKey:kSunday] boolValue];
self.mondayButton.selected = [[value objectForKey:kMonday] boolValue];
self.tuesdayButton.selected = [[value objectForKey:kTuesday] boolValue];
self.wednesdayButton.selected = [[value objectForKey:kWednesday] boolValue];
self.thursdayButton.selected = [[value objectForKey:kThursday] boolValue];
self.fridayButton.selected = [[value objectForKey:kFriday] boolValue];
self.saturdayButton.selected = [[value objectForKey:kSaturday] boolValue];
[self.sundayButton setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
[self.mondayButton setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
[self.tuesdayButton setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
[self.wednesdayButton setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
[self.thursdayButton setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
[self.fridayButton setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
[self.saturdayButton setAlpha:((self.rowDescriptor.isDisabled) ? .6 : 1)];
}
-(NSString *)getDayFormButton:(id)sender
{
if (sender == self.sundayButton) return kSunday;
if (sender == self.mondayButton) return kMonday;
if (sender == self.tuesdayButton) return kTuesday;
if (sender == self.wednesdayButton) return kWednesday;
if (sender == self.thursdayButton) return kThursday;
if (sender == self.fridayButton) return kFriday;
return kSaturday;
}
-(void)dayTapped:(UIButton *)button day:(NSString *)day
{
button.selected = !button.selected;
NSMutableDictionary * value = [self.rowDescriptor.value mutableCopy];
[value setObject:@(button.selected) forKey:day];
self.rowDescriptor.value = value;
}
-(void)imageTopTitleBottom:(UIButton *)button
{
// the space between the image and text
CGFloat spacing = 3.0;
// lower the text and push it left so it appears centered
// below the image
CGSize imageSize = button.imageView.image.size;
button.titleEdgeInsets = UIEdgeInsetsMake(0.0, - imageSize.width, - (imageSize.height + spacing), 0.0);
// raise the image and push it right so it appears centered
// above the text
CGSize titleSize = [button.titleLabel.text sizeWithAttributes:@{NSFontAttributeName: button.titleLabel.font}];
button.imageEdgeInsets = UIEdgeInsetsMake(- (titleSize.height + spacing), 0.0, 0.0, - titleSize.width);
}
+(CGFloat)formDescriptorCellHeightForRowDescriptor:(XLFormRowDescriptor *)rowDescriptor
{
return 60;
}
@end
@@ -0,0 +1,250 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6250" systemVersion="14A389" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" rowHeight="60" id="piA-L5-eiN" customClass="XLFormWeekDaysCell">
<rect key="frame" x="0.0" y="0.0" width="382" height="50"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="piA-L5-eiN" id="Yr6-3E-keb">
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="ZAg-Me-yKR">
<rect key="frame" x="5" y="0.0" width="53" height="49"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="S">
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<state key="selected">
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
</state>
<connections>
<action selector="dayTapped:" destination="piA-L5-eiN" eventType="touchUpInside" id="K4V-Xd-Bak"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="UjQ-Cw-7wH" userLabel="separator 1">
<rect key="frame" x="58" y="10" width="1" height="29"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="K3N-3h-MZr"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="N3w-qP-kRZ">
<rect key="frame" x="58" y="0.0" width="53" height="49"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="M">
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="dayTapped:" destination="piA-L5-eiN" eventType="touchUpInside" id="FaQ-oB-Nkl"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kwc-0w-V51" userLabel="separator 2">
<rect key="frame" x="111" y="10" width="1" height="29"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="3mE-sT-ql1"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="cPl-47-rS8">
<rect key="frame" x="111" y="0.0" width="53" height="49"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="T">
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="dayTapped:" destination="piA-L5-eiN" eventType="touchUpInside" id="4vk-5n-jge"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="EiN-2p-Oig" userLabel="separator 3">
<rect key="frame" x="164" y="10" width="1" height="29"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="JyW-GC-0A7"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="6iC-Cl-RyI">
<rect key="frame" x="164" y="0.0" width="54" height="49"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="W">
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="dayTapped:" destination="piA-L5-eiN" eventType="touchUpInside" id="oO1-zj-XRv"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="bRc-5e-QAH" userLabel="separator 4">
<rect key="frame" x="218" y="10" width="1" height="29"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="W9F-iR-Leh"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="eTo-Ip-reh">
<rect key="frame" x="218" y="0.0" width="53" height="49"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="T">
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="dayTapped:" destination="piA-L5-eiN" eventType="touchUpInside" id="SkQ-0a-9Fy"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dHj-rj-mjh" userLabel="separator 5">
<rect key="frame" x="271" y="10" width="1" height="29"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="h5U-x0-9nJ"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Wjb-tu-QEo">
<rect key="frame" x="271" y="0.0" width="53" height="49"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="F">
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="dayTapped:" destination="piA-L5-eiN" eventType="touchUpInside" id="9A8-9a-SGG"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="L7g-lu-boa" userLabel="separator 6">
<rect key="frame" x="324" y="10" width="1" height="29"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="width" constant="1" id="81t-Xh-wZT"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="LNf-b4-GYP">
<rect key="frame" x="324" y="0.0" width="53" height="49"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<state key="normal" title="S">
<color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="dayTapped:" destination="piA-L5-eiN" eventType="touchUpInside" id="I4k-Ho-KxE"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="ZAg-Me-yKR" firstAttribute="leading" secondItem="Yr6-3E-keb" secondAttribute="leading" constant="5" id="0EB-cP-ogn"/>
<constraint firstItem="6iC-Cl-RyI" firstAttribute="width" secondItem="cPl-47-rS8" secondAttribute="width" id="1ZI-HN-9ew"/>
<constraint firstItem="cPl-47-rS8" firstAttribute="leading" secondItem="N3w-qP-kRZ" secondAttribute="trailing" id="1pQ-h0-SEG"/>
<constraint firstItem="eTo-Ip-reh" firstAttribute="leading" secondItem="6iC-Cl-RyI" secondAttribute="trailing" constant="1" id="2UA-Ao-KZF"/>
<constraint firstItem="dHj-rj-mjh" firstAttribute="height" secondItem="L7g-lu-boa" secondAttribute="height" id="4dj-Xx-ksP"/>
<constraint firstAttribute="bottom" secondItem="EiN-2p-Oig" secondAttribute="bottom" constant="10" id="5eK-Bu-wpU"/>
<constraint firstItem="N3w-qP-kRZ" firstAttribute="leading" secondItem="ZAg-Me-yKR" secondAttribute="trailing" id="67F-sV-r6W"/>
<constraint firstItem="Wjb-tu-QEo" firstAttribute="leading" secondItem="dHj-rj-mjh" secondAttribute="trailing" id="6ZX-Ub-2vw"/>
<constraint firstItem="EiN-2p-Oig" firstAttribute="height" secondItem="bRc-5e-QAH" secondAttribute="height" id="7Um-cV-f7p"/>
<constraint firstItem="LNf-b4-GYP" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" id="7YT-x4-m88"/>
<constraint firstItem="6iC-Cl-RyI" firstAttribute="trailing" secondItem="bRc-5e-QAH" secondAttribute="leading" id="ABd-MQ-9sp"/>
<constraint firstAttribute="bottom" secondItem="UjQ-Cw-7wH" secondAttribute="bottom" constant="10" id="ASC-xR-Yxa"/>
<constraint firstAttribute="bottom" secondItem="dHj-rj-mjh" secondAttribute="bottom" constant="10" id="ASP-um-b8o"/>
<constraint firstItem="6iC-Cl-RyI" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" id="Aac-10-vTs"/>
<constraint firstItem="eTo-Ip-reh" firstAttribute="leading" secondItem="6iC-Cl-RyI" secondAttribute="trailing" id="BL5-PL-pac"/>
<constraint firstAttribute="bottom" secondItem="ZAg-Me-yKR" secondAttribute="bottom" id="BeZ-ar-qMN"/>
<constraint firstItem="dHj-rj-mjh" firstAttribute="height" secondItem="bRc-5e-QAH" secondAttribute="height" id="DYn-Cd-g5H"/>
<constraint firstAttribute="bottom" secondItem="kwc-0w-V51" secondAttribute="bottom" constant="10" id="EXu-BP-ftM"/>
<constraint firstAttribute="bottom" secondItem="LNf-b4-GYP" secondAttribute="bottom" id="EYe-ne-rqO"/>
<constraint firstItem="cPl-47-rS8" firstAttribute="leading" secondItem="N3w-qP-kRZ" secondAttribute="trailing" id="Fo8-Tp-bkn"/>
<constraint firstItem="dHj-rj-mjh" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" constant="10" id="GYq-pf-vR0"/>
<constraint firstItem="cPl-47-rS8" firstAttribute="leading" secondItem="UjQ-Cw-7wH" secondAttribute="trailing" constant="72" id="HQ2-jA-X9g"/>
<constraint firstItem="Wjb-tu-QEo" firstAttribute="leading" secondItem="eTo-Ip-reh" secondAttribute="trailing" id="I0s-Ze-pwV"/>
<constraint firstAttribute="bottom" secondItem="bRc-5e-QAH" secondAttribute="bottom" constant="10" id="InL-Hk-twg"/>
<constraint firstItem="UjQ-Cw-7wH" firstAttribute="leading" secondItem="ZAg-Me-yKR" secondAttribute="trailing" id="Jj4-jg-rdr"/>
<constraint firstItem="6iC-Cl-RyI" firstAttribute="leading" secondItem="cPl-47-rS8" secondAttribute="trailing" id="KQe-Ei-8jY"/>
<constraint firstItem="cPl-47-rS8" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" id="Kw5-3R-qXs"/>
<constraint firstItem="bRc-5e-QAH" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" constant="10" id="MXG-vB-U8F"/>
<constraint firstItem="ZAg-Me-yKR" firstAttribute="width" secondItem="N3w-qP-kRZ" secondAttribute="width" id="Mem-UJ-5Js"/>
<constraint firstItem="L7g-lu-boa" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" constant="10" id="OVT-GJ-zq8"/>
<constraint firstItem="kwc-0w-V51" firstAttribute="leading" secondItem="cPl-47-rS8" secondAttribute="trailing" constant="25" id="OYQ-8o-3j8"/>
<constraint firstItem="N3w-qP-kRZ" firstAttribute="width" secondItem="cPl-47-rS8" secondAttribute="width" id="Pl6-Xd-Krq"/>
<constraint firstItem="Wjb-tu-QEo" firstAttribute="width" secondItem="LNf-b4-GYP" secondAttribute="width" id="Pro-fg-wBA"/>
<constraint firstAttribute="bottom" secondItem="6iC-Cl-RyI" secondAttribute="bottom" id="Q5M-8N-hIh"/>
<constraint firstItem="UjQ-Cw-7wH" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" constant="10" id="RGn-ja-FRD"/>
<constraint firstAttribute="trailing" secondItem="LNf-b4-GYP" secondAttribute="trailing" constant="5" id="RlS-d5-rIx"/>
<constraint firstItem="kwc-0w-V51" firstAttribute="trailing" secondItem="cPl-47-rS8" secondAttribute="leading" id="Rs4-Pl-R8X"/>
<constraint firstItem="eTo-Ip-reh" firstAttribute="leading" secondItem="bRc-5e-QAH" secondAttribute="trailing" id="SO9-U6-cVO"/>
<constraint firstAttribute="bottom" secondItem="N3w-qP-kRZ" secondAttribute="bottom" id="STf-aE-Y2E"/>
<constraint firstAttribute="bottom" secondItem="kwc-0w-V51" secondAttribute="bottom" constant="10" id="SWG-oy-aZJ"/>
<constraint firstItem="kwc-0w-V51" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" constant="10" id="TAb-IV-m7A"/>
<constraint firstAttribute="bottom" secondItem="cPl-47-rS8" secondAttribute="bottom" id="Tmp-md-564"/>
<constraint firstItem="kwc-0w-V51" firstAttribute="height" secondItem="UjQ-Cw-7wH" secondAttribute="height" id="Uli-Qb-6Om"/>
<constraint firstItem="6iC-Cl-RyI" firstAttribute="leading" secondItem="cPl-47-rS8" secondAttribute="trailing" id="VcV-kz-XBb"/>
<constraint firstItem="eTo-Ip-reh" firstAttribute="width" secondItem="6iC-Cl-RyI" secondAttribute="width" id="X0k-jG-o63"/>
<constraint firstItem="Wjb-tu-QEo" firstAttribute="leading" secondItem="eTo-Ip-reh" secondAttribute="trailing" id="cOc-P1-ZhU"/>
<constraint firstItem="LNf-b4-GYP" firstAttribute="leading" secondItem="Wjb-tu-QEo" secondAttribute="trailing" id="dSr-cr-ebR"/>
<constraint firstItem="EiN-2p-Oig" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" constant="10" id="fgT-6k-CaP"/>
<constraint firstItem="LNf-b4-GYP" firstAttribute="leading" secondItem="Wjb-tu-QEo" secondAttribute="trailing" id="gNl-wJ-ujY"/>
<constraint firstItem="ZAg-Me-yKR" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" id="glN-lT-q1z"/>
<constraint firstItem="eTo-Ip-reh" firstAttribute="width" secondItem="Wjb-tu-QEo" secondAttribute="width" id="hEH-9C-pGZ"/>
<constraint firstItem="EiN-2p-Oig" firstAttribute="height" secondItem="kwc-0w-V51" secondAttribute="height" id="hOI-fd-H7m"/>
<constraint firstItem="eTo-Ip-reh" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" id="i5C-wG-rRN"/>
<constraint firstItem="eTo-Ip-reh" firstAttribute="trailing" secondItem="dHj-rj-mjh" secondAttribute="leading" id="jsw-H6-2gQ"/>
<constraint firstItem="kwc-0w-V51" firstAttribute="leading" secondItem="cPl-47-rS8" secondAttribute="trailing" id="lQE-r9-9JT"/>
<constraint firstAttribute="bottom" secondItem="L7g-lu-boa" secondAttribute="bottom" constant="10" id="lv1-xB-0zR"/>
<constraint firstItem="kwc-0w-V51" firstAttribute="leading" secondItem="N3w-qP-kRZ" secondAttribute="trailing" id="oQe-Qf-9ZO"/>
<constraint firstItem="Wjb-tu-QEo" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" id="pn7-s8-fDj"/>
<constraint firstItem="EiN-2p-Oig" firstAttribute="leading" secondItem="cPl-47-rS8" secondAttribute="trailing" id="qIf-aB-2ZY"/>
<constraint firstItem="6iC-Cl-RyI" firstAttribute="leading" secondItem="EiN-2p-Oig" secondAttribute="trailing" id="sAE-Nl-Puc"/>
<constraint firstItem="LNf-b4-GYP" firstAttribute="leading" secondItem="L7g-lu-boa" secondAttribute="trailing" id="t1q-Nc-vbg"/>
<constraint firstItem="kwc-0w-V51" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" constant="10" id="tVL-uj-6Ma"/>
<constraint firstItem="Wjb-tu-QEo" firstAttribute="trailing" secondItem="L7g-lu-boa" secondAttribute="leading" id="u3Q-pF-E3A"/>
<constraint firstAttribute="bottom" secondItem="Wjb-tu-QEo" secondAttribute="bottom" id="uh4-LM-Ieo"/>
<constraint firstItem="kwc-0w-V51" firstAttribute="leading" secondItem="cPl-47-rS8" secondAttribute="trailing" constant="25" id="vrx-0B-GOB"/>
<constraint firstAttribute="bottom" secondItem="eTo-Ip-reh" secondAttribute="bottom" id="xIu-Vy-Nff"/>
<constraint firstItem="N3w-qP-kRZ" firstAttribute="leading" secondItem="UjQ-Cw-7wH" secondAttribute="trailing" id="xWy-Uf-QEm"/>
<constraint firstItem="N3w-qP-kRZ" firstAttribute="leading" secondItem="ZAg-Me-yKR" secondAttribute="trailing" id="xsx-BM-yQ5"/>
<constraint firstItem="N3w-qP-kRZ" firstAttribute="top" secondItem="Yr6-3E-keb" secondAttribute="top" id="yEX-Wv-CZQ"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="67F-sV-r6W"/>
<exclude reference="xWy-Uf-QEm"/>
<exclude reference="1pQ-h0-SEG"/>
<exclude reference="HQ2-jA-X9g"/>
<exclude reference="OYQ-8o-3j8"/>
<exclude reference="Rs4-Pl-R8X"/>
<exclude reference="SWG-oy-aZJ"/>
<exclude reference="TAb-IV-m7A"/>
<exclude reference="Uli-Qb-6Om"/>
<exclude reference="lQE-r9-9JT"/>
<exclude reference="vrx-0B-GOB"/>
<exclude reference="KQe-Ei-8jY"/>
<exclude reference="sAE-Nl-Puc"/>
<exclude reference="7Um-cV-f7p"/>
<exclude reference="hOI-fd-H7m"/>
<exclude reference="2UA-Ao-KZF"/>
<exclude reference="SO9-U6-cVO"/>
<exclude reference="6ZX-Ub-2vw"/>
<exclude reference="cOc-P1-ZhU"/>
<exclude reference="4dj-Xx-ksP"/>
<exclude reference="DYn-Cd-g5H"/>
<exclude reference="dSr-cr-ebR"/>
<exclude reference="t1q-Nc-vbg"/>
</mask>
</variation>
</tableViewCellContentView>
<connections>
<outlet property="fridayButton" destination="Wjb-tu-QEo" id="AcP-Qg-i9P"/>
<outlet property="mondayButton" destination="N3w-qP-kRZ" id="u3A-mt-EKd"/>
<outlet property="saturdayButton" destination="LNf-b4-GYP" id="TeM-3b-B1Z"/>
<outlet property="sundayButton" destination="ZAg-Me-yKR" id="GUI-ry-Hm1"/>
<outlet property="thursdayButton" destination="eTo-Ip-reh" id="Dxi-hi-oBK"/>
<outlet property="tuesdayButton" destination="cPl-47-rS8" id="wIn-mO-cUx"/>
<outlet property="wednesdayButton" destination="6iC-Cl-RyI" id="GQe-Oy-pcd"/>
</connections>
<point key="canvasLocation" x="296" y="222"/>
</tableViewCell>
</objects>
</document>
@@ -0,0 +1,75 @@
//
// CustomSelectorsFormViewController.swift
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014-2015 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 MapKit
class CustomSelectorsFormViewController : XLFormViewController {
private enum Tags : String {
case SelectorMap = "selectorMap"
case SelectorMapPopover = "selectorMapPopover"
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
self.initializeForm()
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.initializeForm()
}
func initializeForm() {
let form : XLFormDescriptor
var section : XLFormSectionDescriptor
var row : XLFormRowDescriptor
form = XLFormDescriptor(title: "Custom Selectors")
section = XLFormSectionDescriptor.formSectionWithTitle("TextField Types")
section.footerTitle = "CustomSelectorsFormViewController.swift"
form.addFormSection(section)
// Selector Push
row = XLFormRowDescriptor(tag: Tags.SelectorMap.rawValue, rowType: XLFormRowDescriptorTypeSelectorPush, title: "Coordinate")
row.action.viewControllerClass = MapViewController.self
row.valueTransformer = CLLocationValueTrasformer.self
row.value = CLLocation(latitude: -33, longitude: -56)
section.addFormRow(row)
if UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad {
// Selector PopOver
row = XLFormRowDescriptor(tag: Tags.SelectorMapPopover.rawValue, rowType: XLFormRowDescriptorTypeSelectorPopover, title: "Coordinate PopOver")
row.action.viewControllerClass = MapViewController.self
row.valueTransformer = CLLocationValueTrasformer.self
row.value = CLLocation(latitude: -33, longitude: -56)
section.addFormRow(row)
}
self.form = form
}
}
@@ -0,0 +1,49 @@
//
// CLLocationValueTrasformer.swift
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014-2015 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 MapKit
class CLLocationValueTrasformer : NSValueTransformer {
override class func transformedValueClass() -> AnyClass {
return NSString.self
}
override class func allowsReverseTransformation() -> Bool {
return false
}
override func transformedValue(value: AnyObject?) -> AnyObject? {
if let valueData: AnyObject = value {
let location = valueData as! CLLocation
return String(format: "%0.4f, %0.4f", location.coordinate.latitude, location.coordinate.longitude)
}
return nil
}
}
@@ -0,0 +1,99 @@
//
// MapViewController.swift
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014-2015 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 MapKit
class MapAnnotation : NSObject, MKAnnotation {
@objc var coordinate : CLLocationCoordinate2D
override init() {
self.coordinate = CLLocationCoordinate2D(latitude: -33.0, longitude: -56.0)
super.init()
}
}
@objc(MapViewController)
class MapViewController : UIViewController, XLFormRowDescriptorViewController, MKMapViewDelegate {
var rowDescriptor: XLFormRowDescriptor?
lazy var mapView : MKMapView = {
let mapView = MKMapView(frame: self.view.frame)
mapView.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
return mapView
}()
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
self.view.addSubview(self.mapView)
self.mapView.delegate = self
if let rowDesc = self.rowDescriptor {
if rowDesc.value != nil {
let coordinate = (self.rowDescriptor!.value as! CLLocation).coordinate
self.mapView.setCenterCoordinate(coordinate, animated: false)
self.title = String(format: "%0.4f, %0.4f", self.mapView.centerCoordinate.latitude, self.mapView.centerCoordinate.longitude)
let annotation = MapAnnotation()
annotation.coordinate = coordinate
self.mapView.addAnnotation(annotation)
}
}
}
//MARK - - MKMapViewDelegate
func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
let pinAnnotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: "annotation")
pinAnnotationView.pinColor = MKPinAnnotationColor.Red
pinAnnotationView.draggable = true
pinAnnotationView.animatesDrop = true
return pinAnnotationView
}
func mapView(mapView: MKMapView!, annotationView view: MKAnnotationView!, didChangeDragState newState: MKAnnotationViewDragState, fromOldState oldState: MKAnnotationViewDragState) {
if (newState == MKAnnotationViewDragState.Ending){
self.rowDescriptor!.value = CLLocation(latitude:view.annotation.coordinate.latitude, longitude:view.annotation.coordinate.longitude)
self.title = String(format: "%0.4f, %0.4f", view.annotation.coordinate.latitude, view.annotation.coordinate.longitude)
}
}
}
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="7531" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7520"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MapViewController" customModule="SwiftExample" customModuleProvider="target">
<connections>
<outlet property="view" destination="iN0-l3-epB" id="O5R-PM-tsI"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</objects>
</document>
@@ -0,0 +1,31 @@
//
// DynamicSelectorsFormViewController.h
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "XLFormViewController.h"
@interface DynamicSelectorsFormViewController : XLFormViewController
@end
@@ -0,0 +1,66 @@
//
// DynamicSelectorsFormViewController.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "UsersTableViewController.h"
#import "DynamicSelectorsFormViewController.h"
NSString *const kSelectorUser = @"selectorUser";
NSString *const kSelectorUserPopover = @"kSelectorUserPopover";
@implementation DynamicSelectorsFormViewController
-(id)init
{
self = [super init];
if (self) {
XLFormDescriptor * form = [XLFormDescriptor formDescriptorWithTitle:@"Selectors"];
XLFormSectionDescriptor * section;
XLFormRowDescriptor * row;
// Basic Information
section = [XLFormSectionDescriptor formSectionWithTitle:@"Dynamic Selectors"];
section.footerTitle = @"DynamicSelectorsFormViewController.h";
[form addFormSection:section];
// Selector Push
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorUser rowType:XLFormRowDescriptorTypeSelectorPush title:@"User"];
row.action.viewControllerClass = [UsersTableViewController class];
[section addFormRow:row];
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad){
// Selector PopOver
row = [XLFormRowDescriptor formRowDescriptorWithTag:kSelectorUserPopover rowType:XLFormRowDescriptorTypeSelectorPopover title:@"User Popover"];
row.action.viewControllerClass = [UsersTableViewController class];
[section addFormRow:row];
}
self.form = form;
}
return self;
}
@end
@@ -0,0 +1,63 @@
//
// DynamicSelectorsFormViewController.swift
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014-2015 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.
class DynamicSelectorsFormViewController : XLFormViewController {
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
self.initializeForm()
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.initializeForm()
}
func initializeForm() {
let form = XLFormDescriptor(title: "Selectors")
var section : XLFormSectionDescriptor
var row : XLFormRowDescriptor
// Basic Information
section = XLFormSectionDescriptor.formSectionWithTitle("Dynamic Selectors")
section.footerTitle = "DynamicSelectorsFormViewController.swift"
form.addFormSection(section)
// Selector Push
row = XLFormRowDescriptor(tag: "selectorUser", rowType:XLFormRowDescriptorTypeSelectorPush, title:"User")
row.action.viewControllerClass = UsersTableViewController.self
section.addFormRow(row)
if UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad {
// Selector PopOver
row = XLFormRowDescriptor(tag: "selectorUserPopover", rowType:XLFormRowDescriptorTypeSelectorPopover, title:"User Popover")
row.action.viewControllerClass = UsersTableViewController.self
section.addFormRow(row)
}
self.form = form
}
}
@@ -0,0 +1,31 @@
//
// UsersTableViewController.h
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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"
#import "XLTableViewController.h"
@interface UsersTableViewController : XLTableViewController <XLFormRowDescriptorViewController, XLFormRowDescriptorPopoverViewController>
@end
@@ -0,0 +1,245 @@
//
// UsersTableViewController.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "UsersTableViewController.h"
#import "UserLocalDataLoader.h"
#import "UserRemoteDataLoader.h"
#import "User+Additions.h"
// AFNetworking
#import <AFNetworking/UIImageView+AFNetworking.h>
@interface UserCell : UITableViewCell
@property (nonatomic) UIImageView * userImage;
@property (nonatomic) UILabel * userName;
@end
@implementation UserCell
@synthesize userImage = _userImage;
@synthesize userName = _userName;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
[self.contentView addSubview:self.userImage];
[self.contentView addSubview:self.userName];
[self.contentView addConstraints:[self layoutConstraints]];
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
#pragma mark - Views
-(UIImageView *)userImage
{
if (_userImage) return _userImage;
_userImage = [UIImageView new];
[_userImage setTranslatesAutoresizingMaskIntoConstraints:NO];
_userImage.layer.masksToBounds = YES;
_userImage.layer.cornerRadius = 10.0f;
return _userImage;
}
-(UILabel *)userName
{
if (_userName) return _userName;
_userName = [UILabel new];
[_userName setTranslatesAutoresizingMaskIntoConstraints:NO];
_userName.font = [UIFont fontWithName:@"HelveticaNeue" size:15.f];
return _userName;
}
#pragma mark - Layout Constraints
-(NSArray *)layoutConstraints{
NSMutableArray * result = [NSMutableArray array];
NSDictionary * views = @{ @"image": self.userImage,
@"name": self.userName};
NSDictionary *metrics = @{@"imgSize":@50.0,
@"margin" :@12.0};
[result addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-(margin)-[image(imgSize)]-[name]"
options:NSLayoutFormatAlignAllTop
metrics:metrics
views:views]];
[result addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(margin)-[image(imgSize)]"
options:0
metrics:metrics
views:views]];
return result;
}
@end
@interface UsersTableViewController ()
@end
@implementation UsersTableViewController
@synthesize rowDescriptor = _rowDescriptor;
@synthesize popoverController = __popoverController;
static NSString *const kCellIdentifier = @"CellIdentifier";
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
[self initialize];
}
return self;
}
-(void)initialize
{
// Enable the pagination
self.loadingPagingEnabled = YES;
// Support Search Controller
self.supportSearchController = YES;
[self setLocalDataLoader:[[UserLocalDataLoader alloc] init]];
[self setRemoteDataLoader:[[UserRemoteDataLoader alloc] init]];
// Search
[self setSearchLocalDataLoader:[[UserLocalDataLoader alloc] init]];
[self setSearchRemoteDataLoader:[[UserRemoteDataLoader alloc] init]];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
// SearchBar
self.tableView.tableHeaderView = self.searchDisplayController.searchBar;
// register cells
[self.searchDisplayController.searchResultsTableView registerClass:[UserCell class] forCellReuseIdentifier:kCellIdentifier];
[self.tableView registerClass:[UserCell class] forCellReuseIdentifier:kCellIdentifier];
[self customizeAppearance];
}
#pragma mark - UITableViewDataSource
- (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];
}
else{
user = (User *)[self.searchLocalDataLoader objectAtIndexPath:indexPath];
}
cell.userName.text = user.userName;
NSMutableURLRequest* imageRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:user.userImageURL]];
[imageRequest setValue:@"image/*" forHTTPHeaderField:@"Accept"];
__typeof__(cell) __weak weakCell = cell;
[cell.userImage setImageWithURLRequest: imageRequest
placeholderImage:[User defaultProfileImage]
success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
if (image) {
[weakCell.userImage setImage:image];
}
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
}];
cell.accessoryType = [[self.rowDescriptor.value formValue] isEqual:user.userId] ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
return cell;
}
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 73.0f;
}
#pragma mark - UITableViewDelegate
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
User * user = nil;
if (tableView == self.tableView){
user = (User *)[self.localDataLoader objectAtIndexPath:indexPath];
}
else{
user = (User *)[self.searchLocalDataLoader objectAtIndexPath:indexPath];
}
self.rowDescriptor.value = user;
if (self.popoverController){
[self.popoverController dismissPopoverAnimated:YES];
[self.popoverController.delegate popoverControllerDidDismissPopover:self.popoverController];
}
else if ([self.parentViewController isKindOfClass:[UINavigationController class]]){
[self.navigationController popViewControllerAnimated:YES];
}
}
#pragma mark - Helpers
-(void)customizeAppearance
{
[[self navigationItem] setTitle:@"Select a User"];
[self.tableView setBackgroundColor:[UIColor colorWithWhite:0.9 alpha:1.0]];
[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]];
}
@end
@@ -0,0 +1,245 @@
//
// UsersTableViewController.m
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2015 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 "UsersTableViewController.h"
#import "UserLocalDataLoader.h"
#import "UserRemoteDataLoader.h"
#import "User+Additions.h"
// AFNetworking
#import <AFNetworking/UIImageView+AFNetworking.h>
@interface UserCell : UITableViewCell
@property (nonatomic) UIImageView * userImage;
@property (nonatomic) UILabel * userName;
@end
@implementation UserCell
@synthesize userImage = _userImage;
@synthesize userName = _userName;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
[self.contentView addSubview:self.userImage];
[self.contentView addSubview:self.userName];
[self.contentView addConstraints:[self layoutConstraints]];
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
#pragma mark - Views
-(UIImageView *)userImage
{
if (_userImage) return _userImage;
_userImage = [UIImageView new];
[_userImage setTranslatesAutoresizingMaskIntoConstraints:NO];
_userImage.layer.masksToBounds = YES;
_userImage.layer.cornerRadius = 10.0f;
return _userImage;
}
-(UILabel *)userName
{
if (_userName) return _userName;
_userName = [UILabel new];
[_userName setTranslatesAutoresizingMaskIntoConstraints:NO];
_userName.font = [UIFont fontWithName:@"HelveticaNeue" size:15.f];
return _userName;
}
#pragma mark - Layout Constraints
-(NSArray *)layoutConstraints{
NSMutableArray * result = [NSMutableArray array];
NSDictionary * views = @{ @"image": self.userImage,
@"name": self.userName};
NSDictionary *metrics = @{@"imgSize":@50.0,
@"margin" :@12.0};
[result addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-(margin)-[image(imgSize)]-[name]"
options:NSLayoutFormatAlignAllTop
metrics:metrics
views:views]];
[result addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(margin)-[image(imgSize)]"
options:0
metrics:metrics
views:views]];
return result;
}
@end
@interface UsersTableViewController ()
@end
@implementation UsersTableViewController
@synthesize rowDescriptor = _rowDescriptor;
@synthesize popoverController = __popoverController;
static NSString *const kCellIdentifier = @"CellIdentifier";
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
[self initialize];
}
return self;
}
-(void)initialize
{
// Enable the pagination
self.loadingPagingEnabled = YES;
// Support Search Controller
self.supportSearchController = YES;
[self setLocalDataLoader:[[UserLocalDataLoader alloc] init]];
[self setRemoteDataLoader:[[UserRemoteDataLoader alloc] init]];
// Search
[self setSearchLocalDataLoader:[[UserLocalDataLoader alloc] init]];
[self setSearchRemoteDataLoader:[[UserRemoteDataLoader alloc] init]];
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
// SearchBar
self.tableView.tableHeaderView = self.searchDisplayController.searchBar;
// register cells
[self.searchDisplayController.searchResultsTableView registerClass:[UserCell class] forCellReuseIdentifier:kCellIdentifier];
[self.tableView registerClass:[UserCell class] forCellReuseIdentifier:kCellIdentifier];
[self customizeAppearance];
}
#pragma mark - UITableViewDataSource
- (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];
}
else{
user = (User *)[self.searchLocalDataLoader objectAtIndexPath:indexPath];
}
cell.userName.text = user.userName;
NSMutableURLRequest* imageRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:user.userImageURL]];
[imageRequest setValue:@"image/*" forHTTPHeaderField:@"Accept"];
__typeof__(cell) __weak weakCell = cell;
[cell.userImage setImageWithURLRequest: imageRequest
placeholderImage:[User defaultProfileImage]
success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
if (image) {
[weakCell.userImage setImage:image];
}
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
}];
cell.accessoryType = [[self.rowDescriptor.value formValue] isEqual:user.userId] ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
return cell;
}
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 73.0f;
}
#pragma mark - UITableViewDelegate
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
User * user = nil;
if (tableView == self.tableView){
user = (User *)[self.localDataLoader objectAtIndexPath:indexPath];
}
else{
user = (User *)[self.searchLocalDataLoader objectAtIndexPath:indexPath];
}
self.rowDescriptor.value = user;
if (self.popoverController){
[self.popoverController dismissPopoverAnimated:YES];
[self.popoverController.delegate popoverControllerDidDismissPopover:self.popoverController];
}
else if ([self.parentViewController isKindOfClass:[UINavigationController class]]){
[self.navigationController popViewControllerAnimated:YES];
}
}
#pragma mark - Helpers
-(void)customizeAppearance
{
[[self navigationItem] setTitle:@"Select a User"];
[self.tableView setBackgroundColor:[UIColor colorWithWhite:0.9 alpha:1.0]];
[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]];
}
@end
@@ -0,0 +1,177 @@
//
// ExamplesFormViewController.swift
// XLForm ( https://github.com/xmartlabs/XLForm )
//
// Copyright (c) 2014-2015 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.
class ExamplesFormViewController : XLFormViewController {
private enum Tags : String {
case RealExample = "RealExamples"
case TextFieldAndTextView = "TextFieldAndTextView"
case Selectors = "Selectors"
case Othes = "Others"
case Dates = "Dates"
case Predicates = "BasicPredicates"
case BlogExample = "BlogPredicates"
case Multivalued = "Multivalued"
case MultivaluedOnlyReorder = "MultivaluedOnlyReorder"
case MultivaluedOnlyInsert = "MultivaluedOnlyInsert"
case MultivaluedOnlyDelete = "MultivaluedOnlyDelete"
case Validations = "Validations"
case UICusomization = "Customization"
case Custom = "Custom"
case AccessoryView = "Accessory View"
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
self.initializeForm()
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.initializeForm()
}
// MARK: Helpers
func initializeForm() {
let form : XLFormDescriptor
var section : XLFormSectionDescriptor
var row: XLFormRowDescriptor
form = XLFormDescriptor()
section = XLFormSectionDescriptor.formSectionWithTitle("Real examples")
form.addFormSection(section)
// NativeEventFormViewController
row = XLFormRowDescriptor(tag: Tags.RealExample.rawValue, rowType: XLFormRowDescriptorTypeButton, title: "iOS Calendar Event Form")
row.action.formSegueIdenfifier = "NativeEventNavigationViewControllerSegue"
section.addFormRow(row)
section = XLFormSectionDescriptor.formSectionWithTitle("This form is actually an example")
section.footerTitle = "ExamplesFormViewController.swift, Select an option to view another example"
form.addFormSection(section)
// TextFieldAndTextView
row = XLFormRowDescriptor(tag: Tags.TextFieldAndTextView.rawValue, rowType: XLFormRowDescriptorTypeButton, title: "Text Fields")
row.action.viewControllerClass = InputsFormViewController.self
section.addFormRow(row)
// Selectors
row = XLFormRowDescriptor(tag: Tags.Selectors.rawValue, rowType: XLFormRowDescriptorTypeButton, title: "Selectors")
row.action.formSegueIdenfifier = "SelectorsFormViewControllerSegue"
section.addFormRow(row)
// Dates
row = XLFormRowDescriptor(tag: Tags.Dates.rawValue, rowType: XLFormRowDescriptorTypeButton, title: "Date & Time")
row.action.viewControllerClass = DatesFormViewController.self
section.addFormRow(row)
// Others
row = XLFormRowDescriptor(tag: Tags.Othes.rawValue, rowType: XLFormRowDescriptorTypeButton, title: "Other Rows")
row.action.formSegueIdenfifier = "OthersFormViewControllerSegue"
section.addFormRow(row)
section = XLFormSectionDescriptor.formSectionWithTitle("Multivalued example")
form.addFormSection(section)
row = XLFormRowDescriptor(tag: Tags.Multivalued.rawValue, rowType: XLFormRowDescriptorTypeButton, title: "Multivalued Sections")
row.action.viewControllerClass = MultivaluedFormViewController.self
section.addFormRow(row)
row = XLFormRowDescriptor(tag: Tags.MultivaluedOnlyReorder.rawValue, rowType: XLFormRowDescriptorTypeButton, title: "Multivalued Only Reorder")
row.action.viewControllerClass = MultivaluedOnlyReorderViewController.self
section.addFormRow(row)
row = XLFormRowDescriptor(tag: Tags.MultivaluedOnlyInsert.rawValue, rowType: XLFormRowDescriptorTypeButton, title: "Multivalued Only Insert")
row.action.viewControllerClass = MultivaluedOnlyInserViewController.self
section.addFormRow(row)
row = XLFormRowDescriptor(tag: Tags.MultivaluedOnlyDelete.rawValue, rowType: XLFormRowDescriptorTypeButton, title: "Multivalued Only Delete")
row.action.viewControllerClass = MultivaluedOnlyDeleteViewController.self
section.addFormRow(row)
section = XLFormSectionDescriptor.formSectionWithTitle("UI Customization")
form.addFormSection(section)
row = XLFormRowDescriptor(tag: Tags.UICusomization.rawValue, rowType: XLFormRowDescriptorTypeButton, title:"UI Customization")
row.action.viewControllerClass = UICustomizationFormViewController.self
section.addFormRow(row)
section = XLFormSectionDescriptor.formSectionWithTitle("Custom Rows")
form.addFormSection(section)
row = XLFormRowDescriptor(tag: Tags.Custom.rawValue, rowType: XLFormRowDescriptorTypeButton, title:"Custom Rows")
row.action.viewControllerClass = CustomRowsViewController.self
section.addFormRow(row)
section = XLFormSectionDescriptor.formSectionWithTitle("Accessory View")
form.addFormSection(section)
row = XLFormRowDescriptor(tag: Tags.AccessoryView.rawValue, rowType: XLFormRowDescriptorTypeButton, title:"Accessory Views")
row.action.viewControllerClass = AccessoryViewFormViewController.self
section.addFormRow(row)
section = XLFormSectionDescriptor.formSectionWithTitle("Validation Examples")
form.addFormSection(section)
row = XLFormRowDescriptor(tag: Tags.Validations.rawValue, rowType: XLFormRowDescriptorTypeButton, title: "Validation Examples")
row.action.formSegueIdenfifier = "ValidationExamplesFormViewControllerSegue"
section.addFormRow(row)
section = XLFormSectionDescriptor.formSectionWithTitle("Using Predicates")
form.addFormSection(section)
row = XLFormRowDescriptor(tag: Tags.Predicates.rawValue, rowType: XLFormRowDescriptorTypeButton, title: "Very basic predicates")
row.action.formSegueIdenfifier = "BasicPredicateViewControllerSegue"
section.addFormRow(row)
row = XLFormRowDescriptor(tag: Tags.Predicates.rawValue, rowType: XLFormRowDescriptorTypeButton, title: "Blog Example Hide predicates")
row.action.formSegueIdenfifier = "BlogExampleViewSegue"
section.addFormRow(row)
row = XLFormRowDescriptor(tag: Tags.Predicates.rawValue, rowType: XLFormRowDescriptorTypeButton, title: "Another example")
row.action.formSegueIdenfifier = "PredicateFormViewControllerSegue"
section.addFormRow(row)
self.form = form
}
}
@@ -1,28 +1,33 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"idiom" : "iphone",
"filename" : "xl_appicon_58.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"idiom" : "iphone",
"filename" : "xl_appicon_87.png",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"idiom" : "iphone",
"filename" : "xl_appicon_80-1.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"idiom" : "iphone",
"filename" : "xl_appicon_120-1.png",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"idiom" : "iphone",
"filename" : "xl_appicon_120.png",
"scale" : "2x"
},
{
@@ -51,13 +56,15 @@
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"idiom" : "ipad",
"filename" : "xl_appicon_76.png",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"idiom" : "ipad",
"filename" : "xl_appicon_152.png",
"scale" : "2x"
}
],
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 808 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 883 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 931 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@@ -0,0 +1,52 @@
{
"images" : [
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "retina4",
"filename" : "xl_splash@2x.png",
"minimum-system-version" : "7.0",
"orientation" : "portrait",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "1x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "Apu_Nahasapeemapetilon.png"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "Bart_Simpsons.png"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "Homer_Simpsons.png"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "Lisa_Simpsons.png"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Some files were not shown because too many files have changed in this diff Show More