Skip to content

Commit d453ccd

Browse files
committed
Merge branch 'feature/token-text-field' into develop
2 parents a4909a4 + c5f1fdb commit d453ccd

23 files changed

+1220
-34
lines changed

.swiftlint.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
disabled_rules:
2+
- file_length
23
- line_length
4+
- type_body_length
35
excluded:
46
- Carthage
57
- Pods

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: objective-c
2-
osx_image: xcode7.3
2+
osx_image: xcode7.2
33
env:
44
matrix:
55
- VERSION=8.4
@@ -13,9 +13,10 @@ before_install:
1313
- export LANG=en_US.UTF-8
1414
install:
1515
- make install
16+
before_script:
17+
- xcodebuild -workspace ICInputAccessory.xcworkspace -list
1618
script:
17-
- xcodebuild -project ICInputAccessory.xcodeproj -scheme ICInputAccessory-iOS -sdk iphonesimulator -destination "name=iPhone 6,OS=$VERSION" clean build | xcpretty -c
18-
- xcodebuild -workspace ICInputAccessory.xcworkspace -scheme Example -sdk iphonesimulator -destination "name=iPhone 6,OS=$VERSION" clean test | xcpretty -c
19+
- bundle exec rake ci:test[$VERSION]
1920
notifications:
2021
email: false
2122
slack:

Example/.swiftlint.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
disabled_rules:
2+
- file_length
23
- line_length
4+
- type_body_length
35
included:
46
- ../Source

Example/Example.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88

99
/* Begin PBXBuildFile section */
1010
154CE52873EEBDF8EF05A61F /* Pods_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0DB1D3E89AB75183DB104E0 /* Pods_Example.framework */; };
11+
B52819581C90215C007D01D5 /* CustomizedTokenField.swift in Sources */ = {isa = PBXBuildFile; fileRef = B52819571C90215C007D01D5 /* CustomizedTokenField.swift */; };
1112
B548C5A71C8D55A8009D5AEE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = B548C5A51C8D55A8009D5AEE /* InfoPlist.strings */; };
1213
B548C5A91C8D6150009D5AEE /* ExampleCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = B548C5A81C8D6150009D5AEE /* ExampleCell.swift */; };
1314
B548C5C51C8E91B0009D5AEE /* ICInputAccessoryUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B548C5C41C8E91B0009D5AEE /* ICInputAccessoryUITests.swift */; };
15+
B5C53E191C92851400AF3489 /* CustomizedTokenViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5C53E181C92851400AF3489 /* CustomizedTokenViewController.swift */; };
1416
B5E9F8FF1C8D3B6E00443DC7 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E9F8FE1C8D3B6E00443DC7 /* AppDelegate.swift */; };
1517
B5E9F9011C8D3B6E00443DC7 /* ExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5E9F9001C8D3B6E00443DC7 /* ExampleViewController.swift */; };
1618
B5E9F9061C8D3B6E00443DC7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B5E9F9051C8D3B6E00443DC7 /* Assets.xcassets */; };
@@ -28,11 +30,13 @@
2830
/* End PBXContainerItemProxy section */
2931

3032
/* Begin PBXFileReference section */
33+
B52819571C90215C007D01D5 /* CustomizedTokenField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomizedTokenField.swift; sourceTree = "<group>"; };
3134
B548C5A61C8D55A8009D5AEE /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/InfoPlist.strings; sourceTree = "<group>"; };
3235
B548C5A81C8D6150009D5AEE /* ExampleCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExampleCell.swift; sourceTree = "<group>"; };
3336
B548C5C21C8E91B0009D5AEE /* ICInputAccessoryUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ICInputAccessoryUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
3437
B548C5C41C8E91B0009D5AEE /* ICInputAccessoryUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ICInputAccessoryUITests.swift; sourceTree = "<group>"; };
3538
B548C5C61C8E91B0009D5AEE /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
39+
B5C53E181C92851400AF3489 /* CustomizedTokenViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomizedTokenViewController.swift; sourceTree = "<group>"; };
3640
B5E9F8FB1C8D3B6E00443DC7 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
3741
B5E9F8FE1C8D3B6E00443DC7 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
3842
B5E9F9001C8D3B6E00443DC7 /* ExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleViewController.swift; sourceTree = "<group>"; };
@@ -114,6 +118,8 @@
114118
children = (
115119
B5E9F8FE1C8D3B6E00443DC7 /* AppDelegate.swift */,
116120
B5E9F9051C8D3B6E00443DC7 /* Assets.xcassets */,
121+
B52819571C90215C007D01D5 /* CustomizedTokenField.swift */,
122+
B5C53E181C92851400AF3489 /* CustomizedTokenViewController.swift */,
117123
B548C5A81C8D6150009D5AEE /* ExampleCell.swift */,
118124
B5E9F9001C8D3B6E00443DC7 /* ExampleViewController.swift */,
119125
B5E9F90A1C8D3B6E00443DC7 /* Info.plist */,
@@ -299,6 +305,8 @@
299305
buildActionMask = 2147483647;
300306
files = (
301307
B5E9F8FF1C8D3B6E00443DC7 /* AppDelegate.swift in Sources */,
308+
B52819581C90215C007D01D5 /* CustomizedTokenField.swift in Sources */,
309+
B5C53E191C92851400AF3489 /* CustomizedTokenViewController.swift in Sources */,
302310
B548C5A91C8D6150009D5AEE /* ExampleCell.swift in Sources */,
303311
B5E9F9011C8D3B6E00443DC7 /* ExampleViewController.swift in Sources */,
304312
);
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@
55
<BuildAction
66
parallelizeBuildables = "YES"
77
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "B5E9F8FA1C8D3B6E00443DC7"
18+
BuildableName = "Example.app"
19+
BlueprintName = "Example"
20+
ReferencedContainer = "container:Example.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
824
</BuildAction>
925
<TestAction
1026
buildConfiguration = "Debug"
@@ -23,6 +39,15 @@
2339
</BuildableReference>
2440
</TestableReference>
2541
</Testables>
42+
<MacroExpansion>
43+
<BuildableReference
44+
BuildableIdentifier = "primary"
45+
BlueprintIdentifier = "B5E9F8FA1C8D3B6E00443DC7"
46+
BuildableName = "Example.app"
47+
BlueprintName = "Example"
48+
ReferencedContainer = "container:Example.xcodeproj">
49+
</BuildableReference>
50+
</MacroExpansion>
2651
<AdditionalOptions>
2752
</AdditionalOptions>
2853
</TestAction>
@@ -36,6 +61,16 @@
3661
debugDocumentVersioning = "YES"
3762
debugServiceExtension = "internal"
3863
allowLocationSimulation = "YES">
64+
<BuildableProductRunnable
65+
runnableDebuggingMode = "0">
66+
<BuildableReference
67+
BuildableIdentifier = "primary"
68+
BlueprintIdentifier = "B5E9F8FA1C8D3B6E00443DC7"
69+
BuildableName = "Example.app"
70+
BlueprintName = "Example"
71+
ReferencedContainer = "container:Example.xcodeproj">
72+
</BuildableReference>
73+
</BuildableProductRunnable>
3974
<AdditionalOptions>
4075
</AdditionalOptions>
4176
</LaunchAction>
@@ -45,6 +80,16 @@
4580
savedToolIdentifier = ""
4681
useCustomWorkingDirectory = "NO"
4782
debugDocumentVersioning = "YES">
83+
<BuildableProductRunnable
84+
runnableDebuggingMode = "0">
85+
<BuildableReference
86+
BuildableIdentifier = "primary"
87+
BlueprintIdentifier = "B5E9F8FA1C8D3B6E00443DC7"
88+
BuildableName = "Example.app"
89+
BlueprintName = "Example"
90+
ReferencedContainer = "container:Example.xcodeproj">
91+
</BuildableReference>
92+
</BuildableProductRunnable>
4893
</ProfileAction>
4994
<AnalyzeAction
5095
buildConfiguration = "Debug">
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"filename" : "icook-iphone-input-search.pdf"
6+
}
7+
],
8+
"info" : {
9+
"version" : 1,
10+
"author" : "xcode"
11+
}
12+
}
4.09 KB
Binary file not shown.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
//
2+
// CustomizedTokenField.swift
3+
// Example
4+
//
5+
// Created by Ben on 09/03/2016.
6+
// Copyright © 2016 Polydice, Inc.
7+
//
8+
// Permission is hereby granted, free of charge, to any person obtaining a copy
9+
// of this software and associated documentation files (the "Software"), to deal
10+
// in the Software without restriction, including without limitation the rights
11+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
// copies of the Software, and to permit persons to whom the Software is
13+
// furnished to do so, subject to the following conditions:
14+
//
15+
// The above copyright notice and this permission notice shall be included in all
16+
// copies or substantial portions of the Software.
17+
//
18+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
// SOFTWARE.
25+
//
26+
27+
import UIKit
28+
import ICInputAccessory
29+
30+
class CustomizedTokenField: ICTokenField {
31+
32+
override init(frame: CGRect) {
33+
super.init(frame: frame)
34+
applyCustomizedStyle()
35+
}
36+
37+
required init?(coder aDecoder: NSCoder) {
38+
super.init(coder: aDecoder)
39+
applyCustomizedStyle()
40+
}
41+
42+
}
43+
44+
45+
////////////////////////////////////////////////////////////////////////////////
46+
47+
48+
extension ICTokenField {
49+
50+
func applyCustomizedStyle() {
51+
icon = UIImage(named: "icook-iphone-input-search")
52+
53+
layer.cornerRadius = 5
54+
layer.shouldRasterize = true
55+
layer.rasterizationScale = UIScreen.mainScreen().scale
56+
backgroundColor = UIColor(red:0.8, green:0.32, blue:0.24, alpha:1)
57+
58+
textField.textColor = UIColor.whiteColor()
59+
textField.tintColor = UIColor.whiteColor()
60+
textField.font = UIFont.boldSystemFontOfSize(14)
61+
62+
attributedPlaceholder = NSAttributedString(
63+
string: String(self.dynamicType),
64+
attributes: [
65+
NSForegroundColorAttributeName: UIColor.whiteColor().colorWithAlphaComponent(0.5),
66+
NSFontAttributeName: UIFont.boldSystemFontOfSize(14)
67+
]
68+
)
69+
70+
normalTokenAttributes = [
71+
NSForegroundColorAttributeName: UIColor.whiteColor(),
72+
NSBackgroundColorAttributeName: UIColor.whiteColor().colorWithAlphaComponent(0.25),
73+
NSFontAttributeName: UIFont.boldSystemFontOfSize(14)
74+
]
75+
76+
highlightedTokenAttributes = [
77+
NSForegroundColorAttributeName: UIColor(red:0.8, green:0.32, blue:0.24, alpha:1),
78+
NSBackgroundColorAttributeName: UIColor.whiteColor(),
79+
NSFontAttributeName: UIFont.boldSystemFontOfSize(14)
80+
]
81+
}
82+
83+
}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
//
2+
// CustomizedTokenViewController.swift
3+
// Example
4+
//
5+
// Created by Ben on 11/03/2016.
6+
// Copyright © 2016 Polydice, Inc.
7+
//
8+
// Permission is hereby granted, free of charge, to any person obtaining a copy
9+
// of this software and associated documentation files (the "Software"), to deal
10+
// in the Software without restriction, including without limitation the rights
11+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
// copies of the Software, and to permit persons to whom the Software is
13+
// furnished to do so, subject to the following conditions:
14+
//
15+
// The above copyright notice and this permission notice shall be included in all
16+
// copies or substantial portions of the Software.
17+
//
18+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24+
// SOFTWARE.
25+
//
26+
27+
import UIKit
28+
import ICInputAccessory
29+
30+
class CustomizedTokenViewController: UIViewController, ICTokenFieldDelegate {
31+
32+
private let tokenField = CustomizedTokenField()
33+
private let textView = UITextView()
34+
35+
// MARK: - UIViewController
36+
37+
override func loadView() {
38+
super.loadView()
39+
view.backgroundColor = UIColor.whiteColor()
40+
textView.text = "[\n\n]";
41+
textView.font = UIFont.preferredFontForTextStyle(UIFontTextStyleSubheadline)
42+
textView.frame = view.bounds.insetBy(dx: 10, dy: 10)
43+
textView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
44+
view.addSubview(textView)
45+
}
46+
47+
override func viewDidLoad() {
48+
super.viewDidLoad()
49+
navigationController?.navigationBar.barTintColor = UIColor(red:0.96, green:0.48, blue:0.4, alpha:1)
50+
navigationController?.navigationBar.translucent = false
51+
navigationController?.navigationBar.barStyle = .Black
52+
53+
let cancelBarButton = UIBarButtonItem(barButtonSystemItem: .Cancel, target: self, action: Selector("dismiss:"))
54+
cancelBarButton.tintColor = UIColor.whiteColor()
55+
navigationItem.rightBarButtonItem = cancelBarButton
56+
57+
navigationItem.titleView = tokenField
58+
tokenField.delegate = self
59+
}
60+
61+
override func viewWillAppear(animated: Bool) {
62+
super.viewWillAppear(animated)
63+
tokenField.becomeFirstResponder()
64+
}
65+
66+
override func viewWillDisappear(animated: Bool) {
67+
super.viewWillAppear(animated)
68+
tokenField.resignFirstResponder()
69+
textView.endEditing(true)
70+
}
71+
72+
// MARK: - ICTokenFieldDelegate
73+
74+
func tokenFieldDidBeginEditing(tokenField: ICTokenField) {
75+
print(__FUNCTION__)
76+
}
77+
78+
func tokenFieldDidEndEditing(tokenField: ICTokenField) {
79+
print(__FUNCTION__)
80+
}
81+
82+
func tokenFieldWillReturn(tokenField: ICTokenField) {
83+
print(__FUNCTION__)
84+
}
85+
86+
func tokenField(tokenField: ICTokenField, didEnterText text: String) {
87+
print("Add: \"\(text)\"")
88+
updateTexts()
89+
}
90+
91+
func tokenField(tokenField: ICTokenField, didDeleteText text: String, atIndex index: Int) {
92+
print("Delete: \"\(text)\"")
93+
updateTexts()
94+
}
95+
96+
// MARK: - UIResponder Callbacks
97+
98+
@IBAction private func dismiss(sender: UIBarButtonItem) {
99+
presentingViewController?.dismissViewControllerAnimated(true, completion: nil)
100+
}
101+
102+
// MARK: - Private Methods
103+
104+
private func updateTexts() {
105+
textView.text = "[\n " + tokenField.texts.map { "\"" + $0 + "\"" } .joinWithSeparator(",\n ") + "\n]"
106+
}
107+
108+
}

0 commit comments

Comments
 (0)