Skip to content

Commit 30a66f2

Browse files
committed
Merge branch 'release/2.0.0'
2 parents a607f61 + fcf3197 commit 30a66f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2083
-443
lines changed

.jazzy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ github_url: https://github.com/polydice/ICInputAccessory
55
github_file_prefix: https://github.com/polydice/ICInputAccessory/blob/develop
66
xcodebuild_arguments: [-project, ICInputAccessory.xcodeproj, -scheme, ICInputAccessory-iOS]
77
module: ICInputAccessory
8-
module_version: 1.5.0
8+
module_version: 2.0.0
99
output: docs
1010
theme: fullwidth
1111
skip_undocumented: true

.ruby-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

.swift-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: objective-c
2-
osx_image: xcode9.3beta
2+
osx_image: xcode10
33
cache:
44
bundler: true
55
directories:
@@ -8,13 +8,13 @@ cache:
88
before_install:
99
- export LANG=en_US.UTF-8
1010
- xcrun instruments -s devices
11-
- open -b com.apple.iphonesimulator
11+
- xcrun instruments -w "iPhone X (12.0) [" || true
1212
install:
1313
- make install
1414
before_script:
1515
- xcodebuild -workspace ICInputAccessory.xcworkspace -list
1616
script:
17-
- bundle exec rake ci:test
17+
- bundle exec rake "ci:test[12.0]"
1818
- make -B carthage
1919
- make -B docs
2020
notifications:

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## v2.0.0
2+
3+
* Drop Class Name Prefixes
4+
* Add an easy to use `OptionPickerControl` that displays a `UIPickerView` with given options
5+
16
## v1.5.0
27

38
* Swift 4.0

Example/AppDelegate.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3131

3232
var window: UIWindow?
3333

34-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]? = nil) -> Bool {
34+
func application(_ application: UIApplication,
35+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil)
36+
-> Bool {
3537
window = UIWindow(frame: UIScreen.main.bounds)
3638
window?.backgroundColor = UIColor.white
3739
window?.rootViewController = UINavigationController(rootViewController: ExampleViewController())

Example/Assets.xcassets/AppIcon.appiconset/Contents.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
{
22
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"size" : "20x20",
6+
"scale" : "2x"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"size" : "20x20",
11+
"scale" : "3x"
12+
},
313
{
414
"idiom" : "iphone",
515
"size" : "29x29",
@@ -29,6 +39,11 @@
2939
"idiom" : "iphone",
3040
"size" : "60x60",
3141
"scale" : "3x"
42+
},
43+
{
44+
"idiom" : "ios-marketing",
45+
"size" : "1024x1024",
46+
"scale" : "1x"
3247
}
3348
],
3449
"info" : {

Example/CustomizedTokenField.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import UIKit
2828
import ICInputAccessory
2929

30-
class CustomizedTokenField: ICTokenField {
30+
class CustomizedTokenField: TokenField {
3131

3232
override init(frame: CGRect) {
3333
super.init(frame: frame)
@@ -40,7 +40,7 @@ class CustomizedTokenField: ICTokenField {
4040
}
4141

4242
override var intrinsicContentSize: CGSize {
43-
return UILayoutFittingExpandedSize
43+
return UIView.layoutFittingExpandedSize
4444
}
4545

4646
}
@@ -49,7 +49,7 @@ class CustomizedTokenField: ICTokenField {
4949
////////////////////////////////////////////////////////////////////////////////
5050

5151

52-
extension ICTokenField {
52+
extension TokenField {
5353

5454
func applyCustomizedStyle() {
5555
icon = UIImage(named: "icook-iphone-input-search")

Example/CustomizedTokenViewController.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import UIKit
2828
import ICInputAccessory
2929

30-
class CustomizedTokenViewController: UIViewController, ICTokenFieldDelegate {
30+
class CustomizedTokenViewController: UIViewController, TokenFieldDelegate {
3131

3232
private let tokenField = CustomizedTokenField()
3333
private let textView = UITextView()
@@ -84,40 +84,40 @@ class CustomizedTokenViewController: UIViewController, ICTokenFieldDelegate {
8484
textView.endEditing(true)
8585
}
8686

87-
// MARK: - ICTokenFieldDelegate
87+
// MARK: - TokenFieldDelegate
8888

89-
func tokenFieldDidBeginEditing(_ tokenField: ICTokenField) {
89+
func tokenFieldDidBeginEditing(_ tokenField: TokenField) {
9090
print(#function)
9191
}
9292

93-
func tokenFieldDidEndEditing(_ tokenField: ICTokenField) {
93+
func tokenFieldDidEndEditing(_ tokenField: TokenField) {
9494
print(#function)
9595
}
9696

97-
func tokenFieldWillReturn(_ tokenField: ICTokenField) {
97+
func tokenFieldWillReturn(_ tokenField: TokenField) {
9898
print(#function)
9999
}
100100

101-
func tokenField(_ tokenField: ICTokenField, didChangeInputText text: String) {
101+
func tokenField(_ tokenField: TokenField, didChangeInputText text: String) {
102102
print("Typing \"\(text)\"")
103103
}
104104

105-
func tokenField(_ tokenField: ICTokenField, shouldCompleteText text: String) -> Bool {
105+
func tokenField(_ tokenField: TokenField, shouldCompleteText text: String) -> Bool {
106106
print("Should add \"\(text)\"?")
107107
return text != "42"
108108
}
109109

110-
func tokenField(_ tokenField: ICTokenField, didCompleteText text: String) {
110+
func tokenField(_ tokenField: TokenField, didCompleteText text: String) {
111111
print("Added \"\(text)\"")
112112
updateTexts()
113113
}
114114

115-
func tokenField(_ tokenField: ICTokenField, didDeleteText text: String, atIndex index: Int) {
115+
func tokenField(_ tokenField: TokenField, didDeleteText text: String, atIndex index: Int) {
116116
print("Deleted \"\(text)\"")
117117
updateTexts()
118118
}
119119

120-
func tokenField(_ tokenField: ICTokenField, subsequentDelimiterForCompletedText text: String) -> String {
120+
func tokenField(_ tokenField: TokenField, subsequentDelimiterForCompletedText text: String) -> String {
121121
return " ,"
122122
}
123123

Example/ExampleViewController.swift

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,24 @@ import ICInputAccessory
2929

3030
class ExampleViewController: UITableViewController {
3131

32-
private let types: [UIView.Type] = [
33-
ICKeyboardDismissTextField.self,
34-
ICTokenField.self,
35-
CustomizedTokenField.self
32+
private let showcases: [UIView.Type] = [
33+
KeyboardDismissTextField.self,
34+
TokenField.self,
35+
CustomizedTokenField.self,
36+
OptionPickerControl<Language>.self
3637
]
3738

39+
private lazy var languagePicker: OptionPickerControl<Language> = {
40+
let picker = OptionPickerControl<Language>()
41+
picker.options += Language.availableLanguages.map(Option.init(_:))
42+
picker.addTarget(self, action: .updateLanguage, for: .valueChanged)
43+
return picker
44+
}()
45+
3846
private lazy var flipButton: UIButton = {
3947
let _button = UIButton(type: .system)
4048
_button.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 88)
41-
_button.setTitle("Storyboard", for: UIControlState())
49+
_button.setTitle("Storyboard", for: UIControl.State())
4250
_button.addTarget(self, action: .showStoryboard, for: .touchUpInside)
4351
return _button
4452
}()
@@ -52,42 +60,46 @@ class ExampleViewController: UITableViewController {
5260

5361
// MARK: - UIViewController
5462

55-
override func loadView() {
56-
super.loadView()
63+
override func viewDidLoad() {
64+
super.viewDidLoad()
5765
tableView.rowHeight = 44
5866
tableView.register(ExampleCell.self, forCellReuseIdentifier: String(describing: ExampleCell.self))
5967
tableView.tableFooterView = flipButton
6068
tableView.tableFooterView?.isUserInteractionEnabled = true
69+
view.addSubview(languagePicker)
6170
}
6271

6372
// MARK: - UITableViewDataSource
6473

6574
override func numberOfSections(in tableView: UITableView) -> Int {
66-
return types.count
75+
return showcases.count
6776
}
6877

6978
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
7079
return 1
7180
}
7281

7382
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
74-
switch types[section] {
75-
case is ICKeyboardDismissTextField.Type:
83+
switch showcases[section] {
84+
case is KeyboardDismissTextField.Type:
7685
return "Dismiss Keyboard"
77-
case is ICTokenField.Type:
86+
case is TokenField.Type:
7887
return "Text Field with Tokens"
7988
case is CustomizedTokenField.Type:
8089
return "Customize Token Field"
90+
case is OptionPickerControl<Language>.Type:
91+
return "Option Picker Control"
8192
default:
8293
return ""
8394
}
8495
}
8596

8697
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
8798
let cell = tableView.dequeueReusableCell(withIdentifier: String(describing: ExampleCell.self), for: indexPath)
99+
cell.accessoryType = .none
88100

89-
switch types[indexPath.section] {
90-
case let type as ICKeyboardDismissTextField.Type:
101+
switch showcases[indexPath.section] {
102+
case let type as KeyboardDismissTextField.Type:
91103
let textField = type.init()
92104
textField.leftViewMode = .always
93105
textField.leftView = UIView(frame: CGRect(x: 0, y: 0, width: 15, height: 15))
@@ -98,7 +110,7 @@ class ExampleViewController: UITableViewController {
98110
cell.textLabel?.text = String(describing: type)
99111
cell.accessoryType = .disclosureIndicator
100112

101-
case let type as ICTokenField.Type:
113+
case let type as TokenField.Type:
102114
let container = UIView(frame: cell.bounds)
103115
let tokenField = type.init()
104116
tokenField.placeholder = String(describing: type)
@@ -107,6 +119,11 @@ class ExampleViewController: UITableViewController {
107119
container.addSubview(tokenField)
108120
(cell as? ExampleCell)?.showcase = container
109121

122+
case is OptionPickerControl<Language>.Type:
123+
(cell as? ExampleCell)?.showcase = nil
124+
cell.textLabel?.text = languagePicker.selectedOption.title
125+
cell.accessoryType = .disclosureIndicator
126+
110127
default:
111128
break
112129
}
@@ -116,12 +133,25 @@ class ExampleViewController: UITableViewController {
116133
// MARK: - UITableViewDelegate
117134

118135
override func tableView(_ tableView: UITableView, shouldHighlightRowAt indexPath: IndexPath) -> Bool {
119-
return types[indexPath.section] == CustomizedTokenField.self
136+
switch showcases[indexPath.section] {
137+
case is CustomizedTokenField.Type:
138+
return true
139+
case is OptionPickerControl<Language>.Type:
140+
return true
141+
default:
142+
return false
143+
}
120144
}
121145

122146
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
123-
if types[indexPath.section] == CustomizedTokenField.self {
147+
switch showcases[indexPath.section] {
148+
case is CustomizedTokenField.Type:
124149
present(UINavigationController(rootViewController: CustomizedTokenViewController()), animated: true, completion: nil)
150+
case is OptionPickerControl<Language>.Type:
151+
tableView.deselectRow(at: indexPath, animated: true)
152+
languagePicker.becomeFirstResponder()
153+
default:
154+
break
125155
}
126156
}
127157

@@ -134,6 +164,10 @@ class ExampleViewController: UITableViewController {
134164
}
135165
}
136166

167+
@objc fileprivate func updateLanguage(_ sender: UIControl) {
168+
tableView.reloadData()
169+
}
170+
137171
}
138172

139173

@@ -142,4 +176,5 @@ class ExampleViewController: UITableViewController {
142176

143177
private extension Selector {
144178
static let showStoryboard = #selector(ExampleViewController.showStoryboard(_:))
179+
static let updateLanguage = #selector(ExampleViewController.updateLanguage(_:))
145180
}

0 commit comments

Comments
 (0)