Skip to content

Commit

Permalink
Merge branch 'release/2.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
bcylin committed Oct 31, 2018
2 parents a607f61 + fcf3197 commit 30a66f2
Show file tree
Hide file tree
Showing 48 changed files with 2,083 additions and 443 deletions.
2 changes: 1 addition & 1 deletion .jazzy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ github_url: https://github.com/polydice/ICInputAccessory
github_file_prefix: https://github.com/polydice/ICInputAccessory/blob/develop
xcodebuild_arguments: [-project, ICInputAccessory.xcodeproj, -scheme, ICInputAccessory-iOS]
module: ICInputAccessory
module_version: 1.5.0
module_version: 2.0.0
output: docs
theme: fullwidth
skip_undocumented: true
1 change: 0 additions & 1 deletion .ruby-version

This file was deleted.

1 change: 0 additions & 1 deletion .swift-version

This file was deleted.

6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode9.3beta
osx_image: xcode10
cache:
bundler: true
directories:
Expand All @@ -8,13 +8,13 @@ cache:
before_install:
- export LANG=en_US.UTF-8
- xcrun instruments -s devices
- open -b com.apple.iphonesimulator
- xcrun instruments -w "iPhone X (12.0) [" || true
install:
- make install
before_script:
- xcodebuild -workspace ICInputAccessory.xcworkspace -list
script:
- bundle exec rake ci:test
- bundle exec rake "ci:test[12.0]"
- make -B carthage
- make -B docs
notifications:
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v2.0.0

* Drop Class Name Prefixes
* Add an easy to use `OptionPickerControl` that displays a `UIPickerView` with given options

## v1.5.0

* Swift 4.0
Expand Down
4 changes: 3 additions & 1 deletion Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ 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)
window?.backgroundColor = UIColor.white
window?.rootViewController = UINavigationController(rootViewController: ExampleViewController())
Expand Down
15 changes: 15 additions & 0 deletions Example/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Expand Down Expand Up @@ -29,6 +39,11 @@
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
Expand Down
6 changes: 3 additions & 3 deletions Example/CustomizedTokenField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import UIKit
import ICInputAccessory

class CustomizedTokenField: ICTokenField {
class CustomizedTokenField: TokenField {

override init(frame: CGRect) {
super.init(frame: frame)
Expand All @@ -40,7 +40,7 @@ class CustomizedTokenField: ICTokenField {
}

override var intrinsicContentSize: CGSize {
return UILayoutFittingExpandedSize
return UIView.layoutFittingExpandedSize
}

}
Expand All @@ -49,7 +49,7 @@ class CustomizedTokenField: ICTokenField {
////////////////////////////////////////////////////////////////////////////////


extension ICTokenField {
extension TokenField {

func applyCustomizedStyle() {
icon = UIImage(named: "icook-iphone-input-search")
Expand Down
20 changes: 10 additions & 10 deletions Example/CustomizedTokenViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import UIKit
import ICInputAccessory

class CustomizedTokenViewController: UIViewController, ICTokenFieldDelegate {
class CustomizedTokenViewController: UIViewController, TokenFieldDelegate {

private let tokenField = CustomizedTokenField()
private let textView = UITextView()
Expand Down Expand Up @@ -84,40 +84,40 @@ class CustomizedTokenViewController: UIViewController, ICTokenFieldDelegate {
textView.endEditing(true)
}

// MARK: - ICTokenFieldDelegate
// MARK: - TokenFieldDelegate

func tokenFieldDidBeginEditing(_ tokenField: ICTokenField) {
func tokenFieldDidBeginEditing(_ tokenField: TokenField) {
print(#function)
}

func tokenFieldDidEndEditing(_ tokenField: ICTokenField) {
func tokenFieldDidEndEditing(_ tokenField: TokenField) {
print(#function)
}

func tokenFieldWillReturn(_ tokenField: ICTokenField) {
func tokenFieldWillReturn(_ tokenField: TokenField) {
print(#function)
}

func tokenField(_ tokenField: ICTokenField, didChangeInputText text: String) {
func tokenField(_ tokenField: TokenField, didChangeInputText text: String) {
print("Typing \"\(text)\"")
}

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

func tokenField(_ tokenField: ICTokenField, didCompleteText text: String) {
func tokenField(_ tokenField: TokenField, didCompleteText text: String) {
print("Added \"\(text)\"")
updateTexts()
}

func tokenField(_ tokenField: ICTokenField, didDeleteText text: String, atIndex index: Int) {
func tokenField(_ tokenField: TokenField, didDeleteText text: String, atIndex index: Int) {
print("Deleted \"\(text)\"")
updateTexts()
}

func tokenField(_ tokenField: ICTokenField, subsequentDelimiterForCompletedText text: String) -> String {
func tokenField(_ tokenField: TokenField, subsequentDelimiterForCompletedText text: String) -> String {
return " ,"
}

Expand Down
67 changes: 51 additions & 16 deletions Example/ExampleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,24 @@ import ICInputAccessory

class ExampleViewController: UITableViewController {

private let types: [UIView.Type] = [
ICKeyboardDismissTextField.self,
ICTokenField.self,
CustomizedTokenField.self
private let showcases: [UIView.Type] = [
KeyboardDismissTextField.self,
TokenField.self,
CustomizedTokenField.self,
OptionPickerControl<Language>.self
]

private lazy var languagePicker: OptionPickerControl<Language> = {
let picker = OptionPickerControl<Language>()
picker.options += Language.availableLanguages.map(Option.init(_:))
picker.addTarget(self, action: .updateLanguage, for: .valueChanged)
return picker
}()

private lazy var flipButton: UIButton = {
let _button = UIButton(type: .system)
_button.frame = CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height: 88)
_button.setTitle("Storyboard", for: UIControlState())
_button.setTitle("Storyboard", for: UIControl.State())
_button.addTarget(self, action: .showStoryboard, for: .touchUpInside)
return _button
}()
Expand All @@ -52,42 +60,46 @@ class ExampleViewController: UITableViewController {

// MARK: - UIViewController

override func loadView() {
super.loadView()
override func viewDidLoad() {
super.viewDidLoad()
tableView.rowHeight = 44
tableView.register(ExampleCell.self, forCellReuseIdentifier: String(describing: ExampleCell.self))
tableView.tableFooterView = flipButton
tableView.tableFooterView?.isUserInteractionEnabled = true
view.addSubview(languagePicker)
}

// MARK: - UITableViewDataSource

override func numberOfSections(in tableView: UITableView) -> Int {
return types.count
return showcases.count
}

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

override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
switch types[section] {
case is ICKeyboardDismissTextField.Type:
switch showcases[section] {
case is KeyboardDismissTextField.Type:
return "Dismiss Keyboard"
case is ICTokenField.Type:
case is TokenField.Type:
return "Text Field with Tokens"
case is CustomizedTokenField.Type:
return "Customize Token Field"
case is OptionPickerControl<Language>.Type:
return "Option Picker Control"
default:
return ""
}
}

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

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

case let type as ICTokenField.Type:
case let type as TokenField.Type:
let container = UIView(frame: cell.bounds)
let tokenField = type.init()
tokenField.placeholder = String(describing: type)
Expand All @@ -107,6 +119,11 @@ class ExampleViewController: UITableViewController {
container.addSubview(tokenField)
(cell as? ExampleCell)?.showcase = container

case is OptionPickerControl<Language>.Type:
(cell as? ExampleCell)?.showcase = nil
cell.textLabel?.text = languagePicker.selectedOption.title
cell.accessoryType = .disclosureIndicator

default:
break
}
Expand All @@ -116,12 +133,25 @@ class ExampleViewController: UITableViewController {
// MARK: - UITableViewDelegate

override func tableView(_ tableView: UITableView, shouldHighlightRowAt indexPath: IndexPath) -> Bool {
return types[indexPath.section] == CustomizedTokenField.self
switch showcases[indexPath.section] {
case is CustomizedTokenField.Type:
return true
case is OptionPickerControl<Language>.Type:
return true
default:
return false
}
}

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if types[indexPath.section] == CustomizedTokenField.self {
switch showcases[indexPath.section] {
case is CustomizedTokenField.Type:
present(UINavigationController(rootViewController: CustomizedTokenViewController()), animated: true, completion: nil)
case is OptionPickerControl<Language>.Type:
tableView.deselectRow(at: indexPath, animated: true)
languagePicker.becomeFirstResponder()
default:
break
}
}

Expand All @@ -134,6 +164,10 @@ class ExampleViewController: UITableViewController {
}
}

@objc fileprivate func updateLanguage(_ sender: UIControl) {
tableView.reloadData()
}

}


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

private extension Selector {
static let showStoryboard = #selector(ExampleViewController.showStoryboard(_:))
static let updateLanguage = #selector(ExampleViewController.updateLanguage(_:))
}
2 changes: 1 addition & 1 deletion Example/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.5.0</string>
<string>2.0.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
58 changes: 58 additions & 0 deletions Example/Language.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// Language.swift
// Example
//
// Created by Ben on 20/01/2018.
// Copyright © 2018 bcylin.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//

import Foundation
import ICInputAccessory

enum Language: String, OptionDescriptive {

case english
case french
case german
case japanese
case mandarin
case spanish

static var availableLanguages: [Language] = [
.english,
.french,
.german,
.japanese,
.mandarin,
.spanish
]

// MARK: - OptionDescriptive

var title: String {
return rawValue.capitalized
}

static var titleForOptionalValue: String {
return "(Optional)"
}

}
Loading

0 comments on commit 30a66f2

Please sign in to comment.