diff --git a/Package.resolved b/Package.resolved
new file mode 100644
index 0000000..ed05835
--- /dev/null
+++ b/Package.resolved
@@ -0,0 +1,25 @@
+{
+ "object": {
+ "pins": [
+ {
+ "package": "SnapKit",
+ "repositoryURL": "https://github.com/SnapKit/SnapKit.git",
+ "state": {
+ "branch": null,
+ "revision": "d458564516e5676af9c70b4f4b2a9178294f1bc6",
+ "version": "5.0.1"
+ }
+ },
+ {
+ "package": "UIKitExtensions",
+ "repositoryURL": "https://github.com/code-troopers/UIKitExtensions",
+ "state": {
+ "branch": null,
+ "revision": "d5a267e7958bc838d06678503d8dbee83d86bc7d",
+ "version": "0.3.0"
+ }
+ }
+ ]
+ },
+ "version": 1
+}
diff --git a/Package.swift b/Package.swift
new file mode 100644
index 0000000..1f691c0
--- /dev/null
+++ b/Package.swift
@@ -0,0 +1,29 @@
+// swift-tools-version:5.3
+// The swift-tools-version declares the minimum version of Swift required to build this package.
+
+import PackageDescription
+
+let package = Package(
+ name: "iOSFormUtils",
+ platforms: [
+ .iOS(.v10)
+ ],
+ products: [
+ // Products define the executables and libraries a package produces, and make them visible to other packages.
+ .library(
+ name: "iOSFormUtils",
+ targets: ["iOSFormUtils"]),
+ ],
+ dependencies: [
+ // Dependencies declare other packages that this package depends on.
+ .package(url: "https://github.com/code-troopers/UIKitExtensions", .upToNextMajor(from: "0.3.0")),
+ .package(url: "https://github.com/SnapKit/SnapKit.git", .upToNextMajor(from: "5.0.1"))
+ ],
+ targets: [
+ // Targets are the basic building blocks of a package. A target can define a module or a test suite.
+ // Targets can depend on other targets in this package, and on products in packages this package depends on.
+ .target(
+ name: "iOSFormUtils",
+ dependencies: ["UIKitExtensions", "SnapKit"]),
+ ]
+)
diff --git a/iOSFormUtils/DateDropDown.swift b/Sources/iOSFormUtils/DateDropDown.swift
similarity index 92%
rename from iOSFormUtils/DateDropDown.swift
rename to Sources/iOSFormUtils/DateDropDown.swift
index 29118de..f5a6fa2 100644
--- a/iOSFormUtils/DateDropDown.swift
+++ b/Sources/iOSFormUtils/DateDropDown.swift
@@ -36,9 +36,11 @@ open class DateDropDown: DropDown {
override open func loadView() {
super.loadView()
-
- picker.pickerType = .date
+ picker = SBPickerSwiftSelector(mode: .dateDefault)
+ /*
+ picker.pickerType = .date
picker.onlyDayPicker = true
picker.datePickerType = .onlyDay
+ */
}
}
diff --git a/iOSFormUtils/DropDown.swift b/Sources/iOSFormUtils/DropDown.swift
similarity index 79%
rename from iOSFormUtils/DropDown.swift
rename to Sources/iOSFormUtils/DropDown.swift
index 3b2f82a..bc3304a 100644
--- a/iOSFormUtils/DropDown.swift
+++ b/Sources/iOSFormUtils/DropDown.swift
@@ -7,7 +7,6 @@
//
import Foundation
-import SBPickerSelector
import UIKit
import UIKitExtensions
import SnapKit
@@ -46,7 +45,7 @@ open class DropDown: OwnView {
}
public var dataSource: DropDownDataSource!
- var picker: SBPickerSelector = SBPickerSelector.picker()
+ var picker: SBPickerSwiftSelector? //FIXME CG = SBPickerSwiftSelector.picker()
var values: [String]!
var currentTextField: TextInput!
public var selectedIndex: Int!
@@ -63,7 +62,7 @@ open class DropDown: OwnView {
self.addSubview(self.titleTextField)
rightIcon = UIImageView(frame: CGRect())
- rightIcon.contentMode = UIViewContentMode.center
+ rightIcon.contentMode = UIView.ContentMode.center
self.addSubview(rightIcon)
mainButton = UIButton(type: .custom)
@@ -88,12 +87,11 @@ open class DropDown: OwnView {
self.layoutIfNeeded()
self.layoutSubviews()
- picker.delegate = self
- picker.pickerType = SBPickerSelectorType.text
- picker.doneButtonTitle = "OK"
- picker.doneButton?.tintColor = mainColor
- picker.cancelButtonTitle = "Annuler"
- picker.cancelButton?.tintColor = mainColor
+ picker = SBPickerSwiftSelector(mode: .text)
+ picker?.doneButton?.title = "OK"
+ picker?.doneButton?.tintColor = mainColor
+ picker?.cancelButton?.title = "Annuler"
+ picker?.cancelButton?.tintColor = mainColor
updateUI()
@@ -109,8 +107,8 @@ open class DropDown: OwnView {
func updateUI() {
if let _ = dataSource, let _ = uiDataSource {
- picker.doneButton?.tintColor = uiDataSource.getButtonsColor()
- picker.cancelButton?.tintColor = uiDataSource.getButtonsColor()
+ picker?.doneButton?.tintColor = uiDataSource.getButtonsColor()
+ picker?.cancelButton?.tintColor = uiDataSource.getButtonsColor()
if let existingPlaceholder = dataSource.placeholderKeyForDropDown(self) {
updatePlaceholderWithValue(existingPlaceholder)
@@ -126,18 +124,18 @@ open class DropDown: OwnView {
titleTextField.attributedPlaceholder = NSAttributedString(
string: value,
attributes: [
- NSForegroundColorAttributeName: self.uiDataSource.getPlaceholderColor(),
- NSFontAttributeName: UIFont(name: self.uiDataSource.getFontName(), size: self.uiDataSource.getFontSize())!
+ NSAttributedString.Key.foregroundColor: self.uiDataSource.getPlaceholderColor(),
+ NSAttributedString.Key.font: UIFont(name: self.uiDataSource.getFontName(), size: self.uiDataSource.getFontSize())!
]
)
}
func updateSelectedIndex(_ newIndex: Int) {
selectedIndex = newIndex
- picker.pickerView.selectRow(selectedIndex, inComponent: 0, animated: true)
- if let data: [String] = picker.pickerData as? [String] {
+ picker?.pickerView.selectRow(selectedIndex, inComponent: 0, animated: true)
+ if let data: [String] = picker?.data as? [String] {
pickerSelector(picker, selectedValue: data[selectedIndex], index: selectedIndex)
- picker.pickerView(picker.pickerView, didSelectRow: selectedIndex, inComponent: 0)
+ picker!.pickerView.delegate?.pickerView?(picker!.pickerView, didSelectRow: selectedIndex, inComponent: 0)
}
}
@@ -155,7 +153,7 @@ open class DropDown: OwnView {
offset = 1
}
- picker.pickerData = values
+ picker?.data = values
if let dataSourceSelectedIndex: Int = itsDataSource.selectedIndexForDropDown(self) {
updateSelectedIndex(dataSourceSelectedIndex + offset)
}
@@ -167,15 +165,15 @@ open class DropDown: OwnView {
if let textField = currentTextField {
textField.resignFirstResponder()
}
- picker.showPickerOver(itsDataSource.controllerForDropDownDisplaying(self))
+ picker?.present(into: itsDataSource.controllerForDropDownDisplaying(self))
}
}
- func mainButtonTouched(_ sender: AnyObject) {
+ @objc func mainButtonTouched(_ sender: AnyObject) {
presentDropDown()
}
- func textFieldBecameFirstResponder(_ notification: Notification) {
+ @objc func textFieldBecameFirstResponder(_ notification: Notification) {
if let textField: TextInput = notification.object as? TextInput {
if textField != titleTextField {
currentTextField = textField
@@ -186,8 +184,8 @@ open class DropDown: OwnView {
}
}
-extension DropDown: SBPickerSelectorDelegate {
- public func pickerSelector(_ selector: SBPickerSelector!, selectedValue value: String!, index idx: Int) {
+extension DropDown /*: SBPickerSelectorDelegate */{
+ public func pickerSelector(_ selector: SBPickerSwiftSelector!, selectedValue value: String!, index idx: Int) {
let required = (nil != dataSource && !dataSource.isRequired(self))
var offset = 0
if (required && 0 != idx) || !required {
@@ -212,8 +210,8 @@ extension DropDown: SBPickerSelectorDelegate {
}
}
- public func pickerSelector(_ selector: SBPickerSelector!, dateSelected date: Date!) {
- if .date == picker.pickerType {
+ public func pickerSelector(_ selector: SBPickerSwiftSelector!, dateSelected date: Date!) {
+ if SBPickerSwiftSelector.Mode.dateDefault == picker?.pickerMode {
if let _ = date {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = self.dateFormat
diff --git a/iOSFormUtils/Form.swift b/Sources/iOSFormUtils/Form.swift
similarity index 93%
rename from iOSFormUtils/Form.swift
rename to Sources/iOSFormUtils/Form.swift
index 0e8d8a7..53eeb53 100644
--- a/iOSFormUtils/Form.swift
+++ b/Sources/iOSFormUtils/Form.swift
@@ -99,14 +99,14 @@ open class Form: UIScrollView {
NotificationCenter.default.addObserver(
self,
selector: #selector(Form.keyboardShown(_:)),
- name: NSNotification.Name.UIKeyboardDidShow,
+ name: UIResponder.keyboardDidShowNotification,
object: nil
)
NotificationCenter.default.addObserver(
self,
selector: #selector(Form.keyboardHidden(_:)),
- name: NSNotification.Name.UIKeyboardDidHide,
+ name: UIResponder.keyboardDidHideNotification,
object: nil
)
@@ -204,7 +204,7 @@ open class Form: UIScrollView {
- Parameter notification: the received notification.
*/
- func textFieldReturnedFired(_ notification: Notification) {
+ @objc func textFieldReturnedFired(_ notification: Notification) {
if let textfield = notification.object as? TextInput {
if isLastInput(textfield) {
textfield.stopEditing()
@@ -225,7 +225,7 @@ open class Form: UIScrollView {
- Parameter notification: the received notification.
*/
- func textFieldResignedFirstResponderFired(_ notification: Notification) {
+ @objc func textFieldResignedFirstResponderFired(_ notification: Notification) {
resetScrollingZone()
}
@@ -234,9 +234,9 @@ open class Form: UIScrollView {
- Parameter notification: the received notification
*/
- func keyboardShown(_ notification: Notification) {
+ @objc func keyboardShown(_ notification: Notification) {
let info = (notification as NSNotification).userInfo!
- let value: AnyObject = info[UIKeyboardFrameEndUserInfoKey]! as AnyObject
+ let value: AnyObject = info[UIResponder.keyboardFrameEndUserInfoKey]! as AnyObject
let rawFrame = value.cgRectValue
let keyboardFrame = self.convert(rawFrame!, from: nil)
@@ -248,7 +248,7 @@ open class Form: UIScrollView {
}
}
- func keyboardHidden(_ notification: Notification) {
+ @objc func keyboardHidden(_ notification: Notification) {
resetScrollingZone()
}
@@ -257,7 +257,7 @@ open class Form: UIScrollView {
- Parameter notification: the received notification
*/
- func textFieldBecameFirstResponder(_ notification: Notification) {
+ @objc func textFieldBecameFirstResponder(_ notification: Notification) {
if let textfield = notification.object as? TextInput {
currentInput = textfield
}
diff --git a/iOSFormUtils/ImagePicker.swift b/Sources/iOSFormUtils/ImagePicker.swift
similarity index 94%
rename from iOSFormUtils/ImagePicker.swift
rename to Sources/iOSFormUtils/ImagePicker.swift
index e4c81cb..bc76924 100644
--- a/iOSFormUtils/ImagePicker.swift
+++ b/Sources/iOSFormUtils/ImagePicker.swift
@@ -72,7 +72,7 @@ public class ImagePicker: UIButton {
}
}
- func selfTouched(_ sender: Any) {
+ @objc func selfTouched(_ sender: Any) {
if let _ = dataSource {
dataSource.controllerForDisplaying().present(actionSheet, animated: true)
} else {
@@ -82,8 +82,8 @@ public class ImagePicker: UIButton {
}
extension ImagePicker: UIImagePickerControllerDelegate, UINavigationControllerDelegate {
- public func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String: Any]) {
- if let pickedImage = info[UIImagePickerControllerOriginalImage] as? UIImage {
+ public func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
+ if let pickedImage = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
if let _ = delegate {
self.selectedImage = pickedImage
delegate.imagePicker(self, selectedImage: pickedImage)
diff --git a/iOSFormUtils/TextInput.swift b/Sources/iOSFormUtils/TextInput.swift
similarity index 98%
rename from iOSFormUtils/TextInput.swift
rename to Sources/iOSFormUtils/TextInput.swift
index ab875fa..d284cf2 100644
--- a/iOSFormUtils/TextInput.swift
+++ b/Sources/iOSFormUtils/TextInput.swift
@@ -5,6 +5,7 @@
// Created by Nicolas LELOUP on 18/09/2015.
// Copyright © 2015 Nicolas LELOUP - Buzznative. All rights reserved.
//
+import UIKit
// MARK: Constants
let tfBecameFirstResponderNotifName = "textFieldBecameFirstResponder"
@@ -105,7 +106,7 @@ extension TextInput: UITextFieldDelegate {
public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
if let _ = limit, "" != string {
- return textField.text!.characters.count < limit
+ return textField.text!.count < limit
}
return true
diff --git a/iOSFormUtils/ValidatedForm.swift b/Sources/iOSFormUtils/ValidatedForm.swift
similarity index 100%
rename from iOSFormUtils/ValidatedForm.swift
rename to Sources/iOSFormUtils/ValidatedForm.swift
diff --git a/iOSFormUtils/ValidatedTextInput.swift b/Sources/iOSFormUtils/ValidatedTextInput.swift
similarity index 98%
rename from iOSFormUtils/ValidatedTextInput.swift
rename to Sources/iOSFormUtils/ValidatedTextInput.swift
index 11313e4..42278e8 100644
--- a/iOSFormUtils/ValidatedTextInput.swift
+++ b/Sources/iOSFormUtils/ValidatedTextInput.swift
@@ -67,7 +67,7 @@ extension TextInput: ValidatedTextInput {
if let _ = validationDataSource {
switch validationDataSource.validationTypeForInput(self) {
case .NotBlank :
- if (0 < self.text!.characters.count) {
+ if (0 < self.text!.count) {
return true
}
case .Email :
diff --git a/Sources/iOSFormUtils/Vendored/SBPickerSwiftSelector.swift b/Sources/iOSFormUtils/Vendored/SBPickerSwiftSelector.swift
new file mode 100644
index 0000000..19a4ad1
--- /dev/null
+++ b/Sources/iOSFormUtils/Vendored/SBPickerSwiftSelector.swift
@@ -0,0 +1,353 @@
+// https://raw.githubusercontent.com/Busta117/SBPickerSelector/master/SBPickerSwiftSelector/Source/SBPickerSwiftSelector.swift
+// SBPickerSwiftSelector.swift
+// SBPickerSwiftSelectorExample
+//
+// Created by Santiago Bustamante on 1/25/19.
+// Copyright © 2019 Busta. All rights reserved.
+//
+
+import UIKit
+
+public class SBPickerSwiftSelector: UIViewController {
+
+
+ public enum Mode {
+ case text, dateDefault, dateHour, dateDayMonthYear, dateMonthYear
+ }
+
+ @IBOutlet fileprivate weak var stackView: UIStackView!
+ @IBOutlet fileprivate weak var toolBar: UIToolbar!
+ @IBOutlet public var datePickerView: UIDatePicker!
+ @IBOutlet public var pickerView: UIPickerView!
+ @IBOutlet weak var doneButton: UIBarButtonItem!
+ @IBOutlet weak var cancelButton: UIBarButtonItem!
+
+ var pickerMode: Mode = .text
+ var numberOfComponents = 1
+ var data = [Any]()
+
+ fileprivate var setAction: ((_ values: [Any])->())?
+ fileprivate var cancelAction: (()->())?
+
+ fileprivate var monthList = [String]()
+ fileprivate var yearList = [String]()
+ fileprivate var startDate: Date?
+ fileprivate var endDate: Date?
+ fileprivate var defaultDate: Date?
+
+ override public func viewDidLoad() {
+ super.viewDidLoad()
+
+ let formatter = DateFormatter()
+ monthList = formatter.monthSymbols
+ //repeat the list
+ monthList.append(contentsOf: formatter.monthSymbols)
+ monthList.append(contentsOf: formatter.monthSymbols)
+ monthList.append(contentsOf: formatter.monthSymbols)
+ monthList.append(contentsOf: formatter.monthSymbols)
+
+
+ //create year list
+ var minYear = 1920
+ var maxYear = 2050
+
+ let calendar = Calendar.current
+ if let startDate = startDate {
+ minYear = calendar.component(.year, from: startDate)
+ datePickerView.minimumDate = startDate
+ }
+ if let endDate = endDate {
+ maxYear = calendar.component(.year, from: endDate)
+ datePickerView.maximumDate = endDate
+ }
+ if let defaultDate = defaultDate {
+ datePickerView.setDate(defaultDate, animated: false)
+ }
+
+ let yearArr = Array(minYear ... maxYear).map({"\($0)"})
+ yearList.append(contentsOf: yearArr)
+ yearList.append(contentsOf: yearArr)
+ yearList.append(contentsOf: yearArr)
+ yearList.append(contentsOf: yearArr)
+ yearList.append(contentsOf: yearArr)
+
+ pickerView.delegate = self
+ pickerView.dataSource = self
+
+ view.backgroundColor = UIColor.black.withAlphaComponent(0.5)
+ pickerView.backgroundColor = UIColor.white
+ datePickerView.backgroundColor = UIColor.white
+ setupPicker()
+
+ cancelButton.title = NSLocalizedString("Cancel", comment: "")
+ doneButton.title = NSLocalizedString("Set", comment: "")
+ }
+
+ func setupPicker() {
+ switch pickerMode {
+ case .text:
+ datePickerView.isHidden = true
+ pickerView.isHidden = false
+ case .dateDefault:
+ datePickerView.isHidden = false
+ pickerView.isHidden = true
+ datePickerView.datePickerMode = UIDatePicker.Mode.dateAndTime
+ case .dateHour:
+ datePickerView.isHidden = false
+ pickerView.isHidden = true
+ datePickerView.datePickerMode = UIDatePicker.Mode.time
+ case .dateDayMonthYear:
+ datePickerView.isHidden = false
+ pickerView.isHidden = true
+ datePickerView.datePickerMode = UIDatePicker.Mode.date
+ case .dateMonthYear:
+ datePickerView.isHidden = true
+ pickerView.isHidden = false
+ numberOfComponents = 2
+ setDefaultDateToMonthAndYearPicker()
+ }
+
+ }
+
+ func setDefaultDateToMonthAndYearPicker() {
+ var date = Date()
+
+ if let defaultDate = defaultDate {
+ date = defaultDate
+ }
+
+ let calendar = Calendar.current
+ let formatter = DateFormatter()
+ let months = formatter.monthSymbols!
+ let monthDefault = calendar.component(.month, from: date)
+ let yearDefault = calendar.component(.year, from: date)
+ let month = months[monthDefault-1]
+
+ let monthIndex = monthList.firstIndex(of: month)! + (months.count*2)
+ pickerView.selectRow(monthIndex, inComponent: 0, animated: false)
+
+ if yearDefault >= Int(yearList.first!)! && yearDefault <= Int(yearList.last!)! {
+ let yearIndex = yearList.firstIndex(of: "\(yearDefault)")! + (yearList.count/5*2)
+ pickerView.selectRow(yearIndex, inComponent: 1, animated: false)
+ }
+
+ }
+
+ @IBAction fileprivate func doneAction(_ sender: Any) {
+ switch pickerMode {
+ case .text:
+ var values = [String]()
+ if numberOfComponents > 1 {
+ for index in 0 ..< numberOfComponents {
+ let row = pickerView.selectedRow(inComponent: index)
+ let arrayComp = data[index] as! [String]
+ values.append(arrayComp[row])
+ }
+ } else {
+ let row = pickerView.selectedRow(inComponent: 0)
+ values.append(data[row] as! String)
+ }
+ setAction?(values)
+
+ case .dateDefault, .dateDayMonthYear, .dateHour:
+ setAction?([datePickerView.date])
+
+ case .dateMonthYear:
+ let monthSelectedIndex = pickerView.selectedRow(inComponent: 0)
+ let monthSelected = monthList[monthSelectedIndex]
+ let yearSelectedIndex = pickerView.selectedRow(inComponent: 1)
+ let yearSelected = yearList[yearSelectedIndex]
+
+ let dateFormatter = DateFormatter()
+ dateFormatter.dateFormat = "yyyy-MM"
+ let date = dateFormatter.date(from: "\(yearSelected)-\(monthSelected)")!
+ setAction?([date])
+ }
+
+
+
+ dismiss(animated: true, completion: nil)
+ }
+
+ @IBAction fileprivate func cancelAction(_ sender: Any) {
+ dismiss(animated: true, completion: nil)
+ }
+
+ public func set(_ action: @escaping (_ values: [Any])->()) -> SBPickerSwiftSelector {
+ setAction = action
+ return self
+ }
+
+ public func cancel(_ action: @escaping ()->()) -> SBPickerSwiftSelector {
+ cancelAction = action
+ return self
+ }
+
+
+}
+
+extension SBPickerSwiftSelector: UIPickerViewDataSource, UIPickerViewDelegate {
+
+ public func numberOfComponents(in pickerView: UIPickerView) -> Int {
+ return numberOfComponents
+ }
+
+ public func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
+ if pickerMode == .dateMonthYear {
+ if component == 0 {
+ return monthList.count
+ } else {
+ return yearList.count
+ }
+ }
+
+ if numberOfComponents == 1 {
+ return data.count
+ } else if let arrayComponent = data[component] as? [String] {
+ return arrayComponent.count
+ } else {
+ fatalError("data array is not suitable with the number of components set or the type is not string")
+ }
+
+ }
+
+ public func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
+
+ if pickerMode == .dateMonthYear {
+ if component == 0 {
+ return monthList[row]
+ } else {
+ return yearList[row]
+ }
+ }
+
+ if numberOfComponents == 1 {
+ if let value = data[row] as? String {
+ return value
+ } else {
+ fatalError("value must be string")
+ }
+ } else if let arrayComponent = data[component] as? [String] {
+ return arrayComponent[row]
+ } else {
+ fatalError("data array is not suitable with the number of components set or the type is not string")
+ }
+ }
+
+}
+
+extension SBPickerSwiftSelector {
+
+ public convenience init(mode: Mode, data: [Any]? = nil, startDate: Date? = nil, endDate: Date? = nil, defaultDate: Date? = nil) {
+ self.init(nibName: "SBPickerSwiftSelector", bundle: Bundle(for: SBPickerSwiftSelector.self))
+
+ self.modalPresentationStyle = .overCurrentContext
+ self.pickerMode = mode
+
+ if let data = data {
+ self.data = data
+ if data is [String] {
+ self.numberOfComponents = 1
+ } else {
+ self.numberOfComponents = data.count
+ }
+ }
+
+ self.startDate = startDate
+ self.endDate = endDate
+ self.defaultDate = defaultDate
+ }
+
+ public func present(into viewController: UIViewController) {
+ self.transitioningDelegate = self
+ viewController.present(self, animated: true, completion: nil)
+ }
+
+ public func present(intoRootViewControllerFrom viewController: UIViewController) {
+ self.transitioningDelegate = self
+ parentVC(viewController).present(self, animated: true, completion: nil)
+ }
+
+ // get the most parent view controller to prenset the picker
+ private func parentVC(_ viewController: UIViewController) -> UIViewController {
+ if let parent = viewController.parent {
+ return parentVC(parent)
+ } else {
+ return viewController
+ }
+ }
+
+}
+
+
+let inTransition = InAnimator()
+let outTransition = OutAnimator()
+extension SBPickerSwiftSelector: UIViewControllerTransitioningDelegate {
+
+ public func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
+ return inTransition
+ }
+
+ public func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
+ return outTransition
+ }
+
+}
+
+
+class InAnimator: NSObject, UIViewControllerAnimatedTransitioning {
+ func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
+ return 0.3
+ }
+
+ func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
+
+ let containerView = transitionContext.containerView
+
+ let toView = transitionContext.viewController(forKey: .to)! as! SBPickerSwiftSelector
+ let fromView = transitionContext.viewController(forKey: .from)!
+
+ toView.view.frame = fromView.view.frame
+ containerView.addSubview(toView.view)
+ containerView.bringSubviewToFront(toView.view)
+
+ toView.view.backgroundColor = UIColor.black.withAlphaComponent(0)
+
+ let endFrame = toView.stackView.frame
+ var originFrame = toView.stackView.frame
+ originFrame.origin.y = toView.view.frame.height
+ toView.stackView.frame = originFrame
+
+ UIView.animate(withDuration: 0.3, delay:0.0, animations: {
+ toView.view.backgroundColor = UIColor.black.withAlphaComponent(0.5)
+ toView.stackView.frame = endFrame
+ },completion: { _ in
+ transitionContext.completeTransition(true)
+ })
+ }
+}
+
+class OutAnimator: NSObject, UIViewControllerAnimatedTransitioning {
+ func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
+ return 0.3
+ }
+
+ func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
+
+ let containerView = transitionContext.containerView
+
+ let toView = transitionContext.viewController(forKey: .to)!
+ let fromView = transitionContext.viewController(forKey: .from)! as! SBPickerSwiftSelector
+
+ containerView.addSubview(fromView.view)
+
+ var endFrame = fromView.stackView.frame
+ endFrame.origin.y = toView.view.frame.height
+ UIView.animate(withDuration: 0.3, delay:0.0, animations: {
+ fromView.view.backgroundColor = UIColor.black.withAlphaComponent(0)
+ fromView.stackView.frame = endFrame
+ },completion: { _ in
+ transitionContext.completeTransition(true)
+ })
+ }
+}
diff --git a/Sources/iOSFormUtils/Vendored/SBPickerSwiftSelector.xib b/Sources/iOSFormUtils/Vendored/SBPickerSwiftSelector.xib
new file mode 100644
index 0000000..69075c4
--- /dev/null
+++ b/Sources/iOSFormUtils/Vendored/SBPickerSwiftSelector.xib
@@ -0,0 +1,70 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/iOSFormUtils.podspec b/iOSFormUtils.podspec
index 4100b00..ff04e1c 100644
--- a/iOSFormUtils.podspec
+++ b/iOSFormUtils.podspec
@@ -8,7 +8,7 @@
Pod::Spec.new do |s|
s.name = "iOSFormUtils"
- s.version = "0.4.3"
+ s.version = "0.5.0"
s.summary = "iOSFormUtils helps you developping validated forms in iOS apps."
# This description is used to generate tags and improve search results.
@@ -31,6 +31,6 @@ iOSFormUtils helps you developping validated forms in iOS apps. You could use it
s.source_files = 'iOSFormUtils'
- s.dependency 'SBPickerSelector', '~> 1.1.0'
- s.dependency 'UIKitExtensions', '~> 0.2.5'
+ s.dependency 'SBPickerSelector', '~> 2.0.6'
+ s.dependency 'UIKitExtensions', '~> 0.3.0'
end
diff --git a/iOSFormUtils.xcodeproj/project.pbxproj b/iOSFormUtils.xcodeproj/project.pbxproj
index d177f8d..63be03d 100644
--- a/iOSFormUtils.xcodeproj/project.pbxproj
+++ b/iOSFormUtils.xcodeproj/project.pbxproj
@@ -7,17 +7,17 @@
objects = {
/* Begin PBXFileReference section */
- C8CF38E81DC9DC20002D11DF /* Form.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Form.swift; path = iOSFormUtils/Form.swift; sourceTree = ""; };
+ 7B6A47F1256271090025B242 /* iOSFormUtils */ = {isa = PBXFileReference; lastKnownFileType = folder; name = iOSFormUtils; path = iOSFormUtils/iOSFormUtils; sourceTree = ""; };
C8CF38E91DC9DC20002D11DF /* FormInput.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = FormInput.swift; path = iOSFormUtils/FormInput.swift; sourceTree = ""; };
C8CF38EA1DC9DC20002D11DF /* ValidatedFormInput.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ValidatedFormInput.swift; path = iOSFormUtils/ValidatedFormInput.swift; sourceTree = ""; };
C8CF38EB1DC9DC94002D11DF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
- C8F50C0F1CEF0A26006D8C51 /* ValidatedForm.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ValidatedForm.swift; path = iOSFormUtils/ValidatedForm.swift; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXGroup section */
C8714A461CECC5360006E038 = {
isa = PBXGroup;
children = (
+ 7B6A47F1256271090025B242 /* iOSFormUtils */,
C8C6A7FB1CEDBDED00B9B9D8 /* iOSFormUtils */,
);
sourceTree = "";
@@ -26,10 +26,8 @@
isa = PBXGroup;
children = (
C8CF38EB1DC9DC94002D11DF /* Info.plist */,
- C8CF38E81DC9DC20002D11DF /* Form.swift */,
C8CF38E91DC9DC20002D11DF /* FormInput.swift */,
C8CF38EA1DC9DC20002D11DF /* ValidatedFormInput.swift */,
- C8F50C0F1CEF0A26006D8C51 /* ValidatedForm.swift */,
);
name = iOSFormUtils;
sourceTree = "";
@@ -47,6 +45,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
+ English,
en,
);
mainGroup = C8714A461CECC5360006E038;
diff --git a/iOSFormUtils.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/iOSFormUtils.xcodeproj/project.xcworkspace/contents.xcworkspacedata
index 8807f98..919434a 100644
--- a/iOSFormUtils.xcodeproj/project.xcworkspace/contents.xcworkspacedata
+++ b/iOSFormUtils.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -2,6 +2,6 @@
+ location = "self:">