diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 0000000..b735373
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,35 @@
+---
+name: Bug report
+about: Create a report to help us improve
+
+---
+
+**Describe the bug**
+A clear and concise description of what the bug is.
+
+**To Reproduce**
+Steps to reproduce the behavior:
+1. Go to '...'
+2. Click on '....'
+3. Scroll down to '....'
+4. See error
+
+**Expected behavior**
+A clear and concise description of what you expected to happen.
+
+**Screenshots**
+If applicable, add screenshots to help explain your problem.
+
+**Desktop (please complete the following information):**
+ - OS: [e.g. iOS]
+ - Browser [e.g. chrome, safari]
+ - Version [e.g. 22]
+
+**Smartphone (please complete the following information):**
+ - Device: [e.g. iPhone6]
+ - OS: [e.g. iOS8.1]
+ - Browser [e.g. stock browser, safari]
+ - Version [e.g. 22]
+
+**Additional context**
+Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 0000000..066b2d9
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,17 @@
+---
+name: Feature request
+about: Suggest an idea for this project
+
+---
+
+**Is your feature request related to a problem? Please describe.**
+A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+
+**Describe the solution you'd like**
+A clear and concise description of what you want to happen.
+
+**Describe alternatives you've considered**
+A clear and concise description of any alternative solutions or features you've considered.
+
+**Additional context**
+Add any other context or screenshots about the feature request here.
diff --git a/.swift-version b/.swift-version
index 5186d07..bf77d54 100644
--- a/.swift-version
+++ b/.swift-version
@@ -1 +1 @@
-4.0
+4.2
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..465540e
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,46 @@
+# Contributor Covenant Code of Conduct
+
+## Our Pledge
+
+In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
+
+## Our Standards
+
+Examples of behavior that contributes to creating a positive environment include:
+
+* Using welcoming and inclusive language
+* Being respectful of differing viewpoints and experiences
+* Gracefully accepting constructive criticism
+* Focusing on what is best for the community
+* Showing empathy towards other community members
+
+Examples of unacceptable behavior by participants include:
+
+* The use of sexualized language or imagery and unwelcome sexual attention or advances
+* Trolling, insulting/derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or electronic address, without explicit permission
+* Other conduct which could reasonably be considered inappropriate in a professional setting
+
+## Our Responsibilities
+
+Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
+
+Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
+
+## Scope
+
+This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at dave.greco@icloud.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
+
+Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
+
+[homepage]: http://contributor-covenant.org
+[version]: http://contributor-covenant.org/version/1/4/
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..8995d08
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,6 @@
+## Contributing
+If you're interesting in helping us improve and maintain Former, it is highly encouraged that you fork the repository and submit a pull request with your updates.
+
+If you do chose to submit a pull request, please make sure to clearly document what changes you have made in the description of the PR.
+
+We will try to get this merged as soon as possible and included in an official cocoapod release as soon as it makes sense to do so.
diff --git a/Former-Demo/Former-Demo.xcodeproj/project.pbxproj b/Former-Demo/Former-Demo.xcodeproj/project.pbxproj
index 939265b..7ddfaff 100644
--- a/Former-Demo/Former-Demo.xcodeproj/project.pbxproj
+++ b/Former-Demo/Former-Demo.xcodeproj/project.pbxproj
@@ -458,7 +458,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.ryo.Former-Demo";
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 1;
};
name = Debug;
@@ -475,7 +475,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.ryo.Former-Demo";
PRODUCT_NAME = "$(TARGET_NAME)";
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = 1;
};
name = Release;
diff --git a/Former-Demo/Former-Demo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Former-Demo/Former-Demo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/Former-Demo/Former-Demo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/Former-Demo/Former-Demo/AppDelegate.swift b/Former-Demo/Former-Demo/AppDelegate.swift
index 94d0014..117213e 100644
--- a/Former-Demo/Former-Demo/AppDelegate.swift
+++ b/Former-Demo/Former-Demo/AppDelegate.swift
@@ -13,7 +13,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
- func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
+ func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
let navigationController = UINavigationController(rootViewController: TopViewContoller())
configureNavigationBar(navigationBar: navigationController.navigationBar)
@@ -25,8 +25,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
private func configureNavigationBar(navigationBar: UINavigationBar) {
navigationBar.tintColor = .white
navigationBar.titleTextAttributes = [
- NSAttributedStringKey.foregroundColor: UIColor.white,
- NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 20)
+ NSAttributedString.Key.foregroundColor: UIColor.white,
+ NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 20)
]
navigationBar.isTranslucent = false
navigationBar.shadowImage = UIImage()
diff --git a/Former-Demo/Former-Demo/Controllers/AddEventViewController.swift b/Former-Demo/Former-Demo/Controllers/AddEventViewController.swift
index 591e3ef..7388373 100644
--- a/Former-Demo/Former-Demo/Controllers/AddEventViewController.swift
+++ b/Former-Demo/Former-Demo/Controllers/AddEventViewController.swift
@@ -84,7 +84,7 @@ final class AddEventViewController: FormViewController {
$0.datePicker.datePickerMode = .dateAndTime
}.displayTextFromDate(String.mediumDateShortTime)
let endRow = InlineDatePickerRowFormer() {
- $0.titleLabel.text = "Start"
+ $0.titleLabel.text = "End"
$0.titleLabel.textColor = .formerColor()
$0.titleLabel.font = .boldSystemFont(ofSize: 15)
$0.displayLabel.textColor = .formerSubColor()
@@ -125,7 +125,7 @@ final class AddEventViewController: FormViewController {
let never = Repeat.Never
$0.pickerItems.append(
InlinePickerItem(title: never.title(),
- displayTitle: NSAttributedString(string: never.title(), attributes: [NSAttributedStringKey.foregroundColor: UIColor.lightGray]),
+ displayTitle: NSAttributedString(string: never.title(), attributes: [NSAttributedString.Key.foregroundColor: UIColor.lightGray]),
value: never)
)
$0.pickerItems += Repeat.values().map {
@@ -142,7 +142,7 @@ final class AddEventViewController: FormViewController {
let none = Alert.None
$0.pickerItems.append(
InlinePickerItem(title: none.title(),
- displayTitle: NSAttributedString(string: none.title(), attributes: [NSAttributedStringKey.foregroundColor: UIColor.lightGray]),
+ displayTitle: NSAttributedString(string: none.title(), attributes: [NSAttributedString.Key.foregroundColor: UIColor.lightGray]),
value: none)
)
$0.pickerItems += Alert.values().map {
diff --git a/Former-Demo/Former-Demo/Controllers/CustomCellViewController.swift b/Former-Demo/Former-Demo/Controllers/CustomCellViewController.swift
index 6221f29..80c8fb2 100644
--- a/Former-Demo/Former-Demo/Controllers/CustomCellViewController.swift
+++ b/Former-Demo/Former-Demo/Controllers/CustomCellViewController.swift
@@ -43,7 +43,7 @@ final class CustomCellViewController: FormViewController {
$0.body = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
$0.bodyColor = colors[0]
}.configure {
- $0.rowHeight = UITableViewAutomaticDimension
+ $0.rowHeight = UITableView.automaticDimension
}
let colorListRow = CustomRowFormer(instantiateType: .Nib(nibName: "ColorListCell")) {
diff --git a/Former-Demo/Former-Demo/Controllers/DefaultsViewController.swift b/Former-Demo/Former-Demo/Controllers/DefaultsViewController.swift
index cc97d4b..b9e26cd 100644
--- a/Former-Demo/Former-Demo/Controllers/DefaultsViewController.swift
+++ b/Former-Demo/Former-Demo/Controllers/DefaultsViewController.swift
@@ -71,7 +71,7 @@ final class DefaultsViewController: FormViewController {
$0.titleLabel.text = "Segmented"
}.configure {
$0.segmentTitles = ["Opt1", "Opt2", "Opt3"]
- $0.selectedIndex = UISegmentedControlNoSegment
+ $0.selectedIndex = UISegmentedControl.noSegment
}
let sliderRow = SliderRowFormer(){
diff --git a/Former-Demo/Former-Demo/Controllers/ExampleViewController.swift b/Former-Demo/Former-Demo/Controllers/ExampleViewController.swift
index c449ab9..5b841b9 100644
--- a/Former-Demo/Former-Demo/Controllers/ExampleViewController.swift
+++ b/Former-Demo/Former-Demo/Controllers/ExampleViewController.swift
@@ -9,13 +9,13 @@
import UIKit
import Former
-private extension UITableViewRowAnimation {
+private extension UITableView.RowAnimation {
static func names() -> [String] {
return ["None", "Fade", "Right", "Left", "Top", "Bottom", "Middle", "Automatic"]
}
- static func all() -> [UITableViewRowAnimation] {
+ static func all() -> [UITableView.RowAnimation] {
return [.none, .fade, .right, .left, .top, .bottom, .middle, .automatic]
}
}
@@ -96,17 +96,17 @@ final class ExampleViewController: FormViewController {
self?.insertRowPosition = InsertPosition(rawValue: index)!
}
- let insertRowAnimationRow = InlinePickerRowFormer(instantiateType: .Class) {
+ let insertRowAnimationRow = InlinePickerRowFormer(instantiateType: .Class) {
$0.titleLabel.text = "Animation"
$0.titleLabel.textColor = .formerColor()
$0.titleLabel.font = .boldSystemFont(ofSize: 16)
$0.displayLabel.textColor = .formerSubColor()
$0.displayLabel.font = .boldSystemFont(ofSize: 14)
}.configure {
- $0.pickerItems = UITableViewRowAnimation.names().enumerated().map {
- InlinePickerItem(title: $0.element, value: UITableViewRowAnimation.all()[$0.offset])
+ $0.pickerItems = UITableView.RowAnimation.names().enumerated().map {
+ InlinePickerItem(title: $0.element, value: UITableView.RowAnimation.all()[$0.offset])
}
- $0.selectedRow = UITableViewRowAnimation.all().index(of: insertRowAnimation) ?? 0
+ $0.selectedRow = UITableView.RowAnimation.all().index(of: insertRowAnimation) ?? 0
$0.displayEditingColor = .formerHighlightedSubColor()
}.onValueChanged { [weak self] in
self?.insertRowAnimation = $0.value!
@@ -137,17 +137,17 @@ final class ExampleViewController: FormViewController {
self?.insertSectionPosition = InsertPosition(rawValue: index)!
}
- let insertSectionAnimationRow = InlinePickerRowFormer(instantiateType: .Class) {
+ let insertSectionAnimationRow = InlinePickerRowFormer(instantiateType: .Class) {
$0.titleLabel.text = "Animation"
$0.titleLabel.textColor = .formerColor()
$0.titleLabel.font = .boldSystemFont(ofSize: 16)
$0.displayLabel.textColor = .formerSubColor()
$0.displayLabel.font = .boldSystemFont(ofSize: 14)
}.configure {
- $0.pickerItems = UITableViewRowAnimation.names().enumerated().map {
- InlinePickerItem(title: $0.element, value: UITableViewRowAnimation.all()[$0.offset])
+ $0.pickerItems = UITableView.RowAnimation.names().enumerated().map {
+ InlinePickerItem(title: $0.element, value: UITableView.RowAnimation.all()[$0.offset])
}
- $0.selectedRow = UITableViewRowAnimation.all().index(of: insertSectionAnimation) ?? 0
+ $0.selectedRow = UITableView.RowAnimation.all().index(of: insertSectionAnimation) ?? 0
$0.displayEditingColor = .formerHighlightedSubColor()
}.onValueChanged { [weak self] in
self?.insertSectionAnimation = $0.value!
@@ -263,8 +263,8 @@ final class ExampleViewController: FormViewController {
case Below, Above
}
- private var insertRowAnimation = UITableViewRowAnimation.left
- private var insertSectionAnimation = UITableViewRowAnimation.fade
+ private var insertRowAnimation = UITableView.RowAnimation.left
+ private var insertSectionAnimation = UITableView.RowAnimation.fade
private var insertRowPosition: InsertPosition = .Below
private var insertSectionPosition: InsertPosition = .Below
diff --git a/Former-Demo/Former-Demo/Views/FormerInputAccessoryView.swift b/Former-Demo/Former-Demo/Views/FormerInputAccessoryView.swift
index e996b2a..be0f25d 100644
--- a/Former-Demo/Former-Demo/Views/FormerInputAccessoryView.swift
+++ b/Former-Demo/Former-Demo/Views/FormerInputAccessoryView.swift
@@ -37,10 +37,10 @@ final class FormerInputAccessoryView: UIToolbar {
isUserInteractionEnabled = true
let flexible = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
- let leftArrow = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem(rawValue: 105)!, target: self, action: #selector(FormerInputAccessoryView.handleBackButton))
+ let leftArrow = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem(rawValue: 105)!, target: self, action: #selector(FormerInputAccessoryView.handleBackButton))
let space = UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil)
space.width = 20
- let rightArrow = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem(rawValue: 106)!, target: self, action: #selector(FormerInputAccessoryView.handleForwardButton))
+ let rightArrow = UIBarButtonItem(barButtonSystemItem: UIBarButtonItem.SystemItem(rawValue: 106)!, target: self, action: #selector(FormerInputAccessoryView.handleForwardButton))
let doneButton = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(FormerInputAccessoryView.handleDoneButton))
let rightSpace = UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil)
setItems([leftArrow, space, rightArrow, flexible, doneButton, rightSpace], animated: false)
diff --git a/Former.podspec b/Former.podspec
index 28144b0..1ad3557 100644
--- a/Former.podspec
+++ b/Former.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = "Former"
- spec.version = "1.6.1"
+ spec.version = "1.7.0"
spec.author = { "ra1028" => "r.fe51028.r@gmail.com" }
spec.homepage = "https://github.com/ra1028"
spec.summary = "Former is a fully customizable Swift library for easy creating UITableView based form."
diff --git a/Former.xcodeproj/project.pbxproj b/Former.xcodeproj/project.pbxproj
index e5c3f74..d00ad5d 100644
--- a/Former.xcodeproj/project.pbxproj
+++ b/Former.xcodeproj/project.pbxproj
@@ -475,7 +475,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.ryo.Former;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 4.2;
};
name = Debug;
};
@@ -494,7 +494,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.ryo.Former;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
- SWIFT_VERSION = 4.0;
+ SWIFT_VERSION = 4.2;
};
name = Release;
};
diff --git a/Former/Cells/FormCell.swift b/Former/Cells/FormCell.swift
index 447c4a4..019de2e 100644
--- a/Former/Cells/FormCell.swift
+++ b/Former/Cells/FormCell.swift
@@ -17,7 +17,7 @@ open class FormCell: UITableViewCell, FormableRow {
setup()
}
- override public init(style: UITableViewCellStyle, reuseIdentifier: String?) {
+ override public init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setup()
}
diff --git a/Former/Cells/FormTextFieldCell.swift b/Former/Cells/FormTextFieldCell.swift
index 7797052..c9b2ac8 100644
--- a/Former/Cells/FormTextFieldCell.swift
+++ b/Former/Cells/FormTextFieldCell.swift
@@ -34,7 +34,7 @@ open class FormTextFieldCell: FormCell, TextFieldFormableRow {
super.setup()
let titleLabel = UILabel()
- titleLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 500), for: UILayoutConstraintAxis.horizontal)
+ titleLabel.setContentHuggingPriority(UILayoutPriority(rawValue: 500), for: NSLayoutConstraint.Axis.horizontal)
titleLabel.setContentCompressionResistancePriority(UILayoutPriority(rawValue: 1000), for: .horizontal)
titleLabel.translatesAutoresizingMaskIntoConstraints = false
contentView.insertSubview(titleLabel, at: 0)
diff --git a/Former/Commons/Former.swift b/Former/Commons/Former.swift
index 8321edc..aee842e 100644
--- a/Former/Commons/Former.swift
+++ b/Former/Commons/Former.swift
@@ -10,6 +10,11 @@ import UIKit
public final class Former: NSObject {
+ #if !swift(>=4.2)
+ public typealias Range = CountableRange
+ public typealias ClosedRange = CountableClosedRange
+ #endif
+
// MARK: Public
/**
@@ -86,14 +91,6 @@ public final class Former: NSObject {
return Array(sectionFormers[range])
}
- public subscript(range: CountableRange) -> [SectionFormer] {
- return Array(sectionFormers[range])
- }
-
- public subscript(range: CountableClosedRange) -> [SectionFormer] {
- return Array(sectionFormers[range])
- }
-
/// To find RowFormer from indexPath.
public func rowFormer(indexPath: IndexPath) -> RowFormer {
return self[indexPath.section][indexPath.row]
@@ -289,7 +286,7 @@ public final class Former: NSObject {
/// To select row from indexPath.
@discardableResult
- public func select(indexPath: IndexPath, animated: Bool, scrollPosition: UITableViewScrollPosition = .none) -> Self {
+ public func select(indexPath: IndexPath, animated: Bool, scrollPosition: UITableView.ScrollPosition = .none) -> Self {
if let tableView = tableView {
tableView.selectRow(at: indexPath, animated: animated, scrollPosition: scrollPosition)
_ = self.tableView(tableView, willSelectRowAt: indexPath)
@@ -300,7 +297,7 @@ public final class Former: NSObject {
/// To select row from instance of RowFormer.
@discardableResult
- public func select(rowFormer: RowFormer, animated: Bool, scrollPosition: UITableViewScrollPosition = .none) -> Self {
+ public func select(rowFormer: RowFormer, animated: Bool, scrollPosition:UITableView.ScrollPosition = .none) -> Self {
for (section, sectionFormer) in sectionFormers.enumerated() {
if let row = sectionFormer.rowFormers.index(where: { $0 === rowFormer }) {
return select(indexPath: IndexPath(row: row, section: section), animated: animated, scrollPosition: scrollPosition)
@@ -328,28 +325,28 @@ public final class Former: NSObject {
/// Reload sections from section indexSet.
@discardableResult
- public func reload(sections: IndexSet, rowAnimation: UITableViewRowAnimation = .none) -> Self {
+ public func reload(sections: IndexSet, rowAnimation: UITableView.RowAnimation = .none) -> Self {
tableView?.reloadSections(sections, with: rowAnimation)
return self
}
/// Reload sections from instance of SectionFormer.
@discardableResult
- public func reload(sectionFormer: SectionFormer, rowAnimation: UITableViewRowAnimation = .none) -> Self {
+ public func reload(sectionFormer: SectionFormer, rowAnimation: UITableView.RowAnimation = .none) -> Self {
guard let section = sectionFormers.index(where: { $0 === sectionFormer }) else { return self }
return reload(sections: IndexSet(integer: section), rowAnimation: rowAnimation)
}
/// Reload rows from indesPaths.
@discardableResult
- public func reload(indexPaths: [IndexPath], rowAnimation: UITableViewRowAnimation = .none) -> Self {
+ public func reload(indexPaths: [IndexPath], rowAnimation: UITableView.RowAnimation = .none) -> Self {
tableView?.reloadRows(at: indexPaths, with: rowAnimation)
return self
}
/// Reload rows from instance of RowFormer.
@discardableResult
- public func reload(rowFormer: RowFormer, rowAnimation: UITableViewRowAnimation = .none) -> Self {
+ public func reload(rowFormer: RowFormer, rowAnimation: UITableView.RowAnimation = .none) -> Self {
for (section, sectionFormer) in sectionFormers.enumerated() {
if let row = sectionFormer.rowFormers.index(where: { $0 === rowFormer}) {
return reload(indexPaths: [IndexPath(row: row, section: section)], rowAnimation: rowAnimation)
@@ -434,13 +431,13 @@ public final class Former: NSObject {
/// Insert SectionFormer to index of section with animated updates.
@discardableResult
- public func insertUpdate(sectionFormer: SectionFormer..., toSection: Int, rowAnimation: UITableViewRowAnimation = .none) -> Self {
+ public func insertUpdate(sectionFormer: SectionFormer..., toSection: Int, rowAnimation: UITableView.RowAnimation = .none) -> Self {
return insertUpdate(sectionFormers: sectionFormer, toSection: toSection, rowAnimation: rowAnimation)
}
/// Insert SectionFormers to index of section with animated updates.
@discardableResult
- public func insertUpdate(sectionFormers: [SectionFormer], toSection: Int, rowAnimation: UITableViewRowAnimation = .none) -> Self {
+ public func insertUpdate(sectionFormers: [SectionFormer], toSection: Int, rowAnimation: UITableView.RowAnimation = .none) -> Self {
guard !sectionFormers.isEmpty else { return self }
removeCurrentInlineRowUpdate()
tableView?.beginUpdates()
@@ -452,13 +449,13 @@ public final class Former: NSObject {
/// Insert SectionFormer to above other SectionFormer with animated updates.
@discardableResult
- public func insertUpdate(sectionFormer: SectionFormer..., above: SectionFormer, rowAnimation: UITableViewRowAnimation = .none) -> Self {
+ public func insertUpdate(sectionFormer: SectionFormer..., above: SectionFormer, rowAnimation: UITableView.RowAnimation = .none) -> Self {
return insertUpdate(sectionFormers: sectionFormer, above: above, rowAnimation: rowAnimation)
}
/// Insert SectionFormers to above other SectionFormer with animated updates.
@discardableResult
- public func insertUpdate(sectionFormers: [SectionFormer], above: SectionFormer, rowAnimation: UITableViewRowAnimation = .none) -> Self {
+ public func insertUpdate(sectionFormers: [SectionFormer], above: SectionFormer, rowAnimation: UITableView.RowAnimation = .none) -> Self {
removeCurrentInlineRowUpdate()
for (section, sectionFormer) in self.sectionFormers.enumerated() {
if sectionFormer === above {
@@ -475,13 +472,13 @@ public final class Former: NSObject {
/// Insert SectionFormer to below other SectionFormer with animated updates.
@discardableResult
- public func insertUpdate(sectionFormer: SectionFormer..., below: SectionFormer, rowAnimation: UITableViewRowAnimation = .none) -> Self {
+ public func insertUpdate(sectionFormer: SectionFormer..., below: SectionFormer, rowAnimation: UITableView.RowAnimation = .none) -> Self {
return insertUpdate(sectionFormers: sectionFormer, below: below, rowAnimation: rowAnimation)
}
/// Insert SectionFormers to below other SectionFormer with animated updates.
@discardableResult
- public func insertUpdate(sectionFormers: [SectionFormer], below: SectionFormer, rowAnimation: UITableViewRowAnimation = .none) -> Self {
+ public func insertUpdate(sectionFormers: [SectionFormer], below: SectionFormer, rowAnimation: UITableView.RowAnimation = .none) -> Self {
removeCurrentInlineRowUpdate()
for (section, sectionFormer) in self.sectionFormers.enumerated() {
if sectionFormer === below {
@@ -553,13 +550,13 @@ public final class Former: NSObject {
/// Insert RowFormer with animated updates.
@discardableResult
- public func insertUpdate(rowFormer: RowFormer..., toIndexPath: IndexPath, rowAnimation: UITableViewRowAnimation = .none) -> Self {
+ public func insertUpdate(rowFormer: RowFormer..., toIndexPath: IndexPath, rowAnimation: UITableView.RowAnimation = .none) -> Self {
return insertUpdate(rowFormers: rowFormer, toIndexPath: toIndexPath, rowAnimation: rowAnimation)
}
/// Insert RowFormers with animated updates.
@discardableResult
- public func insertUpdate(rowFormers: [RowFormer], toIndexPath: IndexPath, rowAnimation: UITableViewRowAnimation = .none) -> Self {
+ public func insertUpdate(rowFormers: [RowFormer], toIndexPath: IndexPath, rowAnimation: UITableView.RowAnimation = .none) -> Self {
removeCurrentInlineRowUpdate()
guard !rowFormers.isEmpty else { return self }
tableView?.beginUpdates()
@@ -574,13 +571,13 @@ public final class Former: NSObject {
/// Insert RowFormer to above other RowFormer with animated updates.
@discardableResult
- public func insertUpdate(rowFormer: RowFormer..., above: RowFormer, rowAnimation: UITableViewRowAnimation = .none) -> Self {
+ public func insertUpdate(rowFormer: RowFormer..., above: RowFormer, rowAnimation: UITableView.RowAnimation = .none) -> Self {
return insertUpdate(rowFormers: rowFormer, above: above, rowAnimation: rowAnimation)
}
/// Insert RowFormers to above other RowFormer with animated updates.
@discardableResult
- public func insertUpdate(rowFormers: [RowFormer], above: RowFormer, rowAnimation: UITableViewRowAnimation = .none) -> Self {
+ public func insertUpdate(rowFormers: [RowFormer], above: RowFormer, rowAnimation: UITableView.RowAnimation = .none) -> Self {
removeCurrentInlineRowUpdate()
for (section, sectionFormer) in self.sectionFormers.enumerated() {
for (row, rowFormer) in sectionFormer.rowFormers.enumerated() {
@@ -601,13 +598,13 @@ public final class Former: NSObject {
/// Insert RowFormer to below other RowFormer with animated updates.
@discardableResult
- public func insertUpdate(rowFormer: RowFormer..., below: RowFormer, rowAnimation: UITableViewRowAnimation = .none) -> Self {
+ public func insertUpdate(rowFormer: RowFormer..., below: RowFormer, rowAnimation: UITableView.RowAnimation = .none) -> Self {
return insertUpdate(rowFormers: rowFormer, below: below, rowAnimation: rowAnimation)
}
/// Insert RowFormers to below other RowFormer with animated updates.
@discardableResult
- public func insertUpdate(rowFormers: [RowFormer], below: RowFormer, rowAnimation: UITableViewRowAnimation = .none) -> Self {
+ public func insertUpdate(rowFormers: [RowFormer], below: RowFormer, rowAnimation: UITableView.RowAnimation = .none) -> Self {
removeCurrentInlineRowUpdate()
for (section, sectionFormer) in self.sectionFormers.enumerated() {
for (row, rowFormer) in sectionFormer.rowFormers.enumerated() {
@@ -635,7 +632,7 @@ public final class Former: NSObject {
/// Remove All SectionFormers with animated updates.
@discardableResult
- public func removeAllUpdate(rowAnimation: UITableViewRowAnimation = .none) -> Self {
+ public func removeAllUpdate(rowAnimation: UITableView.RowAnimation = .none) -> Self {
let indexSet = IndexSet(integersIn: 0.. 0 else { return self }
@@ -667,13 +664,13 @@ public final class Former: NSObject {
/// Remove SectionFormers from instances of SectionFormer with animated updates.
@discardableResult
- public func removeUpdate(sectionFormer: SectionFormer..., rowAnimation: UITableViewRowAnimation = .none) -> Self {
+ public func removeUpdate(sectionFormer: SectionFormer..., rowAnimation: UITableView.RowAnimation = .none) -> Self {
return removeUpdate(sectionFormers: sectionFormer, rowAnimation: rowAnimation)
}
/// Remove SectionFormers from instances of SectionFormer with animated updates.
@discardableResult
- public func removeUpdate(sectionFormers: [SectionFormer], rowAnimation: UITableViewRowAnimation = .none) -> Self {
+ public func removeUpdate(sectionFormers: [SectionFormer], rowAnimation: UITableView.RowAnimation = .none) -> Self {
guard !sectionFormers.isEmpty else { return self }
let indexSet = removeSectionFormers(sectionFormers)
guard indexSet.count > 0 else { return self }
@@ -698,13 +695,13 @@ public final class Former: NSObject {
/// Remove RowFormers with animated updates.
@discardableResult
- public func removeUpdate(rowFormer: RowFormer..., rowAnimation: UITableViewRowAnimation = .none) -> Self {
+ public func removeUpdate(rowFormer: RowFormer..., rowAnimation: UITableView.RowAnimation = .none) -> Self {
return removeUpdate(rowFormers: rowFormer, rowAnimation: rowAnimation)
}
/// Remove RowFormers with animated updates.
@discardableResult
- public func removeUpdate(rowFormers: [RowFormer], rowAnimation: UITableViewRowAnimation = .none) -> Self {
+ public func removeUpdate(rowFormers: [RowFormer], rowAnimation: UITableView.RowAnimation = .none) -> Self {
removeCurrentInlineRowUpdate()
guard !rowFormers.isEmpty else { return self }
tableView?.beginUpdates()
@@ -739,8 +736,9 @@ public final class Former: NSObject {
private func setupTableView() {
tableView?.delegate = self
tableView?.dataSource = self
- NotificationCenter.default.addObserver(self, selector: #selector(Former.keyboardWillAppear(notification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
- NotificationCenter.default.addObserver(self, selector: #selector(Former.keyboardWillDisappear(notification:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
+
+ NotificationCenter.default.addObserver(self, selector: #selector(Former.keyboardWillAppear(notification:)), name: UIResponder.keyboardWillShowNotification, object: nil)
+ NotificationCenter.default.addObserver(self, selector: #selector(Former.keyboardWillDisappear(notification:)), name: UIResponder.keyboardWillHideNotification, object: nil)
}
fileprivate func removeCurrentInlineRow() -> IndexPath? {
@@ -829,7 +827,7 @@ public final class Former: NSObject {
if case let (tableView?, cell?) = (tableView, findCellWithSubView(findFirstResponder(tableView))) {
- let frame = (keyboardInfo[UIKeyboardFrameEndUserInfoKey]! as AnyObject).cgRectValue
+ let frame = (keyboardInfo[UIResponder.keyboardFrameEndUserInfoKey]! as AnyObject).cgRectValue
let keyboardFrame = tableView.window!.convert(frame!, to: tableView.superview!)
let bottomInset = tableView.frame.minY + tableView.frame.height - keyboardFrame.minY
guard bottomInset > 0 else { return }
@@ -837,13 +835,13 @@ public final class Former: NSObject {
if oldBottomContentInset == nil {
oldBottomContentInset = tableView.contentInset.bottom
}
- let duration = (keyboardInfo[UIKeyboardAnimationDurationUserInfoKey]! as AnyObject).doubleValue!
- let curve = (keyboardInfo[UIKeyboardAnimationCurveUserInfoKey]! as AnyObject).integerValue!
+ let duration = (keyboardInfo[UIResponder.keyboardAnimationDurationUserInfoKey]! as AnyObject).doubleValue!
+ let curve = (keyboardInfo[UIResponder.keyboardAnimationCurveUserInfoKey]! as AnyObject).integerValue!
guard let indexPath = tableView.indexPath(for: cell) else { return }
UIView.beginAnimations(nil, context: nil)
UIView.setAnimationDuration(duration)
- UIView.setAnimationCurve(UIViewAnimationCurve(rawValue: curve)!)
+ UIView.setAnimationCurve(UIView.AnimationCurve(rawValue: curve)!)
tableView.contentInset.bottom = bottomInset
tableView.scrollIndicatorInsets.bottom = bottomInset
tableView.scrollToRow(at: indexPath, at: .none, animated: false)
@@ -855,12 +853,12 @@ public final class Former: NSObject {
guard let keyboardInfo = notification.userInfo else { return }
if case let (tableView?, inset?) = (tableView, oldBottomContentInset) {
- let duration = (keyboardInfo[UIKeyboardAnimationDurationUserInfoKey]! as AnyObject).doubleValue!
- let curve = (keyboardInfo[UIKeyboardAnimationCurveUserInfoKey]! as AnyObject).integerValue!
+ let duration = (keyboardInfo[UIResponder.keyboardAnimationDurationUserInfoKey]! as AnyObject).doubleValue!
+ let curve = (keyboardInfo[UIResponder.keyboardAnimationCurveUserInfoKey]! as AnyObject).integerValue!
UIView.beginAnimations(nil, context: nil)
UIView.setAnimationDuration(duration)
- UIView.setAnimationCurve(UIViewAnimationCurve(rawValue: curve)!)
+ UIView.setAnimationCurve(UIView.AnimationCurve(rawValue: curve)!)
tableView.contentInset.bottom = inset
tableView.scrollIndicatorInsets.bottom = inset
UIView.commitAnimations()
diff --git a/Former/RowFormers/InlinePickerRowFormer.swift b/Former/RowFormers/InlinePickerRowFormer.swift
index a913246..5ed89b3 100644
--- a/Former/RowFormers/InlinePickerRowFormer.swift
+++ b/Former/RowFormers/InlinePickerRowFormer.swift
@@ -73,10 +73,12 @@ open class InlinePickerRowFormer
if pickerItems.isEmpty {
displayLabel?.text = ""
} else {
-
-// Sets selected row to 0 to avoid 'index out of range' error. This is in case the updated picker items array count
-// is less than the prior array count.
- selectedRow = 0
+
+ // Sets selected row to 0 to avoid 'index out of range' error. This is in case the updated picker items array count
+ // is less than the prior array count.
+ if pickerItems.count <= selectedRow {
+ selectedRow = 0
+ }
displayLabel?.text = pickerItems[selectedRow].title
_ = pickerItems[selectedRow].displayTitle.map { displayLabel?.attributedText = $0 }
diff --git a/Former/RowFormers/SwitchRowFormer.swift b/Former/RowFormers/SwitchRowFormer.swift
index 693af6a..01ac46b 100644
--- a/Former/RowFormers/SwitchRowFormer.swift
+++ b/Former/RowFormers/SwitchRowFormer.swift
@@ -76,7 +76,7 @@ open class SwitchRowFormer
private final var onSwitchChanged: ((Bool) -> Void)?
private final var titleColor: UIColor?
- private final var selectionStyle: UITableViewCellSelectionStyle?
+ private final var selectionStyle: UITableViewCell.SelectionStyle?
@objc private dynamic func switchChanged(_ switchButton: UISwitch) {
if self.enabled {
diff --git a/Former/RowFormers/TextFieldRowFormer.swift b/Former/RowFormers/TextFieldRowFormer.swift
index 24d8334..c7f8ffd 100644
--- a/Former/RowFormers/TextFieldRowFormer.swift
+++ b/Former/RowFormers/TextFieldRowFormer.swift
@@ -40,12 +40,18 @@ open class TextFieldRowFormer
onTextChanged = handler
return self
}
+
+ @discardableResult
+ public final func onReturn(_ handler: @escaping ((String) -> Void)) -> Self {
+ onReturn = handler
+ return self
+ }
open override func cellInitialized(_ cell: T) {
super.cellInitialized(cell)
let textField = cell.formTextField()
textField.delegate = observer
- let events: [(Selector, UIControlEvents)] = [(#selector(TextFieldRowFormer.textChanged(textField:)), .editingChanged),
+ let events: [(Selector, UIControl.Event)] = [(#selector(TextFieldRowFormer.textChanged(textField:)), .editingChanged),
(#selector(TextFieldRowFormer.editingDidBegin(textField:)), .editingDidBegin),
(#selector(TextFieldRowFormer.editingDidEnd(textField:)), .editingDidEnd)]
events.forEach {
@@ -90,6 +96,10 @@ open class TextFieldRowFormer
}
}
+ // MARK: Fileprivate
+
+ fileprivate final var onReturn: ((String) -> Void)?
+
// MARK: Private
private final var onTextChanged: ((String) -> Void)?
@@ -135,6 +145,10 @@ private class Observer: NSObject, UITextFieldDelegate where
fileprivate dynamic func textFieldShouldReturn(_ textField: UITextField) -> Bool {
guard let textFieldRowFormer = textFieldRowFormer else { return false }
+ if let returnHandler = textFieldRowFormer.onReturn {
+ returnHandler(textField.text ?? "")
+ return false
+ }
if textFieldRowFormer.returnToNextRow {
let returnToNextRow = (textFieldRowFormer.former?.canBecomeEditingNext() ?? false) ?
textFieldRowFormer.former?.becomeEditingNext :
diff --git a/README.md b/README.md
index a8645d3..db1e35b 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,11 @@
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![MIT License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/ra1028/Former/master/LICENSE)
+## Maintainers Wanted
+I'm losing `Former` development willingness now.
+If you are willing to develop in place of me, please feel free to contact me.
+I'll grant you authority associated with `Former` development.
+
## Demo
@@ -23,6 +28,7 @@
+ [Customizability](#customizability)
* [Contributing](#contributing)
* [Submitting Issues](#submitting-issues)
+* [Submitting Feature Requests](#submitting-feature-requests)
* [License](#license)
## Requirements
@@ -502,13 +508,10 @@ If you're interesting in helping us improve and maintain Former, it is highly en
If you do chose to submit a pull request, please make sure to clearly document what changes you have made in the description of the PR.
## Submitting Issues
-If you find yourself having any issues with Former, feel free to submit an issue. Please BE SURE to include the following:
-
-* TITLE
-* ISSUE DESCRIPTION
-* HOW TO REPLICATE ISSUE
+Click [HERE](https://github.com/ra1028/Former/issues/new?template=bug_report.md) to get started with filing a bug report. Please use this template to ensure that your issue doesn't get closed due to lack of information.
-If your issue doesn't contain this information, it will be closed due to lack of information.
+## Submitting Feature Requests
+Click [HERE](https://github.com/ra1028/Former/issues/new?template=feature_request.md) to get started with filing a feature request. Please use this template to ensure that your feature request doesn't get denied due to lack of information. Also please keep in mind that while we desire to make this work as well as possible for everyone we won't be able to accomodate all feature requests due to lack of time or alignment with the direction of the plugin, and you may need to consider contributing even if we agree that a feature would benefit the plugin.
## License
Former is available under the MIT license. See the LICENSE file for more info.