Compare commits
36 Commits
3.2.0
...
updateReadme
| Author | SHA1 | Date | |
|---|---|---|---|
| 825c6c3467 | |||
| 1da30107dc | |||
| 4674c3abaf | |||
| 5ca54fd949 | |||
| e64e5b4885 | |||
| b28c902d73 | |||
| dc5f1e6dcd | |||
| 55e440bc57 | |||
| be2fb864be | |||
| cdd498ebc7 | |||
| cd43abc3f0 | |||
| f1a83512d1 | |||
| 00ccf60895 | |||
| 27a172eb65 | |||
| e62404d24b | |||
| d1aff91e63 | |||
| a0a8cf793c | |||
| bb81e88572 | |||
| 64ab7ccac0 | |||
| 9baeda1b0d | |||
| 6879f01230 | |||
| 50e9efe783 | |||
| bf819ba0ed | |||
| 087bbf089c | |||
| eac2f816d7 | |||
| b19bf9bafc | |||
| ce869235bc | |||
| bb93c90c2d | |||
| 7b50e19cf6 | |||
| 8eefa8afd9 | |||
| ca53315145 | |||
| c3263f7645 | |||
| fbf800fc21 | |||
| fbc08a7094 | |||
| f1f8a21bf0 | |||
| 694c08beee |
+1
-1
@@ -1,5 +1,5 @@
|
||||
language: objective-c
|
||||
osx_image: xcode7.2
|
||||
osx_image: xcode8.2
|
||||
before_install:
|
||||
- gem install cocoapods --no-rdoc --no-ri --no-document --quiet
|
||||
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet
|
||||
|
||||
+6
-1
@@ -1,7 +1,12 @@
|
||||
# Change Log
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
### Latest:
|
||||
### Version 3.3.0:
|
||||
* Added `cellConfigForSelector` to style XLFormOptionsViewController
|
||||
* Added properties to **limit number of characters** in `XLFormTextFieldCell` and `XLFormTextViewCell`
|
||||
* Minor fixes
|
||||
|
||||
### Version 3.2.0:
|
||||
* Added XL_APP_EXTENSIONS macro to allow app extensions (@MuscleRumble #357)
|
||||
* Added shouldChangeTextInRange delegate call for UITextView. (@kiancheong #782)
|
||||
* Added support for NSFormatter (@ziogaschr, @fwhenin, @bhirt-bpl #306)
|
||||
|
||||
@@ -105,6 +105,11 @@
|
||||
[row.cellConfigAtConfigure setObject:@(NSTextAlignmentRight) forKey:@"textField.textAlignment"];
|
||||
[section addFormRow:row];
|
||||
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"megabytes" rowType:XLFormRowDescriptorTypeInfo title:@"Megabytes"];
|
||||
row.valueFormatter = [NSByteCountFormatter new];
|
||||
row.value = @(1024);
|
||||
[section addFormRow:row];
|
||||
|
||||
section = [XLFormSectionDescriptor formSection];
|
||||
[formDescriptor addFormSection:section];
|
||||
|
||||
|
||||
@@ -380,11 +380,12 @@
|
||||
attributes = {
|
||||
LastSwiftMigration = 0700;
|
||||
LastSwiftUpdateCheck = 0700;
|
||||
LastUpgradeCheck = 0700;
|
||||
LastUpgradeCheck = 0800;
|
||||
ORGANIZATIONNAME = Xmartlabs;
|
||||
TargetAttributes = {
|
||||
2847A69D1AAF2679000A2ABE = {
|
||||
CreatedOnToolsVersion = 6.2;
|
||||
LastSwiftMigration = 0800;
|
||||
};
|
||||
};
|
||||
};
|
||||
@@ -520,8 +521,10 @@
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
@@ -530,6 +533,7 @@
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
@@ -564,8 +568,10 @@
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INFINITE_RECURSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
@@ -573,6 +579,7 @@
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
@@ -582,6 +589,7 @@
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
@@ -598,6 +606,7 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.xmartlabs.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "SwiftExample/SwiftExample-Bridging-Header.h";
|
||||
SWIFT_VERSION = 3.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -612,6 +621,7 @@
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.xmartlabs.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "SwiftExample/SwiftExample-Bridging-Header.h";
|
||||
SWIFT_VERSION = 3.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
class AccessoryViewFormViewController : XLFormViewController {
|
||||
|
||||
|
||||
private struct Tags {
|
||||
fileprivate struct Tags {
|
||||
static let AccessoryViewRowNavigationEnabled = "RowNavigationEnabled"
|
||||
static let AccessoryViewRowNavigationShowAccessoryView = "RowNavigationShowAccessoryView"
|
||||
static let AccessoryViewRowNavigationStopDisableRow = "rowNavigationStopDisableRow"
|
||||
@@ -44,7 +44,7 @@ class AccessoryViewFormViewController : XLFormViewController {
|
||||
static let AccessoryViewNotes = "notes"
|
||||
}
|
||||
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
initializeForm()
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class AccessoryViewFormViewController : XLFormViewController {
|
||||
var row : XLFormRowDescriptor
|
||||
|
||||
form = XLFormDescriptor(title: "Accessory View")
|
||||
form.rowNavigationOptions = .Enabled
|
||||
form.rowNavigationOptions = .enabled
|
||||
|
||||
// Configuration section
|
||||
section = XLFormSectionDescriptor()
|
||||
@@ -76,25 +76,25 @@ class AccessoryViewFormViewController : XLFormViewController {
|
||||
|
||||
// RowNavigationShowAccessoryView
|
||||
row = XLFormRowDescriptor(tag: Tags.AccessoryViewRowNavigationShowAccessoryView, rowType:XLFormRowDescriptorTypeBooleanCheck, title:"Show input accessory row?")
|
||||
row.value = form.rowNavigationOptions.contains(.Enabled)
|
||||
row.value = form.rowNavigationOptions.contains(.enabled)
|
||||
row.hidden = "$\(Tags.AccessoryViewRowNavigationEnabled) == 0"
|
||||
section.addFormRow(row)
|
||||
|
||||
// RowNavigationStopDisableRow
|
||||
row = XLFormRowDescriptor(tag: Tags.AccessoryViewRowNavigationStopDisableRow, rowType: XLFormRowDescriptorTypeBooleanCheck, title:"Stop when reach disabled row?")
|
||||
row.value = form.rowNavigationOptions.contains(.StopDisableRow)
|
||||
row.value = form.rowNavigationOptions.contains(.stopDisableRow)
|
||||
row.hidden = "$\(Tags.AccessoryViewRowNavigationEnabled) == 0"
|
||||
section.addFormRow(row)
|
||||
|
||||
// RowNavigationStopInlineRow
|
||||
row = XLFormRowDescriptor(tag: Tags.AccessoryViewRowNavigationStopInlineRow, rowType: XLFormRowDescriptorTypeBooleanCheck, title: "Stop when reach inline row?")
|
||||
row.value = form.rowNavigationOptions.contains(.StopInlineRow)
|
||||
row.value = form.rowNavigationOptions.contains(.stopInlineRow)
|
||||
row.hidden = "$\(Tags.AccessoryViewRowNavigationEnabled) == 0"
|
||||
section.addFormRow(row)
|
||||
|
||||
// RowNavigationSkipCanNotBecomeFirstResponderRow
|
||||
row = XLFormRowDescriptor(tag: Tags.AccessoryViewRowNavigationSkipCanNotBecomeFirstResponderRow, rowType:XLFormRowDescriptorTypeBooleanCheck, title:"Skip Can Not Become First Responder Row?")
|
||||
row.value = form.rowNavigationOptions.contains(XLFormRowNavigationOptions.SkipCanNotBecomeFirstResponderRow)
|
||||
row.value = form.rowNavigationOptions.contains(XLFormRowNavigationOptions.skipCanNotBecomeFirstResponderRow)
|
||||
row.hidden = "$\(Tags.AccessoryViewRowNavigationEnabled) == 0"
|
||||
section.addFormRow(row)
|
||||
|
||||
@@ -103,18 +103,18 @@ class AccessoryViewFormViewController : XLFormViewController {
|
||||
|
||||
// Name
|
||||
row = XLFormRowDescriptor(tag: Tags.AccessoryViewName, rowType: XLFormRowDescriptorTypeText, title: "Name")
|
||||
row.required = true
|
||||
row.isRequired = true
|
||||
section.addFormRow(row)
|
||||
|
||||
// Email
|
||||
row = XLFormRowDescriptor(tag: Tags.AccessoryViewEmail, rowType: XLFormRowDescriptorTypeEmail, title: "Email")
|
||||
// validate the email
|
||||
row.addValidator(XLFormValidator.emailValidator())
|
||||
row.addValidator(XLFormValidator.email())
|
||||
section.addFormRow(row)
|
||||
|
||||
// Twitter
|
||||
row = XLFormRowDescriptor(tag: Tags.AccessoryViewTwitter, rowType: XLFormRowDescriptorTypeTwitter, title: "Twitter")
|
||||
row.disabled = NSNumber(bool: true)
|
||||
row.disabled = NSNumber(value: true as Bool)
|
||||
row.value = "@no_editable"
|
||||
section.addFormRow(row)
|
||||
|
||||
@@ -125,7 +125,7 @@ class AccessoryViewFormViewController : XLFormViewController {
|
||||
|
||||
// Date
|
||||
row = XLFormRowDescriptor(tag: Tags.AccessoryViewDate, rowType:XLFormRowDescriptorTypeDateInline, title:"Date Inline")
|
||||
row.value = NSDate()
|
||||
row.value = Date()
|
||||
section.addFormRow(row)
|
||||
|
||||
|
||||
@@ -152,43 +152,43 @@ class AccessoryViewFormViewController : XLFormViewController {
|
||||
}
|
||||
|
||||
|
||||
override func inputAccessoryViewForRowDescriptor(rowDescriptor: XLFormRowDescriptor!) -> UIView! {
|
||||
if form.formRowWithTag(Tags.AccessoryViewRowNavigationShowAccessoryView)!.value!.boolValue == false {
|
||||
override func inputAccessoryView(for rowDescriptor: XLFormRowDescriptor!) -> UIView! {
|
||||
if (form.formRow(withTag: Tags.AccessoryViewRowNavigationShowAccessoryView)!.value! as AnyObject).boolValue == false {
|
||||
return nil
|
||||
}
|
||||
return super.inputAccessoryViewForRowDescriptor(rowDescriptor)
|
||||
return super.inputAccessoryView(for: rowDescriptor)
|
||||
}
|
||||
|
||||
|
||||
//MARK: XLFormDescriptorDelegate
|
||||
|
||||
override func formRowDescriptorValueHasChanged(formRow: XLFormRowDescriptor!, oldValue: AnyObject!, newValue: AnyObject!) {
|
||||
override func formRowDescriptorValueHasChanged(_ formRow: XLFormRowDescriptor!, oldValue: Any!, newValue: Any!) {
|
||||
super.formRowDescriptorValueHasChanged(formRow, oldValue: oldValue, newValue: newValue)
|
||||
if formRow.tag == Tags.AccessoryViewRowNavigationStopDisableRow {
|
||||
if formRow.value!.boolValue == true {
|
||||
form.rowNavigationOptions = form.rowNavigationOptions.union(.StopDisableRow)
|
||||
if (formRow.value! as AnyObject).boolValue == true {
|
||||
form.rowNavigationOptions = form.rowNavigationOptions.union(.stopDisableRow)
|
||||
}
|
||||
else{
|
||||
form.rowNavigationOptions = form.rowNavigationOptions.subtract(.StopDisableRow)
|
||||
form.rowNavigationOptions = form.rowNavigationOptions.subtracting(.stopDisableRow)
|
||||
}
|
||||
}
|
||||
else if formRow.tag == Tags.AccessoryViewRowNavigationStopInlineRow {
|
||||
if formRow.value!.boolValue == true {
|
||||
form.rowNavigationOptions = form.rowNavigationOptions.union(.StopInlineRow)
|
||||
if (formRow.value! as AnyObject).boolValue == true {
|
||||
form.rowNavigationOptions = form.rowNavigationOptions.union(.stopInlineRow)
|
||||
}
|
||||
else{
|
||||
var options = form.rowNavigationOptions
|
||||
options = options.subtract(XLFormRowNavigationOptions.StopInlineRow)
|
||||
options = options.subtracting(XLFormRowNavigationOptions.stopInlineRow)
|
||||
form.rowNavigationOptions = options
|
||||
}
|
||||
}
|
||||
else if formRow.tag == Tags.AccessoryViewRowNavigationSkipCanNotBecomeFirstResponderRow {
|
||||
if formRow.value!.boolValue == true {
|
||||
form.rowNavigationOptions = form.rowNavigationOptions.union(.SkipCanNotBecomeFirstResponderRow)
|
||||
if (formRow.value! as AnyObject).boolValue == true {
|
||||
form.rowNavigationOptions = form.rowNavigationOptions.union(.skipCanNotBecomeFirstResponderRow)
|
||||
}
|
||||
else{
|
||||
var options = form.rowNavigationOptions
|
||||
options = options.subtract(.SkipCanNotBecomeFirstResponderRow)
|
||||
options = options.subtracting(.skipCanNotBecomeFirstResponderRow)
|
||||
form.rowNavigationOptions = options
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
var window: UIWindow?
|
||||
|
||||
|
||||
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
|
||||
|
||||
// Declare custom rows
|
||||
XLFormViewController.cellClassesForRowDescriptorTypes()[XLFormRowDescriptorTypeRate] = "XLFormRatingCell"
|
||||
@@ -25,9 +25,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
XLFormViewController.inlineRowDescriptorTypesForRowDescriptorTypes()[XLFormRowDescriptorTypeSegmentedInline] = XLFormRowDescriptorTypeSegmentedControl
|
||||
|
||||
// Override point for customization after application launch.
|
||||
self.window = UIWindow.init(frame: UIScreen.mainScreen().bounds)
|
||||
self.window = UIWindow.init(frame: UIScreen.main.bounds)
|
||||
// Override point for customization after application launch.
|
||||
self.window!.backgroundColor = .whiteColor()
|
||||
self.window!.backgroundColor = .white
|
||||
|
||||
// load the initial form form Storybiard
|
||||
let storyboard = UIStoryboard.init(name:"iPhoneStoryboard", bundle:nil)
|
||||
@@ -36,25 +36,25 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
return true
|
||||
}
|
||||
|
||||
func applicationWillResignActive(application: UIApplication) {
|
||||
func applicationWillResignActive(_ application: UIApplication) {
|
||||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
}
|
||||
|
||||
func applicationDidEnterBackground(application: UIApplication) {
|
||||
func applicationDidEnterBackground(_ application: UIApplication) {
|
||||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
|
||||
}
|
||||
|
||||
func applicationWillEnterForeground(application: UIApplication) {
|
||||
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.
|
||||
}
|
||||
|
||||
func applicationDidBecomeActive(application: UIApplication) {
|
||||
func applicationDidBecomeActive(_ application: UIApplication) {
|
||||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||
}
|
||||
|
||||
func applicationWillTerminate(application: UIApplication) {
|
||||
func applicationWillTerminate(_ application: UIApplication) {
|
||||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
class CustomRowsViewController : XLFormViewController {
|
||||
|
||||
private struct Tags {
|
||||
fileprivate struct Tags {
|
||||
static let CustomRowFirstRatingTag = "CustomRowFirstRatingTag"
|
||||
static let CustomRowSecondRatingTag = "CustomRowSecondRatingTag"
|
||||
static let CustomRowFloatLabeledTextFieldTag = "CustomRowFloatLabeledTextFieldTag"
|
||||
@@ -33,7 +33,7 @@ class CustomRowsViewController : XLFormViewController {
|
||||
static let CustomRowInline = "CustomRowInline"
|
||||
}
|
||||
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
self.initializeForm()
|
||||
}
|
||||
@@ -64,7 +64,7 @@ class CustomRowsViewController : XLFormViewController {
|
||||
section.addFormRow(row)
|
||||
|
||||
// Section Float Labeled Text Field
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Float Labeled Text Field")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Float Labeled Text Field")
|
||||
form.addFormSection(section)
|
||||
|
||||
row = XLFormRowDescriptor(tag: Tags.CustomRowFloatLabeledTextFieldTag, rowType: XLFormRowDescriptorTypeFloatLabeledTextField, title: "Title")
|
||||
@@ -77,23 +77,23 @@ class CustomRowsViewController : XLFormViewController {
|
||||
section.addFormRow(row)
|
||||
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Weekdays")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Weekdays")
|
||||
form.addFormSection(section)
|
||||
|
||||
// WeekDays
|
||||
row = XLFormRowDescriptor(tag: Tags.CustomRowWeekdays, rowType: XLFormRowDescriptorTypeWeekDays)
|
||||
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
|
||||
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.formSectionWithTitle("Custom inline row")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Custom inline row")
|
||||
form.addFormSection(section)
|
||||
|
||||
// Inline
|
||||
|
||||
+20
-20
@@ -35,9 +35,9 @@ class FloatLabeledTextFieldCell : XLFormBaseCell, UITextFieldDelegate {
|
||||
lazy var floatLabeledTextField: JVFloatLabeledTextField = {
|
||||
let result = JVFloatLabeledTextField(frame: CGRect.zero)
|
||||
result.translatesAutoresizingMaskIntoConstraints = false
|
||||
result.font = UIFont.systemFontOfSize(kFontSize)
|
||||
result.floatingLabel.font = .boldSystemFontOfSize(kFontSize)
|
||||
result.clearButtonMode = .WhileEditing
|
||||
result.font = UIFont.systemFont(ofSize: kFontSize)
|
||||
result.floatingLabel.font = .boldSystemFont(ofSize: kFontSize)
|
||||
result.clearButtonMode = .whileEditing
|
||||
return result
|
||||
}()
|
||||
|
||||
@@ -45,7 +45,7 @@ class FloatLabeledTextFieldCell : XLFormBaseCell, UITextFieldDelegate {
|
||||
|
||||
override func configure() {
|
||||
super.configure()
|
||||
selectionStyle = .None
|
||||
selectionStyle = .none
|
||||
contentView.addSubview(self.floatLabeledTextField)
|
||||
floatLabeledTextField.delegate = self
|
||||
contentView.addConstraints(layoutConstraints())
|
||||
@@ -54,15 +54,15 @@ class FloatLabeledTextFieldCell : XLFormBaseCell, UITextFieldDelegate {
|
||||
override func update() {
|
||||
super.update()
|
||||
if let rowDescriptor = rowDescriptor {
|
||||
floatLabeledTextField.attributedPlaceholder = NSAttributedString(string: rowDescriptor.title ?? "" , attributes: [NSForegroundColorAttributeName: UIColor.lightGrayColor()])
|
||||
floatLabeledTextField.attributedPlaceholder = NSAttributedString(string: rowDescriptor.title ?? "" , attributes: [NSForegroundColorAttributeName: UIColor.lightGray])
|
||||
if let value = rowDescriptor.value {
|
||||
floatLabeledTextField.text = value.displayText()
|
||||
floatLabeledTextField.text = (value as AnyObject).displayText()
|
||||
}
|
||||
else {
|
||||
floatLabeledTextField.text = rowDescriptor.noValueDisplayText
|
||||
}
|
||||
floatLabeledTextField.enabled = !rowDescriptor.isDisabled()
|
||||
floatLabeledTextField.floatingLabelTextColor = .lightGrayColor()
|
||||
floatLabeledTextField.isEnabled = !rowDescriptor.isDisabled()
|
||||
floatLabeledTextField.floatingLabelTextColor = .lightGray
|
||||
floatLabeledTextField.alpha = rowDescriptor.isDisabled() ? 0.6 : 1.0
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ class FloatLabeledTextFieldCell : XLFormBaseCell, UITextFieldDelegate {
|
||||
return self.floatLabeledTextField.becomeFirstResponder()
|
||||
}
|
||||
|
||||
override static func formDescriptorCellHeightForRowDescriptor(rowDescriptor: XLFormRowDescriptor!) -> CGFloat {
|
||||
override static func formDescriptorCellHeight(for rowDescriptor: XLFormRowDescriptor!) -> CGFloat {
|
||||
return 55.0
|
||||
}
|
||||
|
||||
@@ -86,12 +86,12 @@ class FloatLabeledTextFieldCell : XLFormBaseCell, UITextFieldDelegate {
|
||||
func layoutConstraints() -> [NSLayoutConstraint]{
|
||||
let views = ["floatLabeledTextField" : floatLabeledTextField]
|
||||
let metrics = ["hMargin": 15.0, "vMargin": 8.0]
|
||||
var result = NSLayoutConstraint.constraintsWithVisualFormat("H:|-(hMargin)-[floatLabeledTextField]-(hMargin)-|", options:.AlignAllCenterY, metrics:metrics, views:views)
|
||||
result += NSLayoutConstraint.constraintsWithVisualFormat("V:|-(vMargin)-[floatLabeledTextField]-(vMargin)-|", options:.AlignAllCenterX, metrics:metrics, views:views)
|
||||
var result = NSLayoutConstraint.constraints(withVisualFormat: "H:|-(hMargin)-[floatLabeledTextField]-(hMargin)-|", options:.alignAllCenterY, metrics:metrics, views:views)
|
||||
result += NSLayoutConstraint.constraints(withVisualFormat: "V:|-(vMargin)-[floatLabeledTextField]-(vMargin)-|", options:.alignAllCenterX, metrics:metrics, views:views)
|
||||
return result
|
||||
}
|
||||
|
||||
func textFieldDidChange(textField : UITextField) {
|
||||
func textFieldDidChange(_ textField : UITextField) {
|
||||
if floatLabeledTextField == textField {
|
||||
if let rowDescriptor = rowDescriptor, let text = self.floatLabeledTextField.text {
|
||||
if text.isEmpty == false {
|
||||
@@ -105,34 +105,34 @@ class FloatLabeledTextFieldCell : XLFormBaseCell, UITextFieldDelegate {
|
||||
|
||||
//Mark: UITextFieldDelegate
|
||||
|
||||
func textFieldShouldClear(textField: UITextField) -> Bool {
|
||||
func textFieldShouldClear(_ textField: UITextField) -> Bool {
|
||||
return self.formViewController().textFieldShouldClear(textField)
|
||||
}
|
||||
|
||||
func textFieldShouldReturn(textField: UITextField) -> Bool {
|
||||
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||
return self.formViewController().textFieldShouldReturn(textField)
|
||||
}
|
||||
|
||||
func textFieldShouldBeginEditing(textField: UITextField) -> Bool {
|
||||
func textFieldShouldBeginEditing(_ textField: UITextField) -> Bool {
|
||||
return self.formViewController().textFieldShouldBeginEditing(textField)
|
||||
}
|
||||
|
||||
|
||||
func textFieldShouldEndEditing(textField: UITextField) -> Bool {
|
||||
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 textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
|
||||
return self.formViewController().textField(textField, shouldChangeCharactersIn: range, replacementString: string)
|
||||
}
|
||||
|
||||
func textFieldDidBeginEditing(textField: UITextField) {
|
||||
func textFieldDidBeginEditing(_ textField: UITextField) {
|
||||
self.formViewController().textFieldDidBeginEditing(textField)
|
||||
}
|
||||
|
||||
|
||||
func textFieldDidEndEditing(textField: UITextField) {
|
||||
func textFieldDidEndEditing(_ textField: UITextField) {
|
||||
self.textFieldDidChange(textField)
|
||||
self.formViewController().textFieldDidEndEditing(textField)
|
||||
}
|
||||
|
||||
+27
-27
@@ -14,18 +14,18 @@ let XLFormRowDescriptorTypeSegmentedControl = "XLFormRowDescriptorTypeSegmentedC
|
||||
|
||||
class InlineSegmentedCell : XLFormBaseCell {
|
||||
|
||||
override func canBecomeFirstResponder() -> Bool {
|
||||
override var canBecomeFirstResponder : Bool {
|
||||
return true
|
||||
}
|
||||
|
||||
override func becomeFirstResponder() -> Bool {
|
||||
if isFirstResponder() {
|
||||
if isFirstResponder {
|
||||
return super.becomeFirstResponder()
|
||||
}
|
||||
let result = super.becomeFirstResponder()
|
||||
if result {
|
||||
let inlineRowDescriptor : XLFormRowDescriptor = XLFormRowDescriptor(tag: nil, rowType: XLFormViewController.inlineRowDescriptorTypesForRowDescriptorTypes()![rowDescriptor!.rowType] as! String)
|
||||
let cell = inlineRowDescriptor.cellForFormController(formViewController())
|
||||
let cell = inlineRowDescriptor.cell(forForm: formViewController())
|
||||
let inlineCell = cell as? XLFormInlineRowDescriptorCell
|
||||
inlineCell?.inlineRowDescriptor = rowDescriptor
|
||||
rowDescriptor?.sectionDescriptor.addFormRow(inlineRowDescriptor, afterRow: rowDescriptor!)
|
||||
@@ -35,13 +35,13 @@ class InlineSegmentedCell : XLFormBaseCell {
|
||||
}
|
||||
|
||||
override func resignFirstResponder() -> Bool {
|
||||
if isFirstResponder() {
|
||||
if !isFirstResponder {
|
||||
return super.resignFirstResponder()
|
||||
}
|
||||
let selectedRowPath : NSIndexPath = formViewController().form.indexPathOfFormRow(rowDescriptor!)!
|
||||
let nextRowPath = NSIndexPath(forRow: selectedRowPath.row + 1, inSection: selectedRowPath.section)
|
||||
let nextFormRow = formViewController().form.formRowAtIndex(nextRowPath)
|
||||
let section : XLFormSectionDescriptor = formViewController().form.formSectionAtIndex(UInt(nextRowPath.section))!
|
||||
let selectedRowPath : IndexPath = formViewController().form.indexPath(ofFormRow: rowDescriptor!)!
|
||||
let nextRowPath = IndexPath(row: (selectedRowPath as NSIndexPath).row + 1, section: (selectedRowPath as NSIndexPath).section)
|
||||
let nextFormRow = formViewController().form.formRow(atIndex: nextRowPath)
|
||||
let section : XLFormSectionDescriptor = formViewController().form.formSection(at: UInt((nextRowPath as NSIndexPath).section))!
|
||||
let result = super.resignFirstResponder()
|
||||
if result {
|
||||
section.removeFormRow(nextFormRow!)
|
||||
@@ -56,7 +56,7 @@ class InlineSegmentedCell : XLFormBaseCell {
|
||||
}
|
||||
|
||||
override func formDescriptorCellBecomeFirstResponder() -> Bool {
|
||||
if isFirstResponder() {
|
||||
if isFirstResponder {
|
||||
resignFirstResponder()
|
||||
return false
|
||||
}
|
||||
@@ -65,20 +65,20 @@ class InlineSegmentedCell : XLFormBaseCell {
|
||||
|
||||
override func update() {
|
||||
super.update()
|
||||
accessoryType = .None
|
||||
editingAccessoryType = .None
|
||||
selectionStyle = .None
|
||||
accessoryType = .none
|
||||
editingAccessoryType = .none
|
||||
selectionStyle = .none
|
||||
textLabel?.text = rowDescriptor?.title
|
||||
detailTextLabel?.text = valueDisplayText()
|
||||
}
|
||||
|
||||
override func formDescriptorCellDidSelectedWithFormController(controller: XLFormViewController!) {
|
||||
controller.tableView.deselectRowAtIndexPath(controller.form.indexPathOfFormRow(rowDescriptor!)!, animated: true)
|
||||
override func formDescriptorCellDidSelected(withForm controller: XLFormViewController!) {
|
||||
controller.tableView.deselectRow(at: controller.form.indexPath(ofFormRow: rowDescriptor!)!, animated: true)
|
||||
}
|
||||
|
||||
func valueDisplayText() -> String? {
|
||||
if let value = rowDescriptor?.value {
|
||||
return value.displayText()
|
||||
return (value as AnyObject).displayText()
|
||||
}
|
||||
return rowDescriptor?.noValueDisplayText
|
||||
}
|
||||
@@ -93,17 +93,17 @@ class InlineSegmentedControl : XLFormBaseCell, XLFormInlineRowDescriptorCell {
|
||||
|
||||
override func configure() {
|
||||
super.configure()
|
||||
selectionStyle = .None
|
||||
selectionStyle = .none
|
||||
contentView.addSubview(segmentedControl)
|
||||
contentView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|-[segmentedControl]-|", options: .AlignAllCenterY, metrics: nil, views: ["segmentedControl": segmentedControl]))
|
||||
segmentedControl.addTarget(self, action: "valueChanged", forControlEvents: .ValueChanged)
|
||||
contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-[segmentedControl]-|", options: .alignAllCenterY, metrics: nil, views: ["segmentedControl": segmentedControl]))
|
||||
segmentedControl.addTarget(self, action: #selector(InlineSegmentedControl.valueChanged), for: .valueChanged)
|
||||
}
|
||||
|
||||
override func update() {
|
||||
super.update()
|
||||
updateSegmentedControl()
|
||||
segmentedControl.selectedSegmentIndex = selectedIndex()
|
||||
segmentedControl.enabled = rowDescriptor?.isDisabled() == false
|
||||
segmentedControl.isEnabled = rowDescriptor?.isDisabled() == false
|
||||
}
|
||||
|
||||
//MARK: Actions
|
||||
@@ -118,27 +118,27 @@ class InlineSegmentedControl : XLFormBaseCell, XLFormInlineRowDescriptorCell {
|
||||
func getItems() -> NSMutableArray {
|
||||
let result = NSMutableArray()
|
||||
for option in inlineRowDescriptor!.selectorOptions! {
|
||||
result.addObject(option.displayText())
|
||||
result.add((option as AnyObject).displayText())
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func updateSegmentedControl() {
|
||||
segmentedControl.removeAllSegments()
|
||||
getItems().enumerateObjectsUsingBlock { [weak self] object, index, stop in
|
||||
self?.segmentedControl.insertSegmentWithTitle(object.displayText(), atIndex: index, animated: false)
|
||||
}
|
||||
getItems().enumerateObjects({ [weak self] (object, index, stop) in
|
||||
self?.segmentedControl.insertSegment(withTitle: (object as AnyObject).displayText(), at: index, animated: false)
|
||||
})
|
||||
}
|
||||
|
||||
func selectedIndex() -> Int {
|
||||
let formRow = inlineRowDescriptor ?? rowDescriptor
|
||||
if let value = formRow?.value {
|
||||
if let value = formRow?.value as? NSObject {
|
||||
for option in (formRow?.selectorOptions)! {
|
||||
if option.valueData().isEqual(value.valueData()){
|
||||
return formRow?.selectorOptions?.indexOf({ $0.isEqual(option) }) ?? -1
|
||||
if ((option as! NSObject).valueData() as AnyObject) === (value.valueData() as AnyObject) {
|
||||
return formRow?.selectorOptions?.index(where: { ($0 as! NSObject) == (option as! NSObject) } ) ?? -1
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class XLRatingView : AXRatingView {
|
||||
func customize() {
|
||||
baseColor = UIColor(red: (205/255.0), green: (201/255.0), blue: (201/255.0), alpha: 1)
|
||||
highlightColor = UIColor(red: (255/255.0), green: (215/255.0), blue: 0, alpha: 1)
|
||||
markFont = UIFont.systemFontOfSize(23.0)
|
||||
markFont = UIFont.systemFont(ofSize: 23.0)
|
||||
stepInterval = 1.0
|
||||
}
|
||||
|
||||
|
||||
@@ -34,14 +34,14 @@ class XLFormRatingCell : XLFormBaseCell {
|
||||
|
||||
override func configure() {
|
||||
super.configure()
|
||||
selectionStyle = .None
|
||||
ratingView.addTarget(self, action: "rateChanged:", forControlEvents:.ValueChanged)
|
||||
selectionStyle = .none
|
||||
ratingView.addTarget(self, action: #selector(XLFormRatingCell.rateChanged(_:)), for:.valueChanged)
|
||||
}
|
||||
|
||||
|
||||
override func update() {
|
||||
super.update()
|
||||
ratingView.value = rowDescriptor!.value!.floatValue
|
||||
ratingView.value = (rowDescriptor!.value! as AnyObject).floatValue
|
||||
rateTitle.text = rowDescriptor!.title
|
||||
ratingView.alpha = rowDescriptor!.isDisabled() ? 0.6 : 1
|
||||
rateTitle.alpha = rowDescriptor!.isDisabled() ? 0.6 : 1
|
||||
@@ -49,7 +49,7 @@ class XLFormRatingCell : XLFormBaseCell {
|
||||
|
||||
//MARK: Events
|
||||
|
||||
func rateChanged(ratingView : XLRatingView){
|
||||
func rateChanged(_ ratingView : XLRatingView){
|
||||
rowDescriptor!.value = ratingView.value
|
||||
}
|
||||
|
||||
|
||||
@@ -30,29 +30,29 @@ class XLFormWeekDaysCell : XLFormBaseCell {
|
||||
|
||||
enum kWeekDay: Int {
|
||||
case
|
||||
Sunday = 1,
|
||||
Monday,
|
||||
Tuesday,
|
||||
Wednesday,
|
||||
Thursday,
|
||||
Friday,
|
||||
Saturday
|
||||
sunday = 1,
|
||||
monday,
|
||||
tuesday,
|
||||
wednesday,
|
||||
thursday,
|
||||
friday,
|
||||
saturday
|
||||
|
||||
func description() -> String {
|
||||
switch self {
|
||||
case .Sunday:
|
||||
case .sunday:
|
||||
return "Sunday"
|
||||
case .Monday:
|
||||
case .monday:
|
||||
return "Monday"
|
||||
case .Tuesday:
|
||||
case .tuesday:
|
||||
return "Tuesday"
|
||||
case .Wednesday:
|
||||
case .wednesday:
|
||||
return "Wednesday"
|
||||
case .Thursday:
|
||||
case .thursday:
|
||||
return "Thursday"
|
||||
case .Friday:
|
||||
case .friday:
|
||||
return "Friday"
|
||||
case .Saturday:
|
||||
case .saturday:
|
||||
return "Saturday"
|
||||
}
|
||||
}
|
||||
@@ -60,13 +60,13 @@ class XLFormWeekDaysCell : XLFormBaseCell {
|
||||
//Add Custom Functions
|
||||
|
||||
//Allows for iteration as needed (for in ...)
|
||||
static let allValues = [Sunday,
|
||||
Monday,
|
||||
Tuesday,
|
||||
Wednesday,
|
||||
Thursday,
|
||||
Friday,
|
||||
Saturday]
|
||||
static let allValues = [sunday,
|
||||
monday,
|
||||
tuesday,
|
||||
wednesday,
|
||||
thursday,
|
||||
friday,
|
||||
saturday]
|
||||
}
|
||||
|
||||
@IBOutlet weak var sundayButton: UIButton!
|
||||
@@ -81,7 +81,7 @@ class XLFormWeekDaysCell : XLFormBaseCell {
|
||||
|
||||
override func configure() {
|
||||
super.configure()
|
||||
selectionStyle = .None
|
||||
selectionStyle = .none
|
||||
configureButtons()
|
||||
}
|
||||
|
||||
@@ -91,17 +91,17 @@ class XLFormWeekDaysCell : XLFormBaseCell {
|
||||
updateButtons()
|
||||
}
|
||||
|
||||
override static func formDescriptorCellHeightForRowDescriptor(rowDescriptor: XLFormRowDescriptor!) -> CGFloat {
|
||||
override static func formDescriptorCellHeight(for rowDescriptor: XLFormRowDescriptor!) -> CGFloat {
|
||||
return 60
|
||||
}
|
||||
|
||||
//MARK: - Action
|
||||
|
||||
@IBAction func dayTapped(sender: UIButton) {
|
||||
@IBAction func dayTapped(_ sender: UIButton) {
|
||||
let day = getDayFormButton(sender)
|
||||
sender.selected = !sender.selected
|
||||
sender.isSelected = !sender.isSelected
|
||||
var newValue = rowDescriptor!.value as! Dictionary<String, Bool>
|
||||
newValue[day] = sender.selected
|
||||
newValue[day] = sender.isSelected
|
||||
rowDescriptor!.value = newValue
|
||||
}
|
||||
|
||||
@@ -110,8 +110,8 @@ class XLFormWeekDaysCell : XLFormBaseCell {
|
||||
func configureButtons() {
|
||||
for subview in contentView.subviews {
|
||||
if let button = subview as? UIButton {
|
||||
button.setImage(UIImage(named: "uncheckedDay"), forState: .Normal)
|
||||
button.setImage(UIImage(named: "checkedDay"), forState: .Selected)
|
||||
button.setImage(UIImage(named: "uncheckedDay"), for: UIControlState())
|
||||
button.setImage(UIImage(named: "checkedDay"), for: .selected)
|
||||
button.adjustsImageWhenHighlighted = false
|
||||
imageTopTitleBottom(button)
|
||||
}
|
||||
@@ -122,13 +122,13 @@ class XLFormWeekDaysCell : XLFormBaseCell {
|
||||
func updateButtons() {
|
||||
var value = rowDescriptor!.value as! Dictionary<String, Bool>
|
||||
|
||||
sundayButton.selected = value[kWeekDay.Sunday.description()]!
|
||||
mondayButton.selected = value[kWeekDay.Monday.description()]!
|
||||
tuesdayButton.selected = value[kWeekDay.Tuesday.description()]!
|
||||
wednesdayButton.selected = value[kWeekDay.Wednesday.description()]!
|
||||
thursdayButton.selected = value[kWeekDay.Thursday.description()]!
|
||||
fridayButton.selected = value[kWeekDay.Friday.description()]!
|
||||
saturdayButton.selected = value[kWeekDay.Saturday.description()]!
|
||||
sundayButton.isSelected = value[kWeekDay.sunday.description()]!
|
||||
mondayButton.isSelected = value[kWeekDay.monday.description()]!
|
||||
tuesdayButton.isSelected = value[kWeekDay.tuesday.description()]!
|
||||
wednesdayButton.isSelected = value[kWeekDay.wednesday.description()]!
|
||||
thursdayButton.isSelected = value[kWeekDay.thursday.description()]!
|
||||
fridayButton.isSelected = value[kWeekDay.friday.description()]!
|
||||
saturdayButton.isSelected = value[kWeekDay.saturday.description()]!
|
||||
|
||||
sundayButton.alpha = rowDescriptor!.isDisabled() ? 0.6 : 1
|
||||
mondayButton.alpha = mondayButton.alpha
|
||||
@@ -139,7 +139,7 @@ class XLFormWeekDaysCell : XLFormBaseCell {
|
||||
saturdayButton.alpha = mondayButton.alpha
|
||||
}
|
||||
|
||||
func imageTopTitleBottom(button: UIButton) {
|
||||
func imageTopTitleBottom(_ button: UIButton) {
|
||||
// the space between the image and text
|
||||
let spacing : CGFloat = 3.0
|
||||
|
||||
@@ -150,26 +150,26 @@ class XLFormWeekDaysCell : XLFormBaseCell {
|
||||
|
||||
// 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])
|
||||
let titleSize : CGSize = (button.titleLabel!.text! as NSString).size(attributes: [NSFontAttributeName: button.titleLabel!.font])
|
||||
button.imageEdgeInsets = UIEdgeInsetsMake(-(titleSize.height + spacing), 0.0, 0.0, -titleSize.width)
|
||||
}
|
||||
|
||||
func getDayFormButton(button: UIButton) -> String {
|
||||
func getDayFormButton(_ button: UIButton) -> String {
|
||||
switch button {
|
||||
case sundayButton:
|
||||
return kWeekDay.Sunday.description()
|
||||
return kWeekDay.sunday.description()
|
||||
case mondayButton:
|
||||
return kWeekDay.Monday.description()
|
||||
return kWeekDay.monday.description()
|
||||
case tuesdayButton:
|
||||
return kWeekDay.Tuesday.description()
|
||||
return kWeekDay.tuesday.description()
|
||||
case wednesdayButton:
|
||||
return kWeekDay.Wednesday.description()
|
||||
return kWeekDay.wednesday.description()
|
||||
case thursdayButton:
|
||||
return kWeekDay.Thursday.description()
|
||||
return kWeekDay.thursday.description()
|
||||
case fridayButton:
|
||||
return kWeekDay.Friday.description()
|
||||
return kWeekDay.friday.description()
|
||||
default:
|
||||
return kWeekDay.Saturday.description()
|
||||
return kWeekDay.saturday.description()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,12 +28,12 @@ import MapKit
|
||||
|
||||
class CustomSelectorsFormViewController : XLFormViewController {
|
||||
|
||||
private struct Tags {
|
||||
fileprivate struct Tags {
|
||||
static let SelectorMap = "selectorMap"
|
||||
static let SelectorMapPopover = "selectorMapPopover"
|
||||
}
|
||||
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
initializeForm()
|
||||
}
|
||||
@@ -51,7 +51,7 @@ class CustomSelectorsFormViewController : XLFormViewController {
|
||||
|
||||
form = XLFormDescriptor(title: "Custom Selectors")
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("TextField Types")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "TextField Types")
|
||||
section.footerTitle = "CustomSelectorsFormViewController.swift"
|
||||
form.addFormSection(section)
|
||||
|
||||
@@ -62,7 +62,7 @@ class CustomSelectorsFormViewController : XLFormViewController {
|
||||
row.value = CLLocation(latitude: -33, longitude: -56)
|
||||
section.addFormRow(row)
|
||||
|
||||
if UIDevice.currentDevice().userInterfaceIdiom == .Pad {
|
||||
if UIDevice.current.userInterfaceIdiom == .pad {
|
||||
// Selector PopOver
|
||||
row = XLFormRowDescriptor(tag: Tags.SelectorMapPopover, rowType: XLFormRowDescriptorTypeSelectorPopover, title: "Coordinate PopOver")
|
||||
row.action.viewControllerClass = MapViewController.self
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@
|
||||
|
||||
import MapKit
|
||||
|
||||
class CLLocationValueTrasformer : NSValueTransformer {
|
||||
class CLLocationValueTrasformer : ValueTransformer {
|
||||
|
||||
override class func transformedValueClass() -> AnyClass {
|
||||
return NSString.self
|
||||
@@ -37,7 +37,7 @@ class CLLocationValueTrasformer : NSValueTransformer {
|
||||
return false
|
||||
}
|
||||
|
||||
override func transformedValue(value: AnyObject?) -> AnyObject? {
|
||||
override func transformedValue(_ value: Any?) -> Any? {
|
||||
if let valueData = value, let location = valueData as? CLLocation{
|
||||
return String(format: "%0.4f, %0.4f", location.coordinate.latitude, location.coordinate.longitude)
|
||||
}
|
||||
|
||||
+8
-8
@@ -42,11 +42,11 @@ class MapViewController : UIViewController, XLFormRowDescriptorViewController, M
|
||||
var rowDescriptor: XLFormRowDescriptor?
|
||||
lazy var mapView : MKMapView = { [unowned self] in
|
||||
let mapView = MKMapView(frame: self.view.frame)
|
||||
mapView.autoresizingMask = [UIViewAutoresizing.FlexibleHeight, UIViewAutoresizing.FlexibleWidth]
|
||||
mapView.autoresizingMask = [UIViewAutoresizing.flexibleHeight, UIViewAutoresizing.flexibleWidth]
|
||||
return mapView
|
||||
}()
|
||||
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class MapViewController : UIViewController, XLFormRowDescriptorViewController, M
|
||||
view.addSubview(mapView)
|
||||
mapView.delegate = self
|
||||
if let value = rowDescriptor?.value as? CLLocation {
|
||||
mapView.setCenterCoordinate(value.coordinate, animated: false)
|
||||
mapView.setCenter(value.coordinate, animated: false)
|
||||
title = String(format: "%0.4f, %0.4f", mapView.centerCoordinate.latitude, mapView.centerCoordinate.longitude)
|
||||
let annotation = MapAnnotation()
|
||||
annotation.coordinate = value.coordinate
|
||||
@@ -70,18 +70,18 @@ class MapViewController : UIViewController, XLFormRowDescriptorViewController, M
|
||||
|
||||
//MARK - - MKMapViewDelegate
|
||||
|
||||
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
|
||||
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
|
||||
|
||||
let pinAnnotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: "annotation")
|
||||
pinAnnotationView.pinColor = MKPinAnnotationColor.Red
|
||||
pinAnnotationView.draggable = true
|
||||
pinAnnotationView.pinColor = MKPinAnnotationColor.red
|
||||
pinAnnotationView.isDraggable = true
|
||||
pinAnnotationView.animatesDrop = true
|
||||
return pinAnnotationView
|
||||
}
|
||||
|
||||
|
||||
func mapView(mapView: MKMapView, annotationView view: MKAnnotationView, didChangeDragState newState: MKAnnotationViewDragState, fromOldState oldState: MKAnnotationViewDragState) {
|
||||
if (newState == .Ending){
|
||||
func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, didChange newState: MKAnnotationViewDragState, fromOldState oldState: MKAnnotationViewDragState) {
|
||||
if (newState == .ending){
|
||||
if let rowDescriptor = rowDescriptor, let annotation = view.annotation {
|
||||
rowDescriptor.value = CLLocation(latitude:annotation.coordinate.latitude, longitude:annotation.coordinate.longitude)
|
||||
self.title = String(format: "%0.4f, %0.4f", annotation.coordinate.latitude, annotation.coordinate.longitude)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
class DateValueTrasformer : NSValueTransformer {
|
||||
class DateValueTrasformer : ValueTransformer {
|
||||
|
||||
override class func transformedValueClass() -> AnyClass {
|
||||
return NSString.self
|
||||
@@ -34,18 +34,18 @@ class DateValueTrasformer : NSValueTransformer {
|
||||
return false
|
||||
}
|
||||
|
||||
override func transformedValue(value: AnyObject?) -> AnyObject? {
|
||||
if let date = value as? NSDate {
|
||||
let dateFormatter = NSDateFormatter()
|
||||
dateFormatter.dateStyle = .FullStyle
|
||||
dateFormatter.timeStyle = .NoStyle
|
||||
return dateFormatter.stringFromDate(date)
|
||||
override func transformedValue(_ value: Any?) -> Any? {
|
||||
if let date = value as? Date {
|
||||
let dateFormatter = DateFormatter()
|
||||
dateFormatter.dateStyle = .full
|
||||
dateFormatter.timeStyle = .none
|
||||
return dateFormatter.string(from: date)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
class DateTimeValueTrasformer: NSValueTransformer {
|
||||
class DateTimeValueTrasformer: ValueTransformer {
|
||||
|
||||
override class func transformedValueClass() -> AnyClass {
|
||||
return NSString.self
|
||||
@@ -56,12 +56,12 @@ class DateTimeValueTrasformer: NSValueTransformer {
|
||||
return false
|
||||
}
|
||||
|
||||
override func transformedValue(value: AnyObject?) -> AnyObject? {
|
||||
if let date = value as? NSDate {
|
||||
let dateFormatter = NSDateFormatter()
|
||||
dateFormatter.dateStyle = .MediumStyle
|
||||
dateFormatter.timeStyle = .ShortStyle
|
||||
return dateFormatter.stringFromDate(date)
|
||||
override func transformedValue(_ value: Any?) -> Any? {
|
||||
if let date = value as? Date {
|
||||
let dateFormatter = DateFormatter()
|
||||
dateFormatter.dateStyle = .medium
|
||||
dateFormatter.timeStyle = .short
|
||||
return dateFormatter.string(from: date)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
class DatesFormViewController: XLFormViewController {
|
||||
|
||||
private struct Tags {
|
||||
fileprivate struct Tags {
|
||||
static let DateInline = "dateInline"
|
||||
static let TimeInline = "timeInline"
|
||||
static let DateTimeInline = "dateTimeInline"
|
||||
@@ -38,7 +38,7 @@ class DatesFormViewController: XLFormViewController {
|
||||
static let CountDownTimer = "countDownTimer"
|
||||
}
|
||||
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
initializeForm()
|
||||
}
|
||||
@@ -50,15 +50,15 @@ class DatesFormViewController: XLFormViewController {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
let barButton = UIBarButtonItem(title: "Disable", style: .Plain, target: self, action: "disableEnable:")
|
||||
let barButton = UIBarButtonItem(title: "Disable", style: .plain, target: self, action: #selector(DatesFormViewController.disableEnable(_:)))
|
||||
barButton.possibleTitles = Set(["Disable", "Enable"])
|
||||
navigationItem.rightBarButtonItem = barButton
|
||||
}
|
||||
|
||||
|
||||
func disableEnable(button : UIBarButtonItem){
|
||||
form.disabled = !form.disabled
|
||||
button.title = form.disabled ? "Enable" : "Disable"
|
||||
func disableEnable(_ button : UIBarButtonItem){
|
||||
form.isDisabled = !form.isDisabled
|
||||
button.title = form.isDisabled ? "Enable" : "Disable"
|
||||
tableView.endEditing(true)
|
||||
tableView.reloadData()
|
||||
}
|
||||
@@ -70,78 +70,78 @@ class DatesFormViewController: XLFormViewController {
|
||||
|
||||
form = XLFormDescriptor(title: "Date & Time")
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Inline Dates")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Inline Dates")
|
||||
form.addFormSection(section)
|
||||
|
||||
// Date
|
||||
row = XLFormRowDescriptor(tag: Tags.DateInline, rowType: XLFormRowDescriptorTypeDateInline, title:"Date")
|
||||
row.value = NSDate()
|
||||
row.value = Date()
|
||||
section.addFormRow(row)
|
||||
|
||||
// Time
|
||||
row = XLFormRowDescriptor(tag: Tags.TimeInline, rowType: XLFormRowDescriptorTypeTimeInline, title: "Time")
|
||||
row.value = NSDate()
|
||||
row.value = Date()
|
||||
section.addFormRow(row)
|
||||
|
||||
// DateTime
|
||||
row = XLFormRowDescriptor(tag: Tags.DateTimeInline, rowType: XLFormRowDescriptorTypeDateTimeInline, title: "Date Time")
|
||||
row.value = NSDate()
|
||||
row.value = Date()
|
||||
section.addFormRow(row)
|
||||
|
||||
// CountDownTimer
|
||||
row = XLFormRowDescriptor(tag: Tags.CountDownTimerInline, rowType:XLFormRowDescriptorTypeCountDownTimerInline, title:"Countdown Timer")
|
||||
row.value = NSDate()
|
||||
row.value = Date()
|
||||
section.addFormRow(row)
|
||||
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Dates") //
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Dates") //
|
||||
form.addFormSection(section)
|
||||
|
||||
|
||||
// Date
|
||||
row = XLFormRowDescriptor(tag: Tags.Date, rowType:XLFormRowDescriptorTypeDate, title:"Date")
|
||||
row.value = NSDate()
|
||||
row.cellConfigAtConfigure["minimumDate"] = NSDate()
|
||||
row.cellConfigAtConfigure["maximumDate"] = NSDate(timeIntervalSinceNow: 60*60*24*3)
|
||||
row.value = Date()
|
||||
row.cellConfigAtConfigure["minimumDate"] = Date()
|
||||
row.cellConfigAtConfigure["maximumDate"] = Date(timeIntervalSinceNow: 60*60*24*3)
|
||||
section.addFormRow(row)
|
||||
|
||||
// Time
|
||||
row = XLFormRowDescriptor(tag: Tags.Time, rowType: XLFormRowDescriptorTypeTime, title: "Time")
|
||||
row.cellConfigAtConfigure["minuteInterval"] = 10
|
||||
row.value = NSDate()
|
||||
row.value = Date()
|
||||
section.addFormRow(row)
|
||||
|
||||
// DateTime
|
||||
row = XLFormRowDescriptor(tag: Tags.DateTime, rowType: XLFormRowDescriptorTypeDateTime, title: "Date Time")
|
||||
row.value = NSDate()
|
||||
row.value = Date()
|
||||
section.addFormRow(row)
|
||||
|
||||
// CountDownTimer
|
||||
row = XLFormRowDescriptor(tag: Tags.CountDownTimer, rowType: XLFormRowDescriptorTypeCountDownTimer, title: "Countdown Timer")
|
||||
row.value = NSDate()
|
||||
row.value = Date()
|
||||
section.addFormRow(row)
|
||||
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Disabled Dates")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "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()
|
||||
row.disabled = NSNumber(value: true as Bool)
|
||||
row.isRequired = true
|
||||
row.value = Date()
|
||||
section.addFormRow(row)
|
||||
|
||||
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("DatePicker")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "DatePicker")
|
||||
form.addFormSection(section)
|
||||
|
||||
// DatePicker
|
||||
row = XLFormRowDescriptor(tag: Tags.DatePicker, rowType:XLFormRowDescriptorTypeDatePicker)
|
||||
row.cellConfigAtConfigure["datePicker.datePickerMode"] = UIDatePickerMode.Date.rawValue
|
||||
row.value = NSDate()
|
||||
row.cellConfigAtConfigure["datePicker.datePickerMode"] = UIDatePickerMode.date.rawValue
|
||||
row.value = Date()
|
||||
section.addFormRow(row)
|
||||
|
||||
|
||||
@@ -150,8 +150,7 @@ class DatesFormViewController: XLFormViewController {
|
||||
|
||||
|
||||
// MARK: - XLFormDescriptorDelegate
|
||||
|
||||
override func formRowDescriptorValueHasChanged(formRow: XLFormRowDescriptor!, oldValue: AnyObject!, newValue: AnyObject!) {
|
||||
override func formRowDescriptorValueHasChanged(_ formRow: XLFormRowDescriptor!, oldValue: Any!, newValue: Any!) {
|
||||
super.formRowDescriptorValueHasChanged(formRow, oldValue: oldValue, newValue: newValue)
|
||||
if formRow.tag == Tags.DatePicker {
|
||||
let alertView = UIAlertView(title: "DatePicker", message: "Value Has changed!", delegate: self, cancelButtonTitle: "OK")
|
||||
|
||||
+3
-3
@@ -25,7 +25,7 @@
|
||||
|
||||
class DynamicSelectorsFormViewController : XLFormViewController {
|
||||
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
initializeForm()
|
||||
}
|
||||
@@ -42,7 +42,7 @@ class DynamicSelectorsFormViewController : XLFormViewController {
|
||||
var row : XLFormRowDescriptor
|
||||
|
||||
// Basic Information
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Dynamic Selectors")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Dynamic Selectors")
|
||||
section.footerTitle = "DynamicSelectorsFormViewController.swift"
|
||||
form.addFormSection(section)
|
||||
|
||||
@@ -51,7 +51,7 @@ class DynamicSelectorsFormViewController : XLFormViewController {
|
||||
row.action.viewControllerClass = UsersTableViewController.self
|
||||
section.addFormRow(row)
|
||||
|
||||
if UIDevice.currentDevice().userInterfaceIdiom == .Pad {
|
||||
if UIDevice.current.userInterfaceIdiom == .pad {
|
||||
// Selector PopOver
|
||||
row = XLFormRowDescriptor(tag: "selectorUserPopover", rowType:XLFormRowDescriptorTypeSelectorPopover, title:"User Popover")
|
||||
row.action.viewControllerClass = UsersTableViewController.self
|
||||
|
||||
@@ -38,7 +38,7 @@ class UserCell : UITableViewCell {
|
||||
lazy var userName : UILabel = {
|
||||
let tempUserName = UILabel()
|
||||
tempUserName.translatesAutoresizingMaskIntoConstraints = false
|
||||
tempUserName.font = UIFont.systemFontOfSize(15.0)
|
||||
tempUserName.font = UIFont.systemFont(ofSize: 15.0)
|
||||
return tempUserName
|
||||
}()
|
||||
|
||||
@@ -55,7 +55,7 @@ class UserCell : UITableViewCell {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func setSelected(selected: Bool, animated: Bool) {
|
||||
override func setSelected(_ selected: Bool, animated: Bool) {
|
||||
super.setSelected(selected, animated: animated)
|
||||
|
||||
}
|
||||
@@ -63,11 +63,11 @@ class UserCell : UITableViewCell {
|
||||
// MARK: - Layout Constraints
|
||||
|
||||
func layoutConstraints() -> [NSLayoutConstraint]{
|
||||
let views = ["image": self.userImage, "name": self.userName ]
|
||||
let views = ["image": self.userImage, "name": self.userName ] as [String : Any]
|
||||
let metrics = [ "imgSize": 50.0, "margin": 12.0]
|
||||
|
||||
var result = NSLayoutConstraint.constraintsWithVisualFormat("H:|-(margin)-[image(imgSize)]-[name]", options:.AlignAllTop, metrics: metrics, views: views)
|
||||
result += NSLayoutConstraint.constraintsWithVisualFormat("V:|-(margin)-[image(imgSize)]", options:NSLayoutFormatOptions(), metrics:metrics, views: views)
|
||||
var result = NSLayoutConstraint.constraints(withVisualFormat: "H:|-(margin)-[image(imgSize)]-[name]", options:.alignAllTop, metrics: metrics, views: views)
|
||||
result += NSLayoutConstraint.constraints(withVisualFormat: "V:|-(margin)-[image(imgSize)]", options:NSLayoutFormatOptions(), metrics:metrics, views: views)
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -91,9 +91,9 @@ class UsersJSONSerialization {
|
||||
"{\"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)
|
||||
let jsonData = dataString.data(using: String.Encoding.utf8, allowLossyConversion: true)
|
||||
do {
|
||||
let result = try NSJSONSerialization.JSONObjectWithData(jsonData!, options: NSJSONReadingOptions()) as! Array<AnyObject>
|
||||
let result = try JSONSerialization.jsonObject(with: jsonData!, options: JSONSerialization.ReadingOptions()) as! Array<AnyObject>
|
||||
return result
|
||||
}
|
||||
catch let error as NSError {
|
||||
@@ -124,9 +124,9 @@ class User: NSObject, XLFormOptionObject {
|
||||
func formDisplayText() -> String {
|
||||
return self.userName
|
||||
}
|
||||
|
||||
func formValue() -> AnyObject {
|
||||
return self.userId
|
||||
|
||||
func formValue() -> Any {
|
||||
return self.userId as Any
|
||||
}
|
||||
|
||||
}
|
||||
@@ -139,14 +139,14 @@ class UsersTableViewController : UITableViewController, XLFormRowDescriptorViewC
|
||||
|
||||
var userCell : UserCell?
|
||||
|
||||
private let kUserCellIdentifier = "UserCell"
|
||||
fileprivate let kUserCellIdentifier = "UserCell"
|
||||
|
||||
|
||||
override init(style: UITableViewStyle) {
|
||||
super.init(style: style);
|
||||
}
|
||||
|
||||
override init(nibName nibNameOrNil: String!, bundle nibBundleOrNil: NSBundle!) {
|
||||
override init(nibName nibNameOrNil: String!, bundle nibBundleOrNil: Bundle!) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
}
|
||||
|
||||
@@ -156,53 +156,53 @@ class UsersTableViewController : UITableViewController, XLFormRowDescriptorViewC
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
tableView.registerClass(UserCell.self, forCellReuseIdentifier: kUserCellIdentifier)
|
||||
tableView.register(UserCell.self, forCellReuseIdentifier: kUserCellIdentifier)
|
||||
tableView.tableFooterView = UIView(frame: CGRect.zero)
|
||||
}
|
||||
|
||||
// MARK: UITableViewDataSource
|
||||
|
||||
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
|
||||
override func numberOfSections(in tableView: UITableView) -> Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
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
|
||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let cell: UserCell = tableView.dequeueReusableCell(withIdentifier: self.kUserCellIdentifier, for: indexPath) as! UserCell
|
||||
let usersData = UsersJSONSerialization.sharedInstance.userData! as! Array<Dictionary<String, AnyObject>>
|
||||
let userData = usersData[indexPath.row] as Dictionary<String, AnyObject>
|
||||
let userData = usersData[(indexPath as NSIndexPath).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 let value = rowDescriptor?.value {
|
||||
cell.accessoryType = value.formValue().isEqual(userId) ? .Checkmark : .None
|
||||
cell.accessoryType = ((value as? XLFormOptionObject)?.formValue() as? Int) == userId ? .checkmark : .none
|
||||
}
|
||||
return cell;
|
||||
|
||||
}
|
||||
|
||||
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
|
||||
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
||||
return 73.0
|
||||
}
|
||||
|
||||
|
||||
//MARK: UITableViewDelegate
|
||||
|
||||
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
|
||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
|
||||
let usersData = UsersJSONSerialization.sharedInstance.userData! as! Array<Dictionary<String, AnyObject>>
|
||||
let userData = usersData[indexPath.row] as Dictionary<String, AnyObject>
|
||||
let userData = usersData[(indexPath as NSIndexPath).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.dismiss(animated: true)
|
||||
porpOver.delegate?.popoverControllerDidDismissPopover!(porpOver)
|
||||
}
|
||||
else if parentViewController is UINavigationController {
|
||||
navigationController?.popViewControllerAnimated(true)
|
||||
else if parent is UINavigationController {
|
||||
navigationController?.popViewController(animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
class ExamplesFormViewController : XLFormViewController {
|
||||
|
||||
private struct Tags {
|
||||
fileprivate struct Tags {
|
||||
static let RealExample = "RealExamples"
|
||||
static let TextFieldAndTextView = "TextFieldAndTextView"
|
||||
static let Selectors = "Selectors"
|
||||
@@ -46,7 +46,7 @@ class ExamplesFormViewController : XLFormViewController {
|
||||
static let AccessoryView = "Accessory View"
|
||||
}
|
||||
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
initializeForm()
|
||||
}
|
||||
@@ -66,7 +66,7 @@ class ExamplesFormViewController : XLFormViewController {
|
||||
|
||||
form = XLFormDescriptor()
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Real examples")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Real examples")
|
||||
form.addFormSection(section)
|
||||
|
||||
// NativeEventFormViewController
|
||||
@@ -74,7 +74,7 @@ class ExamplesFormViewController : XLFormViewController {
|
||||
row.action.formSegueIdentifier = "NativeEventNavigationViewControllerSegue"
|
||||
section.addFormRow(row)
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("This form is actually an example")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "This form is actually an example")
|
||||
section.footerTitle = "ExamplesFormViewController.swift, Select an option to view another example"
|
||||
form.addFormSection(section)
|
||||
|
||||
@@ -102,7 +102,7 @@ class ExamplesFormViewController : XLFormViewController {
|
||||
section.addFormRow(row)
|
||||
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Multivalued example")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Multivalued example")
|
||||
form.addFormSection(section)
|
||||
|
||||
|
||||
@@ -123,14 +123,14 @@ class ExamplesFormViewController : XLFormViewController {
|
||||
section.addFormRow(row)
|
||||
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("UI Customization")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "UI Customization")
|
||||
form.addFormSection(section)
|
||||
|
||||
row = XLFormRowDescriptor(tag: Tags.UICusomization, rowType: XLFormRowDescriptorTypeButton, title:"UI Customization")
|
||||
row.action.viewControllerClass = UICustomizationFormViewController.self
|
||||
section.addFormRow(row)
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Custom Rows")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Custom Rows")
|
||||
form.addFormSection(section)
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ class ExamplesFormViewController : XLFormViewController {
|
||||
row.action.viewControllerClass = CustomRowsViewController.self
|
||||
section.addFormRow(row)
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Accessory View")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Accessory View")
|
||||
form.addFormSection(section)
|
||||
|
||||
row = XLFormRowDescriptor(tag: Tags.AccessoryView, rowType: XLFormRowDescriptorTypeButton, title:"Accessory Views")
|
||||
@@ -146,7 +146,7 @@ class ExamplesFormViewController : XLFormViewController {
|
||||
section.addFormRow(row)
|
||||
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Validation Examples")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Validation Examples")
|
||||
form.addFormSection(section)
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ class ExamplesFormViewController : XLFormViewController {
|
||||
row.action.formSegueIdentifier = "ValidationExamplesFormViewControllerSegue"
|
||||
section.addFormRow(row)
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Using Predicates")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Using Predicates")
|
||||
form.addFormSection(section)
|
||||
|
||||
|
||||
|
||||
@@ -66,6 +66,11 @@
|
||||
"idiom" : "ipad",
|
||||
"filename" : "xl_appicon_152.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "83.5x83.5",
|
||||
"scale" : "2x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
class InputsFormViewController : XLFormViewController {
|
||||
|
||||
private struct Tags {
|
||||
fileprivate struct Tags {
|
||||
static let Name = "name"
|
||||
static let Email = "email"
|
||||
static let Twitter = "twitter"
|
||||
@@ -41,7 +41,7 @@ class InputsFormViewController : XLFormViewController {
|
||||
static let Notes = "notes"
|
||||
}
|
||||
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
initializeForm()
|
||||
}
|
||||
@@ -60,25 +60,25 @@ class InputsFormViewController : XLFormViewController {
|
||||
form = XLFormDescriptor(title: "Text Fields")
|
||||
form.assignFirstResponderOnShow = true
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("TextField Types")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "TextField Types")
|
||||
section.footerTitle = "This is a long text that will appear on section footer"
|
||||
form.addFormSection(section)
|
||||
|
||||
|
||||
// Name
|
||||
row = XLFormRowDescriptor(tag: Tags.Name, rowType: XLFormRowDescriptorTypeText, title: "Name")
|
||||
row.required = true
|
||||
row.isRequired = true
|
||||
section.addFormRow(row)
|
||||
|
||||
// Email
|
||||
row = XLFormRowDescriptor(tag: Tags.Email, rowType: XLFormRowDescriptorTypeEmail, title: "Email")
|
||||
// validate the email
|
||||
row.addValidator(XLFormValidator.emailValidator())
|
||||
row.addValidator(XLFormValidator.email())
|
||||
section.addFormRow(row)
|
||||
|
||||
// Twitter
|
||||
row = XLFormRowDescriptor(tag: Tags.Name, rowType: XLFormRowDescriptorTypeTwitter, title: "Twitter")
|
||||
row.disabled = NSNumber(bool: true)
|
||||
row.disabled = NSNumber(value: true as Bool)
|
||||
row.value = "@no_editable"
|
||||
section.addFormRow(row)
|
||||
|
||||
@@ -121,7 +121,7 @@ class InputsFormViewController : XLFormViewController {
|
||||
section.addFormRow(row)
|
||||
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("TextView With Label Example")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "TextView With Label Example")
|
||||
form.addFormSection(section)
|
||||
|
||||
row = XLFormRowDescriptor(tag: Tags.Number, rowType: XLFormRowDescriptorTypeTextView, title: "Notes")
|
||||
@@ -134,10 +134,10 @@ class InputsFormViewController : XLFormViewController {
|
||||
override func viewDidLoad()
|
||||
{
|
||||
super.viewDidLoad()
|
||||
navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .Save, target: self, action: "savePressed:")
|
||||
navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .save, target: self, action: #selector(InputsFormViewController.savePressed(_:)))
|
||||
}
|
||||
|
||||
func savePressed(button: UIBarButtonItem)
|
||||
func savePressed(_ button: UIBarButtonItem)
|
||||
{
|
||||
let validationErrors : Array<NSError> = self.formValidationErrors() as! Array<NSError>
|
||||
if (validationErrors.count > 0){
|
||||
|
||||
+36
-34
@@ -31,7 +31,7 @@ class MultivaluedFormViewController : XLFormViewController {
|
||||
initializeForm()
|
||||
}
|
||||
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
initializeForm()
|
||||
}
|
||||
@@ -45,7 +45,7 @@ class MultivaluedFormViewController : XLFormViewController {
|
||||
form = XLFormDescriptor(title: "Multivalued Examples")
|
||||
|
||||
// Multivalued section
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Multivalued TextField", sectionOptions:XLFormSectionOptions.CanReorder.union(.CanInsert).union(.CanDelete), sectionInsertMode:.Button)
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Multivalued TextField", sectionOptions:XLFormSectionOptions.canReorder.union(.canInsert).union(.canDelete), sectionInsertMode:.button)
|
||||
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
|
||||
@@ -56,7 +56,7 @@ class MultivaluedFormViewController : XLFormViewController {
|
||||
form.addFormSection(section)
|
||||
|
||||
// Another Multivalued section
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Multivalued ActionSheet Selector example", sectionOptions:XLFormSectionOptions.CanInsert.union(.CanDelete))
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Multivalued ActionSheet Selector example", sectionOptions:XLFormSectionOptions.canInsert.union(.canDelete))
|
||||
section.footerTitle = "XLFormSectionInsertModeLastRow sectionType adds a '+' icon inside last table view cell allowing us to add a new row."
|
||||
form.addFormSection(section)
|
||||
row = XLFormRowDescriptor(tag: nil, rowType: XLFormRowDescriptorTypeSelectorActionSheet, title: "Tap to select..")
|
||||
@@ -65,7 +65,7 @@ class MultivaluedFormViewController : XLFormViewController {
|
||||
|
||||
|
||||
// Another one
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Multivalued Push Selector example", sectionOptions: XLFormSectionOptions.CanInsert.union(.CanDelete).union(.CanReorder), sectionInsertMode: .Button)
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Multivalued Push Selector example", sectionOptions: XLFormSectionOptions.canInsert.union(.canDelete).union(.canReorder), sectionInsertMode: .button)
|
||||
section.footerTitle = "MultivaluedFormViewController.swift"
|
||||
form.addFormSection(section)
|
||||
row = XLFormRowDescriptor(tag: nil, rowType: XLFormRowDescriptorTypeSelectorPush, title: "Tap to select )..")
|
||||
@@ -78,30 +78,30 @@ class MultivaluedFormViewController : XLFormViewController {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .Edit, target: self, action: "addDidTouch:")
|
||||
navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .edit, target: self, action: #selector(MultivaluedFormViewController.addDidTouch(_:)))
|
||||
}
|
||||
|
||||
//MARK: - Actions
|
||||
|
||||
func addDidTouch(sender: UIBarButtonItem) {
|
||||
let actionSheet = UIActionSheet(title: nil, delegate: self, cancelButtonTitle: "Cancel", destructiveButtonTitle: "Remove Last Section", otherButtonTitles: "Add a section at the end", self.form!.disabled ? "Enable Form" : "Disable Form")
|
||||
actionSheet.showInView(view)
|
||||
func addDidTouch(_ sender: UIBarButtonItem) {
|
||||
let actionSheet = UIActionSheet(title: nil, delegate: self, cancelButtonTitle: "Cancel", destructiveButtonTitle: "Remove Last Section", otherButtonTitles: "Add a section at the end", self.form!.isDisabled ? "Enable Form" : "Disable Form")
|
||||
actionSheet.show(in: view)
|
||||
}
|
||||
|
||||
//MARK: - UIActionSheetDelegate
|
||||
|
||||
|
||||
override func actionSheet(actionSheet: UIActionSheet, clickedButtonAtIndex buttonIndex: Int) {
|
||||
override func actionSheet(_ actionSheet: UIActionSheet, clickedButtonAt buttonIndex: Int) {
|
||||
if actionSheet.destructiveButtonIndex == buttonIndex {
|
||||
if form.formSections.count > 0 {
|
||||
// remove last section
|
||||
form.removeFormSectionAtIndex(UInt(form.formSections.count - 1))
|
||||
form.removeFormSection(at: UInt(form.formSections.count - 1))
|
||||
}
|
||||
}
|
||||
else if actionSheet.buttonTitleAtIndex(buttonIndex) == "Add a section at the end" {
|
||||
else if actionSheet.buttonTitle(at: buttonIndex) == "Add a section at the end" {
|
||||
// add a new section
|
||||
// let dateString = NSDateFormatter.localizedStringFromDate(NSDate(), dateStyle: NSDateFormatterStyle.ShortStyle, timeStyle: NSDateFormatterStyle.ShortStyle)
|
||||
let newSection = XLFormSectionDescriptor.formSectionWithTitle("Section created at \(NSDateFormatter.localizedStringFromDate(NSDate(), dateStyle: NSDateFormatterStyle.ShortStyle, timeStyle: NSDateFormatterStyle.ShortStyle))", sectionOptions:XLFormSectionOptions.CanInsert.union(.CanDelete))
|
||||
let newSection = XLFormSectionDescriptor.formSection(withTitle: "Section created at \(DateFormatter.localizedString(from: Date(), dateStyle: DateFormatter.Style.short, timeStyle: DateFormatter.Style.short))", sectionOptions:XLFormSectionOptions.canInsert.union(.canDelete))
|
||||
newSection.multivaluedTag = "multivaluedPushSelector_\(self.form.formSections.count)"
|
||||
let newRow = XLFormRowDescriptor(tag: nil, rowType: XLFormRowDescriptorTypeSelectorPush, title: "Tap to select )..")
|
||||
newRow.selectorOptions = ["Option 1", "Option 2", "Option 3"]
|
||||
@@ -109,7 +109,7 @@ class MultivaluedFormViewController : XLFormViewController {
|
||||
form.addFormSection(newSection)
|
||||
}
|
||||
else {
|
||||
form.disabled = !self.form.disabled
|
||||
form.isDisabled = !self.form.isDisabled
|
||||
tableView.endEditing(true)
|
||||
tableView.reloadData()
|
||||
}
|
||||
@@ -126,7 +126,7 @@ class MultivaluedOnlyReorderViewController : XLFormViewController {
|
||||
self.initializeForm()
|
||||
}
|
||||
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
self.initializeForm()
|
||||
}
|
||||
@@ -143,29 +143,31 @@ class MultivaluedOnlyReorderViewController : XLFormViewController {
|
||||
form = XLFormDescriptor(title: "Only Reorder Examples")
|
||||
|
||||
// Multivalued Section with inline rows - section set up to support only reordering
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Reordering Inline Rows",
|
||||
sectionOptions:.CanReorder)
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Reordering Inline Rows",
|
||||
sectionOptions:.canReorder)
|
||||
section.footerTitle = "XLFormRowDescriptorTypeDateInline row type"
|
||||
form.addFormSection(section)
|
||||
var idx = 0
|
||||
for listItem in list {
|
||||
let timeIntervalSinceNow = NSTimeInterval(secondsPerDay * ++idx)
|
||||
idx += 1
|
||||
let timeIntervalSinceNow = TimeInterval(secondsPerDay * idx)
|
||||
row = XLFormRowDescriptor(tag: nil, rowType:XLFormRowDescriptorTypeDateInline, title: listItem)
|
||||
row.value = NSDate(timeIntervalSinceNow:timeIntervalSinceNow)
|
||||
row.value = Date(timeIntervalSinceNow:timeIntervalSinceNow)
|
||||
section.addFormRow(row)
|
||||
}
|
||||
|
||||
// Multivalued Section with common rows - section set up to support only reordering
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Reordering Rows", sectionOptions:.CanReorder)
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Reordering Rows", sectionOptions:.canReorder)
|
||||
section.footerTitle = "XLFormRowDescriptorTypeInfo row type"
|
||||
form.addFormSection(section)
|
||||
|
||||
|
||||
idx = 0
|
||||
for listItem in list {
|
||||
let timeIntervalSinceNow = NSTimeInterval(secondsPerDay * ++idx)
|
||||
idx += 1
|
||||
let timeIntervalSinceNow = TimeInterval(secondsPerDay * idx)
|
||||
row = XLFormRowDescriptor(tag: nil, rowType:XLFormRowDescriptorTypeInfo, title: listItem)
|
||||
row.value = NSDateFormatter.localizedStringFromDate(NSDate(timeIntervalSinceNow:timeIntervalSinceNow), dateStyle: .MediumStyle, timeStyle: .NoStyle)
|
||||
row.value = DateFormatter.localizedString(from: Date(timeIntervalSinceNow:timeIntervalSinceNow), dateStyle: .medium, timeStyle: .none)
|
||||
section.addFormRow(row)
|
||||
}
|
||||
|
||||
@@ -182,7 +184,7 @@ class MultivaluedOnlyInserViewController : XLFormViewController {
|
||||
}
|
||||
|
||||
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
self.initializeForm()
|
||||
}
|
||||
@@ -197,7 +199,7 @@ class MultivaluedOnlyInserViewController : XLFormViewController {
|
||||
|
||||
form = XLFormDescriptor(title: "Multivalued Only Insert")
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("XLFormSectionInsertModeButton", sectionOptions:.CanInsert, sectionInsertMode:.Button)
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "XLFormSectionInsertModeButton", sectionOptions:.canInsert, sectionInsertMode:.button)
|
||||
form.addFormSection(section)
|
||||
|
||||
|
||||
@@ -205,15 +207,15 @@ class MultivaluedOnlyInserViewController : XLFormViewController {
|
||||
row.cellConfig["textField.placeholder"] = "Add a new tag"
|
||||
section.multivaluedRowTemplate = row
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("XLFormSectionInsertModeButton With Inline Cells", sectionOptions:.CanInsert, sectionInsertMode:.Button)
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "XLFormSectionInsertModeButton With Inline Cells", sectionOptions:.canInsert, sectionInsertMode:.button)
|
||||
row = XLFormRowDescriptor(tag: nil, rowType:XLFormRowDescriptorTypeDateInline)
|
||||
row.value = NSDate()
|
||||
row.value = Date()
|
||||
row.title = "Date"
|
||||
section.multivaluedRowTemplate = row
|
||||
form.addFormSection(section)
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("XLFormSectionInsertModeLastRow",
|
||||
sectionOptions:.CanInsert, sectionInsertMode:.LastRow)
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "XLFormSectionInsertModeLastRow",
|
||||
sectionOptions:.canInsert, sectionInsertMode:.lastRow)
|
||||
form.addFormSection(section)
|
||||
for tag in nameList {
|
||||
// add a row to the section, the row will be used to crete new rows.
|
||||
@@ -233,19 +235,19 @@ class MultivaluedOnlyDeleteViewController : XLFormViewController {
|
||||
initializeForm()
|
||||
}
|
||||
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
initializeForm()
|
||||
}
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Editing", style: .Plain, target: self, action: "toggleEditing:")
|
||||
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Editing", style: .plain, target: self, action: #selector(MultivaluedOnlyDeleteViewController.toggleEditing(_:)))
|
||||
}
|
||||
|
||||
func toggleEditing(sender : UIBarButtonItem) {
|
||||
tableView.setEditing(!tableView.editing, animated: true)
|
||||
sender.title = tableView.editing ? "Editing" : "Not Editing"
|
||||
func toggleEditing(_ sender : UIBarButtonItem) {
|
||||
tableView.setEditing(!tableView.isEditing, animated: true)
|
||||
sender.title = tableView.isEditing ? "Editing" : "Not Editing"
|
||||
}
|
||||
|
||||
func initializeForm() {
|
||||
@@ -258,7 +260,7 @@ class MultivaluedOnlyDeleteViewController : XLFormViewController {
|
||||
|
||||
form = XLFormDescriptor(title: "Multivalued Only Delete")
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("", sectionOptions:.CanDelete)
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "", sectionOptions:.canDelete)
|
||||
section.footerTitle = "you can swipe to delete when table.editing = NO (Not Editing)"
|
||||
form.addFormSection(section)
|
||||
|
||||
@@ -271,7 +273,7 @@ class MultivaluedOnlyDeleteViewController : XLFormViewController {
|
||||
}
|
||||
|
||||
// Multivalued Section with inline row.
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("", sectionOptions:.CanDelete)
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "", sectionOptions:.canDelete)
|
||||
section.footerTitle = "you can swipe to delete when table.editing = NO (Not Editing)"
|
||||
form.addFormSection(section)
|
||||
|
||||
|
||||
@@ -50,10 +50,10 @@ class XLFormCustomCell : XLFormBaseCell {
|
||||
}
|
||||
}
|
||||
|
||||
override func formDescriptorCellDidSelectedWithFormController(controller: XLFormViewController!) {
|
||||
override func formDescriptorCellDidSelected(withForm controller: XLFormViewController!) {
|
||||
// custom code here
|
||||
// i.e new behaviour when cell has been selected
|
||||
if let string = rowDescriptor?.value as? String where string == "Am a custom cell, select me!" {
|
||||
if let string = rowDescriptor?.value as? String , string == "Am a custom cell, select me!" {
|
||||
self.rowDescriptor?.value = string
|
||||
}
|
||||
else {
|
||||
@@ -61,7 +61,7 @@ class XLFormCustomCell : XLFormBaseCell {
|
||||
}
|
||||
|
||||
update()
|
||||
controller.tableView.selectRowAtIndexPath(nil, animated: true, scrollPosition: .None)
|
||||
controller.tableView.selectRow(at: nil, animated: true, scrollPosition: .none)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import MapKit
|
||||
|
||||
class OthersFormViewController : XLFormViewController {
|
||||
|
||||
private struct Tags {
|
||||
fileprivate struct Tags {
|
||||
static let SwitchBool = "switchBool"
|
||||
static let SwitchCheck = "switchCheck"
|
||||
static let StepCounter = "stepCounter"
|
||||
@@ -46,12 +46,10 @@ class OthersFormViewController : XLFormViewController {
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
self.initializeForm()
|
||||
}
|
||||
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
self.initializeForm()
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +61,7 @@ class OthersFormViewController : XLFormViewController {
|
||||
|
||||
form = XLFormDescriptor(title: "Other Cells")
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Other Cells")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Other Cells")
|
||||
section.footerTitle = "OthersFormViewController.swift"
|
||||
form.addFormSection(section)
|
||||
|
||||
@@ -81,6 +79,12 @@ class OthersFormViewController : XLFormViewController {
|
||||
row.selectorOptions = ["Apple", "Orange", "Pear"]
|
||||
row.value = "Pear"
|
||||
section.addFormRow(row)
|
||||
|
||||
row = XLFormRowDescriptor(tag: Tags.SegmentedControl, rowType: XLFormRowDescriptorTypeSegmentedInline, title: "Fruits Inline")
|
||||
row.selectorOptions = ["Apple", "Orange", "Pear"]
|
||||
row.value = "Pear"
|
||||
section.addFormRow(row)
|
||||
|
||||
|
||||
|
||||
// Slider
|
||||
@@ -99,29 +103,29 @@ class OthersFormViewController : XLFormViewController {
|
||||
// Info cell
|
||||
row = XLFormRowDescriptor(tag: Tags.Info, rowType: XLFormRowDescriptorTypeInfo)
|
||||
row.title = "Version"
|
||||
row.value = NSBundle.mainBundle().infoDictionary!["CFBundleShortVersionString"]
|
||||
row.value = Bundle.main.infoDictionary!["CFBundleShortVersionString"]
|
||||
section.addFormRow(row)
|
||||
|
||||
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Buttons")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Buttons")
|
||||
section.footerTitle = "Blue buttons will show a message when Switch is ON"
|
||||
form.addFormSection(section)
|
||||
|
||||
// Button
|
||||
row = XLFormRowDescriptor(tag: Tags.Button, rowType: XLFormRowDescriptorTypeButton, title: "Button")
|
||||
row.cellConfig["textLabel.textColor"] = UIColor(red: 0.0, green: 122.0/255.0, blue: 1.0, alpha: 1.0)
|
||||
row.action.formSelector = "didTouchButton:"
|
||||
row.action.formSelector = #selector(OthersFormViewController.didTouchButton(_:))
|
||||
section.addFormRow(row)
|
||||
|
||||
|
||||
// Left Button
|
||||
row = XLFormRowDescriptor(tag: Tags.ButtonLeftAligned, rowType: XLFormRowDescriptorTypeButton, title: "Button with Block")
|
||||
row.cellConfig["textLabel.textColor"] = UIColor(red: 0.0, green: 122.0/255.0, blue: 1.0, alpha: 1.0)
|
||||
row.cellConfig["textLabel.textAlignment"] = NSTextAlignment.Left.rawValue
|
||||
row.cellConfig["accessoryType"] = UITableViewCellAccessoryType.DisclosureIndicator.rawValue
|
||||
row.cellConfig["textLabel.textAlignment"] = NSTextAlignment.left.rawValue
|
||||
row.cellConfig["accessoryType"] = UITableViewCellAccessoryType.disclosureIndicator.rawValue
|
||||
row.action.formBlock = { [weak self] (sender: XLFormRowDescriptor!) -> Void in
|
||||
let switchRow = sender.sectionDescriptor.formDescriptor!.formRowWithTag(Tags.SwitchBool)!
|
||||
if let value = switchRow.value where value.boolValue == true {
|
||||
let switchRow = sender.sectionDescriptor.formDescriptor!.formRow(withTag: Tags.SwitchBool)!
|
||||
if let value = switchRow.value , (value as AnyObject).boolValue == true {
|
||||
let alertView = UIAlertView(title: "Switch is ON", message: "Button has checked the switch value...", delegate: self, cancelButtonTitle: "OK")
|
||||
alertView.show()
|
||||
}
|
||||
@@ -160,9 +164,8 @@ class OthersFormViewController : XLFormViewController {
|
||||
self.form = form
|
||||
}
|
||||
|
||||
|
||||
func didTouchButton(sender: XLFormRowDescriptor) {
|
||||
if sender.sectionDescriptor.formDescriptor.formRowWithTag(Tags.SwitchBool)?.value?.boolValue == true{
|
||||
func didTouchButton(_ sender: XLFormRowDescriptor) {
|
||||
if (sender.sectionDescriptor.formDescriptor.formRow(withTag: Tags.SwitchBool)?.value as AnyObject).boolValue == true{
|
||||
let alertView = UIAlertView(title: "Switch is ON", message: "Button has checked the switch value...", delegate: self, cancelButtonTitle: "OK")
|
||||
alertView.show()
|
||||
}
|
||||
@@ -171,15 +174,18 @@ class OthersFormViewController : XLFormViewController {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
let barButton = UIBarButtonItem(title: "Disable", style: .Plain, target: self, action: "disableEnable:")
|
||||
|
||||
initializeForm()
|
||||
|
||||
let barButton = UIBarButtonItem(title: "Disable", style: .plain, target: self, action: #selector(OthersFormViewController.disableEnable(_:)))
|
||||
barButton.possibleTitles = Set(["Disable", "Enable"])
|
||||
navigationItem.rightBarButtonItem = barButton
|
||||
}
|
||||
|
||||
|
||||
func disableEnable(button : UIBarButtonItem) {
|
||||
form.disabled = !form.disabled
|
||||
button.title = form.disabled ? "Enable" : "Disable"
|
||||
func disableEnable(_ button : UIBarButtonItem) {
|
||||
form.isDisabled = !form.isDisabled
|
||||
button.title = form.isDisabled ? "Enable" : "Disable"
|
||||
tableView.endEditing(true)
|
||||
tableView.reloadData()
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
class BasicPredicateViewController : XLFormViewController {
|
||||
|
||||
private struct Tags {
|
||||
fileprivate struct Tags {
|
||||
|
||||
static let HideRow = "tag1"
|
||||
static let HideSection = "tag2"
|
||||
@@ -35,7 +35,7 @@ class BasicPredicateViewController : XLFormViewController {
|
||||
|
||||
}
|
||||
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
initializeForm()
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
class BlogExampleViewController : XLFormViewController {
|
||||
|
||||
private struct Tags {
|
||||
fileprivate struct Tags {
|
||||
static let Hobbies = "hobbies"
|
||||
static let Sport = "sport"
|
||||
static let Film = "films1"
|
||||
@@ -33,7 +33,7 @@ class BlogExampleViewController : XLFormViewController {
|
||||
static let Music = "music"
|
||||
}
|
||||
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
initializeForm()
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
class PredicateFormViewController : XLFormViewController {
|
||||
|
||||
private struct Tags {
|
||||
fileprivate struct Tags {
|
||||
static let Text = "text"
|
||||
static let Integer = "integer"
|
||||
static let Switch = "switch"
|
||||
@@ -34,7 +34,7 @@ class PredicateFormViewController : XLFormViewController {
|
||||
static let Account = "account"
|
||||
}
|
||||
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
initializeForm()
|
||||
}
|
||||
@@ -77,7 +77,7 @@ class PredicateFormViewController : XLFormViewController {
|
||||
|
||||
// Predicate Disabling
|
||||
row = XLFormRowDescriptor(tag: Tags.Date, rowType: XLFormRowDescriptorTypeDateInline, title:"Disabled")
|
||||
row.value = NSDate()
|
||||
row.value = Date()
|
||||
section.addFormRow(row)
|
||||
row.disabled = NSPredicate(format: "$\(Tags.Text).value contains[c] 'disable' OR ($\(Tags.Integer).value between {18, 60}) OR ($\(Tags.Switch).value == 0)")
|
||||
section.hidden = NSPredicate(format: "($\(Tags.Text).value contains[c] 'disable') AND ($\(Tags.Integer).value between {18, 60}) AND ($\(Tags.Switch).value == 0)")
|
||||
@@ -99,9 +99,9 @@ class PredicateFormViewController : XLFormViewController {
|
||||
row.onChangeBlock = { [weak self] oldValue, newValue, _ in
|
||||
let noValue = "No Value"
|
||||
let message = "Old value: \(oldValue ?? noValue), New value: \(newValue ?? noValue)"
|
||||
let alertView = UIAlertController(title: "Account Field changed", message: message, preferredStyle: .ActionSheet)
|
||||
alertView.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: nil))
|
||||
self?.navigationController?.presentViewController(alertView, animated: true, completion: nil)
|
||||
let alertView = UIAlertController(title: "Account Field changed", message: message, preferredStyle: .actionSheet)
|
||||
alertView.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
|
||||
self?.navigationController?.present(alertView, animated: true, completion: nil)
|
||||
}
|
||||
|
||||
self.form = form
|
||||
|
||||
@@ -31,7 +31,7 @@ class NativeEventFormViewController : XLFormViewController {
|
||||
initializeForm()
|
||||
}
|
||||
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
initializeForm()
|
||||
}
|
||||
@@ -50,7 +50,7 @@ class NativeEventFormViewController : XLFormViewController {
|
||||
// Title
|
||||
row = XLFormRowDescriptor(tag: "title", rowType: XLFormRowDescriptorTypeText)
|
||||
row.cellConfigAtConfigure["textField.placeholder"] = "Title"
|
||||
row.required = true
|
||||
row.isRequired = true
|
||||
section.addFormRow(row)
|
||||
|
||||
// Location
|
||||
@@ -67,12 +67,12 @@ class NativeEventFormViewController : XLFormViewController {
|
||||
|
||||
// Starts
|
||||
row = XLFormRowDescriptor(tag: "starts", rowType: XLFormRowDescriptorTypeDateTimeInline, title: "Starts")
|
||||
row.value = NSDate(timeIntervalSinceNow: 60*60*24)
|
||||
row.value = Date(timeIntervalSinceNow: 60*60*24)
|
||||
section.addFormRow(row)
|
||||
|
||||
// Ends
|
||||
row = XLFormRowDescriptor(tag: "ends", rowType: XLFormRowDescriptorTypeDateTimeInline, title: "Ends")
|
||||
row.value = NSDate(timeIntervalSinceNow: 60*60*25)
|
||||
row.value = Date(timeIntervalSinceNow: 60*60*25)
|
||||
section.addFormRow(row)
|
||||
|
||||
section = XLFormSectionDescriptor.formSection()
|
||||
@@ -139,83 +139,83 @@ class NativeEventFormViewController : XLFormViewController {
|
||||
|
||||
override func viewDidLoad(){
|
||||
super.viewDidLoad()
|
||||
navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .Cancel, target: self, action: "cancelPressed:")
|
||||
navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .Save, target: self, action: "savePressed:")
|
||||
navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .cancel, target: self, action: #selector(NativeEventFormViewController.cancelPressed(_:)))
|
||||
navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .save, target: self, action: #selector(NativeEventFormViewController.savePressed(_:)))
|
||||
}
|
||||
|
||||
// MARK: XLFormDescriptorDelegate
|
||||
|
||||
override func formRowDescriptorValueHasChanged(formRow: XLFormRowDescriptor!, oldValue: AnyObject!, newValue: AnyObject!) {
|
||||
override func formRowDescriptorValueHasChanged(_ formRow: XLFormRowDescriptor!, oldValue: Any!, newValue: Any!) {
|
||||
super.formRowDescriptorValueHasChanged(formRow, oldValue: oldValue, newValue: newValue)
|
||||
if formRow.tag == "alert" {
|
||||
if !formRow.value!.valueData().isEqual(0) && oldValue.valueData().isEqual(0) {
|
||||
if !((formRow.value! as AnyObject).valueData() as AnyObject).isEqual(0) && ((oldValue as AnyObject).valueData() as AnyObject).isEqual(0) {
|
||||
|
||||
let newRow = formRow.copy() as! XLFormRowDescriptor
|
||||
newRow.tag = "secondAlert"
|
||||
newRow.title = "Second Alert"
|
||||
form.addFormRow(newRow, afterRow:formRow)
|
||||
}
|
||||
else if !oldValue.valueData().isEqual(0) && newValue.valueData().isEqual(0) {
|
||||
form.removeFormRowWithTag("secondAlert")
|
||||
else if !((oldValue as AnyObject).valueData() as AnyObject).isEqual(0) && ((newValue as AnyObject).valueData() as AnyObject).isEqual(0) {
|
||||
form.removeFormRow(withTag: "secondAlert")
|
||||
}
|
||||
}
|
||||
else if formRow.tag == "all-day" {
|
||||
let startDateDescriptor = form.formRowWithTag("starts")!
|
||||
let endDateDescriptor = form.formRowWithTag("ends")!
|
||||
let dateStartCell: XLFormDateCell = startDateDescriptor.cellForFormController(self) as! XLFormDateCell
|
||||
let dateEndCell: XLFormDateCell = endDateDescriptor.cellForFormController(self) as! XLFormDateCell
|
||||
if formRow.value!.valueData() as? Bool == true {
|
||||
let startDateDescriptor = form.formRow(withTag: "starts")!
|
||||
let endDateDescriptor = form.formRow(withTag: "ends")!
|
||||
let dateStartCell: XLFormDateCell = startDateDescriptor.cell(forForm: self) as! XLFormDateCell
|
||||
let dateEndCell: XLFormDateCell = endDateDescriptor.cell(forForm: self) as! XLFormDateCell
|
||||
if (formRow.value! as AnyObject).valueData() as? Bool == true {
|
||||
startDateDescriptor.valueTransformer = DateValueTrasformer.self
|
||||
endDateDescriptor.valueTransformer = DateValueTrasformer.self
|
||||
dateStartCell.formDatePickerMode = .Date
|
||||
dateEndCell.formDatePickerMode = .Date
|
||||
dateStartCell.formDatePickerMode = .date
|
||||
dateEndCell.formDatePickerMode = .date
|
||||
}
|
||||
else{
|
||||
startDateDescriptor.valueTransformer = DateTimeValueTrasformer.self
|
||||
endDateDescriptor.valueTransformer = DateTimeValueTrasformer.self
|
||||
dateStartCell.formDatePickerMode = .DateTime
|
||||
dateEndCell.formDatePickerMode = .DateTime
|
||||
dateStartCell.formDatePickerMode = .dateTime
|
||||
dateEndCell.formDatePickerMode = .dateTime
|
||||
}
|
||||
updateFormRow(startDateDescriptor)
|
||||
updateFormRow(endDateDescriptor)
|
||||
}
|
||||
else if formRow.tag == "starts" {
|
||||
let startDateDescriptor = form.formRowWithTag("starts")!
|
||||
let endDateDescriptor = form.formRowWithTag("ends")!
|
||||
if startDateDescriptor.value!.compare(endDateDescriptor.value as! NSDate) == .OrderedDescending {
|
||||
let startDateDescriptor = form.formRow(withTag: "starts")!
|
||||
let endDateDescriptor = form.formRow(withTag: "ends")!
|
||||
if (startDateDescriptor.value! as AnyObject).compare(endDateDescriptor.value as! Date) == .orderedDescending {
|
||||
// startDateDescriptor is later than endDateDescriptor
|
||||
endDateDescriptor.value = NSDate(timeInterval: 60*60*24, sinceDate: startDateDescriptor.value as! NSDate)
|
||||
endDateDescriptor.cellConfig.removeObjectForKey("detailTextLabel.attributedText")
|
||||
endDateDescriptor.value = Date(timeInterval: 60*60*24, since: startDateDescriptor.value as! Date)
|
||||
endDateDescriptor.cellConfig.removeObject(forKey: "detailTextLabel.attributedText")
|
||||
updateFormRow(endDateDescriptor)
|
||||
}
|
||||
}
|
||||
else if formRow.tag == "ends" {
|
||||
let startDateDescriptor = form.formRowWithTag("starts")!
|
||||
let endDateDescriptor = form.formRowWithTag("ends")!
|
||||
let dateEndCell = endDateDescriptor.cellForFormController(self) as! XLFormDateCell
|
||||
if startDateDescriptor.value!.compare(endDateDescriptor.value as! NSDate) == .OrderedDescending {
|
||||
let startDateDescriptor = form.formRow(withTag: "starts")!
|
||||
let endDateDescriptor = form.formRow(withTag: "ends")!
|
||||
let dateEndCell = endDateDescriptor.cell(forForm: self) as! XLFormDateCell
|
||||
if (startDateDescriptor.value! as AnyObject).compare(endDateDescriptor.value as! Date) == .orderedDescending {
|
||||
// startDateDescriptor is later than endDateDescriptor
|
||||
dateEndCell.update()
|
||||
let newDetailText = dateEndCell.detailTextLabel!.text!
|
||||
let strikeThroughAttribute = [NSStrikethroughStyleAttributeName : NSUnderlineStyle.StyleSingle.rawValue]
|
||||
let strikeThroughAttribute = [NSStrikethroughStyleAttributeName : NSUnderlineStyle.styleSingle.rawValue]
|
||||
let strikeThroughText = NSAttributedString(string: newDetailText, attributes: strikeThroughAttribute)
|
||||
endDateDescriptor.cellConfig["detailTextLabel.attributedText"] = strikeThroughText
|
||||
updateFormRow(endDateDescriptor)
|
||||
}
|
||||
else{
|
||||
let endDateDescriptor = self.form.formRowWithTag("ends")!
|
||||
endDateDescriptor.cellConfig.removeObjectForKey("detailTextLabel.attributedText")
|
||||
let endDateDescriptor = self.form.formRow(withTag: "ends")!
|
||||
endDateDescriptor.cellConfig.removeObject(forKey: "detailTextLabel.attributedText")
|
||||
updateFormRow(endDateDescriptor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func cancelPressed(button: UIBarButtonItem){
|
||||
dismissViewControllerAnimated(true, completion: nil)
|
||||
func cancelPressed(_ button: UIBarButtonItem){
|
||||
dismiss(animated: true, completion: nil)
|
||||
}
|
||||
|
||||
|
||||
func savePressed(button: UIBarButtonItem){
|
||||
func savePressed(_ button: UIBarButtonItem){
|
||||
let validationErrors : Array<NSError> = formValidationErrors() as! Array<NSError>
|
||||
if (validationErrors.count > 0){
|
||||
showFormValidationError(validationErrors.first)
|
||||
@@ -230,7 +230,7 @@ class NativeEventNavigationViewController : UINavigationController {
|
||||
|
||||
override func viewDidLoad(){
|
||||
super.viewDidLoad()
|
||||
view.tintColor = .redColor()
|
||||
view.tintColor = .red
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import MapKit
|
||||
|
||||
// Mark - NSValueTransformer
|
||||
|
||||
class NSArrayValueTrasformer : NSValueTransformer {
|
||||
class NSArrayValueTrasformer : ValueTransformer {
|
||||
|
||||
override class func transformedValueClass() -> AnyClass {
|
||||
return NSString.self
|
||||
@@ -37,7 +37,7 @@ class NSArrayValueTrasformer : NSValueTransformer {
|
||||
return false
|
||||
}
|
||||
|
||||
override func transformedValue(value: AnyObject?) -> AnyObject? {
|
||||
override func transformedValue(_ value: Any?) -> Any? {
|
||||
if let arrayValue = value as? Array<AnyObject> {
|
||||
return String(format: "%d Item%@", arrayValue.count, arrayValue.count > 1 ? "s" : "")
|
||||
}
|
||||
@@ -48,7 +48,7 @@ class NSArrayValueTrasformer : NSValueTransformer {
|
||||
}
|
||||
}
|
||||
|
||||
class ISOLanguageCodesValueTranformer : NSValueTransformer {
|
||||
class ISOLanguageCodesValueTranformer : ValueTransformer {
|
||||
|
||||
override class func transformedValueClass() -> AnyClass {
|
||||
return NSString.self
|
||||
@@ -59,9 +59,9 @@ class ISOLanguageCodesValueTranformer : NSValueTransformer {
|
||||
return false
|
||||
}
|
||||
|
||||
override func transformedValue(value: AnyObject?) -> AnyObject? {
|
||||
override func transformedValue(_ value: Any?) -> Any? {
|
||||
if let stringValue = value as? String {
|
||||
return NSLocale.currentLocale().displayNameForKey(NSLocaleLanguageCode, value: stringValue)
|
||||
return (Locale.current as NSLocale).displayName(forKey: NSLocale.Key.languageCode, value: stringValue)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -71,7 +71,7 @@ class ISOLanguageCodesValueTranformer : NSValueTransformer {
|
||||
|
||||
class SelectorsFormViewController : XLFormViewController {
|
||||
|
||||
private struct Tags {
|
||||
fileprivate struct Tags {
|
||||
static let Push = "selectorPush"
|
||||
static let Popover = "selectorPopover"
|
||||
static let ActionSheet = "selectorActionSheet"
|
||||
@@ -90,7 +90,7 @@ class SelectorsFormViewController : XLFormViewController {
|
||||
}
|
||||
|
||||
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
initializeForm()
|
||||
}
|
||||
@@ -102,15 +102,15 @@ class SelectorsFormViewController : XLFormViewController {
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
let barButton = UIBarButtonItem(title: "Disable", style: .Plain, target: self, action: "disableEnable:")
|
||||
let barButton = UIBarButtonItem(title: "Disable", style: .plain, target: self, action: #selector(SelectorsFormViewController.disableEnable(_:)))
|
||||
barButton.possibleTitles = Set(["Disable", "Enable"])
|
||||
navigationItem.rightBarButtonItem = barButton
|
||||
}
|
||||
|
||||
func disableEnable(button : UIBarButtonItem)
|
||||
func disableEnable(_ button : UIBarButtonItem)
|
||||
{
|
||||
form.disabled = !form.disabled
|
||||
button.title = form.disabled ? "Enable" : "Disable"
|
||||
form.isDisabled = !form.isDisabled
|
||||
button.title = form.isDisabled ? "Enable" : "Disable"
|
||||
tableView.endEditing(true)
|
||||
tableView.reloadData()
|
||||
}
|
||||
@@ -122,7 +122,7 @@ class SelectorsFormViewController : XLFormViewController {
|
||||
var row : XLFormRowDescriptor
|
||||
|
||||
form = XLFormDescriptor(title: "Selectors")
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Selectors")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Selectors")
|
||||
section.footerTitle = "SelectorsFormViewController.swift"
|
||||
form.addFormSection(section)
|
||||
|
||||
@@ -140,7 +140,7 @@ class SelectorsFormViewController : XLFormViewController {
|
||||
|
||||
|
||||
// Selector Popover
|
||||
if (UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad){
|
||||
if (UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad){
|
||||
row = XLFormRowDescriptor(tag: Tags.Popover, rowType:XLFormRowDescriptorTypeSelectorPopover, title:"PopOver")
|
||||
row.selectorOptions = ["Option 1", "Option 2", "Option 3", "Option 4", "Option 5", "Option 6"]
|
||||
row.value = "Option 2"
|
||||
@@ -169,7 +169,7 @@ class SelectorsFormViewController : XLFormViewController {
|
||||
|
||||
|
||||
// --------- Fixed Controls
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Fixed Controls")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Fixed Controls")
|
||||
form.addFormSection(section)
|
||||
|
||||
row = XLFormRowDescriptor(tag: Tags.Picker, rowType:XLFormRowDescriptorTypePicker)
|
||||
@@ -178,7 +178,7 @@ class SelectorsFormViewController : XLFormViewController {
|
||||
section.addFormRow(row)
|
||||
|
||||
// --------- Inline Selectors
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Inline Selectors")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Inline Selectors")
|
||||
form.addFormSection(section)
|
||||
|
||||
row = XLFormRowDescriptor(tag: Tags.MultipleSelector, rowType:XLFormRowDescriptorTypeSelectorPickerViewInline, title:"Inline Picker View")
|
||||
@@ -187,7 +187,7 @@ class SelectorsFormViewController : XLFormViewController {
|
||||
section.addFormRow(row)
|
||||
|
||||
// --------- MultipleSelector
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Multiple Selectors")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Multiple Selectors")
|
||||
form.addFormSection(section)
|
||||
|
||||
row = XLFormRowDescriptor(tag: Tags.MultipleSelector, rowType:XLFormRowDescriptorTypeMultipleSelector, title:"Multiple Selector")
|
||||
@@ -206,26 +206,26 @@ class SelectorsFormViewController : XLFormViewController {
|
||||
|
||||
// Language multiple selector
|
||||
row = XLFormRowDescriptor(tag: Tags.MultipleSelector, rowType:XLFormRowDescriptorTypeMultipleSelector, title:"Multiple Selector")
|
||||
row.selectorOptions = NSLocale.ISOLanguageCodes()
|
||||
row.selectorOptions = Locale.isoLanguageCodes
|
||||
row.selectorTitle = "Languages"
|
||||
row.valueTransformer = ISOLanguageCodesValueTranformer.self
|
||||
row.value = NSLocale.preferredLanguages()
|
||||
row.value = Locale.preferredLanguages
|
||||
section.addFormRow(row)
|
||||
|
||||
|
||||
if UIDevice.currentDevice().userInterfaceIdiom == .Pad {
|
||||
if UIDevice.current.userInterfaceIdiom == .pad {
|
||||
// Language multiple selector popover
|
||||
row = XLFormRowDescriptor(tag: Tags.MultipleSelectorPopover, rowType:XLFormRowDescriptorTypeMultipleSelectorPopover, title:"Multiple Selector PopOver")
|
||||
row.selectorOptions = NSLocale.ISOLanguageCodes()
|
||||
row.selectorOptions = Locale.isoLanguageCodes
|
||||
row.valueTransformer = ISOLanguageCodesValueTranformer.self
|
||||
row.value = NSLocale.preferredLanguages()
|
||||
row.value = Locale.preferredLanguages
|
||||
section.addFormRow(row)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// --------- Dynamic Selectors
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Dynamic Selectors")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Dynamic Selectors")
|
||||
form.addFormSection(section)
|
||||
|
||||
row = XLFormRowDescriptor(tag: Tags.DynamicSelectors, rowType:XLFormRowDescriptorTypeButton, title:"Dynamic Selectors")
|
||||
@@ -235,7 +235,7 @@ class SelectorsFormViewController : XLFormViewController {
|
||||
|
||||
|
||||
// --------- Custom Selectors
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Custom Selectors")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Custom Selectors")
|
||||
form.addFormSection(section)
|
||||
|
||||
row = XLFormRowDescriptor(tag: Tags.CustomSelectors, rowType:XLFormRowDescriptorTypeButton, title:"Custom Selectors")
|
||||
@@ -244,7 +244,7 @@ class SelectorsFormViewController : XLFormViewController {
|
||||
|
||||
|
||||
// --------- Selector definition types
|
||||
section = XLFormSectionDescriptor.formSectionWithTitle("Selectors")
|
||||
section = XLFormSectionDescriptor.formSection(withTitle: "Selectors")
|
||||
form.addFormSection(section)
|
||||
|
||||
// selector with segue class
|
||||
@@ -280,7 +280,7 @@ class SelectorsFormViewController : XLFormViewController {
|
||||
}
|
||||
|
||||
|
||||
override func storyboardForRow(formRow: XLFormRowDescriptor!) -> UIStoryboard! {
|
||||
override func storyboard(forRow formRow: XLFormRowDescriptor!) -> UIStoryboard! {
|
||||
return UIStoryboard(name: "iPhoneStoryboard", bundle:nil)
|
||||
}
|
||||
|
||||
|
||||
+14
-14
@@ -25,13 +25,13 @@
|
||||
|
||||
class UICustomizationFormViewController : XLFormViewController {
|
||||
|
||||
private struct Tags {
|
||||
fileprivate struct Tags {
|
||||
static let Name = "Name"
|
||||
static let Button = "Button"
|
||||
}
|
||||
|
||||
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
self.initializeForm()
|
||||
}
|
||||
@@ -55,15 +55,15 @@ class UICustomizationFormViewController : XLFormViewController {
|
||||
// Name
|
||||
row = XLFormRowDescriptor(tag: Tags.Name, rowType: XLFormRowDescriptorTypeText, title:"Name")
|
||||
// change the background color
|
||||
row.cellConfigAtConfigure["backgroundColor"] = UIColor.greenColor()
|
||||
row.cellConfigAtConfigure["backgroundColor"] = UIColor.green
|
||||
// font
|
||||
row.cellConfig["textLabel.font"] = UIFont.systemFontOfSize(30)
|
||||
row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 30)
|
||||
// background color
|
||||
row.cellConfig["textField.backgroundColor"] = UIColor.grayColor()
|
||||
row.cellConfig["textField.backgroundColor"] = UIColor.gray
|
||||
// font
|
||||
row.cellConfig["textField.font"] = UIFont.systemFontOfSize(25)
|
||||
row.cellConfig["textField.font"] = UIFont.systemFont(ofSize: 25)
|
||||
// alignment
|
||||
row.cellConfig["textField.textAlignment"] = NSTextAlignment.Right.rawValue
|
||||
row.cellConfig["textField.textAlignment"] = NSTextAlignment.right.rawValue
|
||||
section.addFormRow(row)
|
||||
|
||||
|
||||
@@ -73,23 +73,23 @@ class UICustomizationFormViewController : XLFormViewController {
|
||||
|
||||
//Button
|
||||
row = XLFormRowDescriptor(tag: Tags.Button, rowType: XLFormRowDescriptorTypeButton, title:"Button")
|
||||
row.cellConfigAtConfigure["backgroundColor"] = UIColor.purpleColor()
|
||||
row.cellConfig["textLabel.color"] = UIColor.whiteColor()
|
||||
row.cellConfig["textLabel.font"] = UIFont.systemFontOfSize(40)
|
||||
row.cellConfigAtConfigure["backgroundColor"] = UIColor.purple
|
||||
row.cellConfig["textLabel.color"] = UIColor.white
|
||||
row.cellConfig["textLabel.font"] = UIFont.systemFont(ofSize: 40)
|
||||
section.addFormRow(row)
|
||||
|
||||
self.form = form
|
||||
}
|
||||
|
||||
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
|
||||
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
||||
// change cell height of a particular cell
|
||||
if form.formRowAtIndex(indexPath)?.tag == "Name" {
|
||||
if form.formRow(atIndex: indexPath)?.tag == "Name" {
|
||||
return 60.0
|
||||
}
|
||||
else if form.formRowAtIndex(indexPath)?.tag == "Button" {
|
||||
else if form.formRow(atIndex: indexPath)?.tag == "Button" {
|
||||
return 100.0
|
||||
}
|
||||
return super.tableView(tableView, heightForRowAtIndexPath: indexPath)
|
||||
return super.tableView(tableView, heightForRowAt: indexPath)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+23
-23
@@ -26,7 +26,7 @@
|
||||
|
||||
class ValidationExamplesFormViewController : XLFormViewController {
|
||||
|
||||
private struct Tags {
|
||||
fileprivate struct Tags {
|
||||
static let ValidationName = "Name"
|
||||
static let ValidationEmail = "Email"
|
||||
static let ValidationPassword = "Password"
|
||||
@@ -34,7 +34,7 @@ class ValidationExamplesFormViewController : XLFormViewController {
|
||||
}
|
||||
|
||||
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
|
||||
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
|
||||
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
|
||||
initializeForm()
|
||||
}
|
||||
@@ -60,8 +60,8 @@ class ValidationExamplesFormViewController : XLFormViewController {
|
||||
// Name
|
||||
row = XLFormRowDescriptor(tag: Tags.ValidationName, rowType: XLFormRowDescriptorTypeText, title:"Name")
|
||||
row.cellConfigAtConfigure["textField.placeholder"] = "Required..."
|
||||
row.cellConfigAtConfigure["textField.textAlignment"] = NSTextAlignment.Right.rawValue
|
||||
row.required = true
|
||||
row.cellConfigAtConfigure["textField.textAlignment"] = NSTextAlignment.right.rawValue
|
||||
row.isRequired = true
|
||||
row.value = "Martin"
|
||||
section.addFormRow(row)
|
||||
|
||||
@@ -71,10 +71,10 @@ class ValidationExamplesFormViewController : XLFormViewController {
|
||||
|
||||
// Email
|
||||
row = XLFormRowDescriptor(tag: Tags.ValidationEmail, rowType: XLFormRowDescriptorTypeText, title:"Email")
|
||||
row.cellConfigAtConfigure["textField.textAlignment"] = NSTextAlignment.Right.rawValue
|
||||
row.required = false
|
||||
row.cellConfigAtConfigure["textField.textAlignment"] = NSTextAlignment.right.rawValue
|
||||
row.isRequired = false
|
||||
row.value = "not valid email"
|
||||
row.addValidator(XLFormValidator.emailValidator())
|
||||
row.addValidator(XLFormValidator.email())
|
||||
section.addFormRow(row)
|
||||
|
||||
|
||||
@@ -86,8 +86,8 @@ class ValidationExamplesFormViewController : XLFormViewController {
|
||||
// Password
|
||||
row = XLFormRowDescriptor(tag: Tags.ValidationPassword, rowType: XLFormRowDescriptorTypePassword, title:"Password")
|
||||
row.cellConfigAtConfigure["textField.placeholder"] = "Required..."
|
||||
row.cellConfigAtConfigure["textField.textAlignment"] = NSTextAlignment.Right.rawValue
|
||||
row.required = true
|
||||
row.cellConfigAtConfigure["textField.textAlignment"] = NSTextAlignment.right.rawValue
|
||||
row.isRequired = true
|
||||
row.addValidator(XLFormRegexValidator(msg: "At least 6, max 32 characters", andRegexString: "^(?=.*\\d)(?=.*[A-Za-z]).{6,32}$"))
|
||||
section.addFormRow(row)
|
||||
|
||||
@@ -100,8 +100,8 @@ class ValidationExamplesFormViewController : XLFormViewController {
|
||||
// Integer
|
||||
row = XLFormRowDescriptor(tag: Tags.ValidationInteger, rowType:XLFormRowDescriptorTypeInteger, title:"Integer")
|
||||
row.cellConfigAtConfigure["textField.placeholder"] = "Required..."
|
||||
row.cellConfigAtConfigure["textField.textAlignment"] = NSTextAlignment.Right.rawValue
|
||||
row.required = true
|
||||
row.cellConfigAtConfigure["textField.textAlignment"] = NSTextAlignment.right.rawValue
|
||||
row.isRequired = true
|
||||
row.addValidator(XLFormRegexValidator(msg: "greater than 50 and less than 100", andRegexString: "^([5-9][0-9]|100)$"))
|
||||
section.addFormRow(row)
|
||||
|
||||
@@ -111,30 +111,30 @@ class ValidationExamplesFormViewController : XLFormViewController {
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
navigationItem.rightBarButtonItem?.target = self
|
||||
navigationItem.rightBarButtonItem?.action = "validateForm:"
|
||||
navigationItem.rightBarButtonItem?.action = #selector(ValidationExamplesFormViewController.validateForm(_:))
|
||||
}
|
||||
|
||||
|
||||
|
||||
//MARK: Actions
|
||||
|
||||
func validateForm(buttonItem: UIBarButtonItem) {
|
||||
func validateForm(_ buttonItem: UIBarButtonItem) {
|
||||
let array = formValidationErrors()
|
||||
for errorItem in array {
|
||||
for errorItem in array! {
|
||||
let error = errorItem as! NSError
|
||||
let validationStatus : XLFormValidationStatus = error.userInfo[XLValidationStatusErrorKey] as! XLFormValidationStatus
|
||||
if validationStatus.rowDescriptor!.tag == Tags.ValidationName {
|
||||
if let rowDescriptor = validationStatus.rowDescriptor, let indexPath = form.indexPathOfFormRow(rowDescriptor), let cell = tableView.cellForRowAtIndexPath(indexPath) {
|
||||
cell.backgroundColor = .orangeColor()
|
||||
UIView.animateWithDuration(0.3, animations: { () -> Void in
|
||||
cell.backgroundColor = .whiteColor()
|
||||
if let rowDescriptor = validationStatus.rowDescriptor, let indexPath = form.indexPath(ofFormRow: rowDescriptor), let cell = tableView.cellForRow(at: indexPath) {
|
||||
cell.backgroundColor = .orange
|
||||
UIView.animate(withDuration: 0.3, animations: { () -> Void in
|
||||
cell.backgroundColor = .white
|
||||
})
|
||||
}
|
||||
}
|
||||
else if validationStatus.rowDescriptor!.tag == Tags.ValidationEmail ||
|
||||
validationStatus.rowDescriptor!.tag == Tags.ValidationPassword ||
|
||||
validationStatus.rowDescriptor!.tag == Tags.ValidationInteger {
|
||||
if let rowDescriptor = validationStatus.rowDescriptor, let indexPath = form.indexPathOfFormRow(rowDescriptor), let cell = tableView.cellForRowAtIndexPath(indexPath) {
|
||||
if let rowDescriptor = validationStatus.rowDescriptor, let indexPath = form.indexPath(ofFormRow: rowDescriptor), let cell = tableView.cellForRow(at: indexPath) {
|
||||
self.animateCell(cell)
|
||||
}
|
||||
}
|
||||
@@ -144,14 +144,14 @@ class ValidationExamplesFormViewController : XLFormViewController {
|
||||
|
||||
//MARK: - Helperph
|
||||
|
||||
func animateCell(cell: UITableViewCell) {
|
||||
func animateCell(_ cell: UITableViewCell) {
|
||||
let animation = CAKeyframeAnimation()
|
||||
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.keyTimes = [0, NSNumber(value: 1 / 6.0), NSNumber(value: 3 / 6.0), NSNumber(value: 5 / 6.0), 1]
|
||||
animation.duration = 0.3
|
||||
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)
|
||||
animation.additive = true
|
||||
cell.layer.addAnimation(animation, forKey: "shake")
|
||||
animation.isAdditive = true
|
||||
cell.layer.add(animation, forKey: "shake")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ XLForm
|
||||
By [XMARTLABS](http://xmartlabs.com).
|
||||
|
||||
[](https://travis-ci.org/xmartlabs/XLForm)
|
||||
[](https://github.com/xmartlabs/XLForm/releases)
|
||||
<a href="https://cocoapods.org/pods/XLForm"><img src="https://img.shields.io/cocoapods/v/XLForm.svg" alt="CocoaPods compatible" /></a>
|
||||
|
||||
**If you are looking for Swift 2 native implementation we have recently created [Eureka], a complete re-design of XLForm in Swift 2.** *Do not panic, We will continue maintaining and improving XLForm, obj-c rocks!!*
|
||||
**If you are looking for Swift native implementation we have recently created [Eureka], a complete re-design of XLForm in Swift.** *Do not panic, We will continue maintaining and improving XLForm, obj-c rocks!!*
|
||||
|
||||
Purpose
|
||||
--------------
|
||||
@@ -15,7 +15,7 @@ XLForm is the most flexible and powerful iOS library to create dynamic table-vie
|
||||
|
||||
XLForm provides a very powerful DSL (Domain Specific Language) used to create a form. It keeps track of this specification on runtime, updating the UI on the fly.
|
||||
|
||||
#####Let's see the iOS Calendar Event Form created using XLForm
|
||||
##### Let's see the iOS Calendar Event Form created using XLForm
|
||||
|
||||
|
||||

|
||||
@@ -154,6 +154,8 @@ A form definition is a `XLFormDescriptor` instance that contains one or more sec
|
||||
row = [XLFormRowDescriptor formRowDescriptorWithTag:@"starts" rowType:XLFormRowDescriptorTypeDateTimeInline title:@"Starts"];
|
||||
row.value = [NSDate dateWithTimeIntervalSinceNow:60*60*24];
|
||||
[section addFormRow:row];
|
||||
|
||||
self.form = form;
|
||||
}
|
||||
```
|
||||
|
||||
@@ -180,7 +182,7 @@ How to run XLForm examples
|
||||
|
||||
Rows
|
||||
---------------------
|
||||
####Input Rows
|
||||
#### Input Rows
|
||||
|
||||

|
||||
|
||||
@@ -251,7 +253,7 @@ Will be represented by a `UITextView` with `UITextAutocorrectionTypeDefault`, `U
|
||||
|
||||
|
||||
|
||||
####Selector Rows
|
||||
#### Selector Rows
|
||||
|
||||
Selector rows allow us to select a value or values from a list. XLForm supports 8 types of selectors out of the box:
|
||||
|
||||
@@ -318,7 +320,7 @@ This is the protocol declaration:
|
||||
```
|
||||
|
||||
|
||||
####Date & Time Rows
|
||||
#### Date & Time Rows
|
||||
|
||||
XLForms supports 3 types of dates: `Date`, `DateTime` , `Time` and `Countdown Timer` and it's able to present the `UIDatePicker` control in 2 different ways, inline and non-inline.
|
||||
|
||||
@@ -425,7 +427,7 @@ section.addFormRow(row)
|
||||
self.form = form;
|
||||
|
||||
```
|
||||
####Boolean Rows
|
||||
#### Boolean Rows
|
||||
|
||||
XLForms supports 2 types of boolean controls:
|
||||
|
||||
@@ -443,9 +445,9 @@ static NSString *const XLFormRowDescriptorTypeBooleanSwitch = @"booleanSwitch";
|
||||
We can also simulate other types of Boolean rows using any of the Selector Row Types introduced in the [Selector Rows section](#selector-rows).
|
||||
|
||||
|
||||
####Other Rows
|
||||
#### Other Rows
|
||||
|
||||
#####Stepper
|
||||
##### Stepper
|
||||
|
||||
XLForms supports counting using UIStepper control:
|
||||
|
||||
@@ -467,7 +469,7 @@ You can set the stepper paramaters easily:
|
||||
[row.cellConfigAtConfigure setObject:@100 forKey:@"stepControl.maximumValue"];
|
||||
```
|
||||
|
||||
#####Slider
|
||||
##### Slider
|
||||
|
||||
XLForms supports counting using UISlider control:
|
||||
|
||||
@@ -488,11 +490,11 @@ You can adjust the slider for your own interests very easily:
|
||||
|
||||
Set `steps` to `@(0)` to disable the steps functionality.
|
||||
|
||||
#####Info
|
||||
##### Info
|
||||
|
||||
Sometimes our apps needs to show data that are not editable. XLForm provides us with `XLFormRowDescriptorTypeInfo` row type to display not editable info. An example of usage would be showing the app version in the settings part of an app.
|
||||
|
||||
#####Button
|
||||
##### Button
|
||||
|
||||
Apart from data entry rows, not editable rows and selectors, XLForm has a button row `XLFormRowDescriptorTypeButton` that allows us to do any action when selected. It can be configured using a block (clousure), a selector, a segue identifier, segue class or specifing a view controller to be presented. ViewController specification could be done by setting up the view controller class, the view controller storyboard Id or a nib name. Nib name must match view controller class name.
|
||||
|
||||
@@ -765,7 +767,7 @@ For instance if we want to show or hide a row depending on the value of another
|
||||
Make a row or section invisible depending on other rows values
|
||||
--------------------------------
|
||||
|
||||
###Summary
|
||||
### Summary
|
||||
|
||||
XLForm allows you to define dependencies between rows so that if the value of one row is changed, the behaviour of another one changes automatically. For example, you might have a form where you question the user if he/she has pets. If the answer is 'yes' you might want to ask how their names are.
|
||||
So you can make a row invisible and visible again based on the values of other rows. The same happens with sections.
|
||||
@@ -775,7 +777,7 @@ Take a look at the following example:
|
||||
|
||||
Of course, you could also do this manually by observing the value of some rows and deleting and adding rows accordingly, but that would be a lot of work which is already done.
|
||||
|
||||
###How it works
|
||||
### How it works
|
||||
|
||||
To make the appearance and disappearance of rows and sections automatic, there is a property in each descriptor:
|
||||
|
||||
@@ -864,6 +866,7 @@ You may want to set up another properties of the `UITableViewCell`. To set up an
|
||||
You just have to add the properties to `cellConfig` or `cellConfigAtConfigure` dictionary property of `XLFormRowDescriptor`.
|
||||
The main difference between `cellConfig` and `cellConfigAtConfigure` is the time when the property is set up. `cellConfig` properties are set up each time a cell is about to be displayed. `cellConfigAtConfigure`, on the other hand, set up the property just after the init method of the cell is called and only one time.
|
||||
|
||||
Since version 3.3.0 you can also use `cellConfigForSelector` to configure how the cells of the `XLFormOptionsViewController` look like when it is shown for a selector row.
|
||||
|
||||
For instance if you want to set up the placeholder you can do the following:
|
||||
|
||||
@@ -894,6 +897,25 @@ section.addFormRow(row)
|
||||
FAQ
|
||||
-------
|
||||
|
||||
#### How to customize the header and/or footer of a section
|
||||
|
||||
For this you should use the UITableViewDelegate methods in your XLFormViewController.
|
||||
This means you should implement one or both of these:
|
||||
|
||||
```objc
|
||||
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
||||
|
||||
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
|
||||
```
|
||||
|
||||
Also you might want to implement the following methods to specify the height for these views:
|
||||
|
||||
```objc
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
||||
|
||||
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
||||
```
|
||||
|
||||
#### How to assign the first responder on form appearance
|
||||
|
||||
Assign the first responder when the form is shown is as simple as setting the property `assignFirstResponderOnShow` to `YES`. By default the value of the property is `NO`.
|
||||
@@ -1005,7 +1027,7 @@ row.cellConfig.setObject(UIFont(name: "AppleSDGothicNeo-Regular", size: 17)!, fo
|
||||
|
||||
For further details, please take a look at [UICustomizationFormViewController.m](/Examples/Objective-C/Examples/UICustomization/UICustomizationFormViewController.m) example.
|
||||
|
||||
####How to set min/max for date cells?
|
||||
#### How to set min/max for date cells?
|
||||
|
||||
Each XLFormDateCell has a `minimumDate` and a `maximumDate` property. To set a datetime row to be a value in the next three days you would do as follows:
|
||||
|
||||
@@ -1083,6 +1105,21 @@ XLFormRowDescriptor* row = ...
|
||||
row.height = 55;
|
||||
```
|
||||
|
||||
#### How to change the appearance of the cells of a selector view controller (XLFormOptionsViewController)
|
||||
|
||||
To change the appearance of the cells of a XLFormOptionsViewController you can use the `cellConfigForSelector` property on the row descriptor.
|
||||
Example:
|
||||
```
|
||||
[row.cellConfigForSelector setObject:[UIColor redColor] forKey:@"textLabel.textColor"];
|
||||
```
|
||||
|
||||
#### How to limit the characters of a XLFormTextFieldCell or a XLFormTextViewCell
|
||||
|
||||
You can make this happen using the `textFieldMaxNumberOfCharacters` and the `textViewMaxNumberOfCharacters` respectively.
|
||||
```
|
||||
[row.cellConfigAtConfigure setObject:@(20) forKey:@"textViewMaxNumberOfCharacters"];
|
||||
```
|
||||
|
||||
Installation
|
||||
--------------------------
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ include FileUtils::Verbose
|
||||
namespace :test do
|
||||
desc "Run the XLForm Tests"
|
||||
task :ios do
|
||||
run_tests('XLForm Tests', 'iphonesimulator9.2')
|
||||
run_tests('XLForm Tests', 'iphonesimulator10.2')
|
||||
tests_failed unless $?.success?
|
||||
end
|
||||
end
|
||||
@@ -17,7 +17,7 @@ task :default => 'test'
|
||||
private
|
||||
|
||||
def run_tests(scheme, sdk)
|
||||
sh("xcodebuild -workspace 'Tests/XLForm Tests.xcworkspace' -scheme '#{scheme}' -sdk '#{sdk}' -destination 'name=iPhone 6' -configuration Release clean test | xcpretty -c ; exit ${PIPESTATUS[0]}") rescue nil
|
||||
sh("xcodebuild -workspace 'Tests/XLForm Tests.xcworkspace' -scheme '#{scheme}' -sdk '#{sdk}' -destination 'OS=10.1,name=iPhone 7' -configuration Release clean test | xcpretty -c ; exit ${PIPESTATUS[0]}") rescue nil
|
||||
end
|
||||
|
||||
def tests_failed
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
03885A911D7DD3BD00CC183A /* XLTestTextFieldProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 03885A901D7DD3BD00CC183A /* XLTestTextFieldProperties.m */; };
|
||||
17538872B9BB29167787CF50 /* libPods-XLForm Tests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E68572C5C8328F0F177BBCA1 /* libPods-XLForm Tests.a */; };
|
||||
28657A3E1990879200CE8180 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28657A3D1990879200CE8180 /* XCTest.framework */; };
|
||||
28657A401990879200CE8180 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28657A3F1990879200CE8180 /* Foundation.framework */; };
|
||||
@@ -16,10 +17,12 @@
|
||||
28657A54199154EE00CE8180 /* XLFormValidatorsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 28657A53199154EE00CE8180 /* XLFormValidatorsTests.m */; };
|
||||
3C5B9B7A1AC0BA33000AF1BA /* XLFormExampleTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C5B9B791AC0BA33000AF1BA /* XLFormExampleTest.m */; };
|
||||
3C9817861AC30616003F6ABD /* UITextField+Test.m in Sources */ = {isa = PBXBuildFile; fileRef = 3C9817851AC30616003F6ABD /* UITextField+Test.m */; };
|
||||
6233D65F1D7DF022000E7716 /* XLTestTextViewProperties.m in Sources */ = {isa = PBXBuildFile; fileRef = 6233D65E1D7DF022000E7716 /* XLTestTextViewProperties.m */; };
|
||||
BFD111841AD8323900943D23 /* XLTestHideAndShow.m in Sources */ = {isa = PBXBuildFile; fileRef = BFD111831AD8323900943D23 /* XLTestHideAndShow.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
03885A901D7DD3BD00CC183A /* XLTestTextFieldProperties.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XLTestTextFieldProperties.m; path = Test/XLTestTextFieldProperties.m; sourceTree = "<group>"; };
|
||||
28657A3A1990879200CE8180 /* XLForm Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "XLForm Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
28657A3D1990879200CE8180 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; };
|
||||
28657A3F1990879200CE8180 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
|
||||
@@ -35,6 +38,7 @@
|
||||
3C5B9B791AC0BA33000AF1BA /* XLFormExampleTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XLFormExampleTest.m; path = Test/XLFormExampleTest.m; sourceTree = "<group>"; };
|
||||
3C9817841AC30616003F6ABD /* UITextField+Test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "UITextField+Test.h"; path = "Helpers/UITextField+Test.h"; sourceTree = "<group>"; };
|
||||
3C9817851AC30616003F6ABD /* UITextField+Test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "UITextField+Test.m"; path = "Helpers/UITextField+Test.m"; sourceTree = "<group>"; };
|
||||
6233D65E1D7DF022000E7716 /* XLTestTextViewProperties.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XLTestTextViewProperties.m; path = Test/XLTestTextViewProperties.m; sourceTree = "<group>"; };
|
||||
8ADC094C94CA7ABBB8134573 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = "<group>"; };
|
||||
BFD111831AD8323900943D23 /* XLTestHideAndShow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XLTestHideAndShow.m; path = Test/XLTestHideAndShow.m; sourceTree = "<group>"; };
|
||||
C6B20EA1A9D9591335BEE81F /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
@@ -115,6 +119,8 @@
|
||||
28657A5019914F9700CE8180 /* XLTestCase.h */,
|
||||
28657A5119914F9700CE8180 /* XLTestCase.m */,
|
||||
28657A53199154EE00CE8180 /* XLFormValidatorsTests.m */,
|
||||
03885A901D7DD3BD00CC183A /* XLTestTextFieldProperties.m */,
|
||||
6233D65E1D7DF022000E7716 /* XLTestTextViewProperties.m */,
|
||||
);
|
||||
name = Tests;
|
||||
sourceTree = "<group>";
|
||||
@@ -146,12 +152,12 @@
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 28657A4C1990879200CE8180 /* Build configuration list for PBXNativeTarget "XLForm Tests" */;
|
||||
buildPhases = (
|
||||
6B058765CC1143829C6943B9 /* 📦 Check Pods Manifest.lock */,
|
||||
6B058765CC1143829C6943B9 /* [CP] Check Pods Manifest.lock */,
|
||||
28657A361990879200CE8180 /* Sources */,
|
||||
28657A371990879200CE8180 /* Frameworks */,
|
||||
28657A381990879200CE8180 /* Resources */,
|
||||
3E5FCF05A57F40C6AF367F6D /* 📦 Copy Pods Resources */,
|
||||
6A2C507B76209618EDA57426 /* 📦 Embed Pods Frameworks */,
|
||||
3E5FCF05A57F40C6AF367F6D /* [CP] Copy Pods Resources */,
|
||||
6A2C507B76209618EDA57426 /* [CP] Embed Pods Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -199,14 +205,14 @@
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
3E5FCF05A57F40C6AF367F6D /* 📦 Copy Pods Resources */ = {
|
||||
3E5FCF05A57F40C6AF367F6D /* [CP] Copy Pods Resources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "📦 Copy Pods Resources";
|
||||
name = "[CP] Copy Pods Resources";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -214,14 +220,14 @@
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-XLForm Tests/Pods-XLForm Tests-resources.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
6A2C507B76209618EDA57426 /* 📦 Embed Pods Frameworks */ = {
|
||||
6A2C507B76209618EDA57426 /* [CP] Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "📦 Embed Pods Frameworks";
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -229,19 +235,19 @@
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-XLForm Tests/Pods-XLForm Tests-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
6B058765CC1143829C6943B9 /* 📦 Check Pods Manifest.lock */ = {
|
||||
6B058765CC1143829C6943B9 /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "📦 Check Pods Manifest.lock";
|
||||
name = "[CP] Check Pods Manifest.lock";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
|
||||
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
@@ -253,7 +259,9 @@
|
||||
files = (
|
||||
28657A54199154EE00CE8180 /* XLFormValidatorsTests.m in Sources */,
|
||||
28657A5219914F9700CE8180 /* XLTestCase.m in Sources */,
|
||||
03885A911D7DD3BD00CC183A /* XLTestTextFieldProperties.m in Sources */,
|
||||
BFD111841AD8323900943D23 /* XLTestHideAndShow.m in Sources */,
|
||||
6233D65F1D7DF022000E7716 /* XLTestTextViewProperties.m in Sources */,
|
||||
3C5B9B7A1AC0BA33000AF1BA /* XLFormExampleTest.m in Sources */,
|
||||
3C9817861AC30616003F6ABD /* UITextField+Test.m in Sources */,
|
||||
);
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// XLTestTextFieldProperties.m
|
||||
// XLForm Tests
|
||||
//
|
||||
// Created by Claus on 9/5/16.
|
||||
//
|
||||
//
|
||||
|
||||
#import "XLTestCase.h"
|
||||
#import <XLForm/XLFormTextFieldCell.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface XLTestTextFieldProperties : XLTestCase
|
||||
@end
|
||||
|
||||
@implementation XLTestTextFieldProperties
|
||||
|
||||
- (void)testPropertiesGetSet
|
||||
{
|
||||
// Get the tableView
|
||||
UITableView * tableView = self.formController.tableView;
|
||||
|
||||
UITableViewCell * cell = [self.formController tableView:tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
|
||||
|
||||
// Check if the cell contains the correct properties
|
||||
expect(cell).to.beKindOf([XLFormTextFieldCell class]);
|
||||
XLFormTextFieldCell * textFieldCell = (XLFormTextFieldCell *)cell;
|
||||
expect(textFieldCell.textFieldLengthPercentage).to.equal(0.3);
|
||||
expect(textFieldCell.textFieldMaxNumberOfCharacters).to.equal(10);
|
||||
}
|
||||
|
||||
- (void)testMaxNumbersOfCharacters
|
||||
{
|
||||
// Get the tableView
|
||||
UITableView * tableView = self.formController.tableView;
|
||||
|
||||
UITableViewCell * cell = [self.formController tableView:tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
|
||||
expect(cell).to.beKindOf([XLFormTextFieldCell class]);
|
||||
XLFormTextFieldCell * textFieldCell = (XLFormTextFieldCell *)cell;
|
||||
|
||||
// Check if range check works
|
||||
expect(cell).to.conformTo(@protocol(UITextFieldDelegate));
|
||||
id<UITextFieldDelegate> textFieldDelegate = (id<UITextFieldDelegate>)cell;
|
||||
NSRange range = NSMakeRange(0, 0);
|
||||
expect([textFieldDelegate textField:textFieldCell.textField shouldChangeCharactersInRange:range replacementString:@"123"]).to.beTruthy();
|
||||
expect([textFieldDelegate textField:textFieldCell.textField shouldChangeCharactersInRange:range replacementString:@"1234567890"]).to.beTruthy();
|
||||
expect([textFieldDelegate textField:textFieldCell.textField shouldChangeCharactersInRange:range replacementString:@"12345678901"]).to.beFalsy();
|
||||
}
|
||||
|
||||
#pragma mark - Build Form
|
||||
|
||||
-(void)buildForm
|
||||
{
|
||||
XLFormDescriptor * form = [XLFormDescriptor formDescriptor];
|
||||
XLFormSectionDescriptor * section = [XLFormSectionDescriptor formSection];
|
||||
[form addFormSection:section];
|
||||
|
||||
XLFormRowDescriptor * row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeText];
|
||||
[row.cellConfigAtConfigure setObject:@(0.3) forKey:XLFormTextFieldLengthPercentage];
|
||||
[row.cellConfigAtConfigure setObject:@(10) forKey:XLFormTextFieldMaxNumberOfCharacters];
|
||||
[section addFormRow:row];
|
||||
|
||||
self.formController.form = form;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// XLTestTextViewProperties.m
|
||||
// XLForm Tests
|
||||
//
|
||||
// Created by Claus on 9/5/16.
|
||||
//
|
||||
//
|
||||
|
||||
#import "XLTestCase.h"
|
||||
#import <XLForm/XLFormTextViewCell.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface XLTestTextViewProperties : XLTestCase
|
||||
@end
|
||||
|
||||
@implementation XLTestTextViewProperties
|
||||
|
||||
- (void)testPropertiesGetSet
|
||||
{
|
||||
// Get the tableView
|
||||
UITableView * tableView = self.formController.tableView;
|
||||
|
||||
UITableViewCell * cell = [self.formController tableView:tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
|
||||
|
||||
// Check if the cell contains the correct properties
|
||||
expect(cell).to.beKindOf([XLFormTextViewCell class]);
|
||||
XLFormTextViewCell * textViewCell = (XLFormTextViewCell *)cell;
|
||||
expect(textViewCell.textViewLengthPercentage).to.equal(0.3);
|
||||
expect(textViewCell.textViewMaxNumberOfCharacters).to.equal(10);
|
||||
}
|
||||
|
||||
- (void)testMaxNumbersOfCharacters
|
||||
{
|
||||
// Get the tableView
|
||||
UITableView * tableView = self.formController.tableView;
|
||||
|
||||
UITableViewCell * cell = [self.formController tableView:tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
|
||||
expect(cell).to.beKindOf([XLFormTextViewCell class]);
|
||||
XLFormTextViewCell * textViewCell = (XLFormTextViewCell *)cell;
|
||||
|
||||
// Check if range check works
|
||||
expect(cell).to.conformTo(@protocol(UITextViewDelegate));
|
||||
id<UITextViewDelegate> textFieldDelegate = (id<UITextViewDelegate>)cell;
|
||||
NSRange range = NSMakeRange(0, 0);
|
||||
expect([textFieldDelegate textView:textViewCell.textView shouldChangeTextInRange:range replacementText:@"123"]).to.beTruthy();
|
||||
expect([textFieldDelegate textView:textViewCell.textView shouldChangeTextInRange:range replacementText:@"1234567890"]).to.beTruthy();
|
||||
expect([textFieldDelegate textView:textViewCell.textView shouldChangeTextInRange:range replacementText:@"12345678901"]).to.beFalsy();
|
||||
}
|
||||
|
||||
#pragma mark - Build Form
|
||||
|
||||
-(void)buildForm
|
||||
{
|
||||
XLFormDescriptor * form = [XLFormDescriptor formDescriptor];
|
||||
XLFormSectionDescriptor * section = [XLFormSectionDescriptor formSection];
|
||||
[form addFormSection:section];
|
||||
|
||||
XLFormRowDescriptor * row = [XLFormRowDescriptor formRowDescriptorWithTag:nil rowType:XLFormRowDescriptorTypeTextView];
|
||||
[row.cellConfigAtConfigure setObject:@(0.3) forKey:XLFormTextViewLengthPercentage];
|
||||
[row.cellConfigAtConfigure setObject:@(10) forKey:XLFormTextViewMaxNumberOfCharacters];
|
||||
[section addFormRow:row];
|
||||
|
||||
self.formController.form = form;
|
||||
}
|
||||
|
||||
@end
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'XLForm'
|
||||
s.version = '3.2.0'
|
||||
s.version = '3.3.0'
|
||||
s.license = { :type => 'MIT' }
|
||||
s.summary = 'XLForm is the most flexible and powerful iOS library to create dynamic table-view forms.'
|
||||
s.description = <<-DESC
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
@implementation XLFormBaseCell
|
||||
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
|
||||
{
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self) {
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
@implementation XLFormButtonCell
|
||||
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
|
||||
{
|
||||
return [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
}
|
||||
@@ -57,7 +57,7 @@
|
||||
[self.tintColor getRed:&red green:&green blue:&blue alpha:&alpha];
|
||||
self.textLabel.textColor = [UIColor colorWithRed:red green:green blue:blue alpha:(isDisabled ? 0.3 : 1.0)];
|
||||
}
|
||||
|
||||
|
||||
self.detailTextLabel.text = self.rowDescriptor.value;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,5 +38,6 @@ typedef NS_ENUM(NSUInteger, XLFormDateDatePickerMode) {
|
||||
@property (nonatomic) NSDate *minimumDate;
|
||||
@property (nonatomic) NSDate *maximumDate;
|
||||
@property (nonatomic) NSInteger minuteInterval;
|
||||
@property (nonatomic) NSLocale *locale;
|
||||
|
||||
@end
|
||||
|
||||
@@ -179,7 +179,9 @@
|
||||
return [NSDateFormatter localizedStringFromDate:date dateStyle:NSDateFormatterNoStyle timeStyle:NSDateFormatterShortStyle];
|
||||
}
|
||||
else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeCountDownTimer] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeCountDownTimerInline]){
|
||||
NSDateComponents *time = [[NSCalendar currentCalendar] components:NSCalendarUnitHour | NSCalendarUnitMinute fromDate:date];
|
||||
NSCalendar *calendar = [NSCalendar currentCalendar];
|
||||
[calendar setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
|
||||
NSDateComponents *time = [calendar components:NSCalendarUnitHour | NSCalendarUnitMinute fromDate:date];
|
||||
return [NSString stringWithFormat:@"%ld%@ %ldmin", (long)[time hour], (long)[time hour] == 1 ? @"hour" : @"hours", (long)[time minute]];
|
||||
}
|
||||
return [NSDateFormatter localizedStringFromDate:date dateStyle:NSDateFormatterShortStyle timeStyle:NSDateFormatterShortStyle];
|
||||
@@ -195,6 +197,7 @@
|
||||
}
|
||||
else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeCountDownTimer] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeCountDownTimerInline]){
|
||||
datePicker.datePickerMode = UIDatePickerModeCountDownTimer;
|
||||
datePicker.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
|
||||
}
|
||||
else{
|
||||
datePicker.datePickerMode = UIDatePickerModeDateAndTime;
|
||||
@@ -208,6 +211,10 @@
|
||||
|
||||
if (self.maximumDate)
|
||||
datePicker.maximumDate = self.maximumDate;
|
||||
|
||||
if (self.locale) {
|
||||
datePicker.locale = self.locale;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Properties
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
return tranformedValue;
|
||||
}
|
||||
}
|
||||
return [self.rowDescriptor.value displayText];
|
||||
return self.rowDescriptor.displayTextValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -266,7 +266,16 @@
|
||||
alertController.popoverPresentationController.sourceRect = [formViewController.tableView convertRect:v.frame fromView:self];
|
||||
__weak __typeof(self)weakSelf = self;
|
||||
for (id option in self.rowDescriptor.selectorOptions) {
|
||||
[alertController addAction:[UIAlertAction actionWithTitle:[option displayText]
|
||||
NSString *optionTitle = [option displayText];
|
||||
if (self.rowDescriptor.valueTransformer){
|
||||
NSAssert([self.rowDescriptor.valueTransformer isSubclassOfClass:[NSValueTransformer class]], @"valueTransformer is not a subclass of NSValueTransformer");
|
||||
NSValueTransformer * valueTransformer = [self.rowDescriptor.valueTransformer new];
|
||||
NSString * transformedValue = [valueTransformer transformedValue:[option valueData]];
|
||||
if (transformedValue) {
|
||||
optionTitle = transformedValue;
|
||||
}
|
||||
}
|
||||
[alertController addAction:[UIAlertAction actionWithTitle:optionTitle
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction *action) {
|
||||
[weakSelf.rowDescriptor setValue:option];
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
#pragma mark - XLFormStepCounterCell
|
||||
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self) {
|
||||
// Initialization code
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
extern NSString *const XLFormTextFieldLengthPercentage;
|
||||
extern NSString *const XLFormTextFieldMaxNumberOfCharacters;
|
||||
|
||||
@interface XLFormTextFieldCell : XLFormBaseCell <XLFormReturnKeyProtocol>
|
||||
|
||||
@@ -34,5 +35,6 @@ extern NSString *const XLFormTextFieldLengthPercentage;
|
||||
@property (nonatomic, readonly) UITextField * textField;
|
||||
|
||||
@property (nonatomic) NSNumber *textFieldLengthPercentage;
|
||||
@property (nonatomic) NSNumber *textFieldMaxNumberOfCharacters;
|
||||
|
||||
@end
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#import "XLFormTextFieldCell.h"
|
||||
|
||||
NSString *const XLFormTextFieldLengthPercentage = @"textFieldLengthPercentage";
|
||||
NSString *const XLFormTextFieldMaxNumberOfCharacters = @"textFieldMaxNumberOfCharacters";
|
||||
|
||||
@interface XLFormTextFieldCell() <UITextFieldDelegate>
|
||||
|
||||
@@ -278,6 +279,15 @@ NSString *const XLFormTextFieldLengthPercentage = @"textFieldLengthPercentage";
|
||||
}
|
||||
|
||||
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
|
||||
if (self.textFieldMaxNumberOfCharacters) {
|
||||
// Check maximum length requirement
|
||||
NSString *newString = [textField.text stringByReplacingCharactersInRange:range withString:string];
|
||||
if (newString.length > self.textFieldMaxNumberOfCharacters.integerValue) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, leave response to view controller
|
||||
return [self.formViewController textField:textField shouldChangeCharactersInRange:range replacementString:string];
|
||||
}
|
||||
|
||||
@@ -331,7 +341,7 @@ NSString *const XLFormTextFieldLengthPercentage = @"textFieldLengthPercentage";
|
||||
if (!didUseFormatter)
|
||||
{
|
||||
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeNumber] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeDecimal]){
|
||||
self.rowDescriptor.value = [NSDecimalNumber decimalNumberWithString: self.textField.text];
|
||||
self.rowDescriptor.value = [NSDecimalNumber decimalNumberWithString:self.textField.text locale:NSLocale.currentLocale];
|
||||
} else if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeInteger]){
|
||||
self.rowDescriptor.value = @([self.textField.text integerValue]);
|
||||
} else {
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
extern NSString *const XLFormTextViewLengthPercentage;
|
||||
extern NSString *const XLFormTextViewMaxNumberOfCharacters;
|
||||
|
||||
@interface XLFormTextViewCell : XLFormBaseCell
|
||||
|
||||
@@ -36,5 +37,6 @@ extern NSString *const XLFormTextViewLengthPercentage;
|
||||
@property (nonatomic, readonly) XLFormTextView * textView;
|
||||
|
||||
@property (nonatomic) NSNumber *textViewLengthPercentage;
|
||||
@property (nonatomic) NSNumber *textViewMaxNumberOfCharacters;
|
||||
|
||||
@end
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
#import "XLFormTextView.h"
|
||||
#import "XLFormTextViewCell.h"
|
||||
|
||||
NSString *const kFormTextViewCellPlaceholder = @"placeholder";
|
||||
NSString *const XLFormTextViewLengthPercentage = @"textViewLengthPercentage";
|
||||
NSString *const XLFormTextViewMaxNumberOfCharacters = @"textViewMaxNumberOfCharacters";
|
||||
|
||||
@interface XLFormTextViewCell() <UITextViewDelegate>
|
||||
|
||||
@@ -207,6 +207,15 @@ NSString *const XLFormTextViewLengthPercentage = @"textViewLengthPercentage";
|
||||
}
|
||||
|
||||
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
|
||||
if (self.textViewMaxNumberOfCharacters) {
|
||||
// Check maximum length requirement
|
||||
NSString *newText = [textView.text stringByReplacingCharactersInRange:range withString:text];
|
||||
if (newText.length > self.textViewMaxNumberOfCharacters.integerValue) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, leave response to view controller
|
||||
return [self.formViewController textView:textView shouldChangeTextInRange:range replacementText:text];
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
return [[XLFormOptionsObject alloc] initWithValue:value displayText:displayText];
|
||||
}
|
||||
|
||||
-(id)initWithValue:(id)value displayText:(NSString *)displayText
|
||||
-(instancetype)initWithValue:(id)value displayText:(NSString *)displayText
|
||||
{
|
||||
self = [super init];
|
||||
if (self){
|
||||
@@ -94,7 +94,7 @@
|
||||
[encoder encodeObject:self.formDisplayText
|
||||
forKey:@"formDisplayText"];
|
||||
}
|
||||
-(id)initWithCoder:(NSCoder *)decoder
|
||||
-(instancetype)initWithCoder:(NSCoder *)decoder
|
||||
{
|
||||
if ((self=[super init])) {
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
|
||||
@interface XLFormOptionsViewController : UITableViewController<XLFormRowDescriptorViewController, XLFormRowDescriptorPopoverViewController>
|
||||
|
||||
- (id)initWithStyle:(UITableViewStyle)style;
|
||||
- (instancetype)initWithStyle:(UITableViewStyle)style;
|
||||
|
||||
|
||||
- (id)initWithStyle:(UITableViewStyle)style
|
||||
- (instancetype)initWithStyle:(UITableViewStyle)style
|
||||
titleHeaderSection:(NSString *)titleHeaderSection
|
||||
titleFooterSection:(NSString *)titleFooterSection;
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
@synthesize rowDescriptor = _rowDescriptor;
|
||||
@synthesize popoverController = __popoverController;
|
||||
|
||||
- (id)initWithStyle:(UITableViewStyle)style
|
||||
- (instancetype)initWithStyle:(UITableViewStyle)style
|
||||
{
|
||||
self = [super initWithStyle:style];
|
||||
if (self){
|
||||
@@ -57,7 +57,7 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)initWithStyle:(UITableViewStyle)style titleHeaderSection:(NSString *)titleHeaderSection titleFooterSection:(NSString *)titleFooterSection
|
||||
- (instancetype)initWithStyle:(UITableViewStyle)style titleHeaderSection:(NSString *)titleHeaderSection titleFooterSection:(NSString *)titleFooterSection
|
||||
{
|
||||
self = [self initWithStyle:style];
|
||||
if (self){
|
||||
@@ -86,6 +86,11 @@
|
||||
{
|
||||
XLFormRightDetailCell * cell = [tableView dequeueReusableCellWithIdentifier:CELL_REUSE_IDENTIFIER forIndexPath:indexPath];
|
||||
id cellObject = [[self selectorOptions] objectAtIndex:indexPath.row];
|
||||
|
||||
[self.rowDescriptor.cellConfigForSelector enumerateKeysAndObjectsUsingBlock:^(NSString *keyPath, id value, __unused BOOL *stop) {
|
||||
[cell setValue:(value == [NSNull null]) ? nil : value forKeyPath:keyPath];
|
||||
}];
|
||||
|
||||
cell.textLabel.text = [self valueDisplayTextForOption:cellObject];
|
||||
if ([self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelector] || [self.rowDescriptor.rowType isEqualToString:XLFormRowDescriptorTypeMultipleSelectorPopover]){
|
||||
cell.accessoryType = ([self selectedValuesContainsOption:cellObject] ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone);
|
||||
@@ -133,8 +138,8 @@
|
||||
if ([[self.rowDescriptor.value valueData] isEqual:[cellObject valueData]]){
|
||||
if (!self.rowDescriptor.required){
|
||||
self.rowDescriptor.value = nil;
|
||||
cell.accessoryType = UITableViewCellAccessoryNone;
|
||||
}
|
||||
cell.accessoryType = UITableViewCellAccessoryNone;
|
||||
}
|
||||
else{
|
||||
if (self.rowDescriptor.value){
|
||||
|
||||
@@ -68,12 +68,12 @@
|
||||
|
||||
#pragma mark - Initialization
|
||||
|
||||
-(id)initWithForm:(XLFormDescriptor *)form
|
||||
-(instancetype)initWithForm:(XLFormDescriptor *)form
|
||||
{
|
||||
return [self initWithForm:form style:UITableViewStyleGrouped];
|
||||
}
|
||||
|
||||
-(id)initWithForm:(XLFormDescriptor *)form style:(UITableViewStyle)style
|
||||
-(instancetype)initWithForm:(XLFormDescriptor *)form style:(UITableViewStyle)style
|
||||
{
|
||||
self = [self initWithNibName:nil bundle:nil];
|
||||
if (self){
|
||||
|
||||
@@ -67,6 +67,7 @@ typedef void(^XLOnChangeBlock)(id __nullable oldValue,id __nullable newValue,XLF
|
||||
- (nonnull NSString *) editTextValue;
|
||||
|
||||
@property (nonatomic, readonly, nonnull) NSMutableDictionary * cellConfig;
|
||||
@property (nonatomic, readonly, nonnull) NSMutableDictionary * cellConfigForSelector;
|
||||
@property (nonatomic, readonly, nonnull) NSMutableDictionary * cellConfigIfDisabled;
|
||||
@property (nonatomic, readonly, nonnull) NSMutableDictionary * cellConfigAtConfigure;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#import "XLFormRowDescriptor.h"
|
||||
#import "NSString+XLFormAdditions.h"
|
||||
|
||||
CGFloat XLFormUnspecifiedCellHeight = -1.0;
|
||||
CGFloat XLFormUnspecifiedCellHeight = -3.0;
|
||||
CGFloat XLFormRowInitialHeight = -2;
|
||||
|
||||
@interface XLFormDescriptor (_XLFormRowDescriptor)
|
||||
@@ -69,6 +69,7 @@ CGFloat XLFormRowInitialHeight = -2;
|
||||
@synthesize hidePredicateCache = _hidePredicateCache;
|
||||
@synthesize disablePredicateCache = _disablePredicateCache;
|
||||
@synthesize cellConfig = _cellConfig;
|
||||
@synthesize cellConfigForSelector = _cellConfigForSelector;
|
||||
@synthesize cellConfigIfDisabled = _cellConfigIfDisabled;
|
||||
@synthesize cellConfigAtConfigure = _cellConfigAtConfigure;
|
||||
@synthesize height = _height;
|
||||
@@ -165,6 +166,14 @@ CGFloat XLFormRowInitialHeight = -2;
|
||||
return _cellConfig;
|
||||
}
|
||||
|
||||
-(NSMutableDictionary *)cellConfigForSelector
|
||||
{
|
||||
if (_cellConfigForSelector) return _cellConfigForSelector;
|
||||
_cellConfigForSelector = [NSMutableDictionary dictionary];
|
||||
return _cellConfigForSelector;
|
||||
}
|
||||
|
||||
|
||||
-(NSMutableDictionary *)cellConfigIfDisabled
|
||||
{
|
||||
if (_cellConfigIfDisabled) return _cellConfigIfDisabled;
|
||||
@@ -580,7 +589,7 @@ CGFloat XLFormRowInitialHeight = -2;
|
||||
}
|
||||
|
||||
|
||||
-(id)initWithLeftValue:(NSString *)leftValue httpParameterKey:(NSString *)httpParameterKey rightOptions:(NSArray *)rightOptions
|
||||
-(instancetype)initWithLeftValue:(NSString *)leftValue httpParameterKey:(NSString *)httpParameterKey rightOptions:(NSArray *)rightOptions
|
||||
{
|
||||
self = [super init];
|
||||
if (self){
|
||||
|
||||
@@ -69,5 +69,6 @@ typedef NS_ENUM(NSUInteger, XLFormSectionInsertMode) {
|
||||
-(void)addFormRow:(nonnull XLFormRowDescriptor *)formRow beforeRow:(nonnull XLFormRowDescriptor *)beforeRow;
|
||||
-(void)removeFormRowAtIndex:(NSUInteger)index;
|
||||
-(void)removeFormRow:(nonnull XLFormRowDescriptor *)formRow;
|
||||
- (void)moveRowAtIndexPath:(NSIndexPath *)sourceIndex toIndexPath:(NSIndexPath *)destinationIndex;
|
||||
|
||||
@end
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
@implementation XLFormRightDetailCell
|
||||
|
||||
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
|
||||
{
|
||||
return [super initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseIdentifier];
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
@synthesize doneButton = _doneButton;
|
||||
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 44.0)];
|
||||
if (self) {
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)frame
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
if((self = [super initWithFrame:frame])){
|
||||
self.scrollsToTop = NO;
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
@property NSString *msg;
|
||||
@property NSString *regex;
|
||||
|
||||
- (id)initWithMsg:(NSString*)msg andRegexString:(NSString*)regex;
|
||||
- (instancetype)initWithMsg:(NSString*)msg andRegexString:(NSString*)regex;
|
||||
+ (XLFormRegexValidator *)formRegexValidatorWithMsg:(NSString *)msg regex:(NSString *)regex;
|
||||
|
||||
@end
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
@implementation XLFormRegexValidator
|
||||
|
||||
-(id)initWithMsg:(NSString*)msg andRegexString:(NSString*)regex {
|
||||
-(instancetype)initWithMsg:(NSString*)msg andRegexString:(NSString*)regex {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.msg = msg;
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
@property BOOL isValid;
|
||||
@property (nonatomic, weak) XLFormRowDescriptor *rowDescriptor;
|
||||
|
||||
//-(id)initWithMsg:(NSString*)msg andStatus:(BOOL)isValid;
|
||||
-(id)initWithMsg:(NSString*)msg status:(BOOL)isValid rowDescriptor:(XLFormRowDescriptor *)row;
|
||||
//-(instancetype)initWithMsg:(NSString*)msg andStatus:(BOOL)isValid;
|
||||
-(instancetype)initWithMsg:(NSString*)msg status:(BOOL)isValid rowDescriptor:(XLFormRowDescriptor *)row;
|
||||
|
||||
//+(XLFormValidationStatus *)formValidationStatusWithMsg:(NSString *)msg status:(BOOL)status;
|
||||
+(XLFormValidationStatus *)formValidationStatusWithMsg:(NSString *)msg status:(BOOL)status rowDescriptor:(XLFormRowDescriptor *)row;
|
||||
|
||||
@@ -27,11 +27,11 @@
|
||||
|
||||
@implementation XLFormValidationStatus
|
||||
|
||||
-(id)initWithMsg:(NSString*)msg andStatus:(BOOL)isValid {
|
||||
-(instancetype)initWithMsg:(NSString*)msg andStatus:(BOOL)isValid {
|
||||
return [self initWithMsg:msg status:isValid rowDescriptor:nil];
|
||||
}
|
||||
|
||||
-(id)initWithMsg:(NSString*)msg status:(BOOL)isValid rowDescriptor:(XLFormRowDescriptor *)row {
|
||||
-(instancetype)initWithMsg:(NSString*)msg status:(BOOL)isValid rowDescriptor:(XLFormRowDescriptor *)row {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.msg = msg;
|
||||
|
||||
Reference in New Issue
Block a user