Commit 6a47fbca by Daniel Dahan

removed the need to setup the clearButton for TextFields

parent 84168221
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
9663F94E1C7A74EA00AF0965 /* AppLeftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */; }; 9663F94E1C7A74EA00AF0965 /* AppLeftViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */; };
9663F9521C7A751D00AF0965 /* ItemViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9511C7A751D00AF0965 /* ItemViewController.swift */; }; 9663F9521C7A751D00AF0965 /* ItemViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9663F9511C7A751D00AF0965 /* ItemViewController.swift */; };
96CC08881C7FEBD60034FF84 /* RecipesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC08871C7FEBD60034FF84 /* RecipesViewController.swift */; }; 96CC08881C7FEBD60034FF84 /* RecipesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CC08871C7FEBD60034FF84 /* RecipesViewController.swift */; };
96E01FD91CB0485C00411B61 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96E01FD81CB0485C00411B61 /* Material.framework */; };
96E01FDA1CB0485C00411B61 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96E01FD81CB0485C00411B61 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -30,7 +28,6 @@ ...@@ -30,7 +28,6 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
96E01FDA1CB0485C00411B61 /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -52,7 +49,6 @@ ...@@ -52,7 +49,6 @@
9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppLeftViewController.swift; sourceTree = "<group>"; }; 9663F94D1C7A74EA00AF0965 /* AppLeftViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppLeftViewController.swift; sourceTree = "<group>"; };
9663F9511C7A751D00AF0965 /* ItemViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ItemViewController.swift; sourceTree = "<group>"; }; 9663F9511C7A751D00AF0965 /* ItemViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ItemViewController.swift; sourceTree = "<group>"; };
96CC08871C7FEBD60034FF84 /* RecipesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecipesViewController.swift; sourceTree = "<group>"; }; 96CC08871C7FEBD60034FF84 /* RecipesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RecipesViewController.swift; sourceTree = "<group>"; };
96E01FD81CB0485C00411B61 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphonesimulator/Material.framework"; sourceTree = "<absolute>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -60,7 +56,6 @@ ...@@ -60,7 +56,6 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96E01FD91CB0485C00411B61 /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -70,7 +65,6 @@ ...@@ -70,7 +65,6 @@
9663F9251C7A744500AF0965 = { 9663F9251C7A744500AF0965 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96E01FD81CB0485C00411B61 /* Material.framework */,
9663F9301C7A744600AF0965 /* App */, 9663F9301C7A744600AF0965 /* App */,
9663F92F1C7A744600AF0965 /* Products */, 9663F92F1C7A744600AF0965 /* Products */,
); );
......
...@@ -68,7 +68,7 @@ class ItemViewController: UIViewController { ...@@ -68,7 +68,7 @@ class ItemViewController: UIViewController {
prepareView() prepareView()
prepareTitleLabel() prepareTitleLabel()
prepareShareButton() prepareShareButton()
prepareNavigationBar() prepareNavigationItem()
prepareScrollView() prepareScrollView()
prepareImageCardView() prepareImageCardView()
} }
...@@ -123,7 +123,7 @@ class ItemViewController: UIViewController { ...@@ -123,7 +123,7 @@ class ItemViewController: UIViewController {
} }
/// Prepares the navigationItem. /// Prepares the navigationItem.
private func prepareNavigationBar() { private func prepareNavigationItem() {
navigationItem.titleLabel = titleLabel navigationItem.titleLabel = titleLabel
navigationItem.detailLabel = detailLabel navigationItem.detailLabel = detailLabel
navigationItem.rightControls = [shareButton] navigationItem.rightControls = [shareButton]
......
...@@ -58,7 +58,7 @@ class RecipesViewController: UIViewController { ...@@ -58,7 +58,7 @@ class RecipesViewController: UIViewController {
prepareMenuButton() prepareMenuButton()
prepareSwitchControl() prepareSwitchControl()
prepareSearchButton() prepareSearchButton()
prepareNavigationBar() prepareNavigationItem()
prepareTableView() prepareTableView()
} }
...@@ -255,7 +255,7 @@ class RecipesViewController: UIViewController { ...@@ -255,7 +255,7 @@ class RecipesViewController: UIViewController {
} }
/// Prepares the navigationItem. /// Prepares the navigationItem.
private func prepareNavigationBar() { private func prepareNavigationItem() {
navigationItem.titleLabel = titleLabel navigationItem.titleLabel = titleLabel
navigationItem.leftControls = [menuButton] navigationItem.leftControls = [menuButton]
navigationItem.rightControls = [switchControl, searchButton] navigationItem.rightControls = [switchControl, searchButton]
......
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
96E01FC21CB0441800411B61 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E01FC11CB0441800411B61 /* ViewController.swift */; }; 96E01FC21CB0441800411B61 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E01FC11CB0441800411B61 /* ViewController.swift */; };
96E01FC71CB0441800411B61 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96E01FC61CB0441800411B61 /* Assets.xcassets */; }; 96E01FC71CB0441800411B61 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96E01FC61CB0441800411B61 /* Assets.xcassets */; };
96E01FCA1CB0441800411B61 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96E01FC81CB0441800411B61 /* LaunchScreen.storyboard */; }; 96E01FCA1CB0441800411B61 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96E01FC81CB0441800411B61 /* LaunchScreen.storyboard */; };
96E01FD21CB0448F00411B61 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96E01FD11CB0448F00411B61 /* Material.framework */; };
96E01FD31CB0448F00411B61 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96E01FD11CB0448F00411B61 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
...@@ -22,7 +20,6 @@ ...@@ -22,7 +20,6 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
96E01FD31CB0448F00411B61 /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -36,7 +33,6 @@ ...@@ -36,7 +33,6 @@
96E01FC61CB0441800411B61 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 96E01FC61CB0441800411B61 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
96E01FC91CB0441800411B61 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 96E01FC91CB0441800411B61 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
96E01FCB1CB0441800411B61 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 96E01FCB1CB0441800411B61 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
96E01FD11CB0448F00411B61 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
...@@ -44,7 +40,6 @@ ...@@ -44,7 +40,6 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96E01FD21CB0448F00411B61 /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -54,7 +49,6 @@ ...@@ -54,7 +49,6 @@
96E01FB31CB0441800411B61 = { 96E01FB31CB0441800411B61 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96E01FD11CB0448F00411B61 /* Material.framework */,
96E01FBE1CB0441800411B61 /* TabBar */, 96E01FBE1CB0441800411B61 /* TabBar */,
96E01FBD1CB0441800411B61 /* Products */, 96E01FBD1CB0441800411B61 /* Products */,
); );
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
966015D91CB2B0BA00AAB661 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 966015D81CB2B0BA00AAB661 /* Material.framework */; };
966015DA1CB2B0BA00AAB661 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 966015D81CB2B0BA00AAB661 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
966F57A11C226BAA009185B7 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966F57A01C226BAA009185B7 /* AppDelegate.swift */; }; 966F57A11C226BAA009185B7 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966F57A01C226BAA009185B7 /* AppDelegate.swift */; };
966F57A31C226BAA009185B7 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966F57A21C226BAA009185B7 /* ViewController.swift */; }; 966F57A31C226BAA009185B7 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966F57A21C226BAA009185B7 /* ViewController.swift */; };
966F57A81C226BAA009185B7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 966F57A71C226BAA009185B7 /* Assets.xcassets */; }; 966F57A81C226BAA009185B7 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 966F57A71C226BAA009185B7 /* Assets.xcassets */; };
...@@ -14,12 +16,13 @@ ...@@ -14,12 +16,13 @@
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */ /* Begin PBXCopyFilesBuildPhase section */
966F57B51C226CA3009185B7 /* Embed Frameworks */ = { 966015DB1CB2B0BA00AAB661 /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase; isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
966015DA1CB2B0BA00AAB661 /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -27,6 +30,7 @@ ...@@ -27,6 +30,7 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
966015D81CB2B0BA00AAB661 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphoneos/Material.framework"; sourceTree = "<absolute>"; };
966F579D1C226BAA009185B7 /* TextField.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TextField.app; sourceTree = BUILT_PRODUCTS_DIR; }; 966F579D1C226BAA009185B7 /* TextField.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TextField.app; sourceTree = BUILT_PRODUCTS_DIR; };
966F57A01C226BAA009185B7 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 966F57A01C226BAA009185B7 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
966F57A21C226BAA009185B7 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; }; 966F57A21C226BAA009185B7 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
...@@ -40,6 +44,7 @@ ...@@ -40,6 +44,7 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
966015D91CB2B0BA00AAB661 /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -49,6 +54,7 @@ ...@@ -49,6 +54,7 @@
966F57941C226BAA009185B7 = { 966F57941C226BAA009185B7 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
966015D81CB2B0BA00AAB661 /* Material.framework */,
966F579F1C226BAA009185B7 /* TextField */, 966F579F1C226BAA009185B7 /* TextField */,
966F579E1C226BAA009185B7 /* Products */, 966F579E1C226BAA009185B7 /* Products */,
); );
...@@ -84,7 +90,7 @@ ...@@ -84,7 +90,7 @@
966F57991C226BAA009185B7 /* Sources */, 966F57991C226BAA009185B7 /* Sources */,
966F579A1C226BAA009185B7 /* Frameworks */, 966F579A1C226BAA009185B7 /* Frameworks */,
966F579B1C226BAA009185B7 /* Resources */, 966F579B1C226BAA009185B7 /* Resources */,
966F57B51C226CA3009185B7 /* Embed Frameworks */, 966015DB1CB2B0BA00AAB661 /* Embed Frameworks */,
); );
buildRules = ( buildRules = (
); );
......
...@@ -64,17 +64,6 @@ class ViewController: UIViewController, TextFieldDelegate { ...@@ -64,17 +64,6 @@ class ViewController: UIViewController, TextFieldDelegate {
textField.titleLabelColor = MaterialColor.grey.base textField.titleLabelColor = MaterialColor.grey.base
textField.titleLabelActiveColor = MaterialColor.blue.accent3 textField.titleLabelActiveColor = MaterialColor.blue.accent3
let image: UIImage? = MaterialIcon.close
let clearButton: FlatButton = FlatButton()
clearButton.pulseColor = MaterialColor.grey.base
clearButton.pulseScale = false
clearButton.tintColor = MaterialColor.grey.base
clearButton.setImage(image, forState: .Normal)
clearButton.setImage(image, forState: .Highlighted)
textField.clearButton = clearButton
view.addSubview(textField) view.addSubview(textField)
} }
...@@ -102,17 +91,6 @@ class ViewController: UIViewController, TextFieldDelegate { ...@@ -102,17 +91,6 @@ class ViewController: UIViewController, TextFieldDelegate {
textField.detailLabelActiveColor = MaterialColor.red.accent3 textField.detailLabelActiveColor = MaterialColor.red.accent3
// textField.detailLabelAutoHideEnabled = false // Uncomment this line to have manual hiding. // textField.detailLabelAutoHideEnabled = false // Uncomment this line to have manual hiding.
let image: UIImage? = MaterialIcon.close
let clearButton: FlatButton = FlatButton()
clearButton.pulseColor = MaterialColor.grey.base
clearButton.pulseScale = false
clearButton.tintColor = MaterialColor.grey.base
clearButton.setImage(image, forState: .Normal)
clearButton.setImage(image, forState: .Highlighted)
textField.clearButton = clearButton
view.addSubview(textField) view.addSubview(textField)
} }
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
96E01FD61CB0474500411B61 /* Material.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96E01FD51CB0474500411B61 /* Material.framework */; };
96E01FD71CB0474500411B61 /* Material.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 96E01FD51CB0474500411B61 /* Material.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
96F2F2151C97AFC600A5FE27 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F2F20D1C97AFC600A5FE27 /* AppDelegate.swift */; }; 96F2F2151C97AFC600A5FE27 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96F2F20D1C97AFC600A5FE27 /* AppDelegate.swift */; };
96F2F2161C97AFC600A5FE27 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96F2F20E1C97AFC600A5FE27 /* Assets.xcassets */; }; 96F2F2161C97AFC600A5FE27 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 96F2F20E1C97AFC600A5FE27 /* Assets.xcassets */; };
96F2F2171C97AFC600A5FE27 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96F2F20F1C97AFC600A5FE27 /* LaunchScreen.storyboard */; }; 96F2F2171C97AFC600A5FE27 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96F2F20F1C97AFC600A5FE27 /* LaunchScreen.storyboard */; };
...@@ -23,7 +21,6 @@ ...@@ -23,7 +21,6 @@
dstPath = ""; dstPath = "";
dstSubfolderSpec = 10; dstSubfolderSpec = 10;
files = ( files = (
96E01FD71CB0474500411B61 /* Material.framework in Embed Frameworks */,
); );
name = "Embed Frameworks"; name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
...@@ -31,7 +28,6 @@ ...@@ -31,7 +28,6 @@
/* End PBXCopyFilesBuildPhase section */ /* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
96E01FD51CB0474500411B61 /* Material.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Material.framework; path = "/Users/danieldahan/Library/Developer/Xcode/DerivedData/Material-hbpnflxhoouqxebjcyhbbhqyesjd/Build/Products/Debug-iphonesimulator/Material.framework"; sourceTree = "<absolute>"; };
96F2F20D1C97AFC600A5FE27 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; }; 96F2F20D1C97AFC600A5FE27 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
96F2F20E1C97AFC600A5FE27 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; }; 96F2F20E1C97AFC600A5FE27 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
96F2F2101C97AFC600A5FE27 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; }; 96F2F2101C97AFC600A5FE27 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
...@@ -46,7 +42,6 @@ ...@@ -46,7 +42,6 @@
isa = PBXFrameworksBuildPhase; isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
96E01FD61CB0474500411B61 /* Material.framework in Frameworks */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
...@@ -69,7 +64,6 @@ ...@@ -69,7 +64,6 @@
9ABEC5081C15085400F6895E = { 9ABEC5081C15085400F6895E = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
96E01FD51CB0474500411B61 /* Material.framework */,
96F2F20C1C97AFC600A5FE27 /* Toolbar */, 96F2F20C1C97AFC600A5FE27 /* Toolbar */,
9ABEC5121C15085400F6895E /* Products */, 9ABEC5121C15085400F6895E /* Products */,
); );
......
...@@ -46,6 +46,7 @@ public struct MaterialIcon { ...@@ -46,6 +46,7 @@ public struct MaterialIcon {
public static let add: UIImage? = UIImage(named: "ic_add_white", inBundle: bundle, compatibleWithTraitCollection: nil)?.imageWithRenderingMode(.AlwaysTemplate) public static let add: UIImage? = UIImage(named: "ic_add_white", inBundle: bundle, compatibleWithTraitCollection: nil)?.imageWithRenderingMode(.AlwaysTemplate)
public static let arrowBack: UIImage? = UIImage(named: "ic_arrow_back_white", inBundle: bundle, compatibleWithTraitCollection: nil)?.imageWithRenderingMode(.AlwaysTemplate) public static let arrowBack: UIImage? = UIImage(named: "ic_arrow_back_white", inBundle: bundle, compatibleWithTraitCollection: nil)?.imageWithRenderingMode(.AlwaysTemplate)
public static let arrowDownward: UIImage? = UIImage(named: "ic_arrow_downward_white", inBundle: bundle, compatibleWithTraitCollection: nil)?.imageWithRenderingMode(.AlwaysTemplate) public static let arrowDownward: UIImage? = UIImage(named: "ic_arrow_downward_white", inBundle: bundle, compatibleWithTraitCollection: nil)?.imageWithRenderingMode(.AlwaysTemplate)
public static let bell: UIImage? = UIImage(named: "ic_bell_white", inBundle: bundle, compatibleWithTraitCollection: nil)?.imageWithRenderingMode(.AlwaysTemplate)
public static let clear: UIImage? = UIImage(named: "ic_close_white", inBundle: bundle, compatibleWithTraitCollection: nil)?.imageWithRenderingMode(.AlwaysTemplate) public static let clear: UIImage? = UIImage(named: "ic_close_white", inBundle: bundle, compatibleWithTraitCollection: nil)?.imageWithRenderingMode(.AlwaysTemplate)
public static let close: UIImage? = UIImage(named: "ic_close_white", inBundle: bundle, compatibleWithTraitCollection: nil)?.imageWithRenderingMode(.AlwaysTemplate) public static let close: UIImage? = UIImage(named: "ic_close_white", inBundle: bundle, compatibleWithTraitCollection: nil)?.imageWithRenderingMode(.AlwaysTemplate)
public static let menu: UIImage? = UIImage(named: "ic_menu_white", inBundle: bundle, compatibleWithTraitCollection: nil)?.imageWithRenderingMode(.AlwaysTemplate) public static let menu: UIImage? = UIImage(named: "ic_menu_white", inBundle: bundle, compatibleWithTraitCollection: nil)?.imageWithRenderingMode(.AlwaysTemplate)
......
...@@ -34,16 +34,6 @@ public class SearchBar : StatusBarView { ...@@ -34,16 +34,6 @@ public class SearchBar : StatusBarView {
/// The UITextField for the searchBar. /// The UITextField for the searchBar.
public private(set) lazy var textField: TextField = TextField() public private(set) lazy var textField: TextField = TextField()
/// The UIImage for the clear icon.
public var clearButton: UIButton? {
get {
return textField.clearButton
}
set(value) {
textField.clearButton = value
}
}
/// TintColor for searchBar. /// TintColor for searchBar.
@IBInspectable public override var tintColor: UIColor? { @IBInspectable public override var tintColor: UIColor? {
didSet { didSet {
......
...@@ -275,22 +275,8 @@ public class TextField : UITextField { ...@@ -275,22 +275,8 @@ public class TextField : UITextField {
} }
} }
/// The UIImage for the clear icon. /// Reference to the clearButton.
public var clearButton: UIButton? { public private(set) var clearButton: FlatButton!
didSet {
if let v: UIButton = clearButton {
clearButtonMode = .Never
rightViewMode = .WhileEditing
v.contentEdgeInsets = UIEdgeInsetsZero
v.addTarget(self, action: #selector(handleClearButton), forControlEvents: .TouchUpInside)
} else {
clearButtonMode = .WhileEditing
rightViewMode = .Never
}
rightView = clearButton
reloadView()
}
}
/// The bottom border layer. /// The bottom border layer.
public private(set) lazy var bottomBorderLayer: CAShapeLayer = CAShapeLayer() public private(set) lazy var bottomBorderLayer: CAShapeLayer = CAShapeLayer()
...@@ -301,32 +287,6 @@ public class TextField : UITextField { ...@@ -301,32 +287,6 @@ public class TextField : UITextField {
*/ */
@IBInspectable public var bottomBorderLayerDistance: CGFloat = 4 @IBInspectable public var bottomBorderLayerDistance: CGFloat = 4
/// The color of the bottomBorderLayer when the textField is not active.
@IBInspectable public var bottomBorderColor: UIColor? {
didSet {
MaterialAnimation.animationDisabled { [unowned self] in
self.bottomBorderLayer.backgroundColor = self.bottomBorderColor?.CGColor
}
}
}
/// The color of the bottomBorderLayer when the textField is active.
@IBInspectable public var bottomBorderTitleActiveColor: UIColor?
/**
The color of the bottomBorderLayer when the detailLabelHidden property is
set to false.
*/
@IBInspectable public var bottomBorderDetailActiveColor: UIColor? {
didSet {
if !detailLabelHidden {
MaterialAnimation.animationDisabled { [unowned self] in
self.bottomBorderLayer.backgroundColor = self.bottomBorderDetailActiveColor?.CGColor
}
}
}
}
/** /**
The title UILabel that is displayed when there is text. The The title UILabel that is displayed when there is text. The
titleLabel text value is updated with the placeholder text titleLabel text value is updated with the placeholder text
...@@ -343,12 +303,10 @@ public class TextField : UITextField { ...@@ -343,12 +303,10 @@ public class TextField : UITextField {
didSet { didSet {
titleLabel?.textColor = titleLabelColor titleLabel?.textColor = titleLabelColor
MaterialAnimation.animationDisabled { [unowned self] in MaterialAnimation.animationDisabled { [unowned self] in
if nil != self.bottomBorderTitleActiveColor {
self.bottomBorderLayer.backgroundColor = self.titleLabelColor?.CGColor self.bottomBorderLayer.backgroundColor = self.titleLabelColor?.CGColor
} }
} }
} }
}
/// The color of the titleLabel text when the textField is active. /// The color of the titleLabel text when the textField is active.
@IBInspectable public var titleLabelActiveColor: UIColor? @IBInspectable public var titleLabelActiveColor: UIColor?
...@@ -385,13 +343,11 @@ public class TextField : UITextField { ...@@ -385,13 +343,11 @@ public class TextField : UITextField {
if !detailLabelHidden { if !detailLabelHidden {
detailLabel?.textColor = detailLabelActiveColor detailLabel?.textColor = detailLabelActiveColor
MaterialAnimation.animationDisabled { [unowned self] in MaterialAnimation.animationDisabled { [unowned self] in
if nil != self.bottomBorderDetailActiveColor {
self.bottomBorderLayer.backgroundColor = self.detailLabelActiveColor?.CGColor self.bottomBorderLayer.backgroundColor = self.detailLabelActiveColor?.CGColor
} }
} }
} }
} }
}
/** /**
A property that sets the distance between the textField and A property that sets the distance between the textField and
...@@ -413,30 +369,13 @@ public class TextField : UITextField { ...@@ -413,30 +369,13 @@ public class TextField : UITextField {
if detailLabelHidden { if detailLabelHidden {
detailLabel?.textColor = titleLabelColor detailLabel?.textColor = titleLabelColor
MaterialAnimation.animationDisabled { [unowned self] in MaterialAnimation.animationDisabled { [unowned self] in
var activeColor: CGColor? = self.titleLabelActiveColor?.CGColor self.bottomBorderLayer.backgroundColor = self.editing ? self.titleLabelActiveColor?.CGColor : self.titleLabelColor?.CGColor
var inactiveColor: CGColor? = self.titleLabelColor?.CGColor
if let bottomBorderColor: CGColor = self.bottomBorderTitleActiveColor?.CGColor {
activeColor = bottomBorderColor
}
if let bottomBorderColor: CGColor = self.bottomBorderColor?.CGColor {
inactiveColor = bottomBorderColor
}
self.bottomBorderLayer.backgroundColor = self.editing ? activeColor : inactiveColor
} }
hideDetailLabel() hideDetailLabel()
} else { } else {
detailLabel?.textColor = detailLabelActiveColor detailLabel?.textColor = detailLabelActiveColor
MaterialAnimation.animationDisabled { [unowned self] in MaterialAnimation.animationDisabled { [unowned self] in
var activeColor: CGColor? = self.detailLabelActiveColor?.CGColor self.bottomBorderLayer.backgroundColor = self.detailLabelActiveColor?.CGColor
if let bottomBorderColor: CGColor = self.bottomBorderDetailActiveColor?.CGColor {
activeColor = bottomBorderColor
}
self.bottomBorderLayer.backgroundColor = activeColor
} }
showDetailLabel() showDetailLabel()
} }
...@@ -560,14 +499,15 @@ public class TextField : UITextField { ...@@ -560,14 +499,15 @@ public class TextField : UITextField {
public func prepareView() { public func prepareView() {
backgroundColor = MaterialColor.white backgroundColor = MaterialColor.white
masksToBounds = false masksToBounds = false
clearButtonMode = .WhileEditing
prepareBottomBorderLayer() prepareBottomBorderLayer()
prepareClearButton()
reloadView()
} }
/// Reloads the view. /// Reloads the view.
public func reloadView() { public func reloadView() {
/// Prepare the clearButton. /// Prepare the clearButton.
if let v: UIButton = clearButton { if let v: FlatButton = clearButton {
v.frame = CGRectMake(width - height, 0, height, height) v.frame = CGRectMake(width - height, 0, height, height)
} }
} }
...@@ -583,13 +523,7 @@ public class TextField : UITextField { ...@@ -583,13 +523,7 @@ public class TextField : UITextField {
if detailLabelAutoHideEnabled && !detailLabelHidden { if detailLabelAutoHideEnabled && !detailLabelHidden {
detailLabelHidden = true detailLabelHidden = true
MaterialAnimation.animationDisabled { [unowned self] in MaterialAnimation.animationDisabled { [unowned self] in
var activeColor: CGColor? = self.titleLabelActiveColor?.CGColor self.bottomBorderLayer.backgroundColor = self.titleLabelActiveColor?.CGColor
if let bottomBorderColor: CGColor = self.bottomBorderTitleActiveColor?.CGColor {
activeColor = bottomBorderColor
}
self.bottomBorderLayer.backgroundColor = activeColor
} }
} }
} }
...@@ -598,22 +532,10 @@ public class TextField : UITextField { ...@@ -598,22 +532,10 @@ public class TextField : UITextField {
internal func textFieldDidBegin() { internal func textFieldDidBegin() {
titleLabel?.textColor = titleLabelActiveColor titleLabel?.textColor = titleLabelActiveColor
MaterialAnimation.animationDisabled { [unowned self] in MaterialAnimation.animationDisabled { [unowned self] in
var titleActiveColor: CGColor? = self.titleLabelActiveColor?.CGColor self.bottomBorderLayer.backgroundColor = self.detailLabelHidden ? self.titleLabelActiveColor?.CGColor : self.detailLabelActiveColor?.CGColor
var detailActiveColor: CGColor? = self.detailLabelActiveColor?.CGColor
if let bottomBorderColor: CGColor = self.bottomBorderTitleActiveColor?.CGColor {
titleActiveColor = bottomBorderColor
}
if let bottomBorderColor: CGColor = self.bottomBorderDetailActiveColor?.CGColor {
detailActiveColor = bottomBorderColor
}
self.bottomBorderLayer.backgroundColor = self.detailLabelHidden ? titleActiveColor : detailActiveColor
} }
} }
/// Handler for text changed. /// Handler for text changed.
internal func textFieldDidChange() { internal func textFieldDidChange() {
if 0 < text?.utf16.count { if 0 < text?.utf16.count {
...@@ -633,18 +555,7 @@ public class TextField : UITextField { ...@@ -633,18 +555,7 @@ public class TextField : UITextField {
} }
titleLabel?.textColor = titleLabelColor titleLabel?.textColor = titleLabelColor
MaterialAnimation.animationDisabled { [unowned self] in MaterialAnimation.animationDisabled { [unowned self] in
var borderColor: CGColor? = self.titleLabelColor?.CGColor self.bottomBorderLayer.backgroundColor = self.detailLabelHidden ? self.titleLabelColor?.CGColor : self.detailLabelActiveColor?.CGColor
var detailActiveColor: CGColor? = self.detailLabelActiveColor?.CGColor
if let bottomBorderColor: CGColor = self.bottomBorderColor?.CGColor {
borderColor = bottomBorderColor
}
if let bottomBorderColor: CGColor = self.bottomBorderDetailActiveColor?.CGColor {
detailActiveColor = bottomBorderColor
}
self.bottomBorderLayer.backgroundColor = self.detailLabelHidden ? borderColor : detailActiveColor
} }
} }
...@@ -681,9 +592,9 @@ public class TextField : UITextField { ...@@ -681,9 +592,9 @@ public class TextField : UITextField {
} else { } else {
v.alpha = 0 v.alpha = 0
} }
addTarget(self, action: #selector(textFieldDidBegin), forControlEvents: .EditingDidBegin) addTarget(self, action: "textFieldDidBegin", forControlEvents: .EditingDidBegin)
addTarget(self, action: #selector(textFieldDidChange), forControlEvents: .EditingChanged) addTarget(self, action: "textFieldDidChange", forControlEvents: .EditingChanged)
addTarget(self, action: #selector(textFieldDidEnd), forControlEvents: .EditingDidEnd) addTarget(self, action: "textFieldDidEnd", forControlEvents: .EditingDidEnd)
} }
} }
...@@ -698,11 +609,11 @@ public class TextField : UITextField { ...@@ -698,11 +609,11 @@ public class TextField : UITextField {
showDetailLabel() showDetailLabel()
} }
if nil == titleLabel { if nil == titleLabel {
addTarget(self, action: #selector(textFieldDidBegin), forControlEvents: .EditingDidBegin) addTarget(self, action: "textFieldDidBegin", forControlEvents: .EditingDidBegin)
addTarget(self, action: #selector(textFieldDidChange), forControlEvents: .EditingChanged) addTarget(self, action: "textFieldDidChange", forControlEvents: .EditingChanged)
addTarget(self, action: #selector(textFieldDidEnd), forControlEvents: .EditingDidEnd) addTarget(self, action: "textFieldDidEnd", forControlEvents: .EditingDidEnd)
} }
addTarget(self, action: #selector(textFieldValueChanged), forControlEvents: .ValueChanged) addTarget(self, action: "textFieldValueChanged", forControlEvents: .ValueChanged)
} }
} }
...@@ -711,6 +622,22 @@ public class TextField : UITextField { ...@@ -711,6 +622,22 @@ public class TextField : UITextField {
layer.addSublayer(bottomBorderLayer) layer.addSublayer(bottomBorderLayer)
} }
/// Prepares the clearButton.
private func prepareClearButton() {
let image: UIImage? = MaterialIcon.close
clearButton = FlatButton()
clearButton.contentEdgeInsets = UIEdgeInsetsZero
clearButton.pulseColor = MaterialColor.grey.base
clearButton.pulseScale = false
clearButton.tintColor = MaterialColor.grey.base
clearButton.setImage(image, forState: .Normal)
clearButton.setImage(image, forState: .Highlighted)
clearButton.addTarget(self, action: "handleClearButton", forControlEvents: .TouchUpInside)
clearButtonMode = .Never
rightViewMode = .WhileEditing
rightView = clearButton
}
/// Shows and animates the titleLabel property. /// Shows and animates the titleLabel property.
private func showTitleLabel() { private func showTitleLabel() {
if let v: UILabel = titleLabel { if let v: UILabel = titleLabel {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment