├── .gitignore ├── ColorPicker ├── ColorPalettes.swift ├── ColorPickerRow.swift ├── ColorRow.swift ├── ColorSwatchCell.swift ├── ColorSwatchView.swift └── InlineColorPickerRow.swift ├── ColorPickerRow.podspec ├── Example.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── IDEWorkspaceChecks.plist │ └── xcuserdata │ │ └── mall.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcshareddata │ └── xcschemes │ └── Example.xcscheme ├── Example.xcworkspace ├── contents.xcworkspacedata └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── Example ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist └── ViewController.swift ├── LICENSE ├── Package.swift ├── Podfile ├── Podfile.lock ├── Pods ├── Eureka │ ├── LICENSE │ ├── README.md │ └── Source │ │ ├── Core │ │ ├── BaseRow.swift │ │ ├── Cell.swift │ │ ├── CellType.swift │ │ ├── Core.swift │ │ ├── Form.swift │ │ ├── HeaderFooterView.swift │ │ ├── Helpers.swift │ │ ├── InlineRowType.swift │ │ ├── NavigationAccessoryView.swift │ │ ├── Operators.swift │ │ ├── PresenterRowType.swift │ │ ├── Row.swift │ │ ├── RowControllerType.swift │ │ ├── RowProtocols.swift │ │ ├── RowType.swift │ │ ├── Section.swift │ │ ├── SelectableRowType.swift │ │ ├── SelectableSection.swift │ │ ├── SwipeActions.swift │ │ └── Validation.swift │ │ ├── Rows │ │ ├── ActionSheetRow.swift │ │ ├── AlertRow.swift │ │ ├── ButtonRow.swift │ │ ├── ButtonRowWithPresent.swift │ │ ├── CheckRow.swift │ │ ├── Common │ │ │ ├── AlertOptionsRow.swift │ │ │ ├── DateFieldRow.swift │ │ │ ├── DateInlineFieldRow.swift │ │ │ ├── DecimalFormatter.swift │ │ │ ├── FieldRow.swift │ │ │ ├── GenericMultipleSelectorRow.swift │ │ │ ├── OptionsRow.swift │ │ │ ├── Protocols.swift │ │ │ └── SelectorRow.swift │ │ ├── Controllers │ │ │ ├── MultipleSelectorViewController.swift │ │ │ ├── SelectorAlertController.swift │ │ │ └── SelectorViewController.swift │ │ ├── DateInlineRow.swift │ │ ├── DatePickerRow.swift │ │ ├── DateRow.swift │ │ ├── DoublePickerInputRow.swift │ │ ├── DoublePickerRow.swift │ │ ├── FieldsRow.swift │ │ ├── LabelRow.swift │ │ ├── MultipleSelectorRow.swift │ │ ├── PickerInlineRow.swift │ │ ├── PickerInputRow.swift │ │ ├── PickerRow.swift │ │ ├── PopoverSelectorRow.swift │ │ ├── PushRow.swift │ │ ├── SegmentedRow.swift │ │ ├── SelectableRows │ │ │ └── ListCheckRow.swift │ │ ├── SliderRow.swift │ │ ├── StepperRow.swift │ │ ├── SwitchRow.swift │ │ ├── TextAreaRow.swift │ │ ├── TriplePickerInputRow.swift │ │ └── TriplePickerRow.swift │ │ └── Validations │ │ ├── RuleClosure.swift │ │ ├── RuleEmail.swift │ │ ├── RuleEqualsToRow.swift │ │ ├── RuleLength.swift │ │ ├── RuleRange.swift │ │ ├── RuleRegExp.swift │ │ ├── RuleRequired.swift │ │ └── RuleURL.swift ├── Manifest.lock ├── Pods.xcodeproj │ └── project.pbxproj ├── Target Support Files │ ├── Eureka │ │ ├── Eureka-Info.plist │ │ ├── Eureka-dummy.m │ │ ├── Eureka-prefix.pch │ │ ├── Eureka-umbrella.h │ │ ├── Eureka.modulemap │ │ ├── Eureka.xcconfig │ │ └── Info.plist │ ├── Pods-ColorPicker │ │ ├── Info.plist │ │ ├── Pods-ColorPicker-Info.plist │ │ ├── Pods-ColorPicker-acknowledgements.markdown │ │ ├── Pods-ColorPicker-acknowledgements.plist │ │ ├── Pods-ColorPicker-dummy.m │ │ ├── Pods-ColorPicker-frameworks.sh │ │ ├── Pods-ColorPicker-resources.sh │ │ ├── Pods-ColorPicker-umbrella.h │ │ ├── Pods-ColorPicker.debug.xcconfig │ │ ├── Pods-ColorPicker.modulemap │ │ └── Pods-ColorPicker.release.xcconfig │ └── UIColor_Hex_Swift │ │ ├── Info.plist │ │ ├── UIColor_Hex_Swift-Info.plist │ │ ├── UIColor_Hex_Swift-dummy.m │ │ ├── UIColor_Hex_Swift-prefix.pch │ │ ├── UIColor_Hex_Swift-umbrella.h │ │ ├── UIColor_Hex_Swift.modulemap │ │ └── UIColor_Hex_Swift.xcconfig └── UIColor_Hex_Swift │ ├── HEXColor │ ├── HEXColor.h │ ├── StringExtension.swift │ ├── UIColorExtension.swift │ └── UIColorInputError.swift │ ├── LICENSE │ └── README.md ├── README.md └── Screenshots └── ColorPicker.gif /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | xcuserdata 3 | *.xcuserstate 4 | -------------------------------------------------------------------------------- /ColorPicker/ColorRow.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColorRow.swift 3 | // EurekaColorPicker 4 | // 5 | // Created by Mark Alldritt on 2016-12-05. 6 | // Copyright © 2017 Late Night Software Ltd. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Eureka 11 | 12 | 13 | public final class ColorCell : Cell, CellType { 14 | 15 | public var swatchView : ColorSwatchView 16 | public var isCircular = false { 17 | didSet { 18 | swatchView.isCircular = isCircular 19 | } 20 | } 21 | 22 | private var dynamicConstraints = [NSLayoutConstraint]() 23 | 24 | required public init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 25 | swatchView = ColorSwatchView(frame: CGRect(x: 0, y: 0, width: 30, height: 30)) 26 | 27 | super.init(style: style, reuseIdentifier: reuseIdentifier) 28 | 29 | swatchView.translatesAutoresizingMaskIntoConstraints = false 30 | swatchView.isSelected = true 31 | } 32 | 33 | required public init?(coder aDecoder: NSCoder) { 34 | fatalError("init(coder:) has not been implemented") 35 | } 36 | 37 | public override func update() { 38 | super.update() 39 | } 40 | 41 | public override func setup() { 42 | super.setup() 43 | 44 | swatchView.color = row.value 45 | selectionStyle = .none 46 | accessoryView = swatchView 47 | } 48 | } 49 | 50 | // MARK: ColorRow 51 | 52 | public class _ColorRow: Row { 53 | 54 | var isCircular = false { 55 | didSet { 56 | guard let _ = section?.form else { return } 57 | updateCell() 58 | } 59 | } 60 | 61 | override open func updateCell() { 62 | super.updateCell() 63 | cell.isCircular = isCircular 64 | cell.swatchView.color = value 65 | } 66 | 67 | required public init(tag: String?) { 68 | super.init(tag: tag) 69 | displayValueFor = nil 70 | } 71 | } 72 | 73 | public final class ColorRow: _ColorRow, RowType { 74 | 75 | required public init(tag: String?) { 76 | super.init(tag: tag) 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /ColorPicker/ColorSwatchCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColorSwatchCell.swift 3 | // EurekaColorPicker 4 | // 5 | // Created by Mark Alldritt on 2016-11-20. 6 | // Copyright © 2017 Late Night Software Ltd. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | 12 | public class ColorSwatchCell: UICollectionViewCell { 13 | var swatchView : ColorSwatchView 14 | 15 | override init(frame: CGRect) { 16 | swatchView = ColorSwatchView(frame: CGRect(x: 0.0, y: 0.0, width: frame.width, height: frame.height)) 17 | 18 | super.init(frame: frame) 19 | 20 | contentView.addSubview(swatchView) 21 | } 22 | 23 | required init?(coder aDecoder: NSCoder) { 24 | fatalError("init(coder:) has not been implemented") 25 | } 26 | 27 | public var colorSpec : ColorSpec? { 28 | didSet { 29 | swatchView.color = colorSpec?.color 30 | } 31 | } 32 | 33 | public override var isSelected: Bool { 34 | didSet { 35 | swatchView.isSelected = isSelected 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ColorPicker/ColorSwatchView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ColorSwatchView.swift 3 | // EurekaColorPicker 4 | // 5 | // Created by Mark Alldritt on 2017-04-22. 6 | // Copyright © 2017 Late Night Software Ltd. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | 12 | extension UIColor { 13 | func rgba() -> (r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat) { 14 | let components = self.cgColor.components 15 | let numberOfComponents = self.cgColor.numberOfComponents 16 | 17 | switch numberOfComponents { 18 | case 4: 19 | return (components![0], components![1], components![2], components![3]) 20 | case 2: 21 | return (components![0], components![0], components![0], components![1]) 22 | default: 23 | // FIXME: Fallback to black 24 | return (0, 0, 0, 1) 25 | } 26 | } 27 | 28 | func blackOrWhiteContrastingColor() -> UIColor { 29 | let rgbaT = rgba() 30 | let value = 1 - ((0.299 * rgbaT.r) + (0.587 * rgbaT.g) + (0.114 * rgbaT.b)); 31 | return value < 0.65 ? UIColor.black : UIColor.white 32 | } 33 | 34 | func blackOrGrayContrastingColor() -> UIColor { 35 | let rgbaT = rgba() 36 | let value = 1 - ((0.299 * rgbaT.r) + (0.587 * rgbaT.g) + (0.114 * rgbaT.b)); 37 | return value < 0.75 ? UIColor.black : UIColor.lightGray 38 | } 39 | } 40 | 41 | 42 | public class ColorSwatchView : UIView { 43 | override init(frame: CGRect) { 44 | super.init(frame: frame) 45 | backgroundColor = UIColor.clear 46 | } 47 | 48 | required init?(coder aDecoder: NSCoder) { 49 | super.init(coder: aDecoder) 50 | backgroundColor = UIColor.clear 51 | } 52 | 53 | public var isCircular = false { 54 | didSet { 55 | setNeedsDisplay() 56 | } 57 | } 58 | public var color : UIColor? { 59 | didSet { 60 | setNeedsDisplay() 61 | } 62 | } 63 | public var isSelected = false { 64 | didSet { 65 | setNeedsDisplay() 66 | } 67 | } 68 | 69 | override public func draw(_ rect: CGRect) { 70 | if let color = color { 71 | let swatchRect = bounds.insetBy(dx: 1.0, dy: 1.0) 72 | let path = isCircular ? UIBezierPath(ovalIn: swatchRect) : UIBezierPath(roundedRect: swatchRect, cornerRadius: CGFloat(Int(swatchRect.width * 0.2))) 73 | 74 | color.setFill() 75 | path.fill() 76 | 77 | if isSelected { 78 | let frameColor = color.blackOrGrayContrastingColor() 79 | let selectRect = bounds.insetBy(dx: 2.0, dy: 2.0) 80 | let selectPath = isCircular ? UIBezierPath(ovalIn: selectRect) : UIBezierPath(roundedRect: selectRect, cornerRadius: CGFloat(Int(selectRect.width * 0.2))) 81 | 82 | frameColor.setStroke() 83 | selectPath.lineWidth = 3.0 84 | selectPath.stroke() 85 | 86 | if frameColor == UIColor.white && false { 87 | let outlinePath = isCircular ? UIBezierPath(ovalIn: bounds) : UIBezierPath(roundedRect: bounds, cornerRadius: CGFloat(Int(bounds.width * 0.2))) 88 | UIColor.black.setStroke() 89 | outlinePath.lineWidth = 0.5 90 | outlinePath.stroke() 91 | } 92 | } 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /ColorPicker/InlineColorPickerRow.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InlineColorPickerRow.swift 3 | // ColorPicker 4 | // 5 | // Created by Mark Alldritt on 2018-01-07. 6 | // Copyright © 2018 Late Night Software Ltd. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Eureka 11 | 12 | 13 | public final class InlineColorPickerCell : Cell, CellType { 14 | 15 | var swatchView : ColorSwatchView 16 | var isCircular = false { 17 | didSet { 18 | swatchView.isCircular = isCircular 19 | } 20 | } 21 | 22 | private var dynamicConstraints = [NSLayoutConstraint]() 23 | 24 | required public init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 25 | swatchView = ColorSwatchView(frame: CGRect(x: 0, y: 0, width: 30, height: 30)) 26 | 27 | super.init(style: style, reuseIdentifier: reuseIdentifier) 28 | 29 | swatchView.translatesAutoresizingMaskIntoConstraints = false 30 | swatchView.isSelected = true 31 | } 32 | 33 | required public init?(coder aDecoder: NSCoder) { 34 | fatalError("init(coder:) has not been implemented") 35 | } 36 | 37 | public override func update() { 38 | super.update() 39 | } 40 | 41 | public override func setup() { 42 | super.setup() 43 | 44 | swatchView.color = row.value 45 | selectionStyle = .default 46 | accessoryView = swatchView 47 | } 48 | } 49 | 50 | // MARK: InlineColorPickerRow 51 | 52 | public class _InlineColorPickerRow: Row { 53 | 54 | open var isCircular = false { 55 | didSet { 56 | guard let _ = section?.form else { return } 57 | updateCell() 58 | } 59 | } 60 | 61 | open var showsPaletteNames = true { 62 | didSet { 63 | guard let _ = section?.form else { return } 64 | updateCell() 65 | } 66 | } 67 | 68 | open var palettes : [ColorPalette] = [iOS().palette, 69 | Solarised().palette, 70 | WP8().palette, 71 | Flat().palette, 72 | Material().palette, 73 | Metro().palette] 74 | 75 | override open func updateCell() { 76 | super.updateCell() 77 | cell.isCircular = isCircular 78 | cell.swatchView.color = value 79 | cell.selectionStyle = isDisabled ? .none : .default 80 | } 81 | 82 | required public init(tag: String?) { 83 | super.init(tag: tag) 84 | displayValueFor = nil 85 | } 86 | } 87 | 88 | public final class InlineColorPickerRow: _InlineColorPickerRow, RowType, InlineRowType { 89 | public func setupInlineRow(_ inlineRow: ColorPickerRow) { 90 | inlineRow.value = value 91 | inlineRow.isCircular = isCircular 92 | inlineRow.showsCurrentSwatch = false 93 | inlineRow.cell.palettes = palettes 94 | inlineRow.showsPaletteNames = showsPaletteNames 95 | 96 | if value != nil, let indexPath = inlineRow.cell.indexPath(forColor: value!) { 97 | inlineRow.cell.colorsView.selectItem(at: indexPath, animated: true, scrollPosition: .centeredHorizontally) 98 | } 99 | } 100 | 101 | public typealias InlineRow = ColorPickerRow 102 | 103 | required public init(tag: String?) { 104 | super.init(tag: tag) 105 | onExpandInlineRow { cell, row, _ in 106 | row.deselect() 107 | } 108 | onCollapseInlineRow { cell, row, _ in 109 | row.deselect() 110 | } 111 | } 112 | 113 | public override func customDidSelect() { 114 | super.customDidSelect() 115 | if !isDisabled { 116 | toggleInlineRow() 117 | 118 | if isExpanded { 119 | if value != nil, let indexPath = inlineRow?.cell.indexPath(forColor: value!) { 120 | inlineRow?.cell.colorsView.selectItem(at: indexPath, animated: false, scrollPosition: .centeredHorizontally) 121 | } 122 | } 123 | } 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /ColorPickerRow.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'ColorPickerRow' 3 | s.version = '1.3.3' 4 | s.license = 'MIT' 5 | s.summary = 'A color picker row for use with the Eureka form library' 6 | s.homepage = 'https://github.com/EurekaCommunity/ColorPickerRow' 7 | s.source = { :git => 'https://github.com/EurekaCommunity/ColorPickerRow.git', :tag => s.version.to_s } 8 | s.ios.deployment_target = '9.3' 9 | s.ios.frameworks = 'UIKit' 10 | s.source_files = 'ColorPicker/**/*.swift' 11 | s.swift_version = '5.0' 12 | s.requires_arc = true 13 | s.author = "Mark Alldritt" 14 | s.dependencies = { 15 | 'Eureka' => '>= 5.0.0', 16 | 'UIColor_Hex_Swift' => '>= 3.0.0' 17 | } 18 | end 19 | -------------------------------------------------------------------------------- /Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example.xcodeproj/project.xcworkspace/xcuserdata/mall.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EurekaCommunity/ColorPickerRow/a6a367836a65b88dc407e63a3af51863ad116fee/Example.xcodeproj/project.xcworkspace/xcuserdata/mall.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Example.xcodeproj/xcshareddata/xcschemes/Example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 43 | 45 | 51 | 52 | 53 | 54 | 60 | 62 | 68 | 69 | 70 | 71 | 73 | 74 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /Example.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Example/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // EurekaColorPicker 4 | // 5 | // Created by Mark Alldritt on 2016-12-05. 6 | // Copyright © 2017 Late Night Software Ltd. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // 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. 24 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /Example/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "1x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "76x76" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "scale" : "2x", 86 | "size" : "83.5x83.5" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "scale" : "1x", 91 | "size" : "1024x1024" 92 | } 93 | ], 94 | "info" : { 95 | "author" : "xcode", 96 | "version" : 1 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Example/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Example/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Mark Alldritt and Late Night Software Ltd. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.3 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "ColorPickerRow", 8 | products: [ 9 | .library( 10 | name: "ColorPickerRow", 11 | targets: ["ColorPickerRow"]), 12 | ], 13 | dependencies: [ 14 | .package(url: "https://github.com/xmartlabs/Eureka.git", from: "5.3.2"), 15 | .package(name: "UIColorHexSwift", url: "https://github.com/yeahdongcn/UIColor-Hex-Swift.git", from: "5.1.0") 16 | ], 17 | targets: [ 18 | .target( 19 | name: "ColorPickerRow", 20 | dependencies: ["Eureka", "UIColorHexSwift"], 21 | path: "ColorPicker"), 22 | ] 23 | ) 24 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '10.0' 2 | source 'https://github.com/CocoaPods/Specs.git' 3 | 4 | target 'ColorPicker' do 5 | use_frameworks! 6 | 7 | pod 'Eureka', '>= 5.0' 8 | pod 'UIColor_Hex_Swift' 9 | 10 | end 11 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Eureka (5.2.1) 3 | - UIColor_Hex_Swift (5.1.0) 4 | 5 | DEPENDENCIES: 6 | - Eureka (>= 5.0) 7 | - UIColor_Hex_Swift 8 | 9 | SPEC REPOS: 10 | https://github.com/CocoaPods/Specs.git: 11 | - Eureka 12 | - UIColor_Hex_Swift 13 | 14 | SPEC CHECKSUMS: 15 | Eureka: c883105488e05bc65539f583246ecf9657cabbfe 16 | UIColor_Hex_Swift: 8be7432edacb7fa91c78aa05ef3c30b66e4f9415 17 | 18 | PODFILE CHECKSUM: a0477ad9f51c16a433fb0de98daa2dd2faaf4efe 19 | 20 | COCOAPODS: 1.8.4 21 | -------------------------------------------------------------------------------- /Pods/Eureka/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019 XMARTLABS 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Core/CellType.swift: -------------------------------------------------------------------------------- 1 | // CellType.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | // MARK: Cell Protocols 29 | 30 | public protocol BaseCellType : class { 31 | 32 | /// Method that will return the height of the cell 33 | var height : (() -> CGFloat)? { get } 34 | 35 | /** 36 | Method called once when creating a cell. Responsible for setting up the cell. 37 | */ 38 | func setup() 39 | 40 | /** 41 | Method called each time the cell is updated (e.g. 'cellForRowAtIndexPath' is called). Responsible for updating the cell. 42 | */ 43 | func update() 44 | 45 | /** 46 | Method called each time the cell is selected (tapped on by the user). 47 | */ 48 | func didSelect() 49 | 50 | /** 51 | Called when cell is about to become first responder 52 | 53 | - returns: If the cell should become first responder. 54 | */ 55 | func cellCanBecomeFirstResponder() -> Bool 56 | 57 | /** 58 | Method called when the cell becomes first responder 59 | */ 60 | func cellBecomeFirstResponder(withDirection: Direction) -> Bool 61 | 62 | /** 63 | Method called when the cell resigns first responder 64 | */ 65 | func cellResignFirstResponder() -> Bool 66 | 67 | /** 68 | A reference to the controller in which the cell is displayed. 69 | */ 70 | func formViewController () -> FormViewController? 71 | } 72 | 73 | public protocol TypedCellType: BaseCellType { 74 | 75 | associatedtype Value: Equatable 76 | 77 | /// The row associated to this cell. 78 | var row: RowOf! { get set } 79 | } 80 | 81 | public protocol CellType: TypedCellType {} 82 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Core/HeaderFooterView.swift: -------------------------------------------------------------------------------- 1 | // HeaderFooterView.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | /** 29 | Enumeration used to generate views for the header and footer of a section. 30 | 31 | - Class: Will generate a view of the specified class. 32 | - Callback->ViewType: Will generate the view as a result of the given closure. 33 | - NibFile: Will load the view from a nib file. 34 | */ 35 | public enum HeaderFooterProvider { 36 | 37 | /** 38 | * Will generate a view of the specified class. 39 | */ 40 | case `class` 41 | 42 | /** 43 | * Will generate the view as a result of the given closure. 44 | */ 45 | case callback(()->ViewType) 46 | 47 | /** 48 | * Will load the view from a nib file. 49 | */ 50 | case nibFile(name: String, bundle: Bundle?) 51 | 52 | internal func createView() -> ViewType { 53 | switch self { 54 | case .class: 55 | return ViewType() 56 | case .callback(let builder): 57 | return builder() 58 | case .nibFile(let nibName, let bundle): 59 | return (bundle ?? Bundle(for: ViewType.self)).loadNibNamed(nibName, owner: nil, options: nil)![0] as! ViewType 60 | } 61 | } 62 | } 63 | 64 | /** 65 | * Represents headers and footers of sections 66 | */ 67 | public enum HeaderFooterType { 68 | case header, footer 69 | } 70 | 71 | /** 72 | * Struct used to generate headers and footers either from a view or a String. 73 | */ 74 | public struct HeaderFooterView : ExpressibleByStringLiteral, HeaderFooterViewRepresentable { 75 | 76 | /// Holds the title of the view if it was set up with a String. 77 | public var title: String? 78 | 79 | /// Generates the view. 80 | public var viewProvider: HeaderFooterProvider? 81 | 82 | /// Closure called when the view is created. Useful to customize its appearance. 83 | public var onSetupView: ((_ view: ViewType, _ section: Section) -> Void)? 84 | 85 | /// A closure that returns the height for the header or footer view. 86 | public var height: (() -> CGFloat)? 87 | 88 | /** 89 | This method can be called to get the view corresponding to the header or footer of a section in a specific controller. 90 | 91 | - parameter section: The section from which to get the view. 92 | - parameter type: Either header or footer. 93 | - parameter controller: The controller from which to get that view. 94 | 95 | - returns: The header or footer of the specified section. 96 | */ 97 | public func viewForSection(_ section: Section, type: HeaderFooterType) -> UIView? { 98 | var view: ViewType? 99 | if type == .header { 100 | view = section.headerView as? ViewType ?? { 101 | let result = viewProvider?.createView() 102 | section.headerView = result 103 | return result 104 | }() 105 | } else { 106 | view = section.footerView as? ViewType ?? { 107 | let result = viewProvider?.createView() 108 | section.footerView = result 109 | return result 110 | }() 111 | } 112 | guard let v = view else { return nil } 113 | onSetupView?(v, section) 114 | return v 115 | } 116 | 117 | /** 118 | Initiates the view with a String as title 119 | */ 120 | public init?(title: String?) { 121 | guard let t = title else { return nil } 122 | self.init(stringLiteral: t) 123 | } 124 | 125 | /** 126 | Initiates the view with a view provider, ideal for customized headers or footers 127 | */ 128 | public init(_ provider: HeaderFooterProvider) { 129 | viewProvider = provider 130 | } 131 | 132 | /** 133 | Initiates the view with a String as title 134 | */ 135 | public init(unicodeScalarLiteral value: String) { 136 | self.title = value 137 | } 138 | 139 | /** 140 | Initiates the view with a String as title 141 | */ 142 | public init(extendedGraphemeClusterLiteral value: String) { 143 | self.title = value 144 | } 145 | 146 | /** 147 | Initiates the view with a String as title 148 | */ 149 | public init(stringLiteral value: String) { 150 | self.title = value 151 | } 152 | } 153 | 154 | extension UIView { 155 | 156 | func eurekaInvalidate() { 157 | setNeedsUpdateConstraints() 158 | updateConstraintsIfNeeded() 159 | setNeedsLayout() 160 | } 161 | 162 | } 163 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Core/Helpers.swift: -------------------------------------------------------------------------------- 1 | // Helpers.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | extension UIView { 29 | 30 | public func findFirstResponder() -> UIView? { 31 | if isFirstResponder { return self } 32 | for subView in subviews { 33 | if let firstResponder = subView.findFirstResponder() { 34 | return firstResponder 35 | } 36 | } 37 | return nil 38 | } 39 | 40 | public func formCell() -> BaseCell? { 41 | if self is UITableViewCell { 42 | return self as? BaseCell 43 | } 44 | return superview?.formCell() 45 | } 46 | } 47 | 48 | extension NSPredicate { 49 | 50 | var predicateVars: [String] { 51 | var ret = [String]() 52 | if let compoundPredicate = self as? NSCompoundPredicate { 53 | for subPredicate in compoundPredicate.subpredicates where subPredicate is NSPredicate { 54 | ret.append(contentsOf: (subPredicate as! NSPredicate).predicateVars) 55 | } 56 | } else if let comparisonPredicate = self as? NSComparisonPredicate { 57 | ret.append(contentsOf: comparisonPredicate.leftExpression.expressionVars) 58 | ret.append(contentsOf: comparisonPredicate.rightExpression.expressionVars) 59 | } 60 | return ret 61 | } 62 | } 63 | 64 | extension NSExpression { 65 | 66 | var expressionVars: [String] { 67 | switch expressionType { 68 | case .function, .variable: 69 | let str = "\(self)" 70 | if let range = str.range(of: ".") { 71 | return [String(str[str.index(str.startIndex, offsetBy: 1).. Void) -> Self { 122 | callbackOnExpandInlineRow = callback 123 | return self 124 | } 125 | 126 | /** 127 | Sets a block to be executed when a row is collapsed. 128 | */ 129 | @discardableResult 130 | public func onCollapseInlineRow(_ callback: @escaping (Cell, Self, InlineRow) -> Void) -> Self { 131 | callbackOnCollapseInlineRow = callback 132 | return self 133 | } 134 | 135 | /// Returns the block that will be executed when this row expands 136 | public var onCollapseInlineRowCallback: ((Cell, Self, InlineRow) -> Void)? { 137 | return callbackOnCollapseInlineRow as! ((Cell, Self, InlineRow) -> Void)? 138 | } 139 | 140 | /// Returns the block that will be executed when this row collapses 141 | public var onExpandInlineRowCallback: ((Cell, Self, InlineRow) -> Void)? { 142 | return callbackOnExpandInlineRow as! ((Cell, Self, InlineRow) -> Void)? 143 | } 144 | 145 | public var isExpanded: Bool { return _inlineRow != nil } 146 | public var isCollapsed: Bool { return !isExpanded } 147 | } 148 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Core/Operators.swift: -------------------------------------------------------------------------------- 1 | // Operators.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | 27 | // MARK: Operators 28 | 29 | precedencegroup FormPrecedence { 30 | associativity: left 31 | higherThan: LogicalConjunctionPrecedence 32 | } 33 | 34 | precedencegroup SectionPrecedence { 35 | associativity: left 36 | higherThan: FormPrecedence 37 | } 38 | 39 | infix operator +++ : FormPrecedence 40 | 41 | /** 42 | Appends a section to a form 43 | 44 | - parameter left: the form 45 | - parameter right: the section to be appended 46 | 47 | - returns: the updated form 48 | */ 49 | @discardableResult 50 | public func +++ (left: Form, right: Section) -> Form { 51 | left.append(right) 52 | return left 53 | } 54 | 55 | /** 56 | Appends a row to the last section of a form 57 | 58 | - parameter left: the form 59 | - parameter right: the row 60 | */ 61 | @discardableResult 62 | public func +++ (left: Form, right: BaseRow) -> Form { 63 | let section = Section() 64 | let _ = left +++ section <<< right 65 | return left 66 | } 67 | 68 | /** 69 | Creates a form with two sections 70 | 71 | - parameter left: the first section 72 | - parameter right: the second section 73 | 74 | - returns: the created form 75 | */ 76 | @discardableResult 77 | public func +++ (left: Section, right: Section) -> Form { 78 | let form = Form() 79 | let _ = form +++ left +++ right 80 | return form 81 | } 82 | 83 | /** 84 | Appends the row wrapped in a new section 85 | 86 | - parameter left: a section of the form 87 | - parameter right: a row to be appended 88 | 89 | - returns: the form 90 | */ 91 | @discardableResult 92 | public func +++ (left: Section, right: BaseRow) -> Form { 93 | let section = Section() 94 | section <<< right 95 | return left +++ section 96 | } 97 | 98 | /** 99 | Creates a form with two sections, each containing one row. 100 | 101 | - parameter left: The row for the first section 102 | - parameter right: The row for the second section 103 | 104 | - returns: the created form 105 | */ 106 | @discardableResult 107 | public func +++ (left: BaseRow, right: BaseRow) -> Form { 108 | let form = Section() <<< left +++ Section() <<< right 109 | return form 110 | } 111 | 112 | infix operator <<< : SectionPrecedence 113 | 114 | /** 115 | Appends a row to a section. 116 | 117 | - parameter left: the section 118 | - parameter right: the row to be appended 119 | 120 | - returns: the section 121 | */ 122 | @discardableResult 123 | public func <<< (left: Section, right: BaseRow) -> Section { 124 | left.append(right) 125 | return left 126 | } 127 | 128 | /** 129 | Creates a section with two rows 130 | 131 | - parameter left: The first row 132 | - parameter right: The second row 133 | 134 | - returns: the created section 135 | */ 136 | @discardableResult 137 | public func <<< (left: BaseRow, right: BaseRow) -> Section { 138 | let section = Section() 139 | section <<< left <<< right 140 | return section 141 | } 142 | 143 | /** 144 | Appends a collection of rows to a section 145 | 146 | - parameter lhs: the section 147 | - parameter rhs: the rows to be appended 148 | */ 149 | public func += (lhs: inout Section, rhs: C) where C.Iterator.Element == BaseRow { 150 | lhs.append(contentsOf: rhs) 151 | } 152 | 153 | /** 154 | Appends a collection of section to a form 155 | 156 | - parameter lhs: the form 157 | - parameter rhs: the sections to be appended 158 | */ 159 | public func += (lhs: inout Form, rhs: C) where C.Iterator.Element == Section { 160 | lhs.append(contentsOf: rhs) 161 | } 162 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Core/PresenterRowType.swift: -------------------------------------------------------------------------------- 1 | // PresenterRowType.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | /** 29 | * Protocol that every row that displays a new view controller must conform to. 30 | * This includes presenting or pushing view controllers. 31 | */ 32 | public protocol PresenterRowType: TypedRowType { 33 | 34 | associatedtype PresentedControllerType : UIViewController, TypedRowControllerType 35 | 36 | /// Defines how the view controller will be presented, pushed, etc. 37 | var presentationMode: PresentationMode? { get set } 38 | 39 | /// Will be called before the presentation occurs. 40 | var onPresentCallback: ((FormViewController, PresentedControllerType) -> Void)? { get set } 41 | } 42 | 43 | extension PresenterRowType { 44 | 45 | /** 46 | Sets a block to be executed when the row presents a view controller 47 | 48 | - parameter callback: the block 49 | 50 | - returns: this row 51 | */ 52 | @discardableResult 53 | public func onPresent(_ callback: ((FormViewController, PresentedControllerType) -> Void)?) -> Self { 54 | onPresentCallback = callback 55 | return self 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Core/RowControllerType.swift: -------------------------------------------------------------------------------- 1 | // RowControllerType.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | /** 29 | * Base protocol for view controllers presented by Eureka rows. 30 | */ 31 | public protocol RowControllerType: NSObjectProtocol { 32 | 33 | /// A closure to be called when the controller disappears. 34 | var onDismissCallback: ((UIViewController) -> Void)? { get set } 35 | } 36 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Core/RowProtocols.swift: -------------------------------------------------------------------------------- 1 | // RowProtocols.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | /** 29 | * Protocol that view controllers pushed or presented by a row should conform to. 30 | */ 31 | public protocol TypedRowControllerType: RowControllerType { 32 | associatedtype RowValue: Equatable 33 | 34 | /// The row that pushed or presented this controller 35 | var row: RowOf! { get set } 36 | } 37 | 38 | // MARK: Header Footer Protocols 39 | 40 | /** 41 | * Protocol used to set headers and footers to sections. 42 | * Can be set with a view or a String 43 | */ 44 | public protocol HeaderFooterViewRepresentable { 45 | 46 | /** 47 | This method can be called to get the view corresponding to the header or footer of a section in a specific controller. 48 | 49 | - parameter section: The section from which to get the view. 50 | - parameter type: Either header or footer. 51 | - parameter controller: The controller from which to get that view. 52 | 53 | - returns: The header or footer of the specified section. 54 | */ 55 | func viewForSection(_ section: Section, type: HeaderFooterType) -> UIView? 56 | 57 | /// If the header or footer of a section was created with a String then it will be stored in the title. 58 | var title: String? { get set } 59 | 60 | /// The height of the header or footer. 61 | var height: (() -> CGFloat)? { get set } 62 | } 63 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Core/SelectableRowType.swift: -------------------------------------------------------------------------------- 1 | // SelectableRowType.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | 27 | /** 28 | * Every row that shall be used in a SelectableSection must conform to this protocol. 29 | */ 30 | public protocol SelectableRowType: RowType { 31 | var selectableValue: Cell.Value? { get set } 32 | } 33 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Core/SwipeActions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Swipe.swift 3 | // Eureka 4 | // 5 | // Created by Marco Betschart on 14.06.17. 6 | // Copyright © 2017 Xmartlabs. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | public typealias SwipeActionHandler = (SwipeAction, BaseRow, ((Bool) -> Void)?) -> Void 13 | 14 | public class SwipeAction: ContextualAction { 15 | let handler: SwipeActionHandler 16 | let style: Style 17 | 18 | public var actionBackgroundColor: UIColor? 19 | public var image: UIImage? 20 | public var title: String? 21 | 22 | @available (*, deprecated, message: "Use actionBackgroundColor instead") 23 | public var backgroundColor: UIColor? { 24 | get { return actionBackgroundColor } 25 | set { self.actionBackgroundColor = newValue } 26 | } 27 | 28 | public init(style: Style, title: String?, handler: @escaping SwipeActionHandler){ 29 | self.style = style 30 | self.title = title 31 | self.handler = handler 32 | } 33 | 34 | func contextualAction(forRow: BaseRow) -> ContextualAction { 35 | var action: ContextualAction 36 | if #available(iOS 11, *){ 37 | action = UIContextualAction(style: style.contextualStyle as! UIContextualAction.Style, title: title){ [weak self] action, view, completion -> Void in 38 | guard let strongSelf = self else{ return } 39 | strongSelf.handler(strongSelf, forRow) { shouldComplete in 40 | if #available(iOS 13, *) { // starting in iOS 13, completion handler is not removing the row automatically, so we need to remove it ourselves 41 | if shouldComplete && action.style == .destructive { 42 | forRow.section?.remove(at: forRow.indexPath!.row) 43 | } 44 | } 45 | completion(shouldComplete) 46 | } 47 | } 48 | } else { 49 | action = UITableViewRowAction(style: style.contextualStyle as! UITableViewRowAction.Style,title: title){ [weak self] (action, indexPath) -> Void in 50 | guard let strongSelf = self else{ return } 51 | strongSelf.handler(strongSelf, forRow) { _ in 52 | DispatchQueue.main.async { 53 | guard action.style == .destructive else { 54 | forRow.baseCell?.formViewController()?.tableView?.setEditing(false, animated: true) 55 | return 56 | } 57 | forRow.section?.remove(at: indexPath.row) 58 | } 59 | } 60 | } 61 | } 62 | if let color = self.actionBackgroundColor { 63 | action.actionBackgroundColor = color 64 | } 65 | if let image = self.image { 66 | action.image = image 67 | } 68 | return action 69 | } 70 | 71 | public enum Style { 72 | case normal 73 | case destructive 74 | 75 | var contextualStyle: ContextualStyle { 76 | if #available(iOS 11, *){ 77 | switch self{ 78 | case .normal: 79 | return UIContextualAction.Style.normal 80 | case .destructive: 81 | return UIContextualAction.Style.destructive 82 | } 83 | } else { 84 | switch self{ 85 | case .normal: 86 | return UITableViewRowAction.Style.normal 87 | case .destructive: 88 | return UITableViewRowAction.Style.destructive 89 | } 90 | } 91 | } 92 | } 93 | } 94 | 95 | public struct SwipeConfiguration { 96 | 97 | unowned var row: BaseRow 98 | 99 | init(_ row: BaseRow){ 100 | self.row = row 101 | } 102 | 103 | public var performsFirstActionWithFullSwipe = false 104 | public var actions: [SwipeAction] = [] 105 | } 106 | 107 | extension SwipeConfiguration { 108 | @available(iOS 11.0, *) 109 | var contextualConfiguration: UISwipeActionsConfiguration? { 110 | let contextualConfiguration = UISwipeActionsConfiguration(actions: self.contextualActions as! [UIContextualAction]) 111 | contextualConfiguration.performsFirstActionWithFullSwipe = self.performsFirstActionWithFullSwipe 112 | return contextualConfiguration 113 | } 114 | 115 | var contextualActions: [ContextualAction]{ 116 | return self.actions.map { $0.contextualAction(forRow: self.row) } 117 | } 118 | } 119 | 120 | protocol ContextualAction { 121 | var actionBackgroundColor: UIColor? { get set } 122 | var image: UIImage? { get set } 123 | var title: String? { get set } 124 | } 125 | 126 | extension UITableViewRowAction: ContextualAction { 127 | public var image: UIImage? { 128 | get { return nil } 129 | set { return } 130 | } 131 | 132 | public var actionBackgroundColor: UIColor? { 133 | get { return backgroundColor } 134 | set { self.backgroundColor = newValue } 135 | } 136 | } 137 | 138 | @available(iOS 11.0, *) 139 | extension UIContextualAction: ContextualAction { 140 | 141 | public var actionBackgroundColor: UIColor? { 142 | get { return backgroundColor } 143 | set { self.backgroundColor = newValue } 144 | } 145 | 146 | } 147 | 148 | public protocol ContextualStyle{} 149 | extension UITableViewRowAction.Style: ContextualStyle {} 150 | 151 | @available(iOS 11.0, *) 152 | extension UIContextualAction.Style: ContextualStyle {} 153 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Core/Validation.swift: -------------------------------------------------------------------------------- 1 | // RowValidationType.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | 27 | public struct ValidationError: Equatable { 28 | 29 | public let msg: String 30 | 31 | public init(msg: String) { 32 | self.msg = msg 33 | } 34 | } 35 | 36 | public func == (lhs: ValidationError, rhs: ValidationError) -> Bool { 37 | return lhs.msg == rhs.msg 38 | } 39 | 40 | public protocol BaseRuleType { 41 | var id: String? { get set } 42 | var validationError: ValidationError { get set } 43 | } 44 | 45 | public protocol RuleType: BaseRuleType { 46 | associatedtype RowValueType 47 | 48 | func isValid(value: RowValueType?) -> ValidationError? 49 | } 50 | 51 | public struct ValidationOptions: OptionSet { 52 | 53 | public let rawValue: Int 54 | 55 | public init(rawValue: Int) { 56 | self.rawValue = rawValue 57 | } 58 | 59 | public static let validatesOnDemand = ValidationOptions(rawValue: 1 << 0) 60 | public static let validatesOnChange = ValidationOptions(rawValue: 1 << 1) 61 | public static let validatesOnBlur = ValidationOptions(rawValue: 1 << 2) 62 | public static let validatesOnChangeAfterBlurred = ValidationOptions(rawValue: 1 << 3) 63 | 64 | public static let validatesAlways: ValidationOptions = [.validatesOnChange, .validatesOnBlur] 65 | } 66 | 67 | public struct ValidationRuleHelper where T: Equatable { 68 | let validateFn: ((T?) -> ValidationError?) 69 | let rule: BaseRuleType 70 | } 71 | 72 | public struct RuleSet { 73 | 74 | internal var rules: [ValidationRuleHelper] = [] 75 | 76 | public init() {} 77 | 78 | /// Add a validation Rule to a Row 79 | /// - Parameter rule: RuleType object typed to the same type of the Row.value 80 | public mutating func add(rule: Rule) where T == Rule.RowValueType { 81 | let validFn: ((T?) -> ValidationError?) = { (val: T?) in 82 | return rule.isValid(value: val) 83 | } 84 | rules.append(ValidationRuleHelper(validateFn: validFn, rule: rule)) 85 | } 86 | 87 | public mutating func remove(ruleWithIdentifier identifier: String) { 88 | if let index = rules.firstIndex(where: { (validationRuleHelper) -> Bool in 89 | return validationRuleHelper.rule.id == identifier 90 | }) { 91 | rules.remove(at: index) 92 | } 93 | } 94 | 95 | public mutating func removeAllRules() { 96 | rules.removeAll() 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/ActionSheetRow.swift: -------------------------------------------------------------------------------- 1 | // ActionSheetRow.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | open class AlertSelectorCell : Cell, CellType where T: Equatable { 29 | 30 | required public init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 31 | super.init(style: style, reuseIdentifier: reuseIdentifier) 32 | } 33 | 34 | required public init?(coder aDecoder: NSCoder) { 35 | super.init(coder: aDecoder) 36 | } 37 | 38 | open override func update() { 39 | super.update() 40 | accessoryType = .none 41 | editingAccessoryType = accessoryType 42 | selectionStyle = row.isDisabled ? .none : .default 43 | } 44 | 45 | open override func didSelect() { 46 | super.didSelect() 47 | row.deselect() 48 | } 49 | } 50 | 51 | open class _ActionSheetRow: AlertOptionsRow, PresenterRowType where Cell: BaseCell { 52 | 53 | public typealias ProviderType = SelectorAlertController<_ActionSheetRow> 54 | 55 | public var onPresentCallback: ((FormViewController, ProviderType) -> Void)? 56 | lazy public var presentationMode: PresentationMode? = { 57 | return .presentModally(controllerProvider: ControllerProvider.callback { [weak self] in 58 | let vc = SelectorAlertController<_ActionSheetRow>(title: self?.selectorTitle, message: nil, preferredStyle: .actionSheet) 59 | if let popView = vc.popoverPresentationController { 60 | guard let cell = self?.cell, let tableView = cell.formViewController()?.tableView else { fatalError() } 61 | popView.sourceView = tableView 62 | popView.sourceRect = tableView.convert(cell.detailTextLabel?.frame ?? cell.textLabel?.frame ?? cell.contentView.frame, from: cell) 63 | } 64 | vc.row = self 65 | return vc 66 | }, 67 | onDismiss: { [weak self] in 68 | $0.dismiss(animated: true) 69 | self?.cell?.formViewController()?.tableView?.reloadData() 70 | }) 71 | }() 72 | 73 | public required init(tag: String?) { 74 | super.init(tag: tag) 75 | } 76 | 77 | open override func customDidSelect() { 78 | super.customDidSelect() 79 | if let presentationMode = presentationMode, !isDisabled { 80 | if let controller = presentationMode.makeController() { 81 | controller.row = self 82 | onPresentCallback?(cell.formViewController()!, controller) 83 | presentationMode.present(controller, row: self, presentingController: cell.formViewController()!) 84 | } else { 85 | presentationMode.present(nil, row: self, presentingController: cell.formViewController()!) 86 | } 87 | } 88 | } 89 | } 90 | 91 | /// An options row where the user can select an option from an ActionSheet 92 | public final class ActionSheetRow: _ActionSheetRow>, RowType where T: Equatable { 93 | required public init(tag: String?) { 94 | super.init(tag: tag) 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/AlertRow.swift: -------------------------------------------------------------------------------- 1 | // AlertRow.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | import Foundation 25 | import UIKit 26 | 27 | open class _AlertRow: AlertOptionsRow, PresenterRowType where Cell: BaseCell { 28 | 29 | public typealias PresentedController = SelectorAlertController<_AlertRow> 30 | 31 | open var onPresentCallback: ((FormViewController, PresentedController) -> Void)? 32 | lazy open var presentationMode: PresentationMode? = { 33 | return .presentModally(controllerProvider: ControllerProvider.callback { [weak self] in 34 | let vc = PresentedController(title: self?.selectorTitle, message: nil, preferredStyle: .alert) 35 | vc.row = self 36 | return vc 37 | }, onDismiss: { [weak self] in 38 | $0.dismiss(animated: true) 39 | self?.cell?.formViewController()?.tableView?.reloadData() 40 | }) 41 | }() 42 | 43 | public required init(tag: String?) { 44 | super.init(tag: tag) 45 | } 46 | 47 | open override func customDidSelect() { 48 | super.customDidSelect() 49 | if let presentationMode = presentationMode, !isDisabled { 50 | if let controller = presentationMode.makeController() { 51 | controller.row = self 52 | onPresentCallback?(cell.formViewController()!, controller) 53 | presentationMode.present(controller, row: self, presentingController: cell.formViewController()!) 54 | } else { 55 | presentationMode.present(nil, row: self, presentingController: cell.formViewController()!) 56 | } 57 | } 58 | } 59 | } 60 | 61 | /// An options row where the user can select an option from a modal Alert 62 | public final class AlertRow: _AlertRow>, RowType { 63 | required public init(tag: String?) { 64 | super.init(tag: tag) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/ButtonRow.swift: -------------------------------------------------------------------------------- 1 | // ButtonRow.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | // MARK: ButtonCell 29 | 30 | open class ButtonCellOf: Cell, CellType { 31 | 32 | required public init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 33 | super.init(style: style, reuseIdentifier: reuseIdentifier) 34 | } 35 | 36 | required public init?(coder aDecoder: NSCoder) { 37 | super.init(coder: aDecoder) 38 | } 39 | 40 | open override func update() { 41 | super.update() 42 | selectionStyle = row.isDisabled ? .none : .default 43 | accessoryType = .none 44 | editingAccessoryType = accessoryType 45 | textLabel?.textAlignment = .center 46 | textLabel?.textColor = tintColor.withAlphaComponent(row.isDisabled ? 0.3 : 1.0) 47 | } 48 | 49 | open override func didSelect() { 50 | super.didSelect() 51 | row.deselect() 52 | } 53 | } 54 | 55 | public typealias ButtonCell = ButtonCellOf 56 | 57 | // MARK: ButtonRow 58 | 59 | open class _ButtonRowOf : Row> { 60 | open var presentationMode: PresentationMode? 61 | 62 | required public init(tag: String?) { 63 | super.init(tag: tag) 64 | displayValueFor = nil 65 | cellStyle = .default 66 | } 67 | 68 | open override func customDidSelect() { 69 | super.customDidSelect() 70 | if !isDisabled { 71 | if let presentationMode = presentationMode { 72 | if let controller = presentationMode.makeController() { 73 | presentationMode.present(controller, row: self, presentingController: self.cell.formViewController()!) 74 | } else { 75 | presentationMode.present(nil, row: self, presentingController: self.cell.formViewController()!) 76 | } 77 | } 78 | } 79 | } 80 | 81 | open override func customUpdateCell() { 82 | super.customUpdateCell() 83 | let leftAligmnment = presentationMode != nil 84 | cell.textLabel?.textAlignment = leftAligmnment ? .left : .center 85 | cell.accessoryType = !leftAligmnment || isDisabled ? .none : .disclosureIndicator 86 | cell.editingAccessoryType = cell.accessoryType 87 | cell.textLabel?.textColor = !leftAligmnment ? cell.tintColor.withAlphaComponent(isDisabled ? 0.3 : 1.0) : nil 88 | } 89 | 90 | open override func prepare(for segue: UIStoryboardSegue) { 91 | super.prepare(for: segue) 92 | (segue.destination as? RowControllerType)?.onDismissCallback = presentationMode?.onDismissCallback 93 | } 94 | } 95 | 96 | /// A generic row with a button. The action of this button can be anything but normally will push a new view controller 97 | public final class ButtonRowOf : _ButtonRowOf, RowType { 98 | public required init(tag: String?) { 99 | super.init(tag: tag) 100 | } 101 | } 102 | 103 | /// A row with a button and String value. The action of this button can be anything but normally will push a new view controller 104 | public typealias ButtonRow = ButtonRowOf 105 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/ButtonRowWithPresent.swift: -------------------------------------------------------------------------------- 1 | // Rows.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | open class _ButtonRowWithPresent: Row>, PresenterRowType where VCType: UIViewController { 29 | 30 | open var presentationMode: PresentationMode? 31 | open var onPresentCallback: ((FormViewController, VCType) -> Void)? 32 | 33 | required public init(tag: String?) { 34 | super.init(tag: tag) 35 | displayValueFor = nil 36 | cellStyle = .default 37 | } 38 | 39 | open override func customUpdateCell() { 40 | super.customUpdateCell() 41 | let leftAligmnment = presentationMode != nil 42 | cell.textLabel?.textAlignment = leftAligmnment ? .left : .center 43 | cell.accessoryType = !leftAligmnment || isDisabled ? .none : .disclosureIndicator 44 | cell.editingAccessoryType = cell.accessoryType 45 | if !leftAligmnment { 46 | var red: CGFloat = 0, green: CGFloat = 0, blue: CGFloat = 0, alpha: CGFloat = 0 47 | cell.tintColor.getRed(&red, green: &green, blue: &blue, alpha: &alpha) 48 | cell.textLabel?.textColor = UIColor(red: red, green: green, blue: blue, alpha:isDisabled ? 0.3 : 1.0) 49 | } else { 50 | cell.textLabel?.textColor = nil 51 | } 52 | } 53 | 54 | open override func customDidSelect() { 55 | super.customDidSelect() 56 | if let presentationMode = presentationMode, !isDisabled { 57 | if let controller = presentationMode.makeController() { 58 | controller.row = self 59 | onPresentCallback?(cell.formViewController()!, controller) 60 | presentationMode.present(controller, row: self, presentingController: cell.formViewController()!) 61 | } else { 62 | presentationMode.present(nil, row: self, presentingController: cell.formViewController()!) 63 | } 64 | } 65 | } 66 | 67 | open override func prepare(for segue: UIStoryboardSegue) { 68 | super.prepare(for: segue) 69 | guard let rowVC = segue.destination as? VCType else { 70 | return 71 | } 72 | if let callback = presentationMode?.onDismissCallback { 73 | rowVC.onDismissCallback = callback 74 | } 75 | rowVC.row = self 76 | onPresentCallback?(cell.formViewController()!, rowVC) 77 | } 78 | 79 | } 80 | 81 | // MARK: Rows 82 | 83 | /// A generic row with a button that presents a view controller when tapped 84 | public final class ButtonRowWithPresent : _ButtonRowWithPresent, RowType where VCType: UIViewController { 85 | public required init(tag: String?) { 86 | super.init(tag: tag) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/CheckRow.swift: -------------------------------------------------------------------------------- 1 | // CheckRow.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | // MARK: CheckCell 29 | 30 | open class CheckCell: Cell, CellType { 31 | 32 | required public init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 33 | super.init(style: style, reuseIdentifier: reuseIdentifier) 34 | } 35 | 36 | required public init?(coder aDecoder: NSCoder) { 37 | super.init(coder: aDecoder) 38 | } 39 | 40 | open override func update() { 41 | super.update() 42 | accessoryType = row.value == true ? .checkmark : .none 43 | editingAccessoryType = accessoryType 44 | selectionStyle = .default 45 | if row.isDisabled { 46 | tintAdjustmentMode = .dimmed 47 | selectionStyle = .none 48 | } else { 49 | tintAdjustmentMode = .automatic 50 | } 51 | } 52 | 53 | open override func setup() { 54 | super.setup() 55 | accessoryType = .checkmark 56 | editingAccessoryType = accessoryType 57 | } 58 | 59 | open override func didSelect() { 60 | row.value = row.value ?? false ? false : true 61 | row.deselect() 62 | row.updateCell() 63 | } 64 | 65 | } 66 | 67 | // MARK: CheckRow 68 | 69 | open class _CheckRow: Row { 70 | 71 | required public init(tag: String?) { 72 | super.init(tag: tag) 73 | displayValueFor = nil 74 | } 75 | } 76 | 77 | ///// Boolean row that has a checkmark as accessoryType 78 | public final class CheckRow: _CheckRow, RowType { 79 | 80 | required public init(tag: String?) { 81 | super.init(tag: tag) 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/Common/AlertOptionsRow.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AlertOptionsRow.swift 3 | // Eureka ( https://github.com/xmartlabs/Eureka ) 4 | // 5 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 6 | // 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | import Foundation 27 | 28 | 29 | import Foundation 30 | 31 | open class AlertOptionsRow : OptionsRow, AlertOptionsProviderRow where Cell: BaseCell { 32 | 33 | typealias OptionsProviderType = OptionsProvider 34 | 35 | open var cancelTitle: String? 36 | 37 | required public init(tag: String?) { 38 | super.init(tag: tag) 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/Common/DateFieldRow.swift: -------------------------------------------------------------------------------- 1 | // DateFieldRow.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | public protocol DatePickerRowProtocol: class { 29 | var minimumDate: Date? { get set } 30 | var maximumDate: Date? { get set } 31 | var minuteInterval: Int? { get set } 32 | } 33 | 34 | open class DateCell: Cell, CellType { 35 | 36 | public var datePicker: UIDatePicker 37 | 38 | public required init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 39 | datePicker = UIDatePicker() 40 | super.init(style: style, reuseIdentifier: reuseIdentifier) 41 | } 42 | 43 | required public init?(coder aDecoder: NSCoder) { 44 | datePicker = UIDatePicker() 45 | super.init(coder: aDecoder) 46 | } 47 | 48 | open override func setup() { 49 | super.setup() 50 | accessoryType = .none 51 | editingAccessoryType = .none 52 | datePicker.datePickerMode = datePickerMode() 53 | datePicker.addTarget(self, action: #selector(DateCell.datePickerValueChanged(_:)), for: .valueChanged) 54 | } 55 | 56 | deinit { 57 | datePicker.removeTarget(self, action: nil, for: .allEvents) 58 | } 59 | 60 | open override func update() { 61 | super.update() 62 | selectionStyle = row.isDisabled ? .none : .default 63 | datePicker.setDate(row.value ?? Date(), animated: row is CountDownPickerRow) 64 | datePicker.minimumDate = (row as? DatePickerRowProtocol)?.minimumDate 65 | datePicker.maximumDate = (row as? DatePickerRowProtocol)?.maximumDate 66 | if let minuteIntervalValue = (row as? DatePickerRowProtocol)?.minuteInterval { 67 | datePicker.minuteInterval = minuteIntervalValue 68 | } 69 | if row.isHighlighted { 70 | textLabel?.textColor = tintColor 71 | } 72 | } 73 | 74 | open override func didSelect() { 75 | super.didSelect() 76 | row.deselect() 77 | } 78 | 79 | override open var inputView: UIView? { 80 | if let v = row.value { 81 | datePicker.setDate(v, animated:row is CountDownRow) 82 | } 83 | return datePicker 84 | } 85 | 86 | @objc func datePickerValueChanged(_ sender: UIDatePicker) { 87 | row.value = sender.date 88 | detailTextLabel?.text = row.displayValueFor?(row.value) 89 | } 90 | 91 | private func datePickerMode() -> UIDatePicker.Mode { 92 | switch row { 93 | case is DateRow: 94 | return .date 95 | case is TimeRow: 96 | return .time 97 | case is DateTimeRow: 98 | return .dateAndTime 99 | case is CountDownRow: 100 | return .countDownTimer 101 | default: 102 | return .date 103 | } 104 | } 105 | 106 | open override func cellCanBecomeFirstResponder() -> Bool { 107 | return canBecomeFirstResponder 108 | } 109 | 110 | override open var canBecomeFirstResponder: Bool { 111 | return !row.isDisabled 112 | } 113 | } 114 | 115 | open class _DateFieldRow: Row, DatePickerRowProtocol, NoValueDisplayTextConformance { 116 | 117 | /// The minimum value for this row's UIDatePicker 118 | open var minimumDate: Date? 119 | 120 | /// The maximum value for this row's UIDatePicker 121 | open var maximumDate: Date? 122 | 123 | /// The interval between options for this row's UIDatePicker 124 | open var minuteInterval: Int? 125 | 126 | /// The formatter for the date picked by the user 127 | open var dateFormatter: DateFormatter? 128 | 129 | open var noValueDisplayText: String? = nil 130 | 131 | required public init(tag: String?) { 132 | super.init(tag: tag) 133 | displayValueFor = { [unowned self] value in 134 | guard let val = value, let formatter = self.dateFormatter else { return nil } 135 | return formatter.string(from: val) 136 | } 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/Common/DateInlineFieldRow.swift: -------------------------------------------------------------------------------- 1 | // DateInlineFieldRow.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | open class DateInlineCell: Cell, CellType { 29 | 30 | public required init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 31 | super.init(style: style, reuseIdentifier: reuseIdentifier) 32 | } 33 | 34 | required public init?(coder aDecoder: NSCoder) { 35 | super.init(coder: aDecoder) 36 | } 37 | 38 | open override func setup() { 39 | super.setup() 40 | accessoryType = .none 41 | editingAccessoryType = .none 42 | } 43 | 44 | open override func update() { 45 | super.update() 46 | selectionStyle = row.isDisabled ? .none : .default 47 | } 48 | 49 | open override func didSelect() { 50 | super.didSelect() 51 | row.deselect() 52 | } 53 | } 54 | 55 | open class _DateInlineFieldRow: Row, DatePickerRowProtocol, NoValueDisplayTextConformance { 56 | 57 | /// The minimum value for this row's UIDatePicker 58 | open var minimumDate: Date? 59 | 60 | /// The maximum value for this row's UIDatePicker 61 | open var maximumDate: Date? 62 | 63 | /// The interval between options for this row's UIDatePicker 64 | open var minuteInterval: Int? 65 | 66 | /// The formatter for the date picked by the user 67 | open var dateFormatter: DateFormatter? 68 | 69 | open var noValueDisplayText: String? 70 | 71 | required public init(tag: String?) { 72 | super.init(tag: tag) 73 | dateFormatter = DateFormatter() 74 | dateFormatter?.locale = Locale.current 75 | displayValueFor = { [unowned self] value in 76 | guard let val = value, let formatter = self.dateFormatter else { return nil } 77 | return formatter.string(from: val) 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/Common/DecimalFormatter.swift: -------------------------------------------------------------------------------- 1 | // DecimalFormatter.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | /// A custom formatter for numbers with two digits after the decimal mark 29 | open class DecimalFormatter: NumberFormatter, FormatterProtocol { 30 | 31 | /// Creates the formatter with 2 Fraction Digits, Locale set to .current and .decimal NumberFormatter.Style 32 | public override init() { 33 | super.init() 34 | locale = Locale.current 35 | numberStyle = .decimal 36 | minimumFractionDigits = 2 37 | maximumFractionDigits = 2 38 | } 39 | 40 | required public init?(coder aDecoder: NSCoder) { 41 | fatalError("init(coder:) has not been implemented") 42 | } 43 | 44 | /// Creates an NSNumber from the given String 45 | /// - Parameter obj: Pointer to NSNumber object to assign 46 | /// - Parameter string: String with number assumed to have the configured min. fraction digits. 47 | /// - Parameter rangep: Unused range parameter 48 | override open func getObjectValue(_ obj: AutoreleasingUnsafeMutablePointer?, for string: String, range rangep: UnsafeMutablePointer?) throws { 49 | guard obj != nil else { return } 50 | let str = string.components(separatedBy: CharacterSet.decimalDigits.inverted).joined(separator: "") 51 | // Recover the number from the string in a way that forces the formatter's fraction digits 52 | // numberWithoutDecimals / 10 ^ minimumFractionDigits 53 | obj?.pointee = NSNumber(value: (Double(str) ?? 0.0)/Double(pow(10.0, Double(minimumFractionDigits)))) 54 | } 55 | 56 | open func getNewPosition(forPosition position: UITextPosition, inTextInput textInput: UITextInput, oldValue: String?, newValue: String?) -> UITextPosition { 57 | return textInput.position(from: position, offset:((newValue?.count ?? 0) - (oldValue?.count ?? 0))) ?? position 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/Common/GenericMultipleSelectorRow.swift: -------------------------------------------------------------------------------- 1 | // GenericMultipleSelectorRow.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | /// Generic options selector row that allows multiple selection. 29 | open class GenericMultipleSelectorRow: Row, PresenterRowType, NoValueDisplayTextConformance, OptionsProviderRow 30 | where Cell: BaseCell, Cell.Value == Set { 31 | 32 | public typealias PresentedController = MultipleSelectorViewController> 33 | 34 | /// Defines how the view controller will be presented, pushed, etc. 35 | open var presentationMode: PresentationMode? 36 | 37 | /// Will be called before the presentation occurs. 38 | open var onPresentCallback: ((FormViewController, PresentedController) -> Void)? 39 | 40 | /// Title to be displayed for the options 41 | open var selectorTitle: String? 42 | open var noValueDisplayText: String? 43 | 44 | /// Options from which the user will choose 45 | open var optionsProvider: OptionsProvider? 46 | 47 | required public init(tag: String?) { 48 | super.init(tag: tag) 49 | displayValueFor = { (rowValue: Set?) in 50 | return rowValue?.map({ String(describing: $0) }).sorted().joined(separator: ", ") 51 | } 52 | presentationMode = .show(controllerProvider: ControllerProvider.callback { 53 | return MultipleSelectorViewController>() 54 | }, onDismiss: { vc in 55 | let _ = vc.navigationController?.popViewController(animated: true) 56 | }) 57 | } 58 | 59 | /** 60 | Extends `didSelect` method 61 | */ 62 | open override func customDidSelect() { 63 | super.customDidSelect() 64 | guard let presentationMode = presentationMode, !isDisabled else { return } 65 | if let controller = presentationMode.makeController() { 66 | controller.row = self 67 | controller.title = selectorTitle ?? controller.title 68 | onPresentCallback?(cell.formViewController()!, controller) 69 | presentationMode.present(controller, row: self, presentingController: self.cell.formViewController()!) 70 | } else { 71 | presentationMode.present(nil, row: self, presentingController: self.cell.formViewController()!) 72 | } 73 | } 74 | 75 | /** 76 | Prepares the pushed row setting its title and completion callback. 77 | */ 78 | open override func prepare(for segue: UIStoryboardSegue) { 79 | super.prepare(for: segue) 80 | guard let rowVC = segue.destination as Any as? PresentedController else { return } 81 | rowVC.title = selectorTitle ?? rowVC.title 82 | rowVC.onDismissCallback = presentationMode?.onDismissCallback ?? rowVC.onDismissCallback 83 | onPresentCallback?(cell.formViewController()!, rowVC) 84 | rowVC.row = self 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/Common/OptionsRow.swift: -------------------------------------------------------------------------------- 1 | // OptionsRow.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | 27 | open class OptionsRow : Row, NoValueDisplayTextConformance, OptionsProviderRow where Cell: BaseCell { 28 | 29 | open var optionsProvider: OptionsProvider? 30 | 31 | open var selectorTitle: String? 32 | open var noValueDisplayText: String? 33 | 34 | required public init(tag: String?) { 35 | super.init(tag: tag) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/Common/Protocols.swift: -------------------------------------------------------------------------------- 1 | // Protocols.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | 27 | public protocol FormatterConformance: class { 28 | var formatter: Formatter? { get set } 29 | var useFormatterDuringInput: Bool { get set } 30 | var useFormatterOnDidBeginEditing: Bool? { get set } 31 | } 32 | 33 | public protocol NoValueDisplayTextConformance: class { 34 | var noValueDisplayText: String? { get set } 35 | } 36 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/Common/SelectorRow.swift: -------------------------------------------------------------------------------- 1 | // SelectorRow.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | open class PushSelectorCell : Cell, CellType { 29 | 30 | required public init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 31 | super.init(style: style, reuseIdentifier: reuseIdentifier) 32 | } 33 | 34 | required public init?(coder aDecoder: NSCoder) { 35 | super.init(coder: aDecoder) 36 | } 37 | 38 | open override func update() { 39 | super.update() 40 | accessoryType = .disclosureIndicator 41 | editingAccessoryType = accessoryType 42 | selectionStyle = row.isDisabled ? .none : .default 43 | } 44 | } 45 | 46 | /// Generic row type where a user must select a value among several options. 47 | open class SelectorRow: OptionsRow, PresenterRowType where Cell: BaseCell { 48 | 49 | 50 | /// Defines how the view controller will be presented, pushed, etc. 51 | open var presentationMode: PresentationMode>>? 52 | 53 | /// Will be called before the presentation occurs. 54 | open var onPresentCallback: ((FormViewController, SelectorViewController>) -> Void)? 55 | 56 | required public init(tag: String?) { 57 | super.init(tag: tag) 58 | } 59 | 60 | /** 61 | Extends `didSelect` method 62 | */ 63 | open override func customDidSelect() { 64 | super.customDidSelect() 65 | guard let presentationMode = presentationMode, !isDisabled else { return } 66 | if let controller = presentationMode.makeController() { 67 | controller.row = self 68 | controller.title = selectorTitle ?? controller.title 69 | onPresentCallback?(cell.formViewController()!, controller) 70 | presentationMode.present(controller, row: self, presentingController: self.cell.formViewController()!) 71 | } else { 72 | presentationMode.present(nil, row: self, presentingController: self.cell.formViewController()!) 73 | } 74 | } 75 | 76 | /** 77 | Prepares the pushed row setting its title and completion callback. 78 | */ 79 | open override func prepare(for segue: UIStoryboardSegue) { 80 | super.prepare(for: segue) 81 | guard let rowVC = segue.destination as Any as? SelectorViewController> else { return } 82 | rowVC.title = selectorTitle ?? rowVC.title 83 | rowVC.onDismissCallback = presentationMode?.onDismissCallback ?? rowVC.onDismissCallback 84 | onPresentCallback?(cell.formViewController()!, rowVC) 85 | rowVC.row = self 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/Controllers/SelectorAlertController.swift: -------------------------------------------------------------------------------- 1 | // SelectorAlertController.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | /// Specific type, Responsible for the options passed to a selector alert view controller 29 | public protocol AlertOptionsProviderRow: OptionsProviderRow { 30 | 31 | var cancelTitle: String? { get set } 32 | 33 | } 34 | 35 | /// Selector UIAlertController 36 | open class SelectorAlertController: UIAlertController, TypedRowControllerType where AlertOptionsRow.OptionsProviderType.Option == AlertOptionsRow.Cell.Value, AlertOptionsRow: BaseRow { 37 | 38 | /// The row that pushed or presented this controller 39 | public var row: RowOf! 40 | 41 | @available(*, deprecated, message: "Use AlertOptionsRow.cancelTitle instead.") 42 | public var cancelTitle = NSLocalizedString("Cancel", comment: "") 43 | 44 | /// A closure to be called when the controller disappears. 45 | public var onDismissCallback: ((UIViewController) -> Void)? 46 | 47 | /// Options provider to use to get available options. 48 | /// If not set will use synchronous data provider built with `row.dataProvider.arrayData`. 49 | // public var optionsProvider: OptionsProvider? 50 | public var optionsProviderRow: AlertOptionsRow { 51 | return row as Any as! AlertOptionsRow 52 | } 53 | 54 | override public init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { 55 | super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) 56 | } 57 | 58 | required public init?(coder aDecoder: NSCoder) { 59 | super.init(coder: aDecoder) 60 | } 61 | 62 | convenience public init(_ callback: ((UIViewController) -> Void)?) { 63 | self.init() 64 | onDismissCallback = callback 65 | } 66 | 67 | open override func viewDidLoad() { 68 | super.viewDidLoad() 69 | guard let options = optionsProviderRow.options else { return } 70 | let cancelTitle = optionsProviderRow.cancelTitle ?? NSLocalizedString("Cancel", comment: "") 71 | addAction(UIAlertAction(title: cancelTitle, style: .cancel, handler: nil)) 72 | for option in options { 73 | addAction(UIAlertAction(title: row.displayValueFor?(option), style: .default, handler: { [weak self] _ in 74 | self?.row.value = option 75 | self?.onDismissCallback?(self!) 76 | })) 77 | } 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/DatePickerRow.swift: -------------------------------------------------------------------------------- 1 | // DateRow.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | open class DatePickerCell: Cell, CellType { 29 | 30 | @IBOutlet weak public var datePicker: UIDatePicker! 31 | 32 | public required init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 33 | let datePicker = UIDatePicker() 34 | self.datePicker = datePicker 35 | self.datePicker.translatesAutoresizingMaskIntoConstraints = false 36 | 37 | super.init(style: style, reuseIdentifier: reuseIdentifier) 38 | 39 | self.contentView.addSubview(self.datePicker) 40 | self.contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[picker]-0-|", options: [], metrics: nil, views: ["picker": self.datePicker!])) 41 | self.contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[picker]-0-|", options: [], metrics: nil, views: ["picker": self.datePicker!])) 42 | } 43 | 44 | required public init?(coder aDecoder: NSCoder) { 45 | super.init(coder: aDecoder) 46 | } 47 | 48 | open override func setup() { 49 | super.setup() 50 | selectionStyle = .none 51 | accessoryType = .none 52 | editingAccessoryType = .none 53 | height = { UITableView.automaticDimension } 54 | datePicker.datePickerMode = datePickerMode() 55 | datePicker.addTarget(self, action: #selector(DatePickerCell.datePickerValueChanged(_:)), for: .valueChanged) 56 | } 57 | 58 | deinit { 59 | datePicker?.removeTarget(self, action: nil, for: .allEvents) 60 | } 61 | 62 | open override func update() { 63 | super.update() 64 | selectionStyle = row.isDisabled ? .none : .default 65 | datePicker.isUserInteractionEnabled = !row.isDisabled 66 | detailTextLabel?.text = nil 67 | textLabel?.text = nil 68 | datePicker.setDate(row.value ?? Date(), animated: row is CountDownPickerRow) 69 | datePicker.minimumDate = (row as? DatePickerRowProtocol)?.minimumDate 70 | datePicker.maximumDate = (row as? DatePickerRowProtocol)?.maximumDate 71 | if let minuteIntervalValue = (row as? DatePickerRowProtocol)?.minuteInterval { 72 | datePicker.minuteInterval = minuteIntervalValue 73 | } 74 | } 75 | 76 | @objc func datePickerValueChanged(_ sender: UIDatePicker) { 77 | row?.value = sender.date 78 | 79 | // workaround for UIDatePicker bug when it doesn't trigger "value changed" event after trying to pick 00:00 value 80 | // for details see this comment: https://stackoverflow.com/questions/20181980/uidatepicker-bug-uicontroleventvaluechanged-after-hitting-minimum-internal#comment56681891_20204225 81 | if sender.datePickerMode == .countDownTimer && sender.countDownDuration == TimeInterval(sender.minuteInterval * 60) { 82 | datePicker.countDownDuration = sender.countDownDuration 83 | } 84 | 85 | } 86 | 87 | private func datePickerMode() -> UIDatePicker.Mode { 88 | switch row { 89 | case is DatePickerRow: 90 | return .date 91 | case is TimePickerRow: 92 | return .time 93 | case is DateTimePickerRow: 94 | return .dateAndTime 95 | case is CountDownPickerRow: 96 | return .countDownTimer 97 | default: 98 | return .date 99 | } 100 | } 101 | 102 | } 103 | 104 | open class _DatePickerRow: Row, DatePickerRowProtocol { 105 | 106 | open var minimumDate: Date? 107 | open var maximumDate: Date? 108 | open var minuteInterval: Int? 109 | 110 | required public init(tag: String?) { 111 | super.init(tag: tag) 112 | displayValueFor = nil 113 | } 114 | } 115 | 116 | /// A row with an Date as value where the user can select a date directly. 117 | public final class DatePickerRow: _DatePickerRow, RowType { 118 | public required init(tag: String?) { 119 | super.init(tag: tag) 120 | } 121 | } 122 | 123 | /// A row with an Date as value where the user can select a time directly. 124 | public final class TimePickerRow: _DatePickerRow, RowType { 125 | public required init(tag: String?) { 126 | super.init(tag: tag) 127 | } 128 | } 129 | 130 | /// A row with an Date as value where the user can select date and time directly. 131 | public final class DateTimePickerRow: _DatePickerRow, RowType { 132 | public required init(tag: String?) { 133 | super.init(tag: tag) 134 | } 135 | } 136 | 137 | /// A row with an Date as value where the user can select hour and minute as a countdown timer. 138 | public final class CountDownPickerRow: _DatePickerRow, RowType { 139 | public required init(tag: String?) { 140 | super.init(tag: tag) 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/DateRow.swift: -------------------------------------------------------------------------------- 1 | // DateRow.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | import Foundation 25 | 26 | open class _DateRow: _DateFieldRow { 27 | required public init(tag: String?) { 28 | super.init(tag: tag) 29 | dateFormatter = DateFormatter() 30 | dateFormatter?.timeStyle = .none 31 | dateFormatter?.dateStyle = .medium 32 | dateFormatter?.locale = Locale.current 33 | } 34 | } 35 | 36 | open class _TimeRow: _DateFieldRow { 37 | required public init(tag: String?) { 38 | super.init(tag: tag) 39 | dateFormatter = DateFormatter() 40 | dateFormatter?.timeStyle = .short 41 | dateFormatter?.dateStyle = .none 42 | dateFormatter?.locale = Locale.current 43 | } 44 | } 45 | 46 | open class _DateTimeRow: _DateFieldRow { 47 | required public init(tag: String?) { 48 | super.init(tag: tag) 49 | dateFormatter = DateFormatter() 50 | dateFormatter?.timeStyle = .short 51 | dateFormatter?.dateStyle = .short 52 | dateFormatter?.locale = Locale.current 53 | } 54 | } 55 | 56 | open class _CountDownRow: _DateFieldRow { 57 | required public init(tag: String?) { 58 | super.init(tag: tag) 59 | displayValueFor = { [unowned self] value in 60 | guard let val = value else { 61 | return nil 62 | } 63 | if let formatter = self.dateFormatter { 64 | return formatter.string(from: val) 65 | } 66 | 67 | let dateComponents = Calendar.current.dateComponents([.hour, .minute], from: val) 68 | return DateComponentsFormatter.localizedString(from: dateComponents, unitsStyle: .full)?.replacingOccurrences(of: ",", with: "") 69 | } 70 | } 71 | } 72 | 73 | /// A row with an Date as value where the user can select a date from a picker view. 74 | public final class DateRow: _DateRow, RowType { 75 | required public init(tag: String?) { 76 | super.init(tag: tag) 77 | } 78 | } 79 | 80 | /// A row with an Date as value where the user can select a time from a picker view. 81 | public final class TimeRow: _TimeRow, RowType { 82 | required public init(tag: String?) { 83 | super.init(tag: tag) 84 | } 85 | } 86 | 87 | /// A row with an Date as value where the user can select date and time from a picker view. 88 | public final class DateTimeRow: _DateTimeRow, RowType { 89 | required public init(tag: String?) { 90 | super.init(tag: tag) 91 | } 92 | } 93 | 94 | /// A row with an Date as value where the user can select hour and minute as a countdown timer in a picker view. 95 | public final class CountDownRow: _CountDownRow, RowType { 96 | required public init(tag: String?) { 97 | super.init(tag: tag) 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/DoublePickerInputRow.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DoublePickerInputRow.swift 3 | // Eureka 4 | // 5 | // Created by Mathias Claassen on 5/10/18. 6 | // Copyright © 2018 Xmartlabs. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | open class DoublePickerInputCell : _PickerInputCell> where A: Equatable, B: Equatable { 13 | 14 | private var pickerRow: _DoublePickerInputRow! { return row as? _DoublePickerInputRow } 15 | 16 | public required init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 17 | super.init(style: style, reuseIdentifier: reuseIdentifier) 18 | } 19 | 20 | required public init?(coder aDecoder: NSCoder) { 21 | super.init(coder: aDecoder) 22 | } 23 | 24 | open override func update() { 25 | super.update() 26 | if let selectedValue = pickerRow.value, let indexA = pickerRow.firstOptions().firstIndex(of: selectedValue.a), 27 | let indexB = pickerRow.secondOptions(selectedValue.a).firstIndex(of: selectedValue.b) { 28 | picker.selectRow(indexA, inComponent: 0, animated: true) 29 | picker.selectRow(indexB, inComponent: 1, animated: true) 30 | } 31 | } 32 | 33 | open override func numberOfComponents(in pickerView: UIPickerView) -> Int { 34 | return 2 35 | } 36 | 37 | open override func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { 38 | return component == 0 ? pickerRow.firstOptions().count : pickerRow.secondOptions(pickerRow.selectedFirst()).count 39 | } 40 | 41 | open override func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { 42 | if component == 0 { 43 | return pickerRow.displayValueForFirstRow(pickerRow.firstOptions()[row]) 44 | } else { 45 | return pickerRow.displayValueForSecondRow(pickerRow.secondOptions(pickerRow.selectedFirst())[row]) 46 | } 47 | } 48 | 49 | open override func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { 50 | if component == 0 { 51 | let a = pickerRow.firstOptions()[row] 52 | if let value = pickerRow.value { 53 | guard value.a != a else { 54 | return 55 | } 56 | if pickerRow.secondOptions(a).contains(value.b) { 57 | pickerRow.value = Tuple(a: a, b: value.b) 58 | pickerView.reloadComponent(1) 59 | update() 60 | return 61 | } else { 62 | pickerRow.value = Tuple(a: a, b: pickerRow.secondOptions(a)[0]) 63 | } 64 | } else { 65 | pickerRow.value = Tuple(a: a, b: pickerRow.secondOptions(a)[0]) 66 | } 67 | pickerView.reloadComponent(1) 68 | pickerView.selectRow(0, inComponent: 1, animated: true) 69 | } else { 70 | let a = pickerRow.selectedFirst() 71 | pickerRow.value = Tuple(a: a, b: pickerRow.secondOptions(a)[row]) 72 | } 73 | update() 74 | } 75 | } 76 | 77 | open class _DoublePickerInputRow : Row>, NoValueDisplayTextConformance { 78 | 79 | open var noValueDisplayText: String? = nil 80 | /// Options for first component. Will be called often so should be O(1) 81 | public var firstOptions: (() -> [A]) = {[]} 82 | /// Options for second component given the selected value from the first component. Will be called often so should be O(1) 83 | public var secondOptions: ((A) -> [B]) = {_ in []} 84 | 85 | /// Modify the displayed values for the first picker row. 86 | public var displayValueForFirstRow: ((A) -> (String)) = { a in return String(describing: a) } 87 | /// Modify the displayed values for the second picker row. 88 | public var displayValueForSecondRow: ((B) -> (String)) = { b in return String(describing: b) } 89 | 90 | required public init(tag: String?) { 91 | super.init(tag: tag) 92 | } 93 | 94 | func selectedFirst() -> A { 95 | return value?.a ?? firstOptions()[0] 96 | } 97 | 98 | } 99 | 100 | /// A generic row where the user can pick an option from a picker view displayed in the keyboard area 101 | public final class DoublePickerInputRow: _DoublePickerInputRow, RowType where A: Equatable, B: Equatable { 102 | 103 | required public init(tag: String?) { 104 | super.init(tag: tag) 105 | self.displayValueFor = { [weak self] tuple in 106 | guard let tuple = tuple else { 107 | return self?.noValueDisplayText 108 | } 109 | return String(describing: tuple.a) + ", " + String(describing: tuple.b) 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/DoublePickerRow.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MultiplePickerRow.swift 3 | // Eureka 4 | // 5 | // Created by Mathias Claassen on 5/8/18. 6 | // Copyright © 2018 Xmartlabs. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | public struct Tuple { 13 | 14 | public let a: A 15 | public let b: B 16 | 17 | public init(a: A, b: B) { 18 | self.a = a 19 | self.b = b 20 | } 21 | 22 | } 23 | 24 | extension Tuple: Equatable {} 25 | 26 | public func == (lhs: Tuple, rhs: Tuple) -> Bool { 27 | return lhs.a == rhs.a && lhs.b == rhs.b 28 | } 29 | 30 | // MARK: MultiplePickerCell 31 | 32 | open class DoublePickerCell : _PickerCell> where A: Equatable, B: Equatable { 33 | 34 | private var pickerRow: _DoublePickerRow? { return row as? _DoublePickerRow } 35 | 36 | public required init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 37 | super.init(style: style, reuseIdentifier: reuseIdentifier) 38 | } 39 | 40 | required public init?(coder aDecoder: NSCoder) { 41 | super.init(coder: aDecoder) 42 | } 43 | 44 | open override func update() { 45 | super.update() 46 | if let selectedValue = pickerRow?.value, let indexA = pickerRow?.firstOptions().firstIndex(of: selectedValue.a), 47 | let indexB = pickerRow?.secondOptions(selectedValue.a).firstIndex(of: selectedValue.b) { 48 | picker.selectRow(indexA, inComponent: 0, animated: true) 49 | picker.selectRow(indexB, inComponent: 1, animated: true) 50 | } 51 | } 52 | 53 | open override func numberOfComponents(in pickerView: UIPickerView) -> Int { 54 | return 2 55 | } 56 | 57 | open override func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { 58 | guard let pickerRow = pickerRow else { return 0 } 59 | return component == 0 ? pickerRow.firstOptions().count : pickerRow.secondOptions(pickerRow.selectedFirst()).count 60 | } 61 | 62 | open override func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { 63 | guard let pickerRow = pickerRow else { return "" } 64 | if component == 0 { 65 | return pickerRow.displayValueForFirstRow(pickerRow.firstOptions()[row]) 66 | } else { 67 | return pickerRow.displayValueForSecondRow(pickerRow.secondOptions(pickerRow.selectedFirst())[row]) 68 | } 69 | } 70 | 71 | open override func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { 72 | guard let pickerRow = pickerRow else { return } 73 | if component == 0 { 74 | let a = pickerRow.firstOptions()[row] 75 | if let value = pickerRow.value { 76 | guard value.a != a else { 77 | return 78 | } 79 | if pickerRow.secondOptions(a).contains(value.b) { 80 | pickerRow.value = Tuple(a: a, b: value.b) 81 | pickerView.reloadComponent(1) 82 | return 83 | } else { 84 | pickerRow.value = Tuple(a: a, b: pickerRow.secondOptions(a)[0]) 85 | } 86 | } else { 87 | pickerRow.value = Tuple(a: a, b: pickerRow.secondOptions(a)[0]) 88 | } 89 | pickerView.reloadComponent(1) 90 | pickerView.selectRow(0, inComponent: 1, animated: true) 91 | } else { 92 | let a = pickerRow.selectedFirst() 93 | pickerRow.value = Tuple(a: a, b: pickerRow.secondOptions(a)[row]) 94 | } 95 | } 96 | 97 | } 98 | 99 | // MARK: PickerRow 100 | open class _DoublePickerRow : Row> where A: Equatable, B: Equatable { 101 | 102 | /// Options for first component. Will be called often so should be O(1) 103 | public var firstOptions: (() -> [A]) = {[]} 104 | /// Options for second component given the selected value from the first component. Will be called often so should be O(1) 105 | public var secondOptions: ((A) -> [B]) = {_ in []} 106 | 107 | /// Modify the displayed values for the first picker row. 108 | public var displayValueForFirstRow: ((A) -> (String)) = { a in return String(describing: a) } 109 | /// Modify the displayed values for the second picker row. 110 | public var displayValueForSecondRow: ((B) -> (String)) = { b in return String(describing: b) } 111 | 112 | required public init(tag: String?) { 113 | super.init(tag: tag) 114 | } 115 | 116 | func selectedFirst() -> A { 117 | return value?.a ?? firstOptions()[0] 118 | } 119 | 120 | } 121 | 122 | /// A generic row where the user can pick an option from a picker view 123 | public final class DoublePickerRow: _DoublePickerRow, RowType where A: Equatable, B: Equatable { 124 | 125 | required public init(tag: String?) { 126 | super.init(tag: tag) 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/LabelRow.swift: -------------------------------------------------------------------------------- 1 | // LabelRow.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | // MARK: LabelCell 29 | 30 | open class LabelCellOf: Cell, CellType { 31 | 32 | required public init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 33 | super.init(style: style, reuseIdentifier: reuseIdentifier) 34 | } 35 | 36 | required public init?(coder aDecoder: NSCoder) { 37 | super.init(coder: aDecoder) 38 | } 39 | 40 | open override func setup() { 41 | super.setup() 42 | selectionStyle = .none 43 | } 44 | } 45 | 46 | public typealias LabelCell = LabelCellOf 47 | 48 | // MARK: LabelRow 49 | 50 | open class _LabelRow: Row { 51 | required public init(tag: String?) { 52 | super.init(tag: tag) 53 | } 54 | } 55 | 56 | /// Simple row that can show title and value but is not editable by user. 57 | public final class LabelRow: _LabelRow, RowType { 58 | required public init(tag: String?) { 59 | super.init(tag: tag) 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/MultipleSelectorRow.swift: -------------------------------------------------------------------------------- 1 | // MultipleSelectorRow.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | 27 | open class _MultipleSelectorRow: GenericMultipleSelectorRow where Cell: BaseCell, Cell.Value == Set { 28 | public required init(tag: String?) { 29 | super.init(tag: tag) 30 | } 31 | } 32 | 33 | /// A selector row where the user can pick several options from a pushed view controller 34 | public final class MultipleSelectorRow : _MultipleSelectorRow>>, RowType { 35 | public required init(tag: String?) { 36 | super.init(tag: tag) 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/PickerInputRow.swift: -------------------------------------------------------------------------------- 1 | // PickerInputRow.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | // MARK: PickerInputCell 29 | 30 | open class _PickerInputCell : Cell, CellType, UIPickerViewDataSource, UIPickerViewDelegate where T: Equatable { 31 | 32 | lazy public var picker: UIPickerView = { 33 | let picker = UIPickerView() 34 | picker.translatesAutoresizingMaskIntoConstraints = false 35 | return picker 36 | }() 37 | 38 | fileprivate var pickerInputRow: _PickerInputRow? { return row as? _PickerInputRow } 39 | 40 | public required init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 41 | super.init(style: style, reuseIdentifier: reuseIdentifier) 42 | } 43 | 44 | required public init?(coder aDecoder: NSCoder) { 45 | super.init(coder: aDecoder) 46 | } 47 | 48 | open override func setup() { 49 | super.setup() 50 | accessoryType = .none 51 | editingAccessoryType = .none 52 | picker.delegate = self 53 | picker.dataSource = self 54 | } 55 | 56 | deinit { 57 | picker.delegate = nil 58 | picker.dataSource = nil 59 | } 60 | 61 | open override func update() { 62 | super.update() 63 | selectionStyle = row.isDisabled ? .none : .default 64 | 65 | if row.title?.isEmpty == false { 66 | detailTextLabel?.text = row.displayValueFor?(row.value) ?? (row as? NoValueDisplayTextConformance)?.noValueDisplayText 67 | } else { 68 | textLabel?.text = row.displayValueFor?(row.value) ?? (row as? NoValueDisplayTextConformance)?.noValueDisplayText 69 | detailTextLabel?.text = nil 70 | } 71 | 72 | if #available(iOS 13.0, *) { 73 | textLabel?.textColor = row.isDisabled ? .tertiaryLabel : .label 74 | } else { 75 | textLabel?.textColor = row.isDisabled ? .gray : .black 76 | } 77 | if row.isHighlighted { 78 | textLabel?.textColor = tintColor 79 | } 80 | 81 | picker.reloadAllComponents() 82 | } 83 | 84 | open override func didSelect() { 85 | super.didSelect() 86 | row.deselect() 87 | } 88 | 89 | open override var inputView: UIView? { 90 | return picker 91 | } 92 | 93 | open override func cellCanBecomeFirstResponder() -> Bool { 94 | return canBecomeFirstResponder 95 | } 96 | 97 | override open var canBecomeFirstResponder: Bool { 98 | return !row.isDisabled 99 | } 100 | 101 | open func numberOfComponents(in pickerView: UIPickerView) -> Int { 102 | return 1 103 | } 104 | 105 | open func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { 106 | return pickerInputRow?.options.count ?? 0 107 | } 108 | 109 | open func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { 110 | return pickerInputRow?.displayValueFor?(pickerInputRow?.options[row]) 111 | } 112 | 113 | open func pickerView(_ pickerView: UIPickerView, didSelectRow rowNumber: Int, inComponent component: Int) { 114 | if let picker = pickerInputRow, picker.options.count > rowNumber { 115 | picker.value = picker.options[rowNumber] 116 | update() 117 | } 118 | } 119 | } 120 | 121 | open class PickerInputCell: _PickerInputCell where T: Equatable { 122 | 123 | public required init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 124 | super.init(style: style, reuseIdentifier: reuseIdentifier) 125 | } 126 | 127 | required public init?(coder aDecoder: NSCoder) { 128 | super.init(coder: aDecoder) 129 | } 130 | 131 | open override func update() { 132 | super.update() 133 | if let selectedValue = pickerInputRow?.value, let index = pickerInputRow?.options.firstIndex(of: selectedValue) { 134 | picker.selectRow(index, inComponent: 0, animated: true) 135 | } 136 | } 137 | 138 | } 139 | 140 | // MARK: PickerInputRow 141 | 142 | open class _PickerInputRow : Row>, NoValueDisplayTextConformance where T: Equatable { 143 | open var noValueDisplayText: String? = nil 144 | 145 | open var options = [T]() 146 | 147 | required public init(tag: String?) { 148 | super.init(tag: tag) 149 | 150 | } 151 | } 152 | 153 | /// A generic row where the user can pick an option from a picker view displayed in the keyboard area 154 | public final class PickerInputRow: _PickerInputRow, RowType where T: Equatable { 155 | 156 | required public init(tag: String?) { 157 | super.init(tag: tag) 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/PickerRow.swift: -------------------------------------------------------------------------------- 1 | // PickerRow.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | // MARK: PickerCell 29 | 30 | open class _PickerCell : Cell, CellType, UIPickerViewDataSource, UIPickerViewDelegate where T: Equatable { 31 | 32 | @IBOutlet public weak var picker: UIPickerView! 33 | 34 | fileprivate var pickerRow: _PickerRow? { return row as? _PickerRow } 35 | 36 | public required init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 37 | let pickerView = UIPickerView() 38 | self.picker = pickerView 39 | self.picker?.translatesAutoresizingMaskIntoConstraints = false 40 | 41 | super.init(style: style, reuseIdentifier: reuseIdentifier) 42 | 43 | self.contentView.addSubview(pickerView) 44 | self.contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[picker]-0-|", options: [], metrics: nil, views: ["picker": pickerView])) 45 | self.contentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[picker]-0-|", options: [], metrics: nil, views: ["picker": pickerView])) 46 | } 47 | 48 | required public init?(coder aDecoder: NSCoder) { 49 | super.init(coder: aDecoder) 50 | } 51 | 52 | open override func setup() { 53 | super.setup() 54 | accessoryType = .none 55 | editingAccessoryType = .none 56 | height = { UITableView.automaticDimension } 57 | picker.delegate = self 58 | picker.dataSource = self 59 | } 60 | 61 | open override func update() { 62 | super.update() 63 | textLabel?.text = nil 64 | detailTextLabel?.text = nil 65 | picker.reloadAllComponents() 66 | } 67 | 68 | deinit { 69 | picker?.delegate = nil 70 | picker?.dataSource = nil 71 | } 72 | 73 | open var pickerTextAttributes: [NSAttributedString.Key: Any]? 74 | 75 | open func numberOfComponents(in pickerView: UIPickerView) -> Int { 76 | return 1 77 | } 78 | 79 | open func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { 80 | return pickerRow?.options.count ?? 0 81 | } 82 | 83 | open func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { 84 | return pickerRow?.displayValueFor?(pickerRow?.options[row]) 85 | } 86 | 87 | open func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { 88 | if let picker = pickerRow, !picker.options.isEmpty { 89 | picker.value = picker.options[row] 90 | } 91 | } 92 | 93 | open func pickerView(_ pickerView: UIPickerView, attributedTitleForRow row: Int, forComponent component: Int) -> NSAttributedString? { 94 | guard let pickerTextAttributes = pickerTextAttributes, let text = self.pickerView(pickerView, titleForRow: row, forComponent: component) else { 95 | return nil 96 | } 97 | return NSAttributedString(string: text, attributes: pickerTextAttributes) 98 | } 99 | } 100 | 101 | open class PickerCell : _PickerCell where T: Equatable { 102 | 103 | required public init?(coder aDecoder: NSCoder) { 104 | super.init(coder: aDecoder) 105 | } 106 | 107 | public required init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 108 | super.init(style: style, reuseIdentifier: reuseIdentifier) 109 | } 110 | 111 | open override func update() { 112 | super.update() 113 | if let selectedValue = pickerRow?.value, let index = pickerRow?.options.firstIndex(of: selectedValue) { 114 | picker.selectRow(index, inComponent: 0, animated: true) 115 | } 116 | } 117 | 118 | } 119 | 120 | // MARK: PickerRow 121 | 122 | open class _PickerRow : Row> where T: Equatable { 123 | 124 | open var options = [T]() 125 | 126 | required public init(tag: String?) { 127 | super.init(tag: tag) 128 | } 129 | } 130 | 131 | /// A generic row where the user can pick an option from a picker view 132 | public final class PickerRow: _PickerRow, RowType where T: Equatable { 133 | 134 | required public init(tag: String?) { 135 | super.init(tag: tag) 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/PopoverSelectorRow.swift: -------------------------------------------------------------------------------- 1 | // PopoverSelectorRow.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | open class _PopoverSelectorRow : SelectorRow where Cell: BaseCell { 29 | 30 | public required init(tag: String?) { 31 | super.init(tag: tag) 32 | onPresentCallback = { [weak self] (_, viewController) -> Void in 33 | guard let porpoverController = viewController.popoverPresentationController, let tableView = self?.baseCell.formViewController()?.tableView, let cell = self?.cell else { 34 | fatalError() 35 | } 36 | porpoverController.sourceView = tableView 37 | porpoverController.sourceRect = tableView.convert(cell.detailTextLabel?.frame ?? cell.textLabel?.frame ?? cell.contentView.frame, from: cell) 38 | } 39 | presentationMode = .popover(controllerProvider: ControllerProvider.callback { return SelectorViewController> { _ in } }, onDismiss: { [weak self] in 40 | $0.dismiss(animated: true) 41 | self?.reload() 42 | }) 43 | } 44 | 45 | open override func didSelect() { 46 | deselect() 47 | super.didSelect() 48 | } 49 | } 50 | 51 | public final class PopoverSelectorRow : _PopoverSelectorRow>, RowType { 52 | public required init(tag: String?) { 53 | super.init(tag: tag) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/PushRow.swift: -------------------------------------------------------------------------------- 1 | // PushRow.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | open class _PushRow: SelectorRow where Cell: BaseCell { 29 | 30 | public required init(tag: String?) { 31 | super.init(tag: tag) 32 | presentationMode = .show(controllerProvider: ControllerProvider.callback { return SelectorViewController> { _ in } }, onDismiss: { vc in 33 | let _ = vc.navigationController?.popViewController(animated: true) }) 34 | } 35 | } 36 | 37 | /// A selector row where the user can pick an option from a pushed view controller 38 | public final class PushRow : _PushRow>, RowType { 39 | public required init(tag: String?) { 40 | super.init(tag: tag) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/SelectableRows/ListCheckRow.swift: -------------------------------------------------------------------------------- 1 | // ListCheckRow.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | open class ListCheckCell : Cell, CellType { 29 | 30 | required public init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 31 | super.init(style: style, reuseIdentifier: reuseIdentifier) 32 | } 33 | 34 | required public init?(coder aDecoder: NSCoder) { 35 | super.init(coder: aDecoder) 36 | } 37 | 38 | open override func update() { 39 | super.update() 40 | accessoryType = row.value != nil ? .checkmark : .none 41 | editingAccessoryType = accessoryType 42 | selectionStyle = .default 43 | if row.isDisabled { 44 | tintAdjustmentMode = .dimmed 45 | selectionStyle = .none 46 | } else { 47 | tintAdjustmentMode = .automatic 48 | } 49 | } 50 | 51 | open override func setup() { 52 | super.setup() 53 | accessoryType = .checkmark 54 | editingAccessoryType = accessoryType 55 | } 56 | 57 | open override func didSelect() { 58 | row.deselect() 59 | row.updateCell() 60 | } 61 | 62 | } 63 | 64 | public final class ListCheckRow: Row>, SelectableRowType, RowType where T: Equatable { 65 | public var selectableValue: T? 66 | required public init(tag: String?) { 67 | super.init(tag: tag) 68 | displayValueFor = nil 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Rows/SwitchRow.swift: -------------------------------------------------------------------------------- 1 | // SwitchRow.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | // MARK: SwitchCell 29 | 30 | open class SwitchCell: Cell, CellType { 31 | 32 | @IBOutlet public weak var switchControl: UISwitch! 33 | 34 | required public init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { 35 | super.init(style: style, reuseIdentifier: reuseIdentifier) 36 | let switchC = UISwitch() 37 | switchControl = switchC 38 | accessoryView = switchControl 39 | editingAccessoryView = accessoryView 40 | } 41 | 42 | required public init?(coder aDecoder: NSCoder) { 43 | super.init(coder: aDecoder) 44 | } 45 | 46 | open override func setup() { 47 | super.setup() 48 | selectionStyle = .none 49 | switchControl.addTarget(self, action: #selector(SwitchCell.valueChanged), for: .valueChanged) 50 | } 51 | 52 | deinit { 53 | switchControl?.removeTarget(self, action: nil, for: .allEvents) 54 | } 55 | 56 | open override func update() { 57 | super.update() 58 | switchControl.isOn = row.value ?? false 59 | switchControl.isEnabled = !row.isDisabled 60 | } 61 | 62 | @objc func valueChanged() { 63 | row.value = switchControl?.isOn ?? false 64 | } 65 | } 66 | 67 | // MARK: SwitchRow 68 | 69 | open class _SwitchRow: Row { 70 | required public init(tag: String?) { 71 | super.init(tag: tag) 72 | displayValueFor = nil 73 | } 74 | } 75 | 76 | /// Boolean row that has a UISwitch as accessoryType 77 | public final class SwitchRow: _SwitchRow, RowType { 78 | required public init(tag: String?) { 79 | super.init(tag: tag) 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Validations/RuleClosure.swift: -------------------------------------------------------------------------------- 1 | // RuleClosure.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | 27 | public struct RuleClosure: RuleType { 28 | 29 | public var id: String? 30 | public var validationError: ValidationError 31 | 32 | public var closure: (T?) -> ValidationError? 33 | 34 | public func isValid(value: T?) -> ValidationError? { 35 | return closure(value) 36 | } 37 | 38 | public init(validationError: ValidationError = ValidationError(msg: "Field validation fails.."), id: String? = nil, closure: @escaping ((T?) -> ValidationError?)) { 39 | self.validationError = validationError 40 | self.closure = closure 41 | self.id = id 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Validations/RuleEmail.swift: -------------------------------------------------------------------------------- 1 | // RuleEmail.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | 27 | public class RuleEmail: RuleRegExp { 28 | 29 | public init(msg: String = "Field value should be a valid email!", id: String? = nil) { 30 | super.init(regExpr: RegExprPattern.EmailAddress.rawValue, allowsEmpty: true, msg: msg, id: id) 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Validations/RuleEqualsToRow.swift: -------------------------------------------------------------------------------- 1 | // RuleRequire.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | 27 | public struct RuleEqualsToRow: RuleType { 28 | 29 | public init(form: Form, tag: String, msg: String = "Fields don't match!", id: String? = nil) { 30 | self.validationError = ValidationError(msg: msg) 31 | self.form = form 32 | self.tag = tag 33 | self.row = nil 34 | self.id = id 35 | } 36 | 37 | public init(row: RowOf, msg: String = "Fields don't match!", id: String? = nil) { 38 | self.validationError = ValidationError(msg: msg) 39 | self.form = nil 40 | self.tag = nil 41 | self.row = row 42 | self.id = id 43 | } 44 | 45 | public var id: String? 46 | public var validationError: ValidationError 47 | public weak var form: Form? 48 | public var tag: String? 49 | public weak var row: RowOf? 50 | 51 | public func isValid(value: T?) -> ValidationError? { 52 | let rowAux: RowOf = row ?? form!.rowBy(tag: tag!)! 53 | return rowAux.value == value ? nil : validationError 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Validations/RuleLength.swift: -------------------------------------------------------------------------------- 1 | // RuleLength.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | 27 | public struct RuleMinLength: RuleType { 28 | 29 | let min: UInt 30 | 31 | public var id: String? 32 | public var validationError: ValidationError 33 | 34 | public init(minLength: UInt, msg: String? = nil, id: String? = nil) { 35 | let ruleMsg = msg ?? "Field value must have at least \(minLength) characters" 36 | min = minLength 37 | validationError = ValidationError(msg: ruleMsg) 38 | self.id = id 39 | } 40 | 41 | public func isValid(value: String?) -> ValidationError? { 42 | guard let value = value, !value.isEmpty else { return nil } 43 | return value.count < Int(min) ? validationError : nil 44 | } 45 | } 46 | 47 | public struct RuleMaxLength: RuleType { 48 | 49 | let max: UInt 50 | 51 | public var id: String? 52 | public var validationError: ValidationError 53 | 54 | public init(maxLength: UInt, msg: String? = nil, id: String? = nil) { 55 | let ruleMsg = msg ?? "Field value must have less than \(maxLength) characters" 56 | max = maxLength 57 | validationError = ValidationError(msg: ruleMsg) 58 | self.id = id 59 | } 60 | 61 | public func isValid(value: String?) -> ValidationError? { 62 | guard let value = value, !value.isEmpty else { return nil } 63 | return value.count > Int(max) ? validationError : nil 64 | } 65 | } 66 | 67 | public struct RuleExactLength: RuleType { 68 | let length: UInt 69 | 70 | public var id: String? 71 | public var validationError: ValidationError 72 | 73 | public init(exactLength: UInt, msg: String? = nil, id: String? = nil) { 74 | let ruleMsg = msg ?? "Field value must have exactly \(exactLength) characters" 75 | length = exactLength 76 | validationError = ValidationError(msg: ruleMsg) 77 | self.id = id 78 | } 79 | 80 | public func isValid(value: String?) -> ValidationError? { 81 | guard let value = value, !value.isEmpty else { return nil } 82 | return value.count != Int(length) ? validationError : nil 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Validations/RuleRange.swift: -------------------------------------------------------------------------------- 1 | // RuleRange.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | 27 | public struct RuleGreaterThan: RuleType { 28 | 29 | let min: T 30 | 31 | public var id: String? 32 | public var validationError: ValidationError 33 | 34 | public init(min: T, msg: String? = nil, id: String? = nil) { 35 | let ruleMsg = msg ?? "Field value must be greater than \(min)" 36 | self.min = min 37 | self.validationError = ValidationError(msg: ruleMsg) 38 | self.id = id 39 | } 40 | 41 | public func isValid(value: T?) -> ValidationError? { 42 | guard let val = value else { return nil } 43 | guard val > min else { return validationError } 44 | return nil 45 | } 46 | } 47 | 48 | public struct RuleGreaterOrEqualThan: RuleType { 49 | 50 | let min: T 51 | 52 | public var id: String? 53 | public var validationError: ValidationError 54 | 55 | public init(min: T, msg: String? = nil, id: String? = nil) { 56 | let ruleMsg = msg ?? "Field value must be greater or equals than \(min)" 57 | self.min = min 58 | self.validationError = ValidationError(msg: ruleMsg) 59 | self.id = id 60 | } 61 | 62 | public func isValid(value: T?) -> ValidationError? { 63 | guard let val = value else { return nil } 64 | guard val >= min else { return validationError } 65 | return nil 66 | } 67 | } 68 | 69 | public struct RuleSmallerThan: RuleType { 70 | 71 | let max: T 72 | 73 | public var id: String? 74 | public var validationError: ValidationError 75 | 76 | public init(max: T, msg: String? = nil, id: String? = nil) { 77 | let ruleMsg = msg ?? "Field value must be smaller than \(max)" 78 | self.max = max 79 | self.validationError = ValidationError(msg: ruleMsg) 80 | self.id = id 81 | } 82 | 83 | public func isValid(value: T?) -> ValidationError? { 84 | guard let val = value else { return nil } 85 | guard val < max else { return validationError } 86 | return nil 87 | } 88 | } 89 | 90 | public struct RuleSmallerOrEqualThan: RuleType { 91 | 92 | let max: T 93 | 94 | public var id: String? 95 | public var validationError: ValidationError 96 | 97 | public init(max: T, msg: String? = nil, id: String? = nil) { 98 | let ruleMsg = msg ?? "Field value must be smaller or equals than \(max)" 99 | self.max = max 100 | self.validationError = ValidationError(msg: ruleMsg) 101 | self.id = id 102 | } 103 | 104 | public func isValid(value: T?) -> ValidationError? { 105 | guard let val = value else { return nil } 106 | guard val <= max else { return validationError } 107 | return nil 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Validations/RuleRegExp.swift: -------------------------------------------------------------------------------- 1 | // RegexRule.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | 27 | public enum RegExprPattern: String { 28 | case EmailAddress = "^[_A-Za-z0-9-+]+(\\.[_A-Za-z0-9-+]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z‌​]{2,})$" 29 | case URL = "((https|http)://)((\\w|-)+)(([.]|[/])((\\w|-)+))+([/?#]\\S*)?" 30 | case ContainsNumber = ".*\\d.*" 31 | case ContainsCapital = "^.*?[A-Z].*?$" 32 | case ContainsLowercase = "^.*?[a-z].*?$" 33 | } 34 | 35 | open class RuleRegExp: RuleType { 36 | 37 | public var regExpr: String = "" 38 | public var id: String? 39 | public var validationError: ValidationError 40 | public var allowsEmpty = true 41 | 42 | public init(regExpr: String, allowsEmpty: Bool = true, msg: String = "Invalid field value!", id: String? = nil) { 43 | self.validationError = ValidationError(msg: msg) 44 | self.regExpr = regExpr 45 | self.allowsEmpty = allowsEmpty 46 | self.id = id 47 | } 48 | 49 | public func isValid(value: String?) -> ValidationError? { 50 | if let value = value, !value.isEmpty { 51 | let predicate = NSPredicate(format: "SELF MATCHES %@", regExpr) 52 | guard predicate.evaluate(with: value) else { 53 | return validationError 54 | } 55 | return nil 56 | } else if !allowsEmpty { 57 | return validationError 58 | } 59 | return nil 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Validations/RuleRequired.swift: -------------------------------------------------------------------------------- 1 | // RuleRequire.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | 27 | public struct RuleRequired: RuleType { 28 | 29 | public init(msg: String = "Field required!", id: String? = nil) { 30 | self.validationError = ValidationError(msg: msg) 31 | self.id = id 32 | } 33 | 34 | public var id: String? 35 | public var validationError: ValidationError 36 | 37 | public func isValid(value: T?) -> ValidationError? { 38 | if let str = value as? String { 39 | return str.isEmpty ? validationError : nil 40 | } 41 | return value != nil ? nil : validationError 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Pods/Eureka/Source/Validations/RuleURL.swift: -------------------------------------------------------------------------------- 1 | // RuleURL.swift 2 | // Eureka ( https://github.com/xmartlabs/Eureka ) 3 | // 4 | // Copyright (c) 2016 Xmartlabs SRL ( http://xmartlabs.com ) 5 | // 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | 25 | import Foundation 26 | import UIKit 27 | 28 | public struct RuleURL: RuleType { 29 | 30 | public init(allowsEmpty: Bool = true, requiresProtocol: Bool = false, msg: String = "Field value must be an URL!", id: String? = nil) { 31 | validationError = ValidationError(msg: msg) 32 | self.allowsEmpty = allowsEmpty 33 | self.requiresProtocol = requiresProtocol 34 | self.id = id 35 | } 36 | 37 | public var id: String? 38 | public var allowsEmpty = true 39 | public var requiresProtocol = false 40 | public var validationError: ValidationError 41 | 42 | public func isValid(value: URL?) -> ValidationError? { 43 | if let value = value, value.absoluteString.isEmpty == false { 44 | let predicate = NSPredicate(format:"SELF MATCHES %@", RegExprPattern.URL.rawValue) 45 | guard predicate.evaluate(with: value.absoluteString) else { 46 | return validationError 47 | } 48 | return nil 49 | } else if !allowsEmpty { 50 | return validationError 51 | } 52 | return nil 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Eureka (5.2.1) 3 | - UIColor_Hex_Swift (5.1.0) 4 | 5 | DEPENDENCIES: 6 | - Eureka (>= 5.0) 7 | - UIColor_Hex_Swift 8 | 9 | SPEC REPOS: 10 | https://github.com/CocoaPods/Specs.git: 11 | - Eureka 12 | - UIColor_Hex_Swift 13 | 14 | SPEC CHECKSUMS: 15 | Eureka: c883105488e05bc65539f583246ecf9657cabbfe 16 | UIColor_Hex_Swift: 8be7432edacb7fa91c78aa05ef3c30b66e4f9415 17 | 18 | PODFILE CHECKSUM: a0477ad9f51c16a433fb0de98daa2dd2faaf4efe 19 | 20 | COCOAPODS: 1.8.4 21 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Eureka/Eureka-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 5.2.1 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Eureka/Eureka-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Eureka : NSObject 3 | @end 4 | @implementation PodsDummy_Eureka 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Eureka/Eureka-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Eureka/Eureka-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double EurekaVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char EurekaVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Eureka/Eureka.modulemap: -------------------------------------------------------------------------------- 1 | framework module Eureka { 2 | umbrella header "Eureka-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Eureka/Eureka.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/Eureka 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | OTHER_LDFLAGS = $(inherited) -framework "Foundation" -framework "UIKit" 4 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/Eureka 9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 10 | SKIP_INSTALL = YES 11 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 12 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Eureka/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 4.3.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ColorPicker/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ColorPicker/Pods-ColorPicker-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ColorPicker/Pods-ColorPicker-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## Eureka 5 | 6 | The MIT License (MIT) 7 | 8 | Copyright (c) 2019 XMARTLABS 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | 29 | ## UIColor_Hex_Swift 30 | 31 | The MIT License (MIT) 32 | 33 | Copyright (c) 2014 R0CKSTAR 34 | 35 | Permission is hereby granted, free of charge, to any person obtaining a copy 36 | of this software and associated documentation files (the "Software"), to deal 37 | in the Software without restriction, including without limitation the rights 38 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 39 | copies of the Software, and to permit persons to whom the Software is 40 | furnished to do so, subject to the following conditions: 41 | 42 | The above copyright notice and this permission notice shall be included in all 43 | copies or substantial portions of the Software. 44 | 45 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 46 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 47 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 48 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 49 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 50 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 51 | SOFTWARE. 52 | Generated by CocoaPods - https://cocoapods.org 53 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ColorPicker/Pods-ColorPicker-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | The MIT License (MIT) 18 | 19 | Copyright (c) 2019 XMARTLABS 20 | 21 | Permission is hereby granted, free of charge, to any person obtaining a copy 22 | of this software and associated documentation files (the "Software"), to deal 23 | in the Software without restriction, including without limitation the rights 24 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 25 | copies of the Software, and to permit persons to whom the Software is 26 | furnished to do so, subject to the following conditions: 27 | 28 | The above copyright notice and this permission notice shall be included in all 29 | copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 34 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 36 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 37 | SOFTWARE. 38 | 39 | License 40 | MIT 41 | Title 42 | Eureka 43 | Type 44 | PSGroupSpecifier 45 | 46 | 47 | FooterText 48 | The MIT License (MIT) 49 | 50 | Copyright (c) 2014 R0CKSTAR 51 | 52 | Permission is hereby granted, free of charge, to any person obtaining a copy 53 | of this software and associated documentation files (the "Software"), to deal 54 | in the Software without restriction, including without limitation the rights 55 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 56 | copies of the Software, and to permit persons to whom the Software is 57 | furnished to do so, subject to the following conditions: 58 | 59 | The above copyright notice and this permission notice shall be included in all 60 | copies or substantial portions of the Software. 61 | 62 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 63 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 64 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 65 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 66 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 67 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 68 | SOFTWARE. 69 | License 70 | MIT 71 | Title 72 | UIColor_Hex_Swift 73 | Type 74 | PSGroupSpecifier 75 | 76 | 77 | FooterText 78 | Generated by CocoaPods - https://cocoapods.org 79 | Title 80 | 81 | Type 82 | PSGroupSpecifier 83 | 84 | 85 | StringsTable 86 | Acknowledgements 87 | Title 88 | Acknowledgements 89 | 90 | 91 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ColorPicker/Pods-ColorPicker-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_ColorPicker : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_ColorPicker 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ColorPicker/Pods-ColorPicker-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_ColorPickerVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_ColorPickerVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ColorPicker/Pods-ColorPicker.debug.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Eureka" "${PODS_CONFIGURATION_BUILD_DIR}/UIColor_Hex_Swift" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Eureka/Eureka.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/UIColor_Hex_Swift/UIColor_Hex_Swift.framework/Headers" 5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 6 | OTHER_LDFLAGS = $(inherited) -framework "Eureka" -framework "Foundation" -framework "UIColor_Hex_Swift" -framework "UIKit" 7 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 8 | PODS_BUILD_DIR = ${BUILD_DIR} 9 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 13 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ColorPicker/Pods-ColorPicker.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_ColorPicker { 2 | umbrella header "Pods-ColorPicker-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-ColorPicker/Pods-ColorPicker.release.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Eureka" "${PODS_CONFIGURATION_BUILD_DIR}/UIColor_Hex_Swift" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Eureka/Eureka.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/UIColor_Hex_Swift/UIColor_Hex_Swift.framework/Headers" 5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 6 | OTHER_LDFLAGS = $(inherited) -framework "Eureka" -framework "Foundation" -framework "UIColor_Hex_Swift" -framework "UIKit" 7 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 8 | PODS_BUILD_DIR = ${BUILD_DIR} 9 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 13 | -------------------------------------------------------------------------------- /Pods/Target Support Files/UIColor_Hex_Swift/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 4.2.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/UIColor_Hex_Swift/UIColor_Hex_Swift-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 5.1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/UIColor_Hex_Swift/UIColor_Hex_Swift-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_UIColor_Hex_Swift : NSObject 3 | @end 4 | @implementation PodsDummy_UIColor_Hex_Swift 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/UIColor_Hex_Swift/UIColor_Hex_Swift-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Pods/Target Support Files/UIColor_Hex_Swift/UIColor_Hex_Swift-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | #import "HEXColor.h" 14 | 15 | FOUNDATION_EXPORT double UIColor_Hex_SwiftVersionNumber; 16 | FOUNDATION_EXPORT const unsigned char UIColor_Hex_SwiftVersionString[]; 17 | 18 | -------------------------------------------------------------------------------- /Pods/Target Support Files/UIColor_Hex_Swift/UIColor_Hex_Swift.modulemap: -------------------------------------------------------------------------------- 1 | framework module UIColor_Hex_Swift { 2 | umbrella header "UIColor_Hex_Swift-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/UIColor_Hex_Swift/UIColor_Hex_Swift.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/UIColor_Hex_Swift 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | OTHER_LDFLAGS = $(inherited) -framework "UIKit" 4 | OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS 5 | PODS_BUILD_DIR = ${BUILD_DIR} 6 | PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/UIColor_Hex_Swift 9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 10 | SKIP_INSTALL = YES 11 | USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES = YES 12 | -------------------------------------------------------------------------------- /Pods/UIColor_Hex_Swift/HEXColor/HEXColor.h: -------------------------------------------------------------------------------- 1 | // 2 | // HEXColor.h 3 | // HEXColor 4 | // 5 | // Created by Yuki Nagai on 10/5/15. 6 | // Copyright © 2015 P.D.Q. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for HEXColor. 12 | FOUNDATION_EXPORT double HEXColorVersionNumber; 13 | 14 | //! Project version string for HEXColor. 15 | FOUNDATION_EXPORT const unsigned char HEXColorVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | -------------------------------------------------------------------------------- /Pods/UIColor_Hex_Swift/HEXColor/StringExtension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // StringExtension.swift 3 | // HEXColor-iOS 4 | // 5 | // Created by Sergey Pugach on 2/2/18. 6 | // Copyright © 2018 P.D.Q. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | extension String { 13 | /** 14 | Convert argb string to rgba string. 15 | */ 16 | public var argb2rgba: String? { 17 | guard self.hasPrefix("#") else { 18 | return nil 19 | } 20 | 21 | let hexString: String = String(self[self.index(self.startIndex, offsetBy: 1)...]) 22 | switch hexString.count { 23 | case 4: 24 | return "#\(String(hexString[self.index(self.startIndex, offsetBy: 1)...]))\(String(hexString[.. 2 | 3 |

4 | 5 | UIColor+Hex, now Swift. 6 | [![Build Status](https://travis-ci.org/yeahdongcn/UIColor-Hex-Swift.svg?branch=master)](https://travis-ci.org/yeahdongcn/UIColor-Hex-Swift) [![codecov.io](https://codecov.io/gh/yeahdongcn/UIColor-Hex-Swift/branch/master/graphs/badge.svg)](https://codecov.io/gh/yeahdongcn/UIColor-Hex-Swift/branch/master) ![](https://img.shields.io/badge/Swift-4.0-blue.svg?style=flat) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) ![](https://img.shields.io/badge/license-MIT-blue.svg?style=flat) 7 | ================= 8 | Convenience method for creating autoreleased color using RGBA hex string. 9 | 10 | ```swift 11 | // Solid color 12 | let strokeColor = UIColor("#FFCC00").CGColor 13 | 14 | // Color with alpha 15 | let fillColor = UIColor("#FFCC00DD").CGColor 16 | 17 | // Supports shorthand 3 character representation 18 | let backgroundColor = UIColor("#FFF") 19 | 20 | // Supports shorthand 4 character representation (with alpha) 21 | let menuTextColor = UIColor("#013E") 22 | 23 | // "#FF0000FF" 24 | let hexString = UIColor.redColor().hexString() 25 | 26 | // Convert shorthand 4 character representation (with alpha) from argb to rgba 27 | if let rgba = "#AFFF".argb2rgba() { 28 | let androidBackgroundColor = UIColor(rgba) 29 | } 30 | 31 | // Convert 8 character representation (with alpha) from argb to rgba 32 | if let rgba = "#AAFFFFFF".argb2rgba() { 33 | let androidFrontColor = UIColor(rgba) 34 | } 35 | ``` 36 | 37 | ## Installation 38 | 39 | ### [CocoaPods](http://cocoapods.org) 40 | 41 | Simply add the following lines to your `Podfile`: 42 | ```ruby 43 | # required by CocoaPods 0.36.0.rc.1 for Swift Pods 44 | use_frameworks! 45 | 46 | pod 'UIColor_Hex_Swift', '~> 5.0.0' 47 | ``` 48 | 49 | Then import it where you use it: 50 | ```swift 51 | import UIColor_Hex_Swift 52 | ``` 53 | 54 | *(CocoaPods v0.36 or later required. See [this blog post](http://blog.cocoapods.org/Pod-Authors-Guide-to-CocoaPods-Frameworks/) for details.)* 55 | 56 | ### [Carthage](http://github.com/Carthage/Carthage) 57 | 58 | Simply add the following line to your `Cartfile`: 59 | 60 | ```ruby 61 | github "yeahdongcn/UIColor-Hex-Swift" >= 5.0.0 62 | ``` 63 | 64 | Then add the HexColor.framework to your frameworks list in the Xcode project. 65 | 66 | Then import it where you use it: 67 | ```swift 68 | import HEXColor 69 | ``` 70 | 71 | --- 72 | 73 | See more in [RSBarcodes_Swift](https://github.com/yeahdongcn/RSBarcodes_Swift) and [objc version](https://github.com/yeahdongcn/RSBarcodes) 74 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | By [Mark Alldritt](http://markalldritt.com). 2 | 3 | ## NEW 4 | 5 | Added a new inline color picker row (InlineColorPickeRow) for version 1.2. 6 | 7 | ## Introduction 8 | 9 | ColorPickerRow is a [Eureka](https://github.com/xmartlabs/Eureka) custom row that allows you to choose colors. ColorRow lets you display a color in a row. 10 | 11 | ![Demo](Screenshots/ColorPicker.gif) 12 | 13 | ## ColorPickerRow & InlineColorPickerRow Usage 14 | 15 | ```swift 16 | import Eureka 17 | 18 | class ViewController: FormViewController { 19 | 20 | override func viewDidLoad() { 21 | super.viewDidLoad() 22 | 23 | form 24 | +++ Section("Color Picker Demo") 25 | <<< ColorPickerRow("colors1") { (row) in 26 | row.title = "Color Picker" 27 | row.isCircular = false 28 | row.showsCurrentSwatch = true 29 | row.showsPaletteNames = true 30 | row.value = UIColor.green 31 | } 32 | .onChange { (picker) in 33 | print("color1: \(picker.value!)") 34 | } 35 | } 36 | } 37 | ``` 38 | 39 | ## ColorRow Usage 40 | 41 | ```swift 42 | import Eureka 43 | 44 | class ViewController: FormViewController { 45 | 46 | override func viewDidLoad() { 47 | super.viewDidLoad() 48 | 49 | form 50 | +++ Section("Color Swatch Demo") 51 | <<< ColorRow("swatch1") { (row) in 52 | row.title = "Chosen Color" 53 | row.value = UIColor.green 54 | } 55 | } 56 | } 57 | ``` 58 | 59 | ## Requirements 60 | 61 | * iOS 10.0+ 62 | * Xcode 8.3+ 63 | * Eureka 2.0.* 64 | 65 | ## Getting involved 66 | 67 | * If you **want to contribute** please feel free to **submit pull requests**. 68 | * If you **have a feature request** please **open an issue**. 69 | * If you **found a bug** or **need help** please **check older issues, [FAQ](#faq) before submitting an issue.**. 70 | 71 | Before contribute check the [CONTRIBUTING](https://github.com/EurekaCommunity/ImageRow/blob/master/CONTRIBUTING.md) file for more info. 72 | 73 | If you use **ColorPickerRow** in your app I would love to hear about it! Drop me a line on [twitter](https://twitter.com/alldritt). 74 | 75 | ## Installation 76 | 77 | 1. Add the following to your Podfile: 78 | 79 | ~~~~ 80 | pod 'ColorPickerRow' 81 | ~~~~ 82 | 83 | 2. Run `$ pod install` 84 | 85 | ## ColorPickerRow Customization 86 | 87 | - `isCircular` allows you to choose between circular and rounded square color swatches. 88 | 89 | - `showsCurrentSwatch` determines if the row displays a swatch to the right of the row title showing the currently selected color. 90 | 91 | - `showsPaletteNames` determines if color palette names are displayed in the color row. 92 | 93 | - `cell.palettes` you can also customize the color palette(s) displayed by configuring the cell's `palettes` property. Here's a brief example (note that a more complete example of how to do this is included in the Example application).' 94 | 95 | ```swift 96 | <<< ColorPickerRow("colors") { (row) in 97 | row.title = "Color Picker" 98 | row.isCircular = true 99 | row.showsCurrentSwatch = false 100 | row.showsPaletteNames = false 101 | row.value = UIColor.white 102 | } 103 | .cellSetup { (cell, row) in 104 | let palette = ColorPalette(name: "All", 105 | palette: [ColorSpec(hex: "#ffffff", name: "White"), 106 | ColorSpec(hex: "#000000", name: "Black")]) 107 | cell.palettes = [palette] 108 | } 109 | ``` 110 | 111 | ## InlineColorPickerRow Customization 112 | 113 | - `isCircular` allows you to choose between circular and rounded square color swatches. 114 | 115 | - `showsCurrentSwatch` determines if the row displays a swatch to the right of the row title showing the currently selected color. 116 | 117 | - `showsPaletteNames` determines if color palette names are displayed in the color row. 118 | 119 | ## ColorRow Customization 120 | 121 | - `isCircular` allows you to choose between circular and rounded square color swatches. 122 | 123 | 124 | ## Author 125 | 126 | - [Mark Alldritt](http://markalldritt.com) 127 | 128 | ## FAQ 129 | 130 | nothing yet 131 | 132 | ## Applications using ColorPickerRow 133 | 134 | - [Tennis Cards](https://itunes.apple.com/us/app/tennis-cards/id1212377801?mt=8) 135 | 136 | ## Other Rows 137 | 138 | See my other contributions to the Eureka Community: 139 | 140 | - [ViewRow](https://github.com/EurekaCommunity/ViewRow) 141 | -------------------------------------------------------------------------------- /Screenshots/ColorPicker.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EurekaCommunity/ColorPickerRow/a6a367836a65b88dc407e63a3af51863ad116fee/Screenshots/ColorPicker.gif --------------------------------------------------------------------------------