Commit 7c2198ec by Daniel Dahan

development: progression with TextField

parent dfcc3fbd
...@@ -107,6 +107,7 @@ ...@@ -107,6 +107,7 @@
TargetAttributes = { TargetAttributes = {
96090AE31D9CDD2E00709CA6 = { 96090AE31D9CDD2E00709CA6 = {
CreatedOnToolsVersion = 8.0; CreatedOnToolsVersion = 8.0;
DevelopmentTeam = 9Z76XCNLGL;
ProvisioningStyle = Automatic; ProvisioningStyle = Automatic;
}; };
}; };
...@@ -262,7 +263,7 @@ ...@@ -262,7 +263,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = 9Z76XCNLGL;
INFOPLIST_FILE = TextField/Info.plist; INFOPLIST_FILE = TextField/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = io.cosmicmind.TextField; PRODUCT_BUNDLE_IDENTIFIER = io.cosmicmind.TextField;
...@@ -275,7 +276,7 @@ ...@@ -275,7 +276,7 @@
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = 9Z76XCNLGL;
INFOPLIST_FILE = TextField/Info.plist; INFOPLIST_FILE = TextField/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = io.cosmicmind.TextField; PRODUCT_BUNDLE_IDENTIFIER = io.cosmicmind.TextField;
......
...@@ -40,9 +40,9 @@ class ViewController: UIViewController { ...@@ -40,9 +40,9 @@ class ViewController: UIViewController {
super.viewDidLoad() super.viewDidLoad()
view.backgroundColor = .white view.backgroundColor = .white
// prepareNameField() prepareNameField()
prepareEmailField() prepareEmailField()
// preparePasswordField() preparePasswordField()
prepareResignResponderButton() prepareResignResponderButton()
} }
...@@ -68,36 +68,39 @@ class ViewController: UIViewController { ...@@ -68,36 +68,39 @@ class ViewController: UIViewController {
} }
private func prepareNameField() { private func prepareNameField() {
let d: CGFloat = 40 let d: CGFloat = 32
nameField = TextField() nameField = TextField()
nameField.text = "Daniel Dahan" nameField.text = "Daniel Dahan"
nameField.placeholder = "Name" nameField.placeholder = "Name"
nameField.detail = "Your given name" nameField.detailLabel.text = "Your given name"
nameField.textAlignment = .center nameField.textAlignment = .center
nameField.clearButtonMode = .whileEditing nameField.clearButtonMode = .whileEditing
// Size the TextField to the maximum width, less 40 pixels on either side let leftView = UIImageView()
// with a top margin of 40 pixels. leftView.image = Icon.email?.tint(with: Color.cyan.base)
view.layout(nameField).top(d).horizontally(left: d, right: d)
nameField.leftView = leftView
nameField.leftViewMode = .always
view.layout(nameField).top(100).horizontally(left: d, right: d).height(d)
} }
private func prepareEmailField() { private func prepareEmailField() {
let d: CGFloat = 32 let d: CGFloat = 32
let leftView = UIImageView(frame: CGRect(x: 0, y: 0, width: d, height: d)) emailField = ErrorTextField(frame: CGRect(x: d, y: 200, width: view.width - (2 * d), height: d))
leftView.image = Icon.email?.tint(with: Color.cyan.base) emailField.placeholderLabel.text = "Email"
leftView.contentMode = .center emailField.detailLabel.text = "Error, incorrect email"
emailField = ErrorTextField(frame: CGRect(x: 40, y: 120, width: view.width - 80, height: d))
emailField.placeholder = "Email"
emailField.detail = "Error, incorrect email"
emailField.isClearIconButtonEnabled = true emailField.isClearIconButtonEnabled = true
emailField.delegate = self emailField.delegate = self
let leftView = UIImageView()
leftView.image = Icon.email?.tint(with: Color.cyan.base)
emailField.leftView = leftView emailField.leftView = leftView
emailField.leftViewMode = .always emailField.leftViewMode = .always
emailField.divider.contentEdgeInsets.left = d
// emailField.placeholderNormalColor = Color.amber.darken4 // emailField.placeholderNormalColor = Color.amber.darken4
// emailField.placeholderActiveColor = Color.pink.base // emailField.placeholderActiveColor = Color.pink.base
...@@ -107,20 +110,24 @@ class ViewController: UIViewController { ...@@ -107,20 +110,24 @@ class ViewController: UIViewController {
} }
private func preparePasswordField() { private func preparePasswordField() {
let d: CGFloat = 40 let d: CGFloat = 32
passwordField = TextField() passwordField = TextField()
passwordField.placeholder = "Password" passwordField.placeholderLabel.text = "Password"
passwordField.detail = "At least 8 characters" passwordField.detailLabel.text = "At least 8 characters"
passwordField.clearButtonMode = .whileEditing passwordField.clearButtonMode = .whileEditing
passwordField.isVisibilityIconButtonEnabled = true passwordField.isVisibilityIconButtonEnabled = true
let leftView = UIImageView()
leftView.image = Icon.email?.tint(with: Color.cyan.base)
passwordField.leftView = leftView
passwordField.leftViewMode = .always
// Setting the visibilityIconButton color. // Setting the visibilityIconButton color.
passwordField.visibilityIconButton?.tintColor = Color.green.base.withAlphaComponent(passwordField.isSecureTextEntry ? 0.38 : 0.54) passwordField.visibilityIconButton?.tintColor = Color.green.base.withAlphaComponent(passwordField.isSecureTextEntry ? 0.38 : 0.54)
// Size the TextField to the maximum width, less 40 pixels on either side view.layout(passwordField).top(300).horizontally(left: d, right: d).height(d)
// with a top margin of 200 pixels.
view.layout(passwordField).top(200).horizontally(left: d, right: d)
} }
} }
......
...@@ -42,6 +42,15 @@ public protocol SearchBarDelegate { ...@@ -42,6 +42,15 @@ public protocol SearchBarDelegate {
optional func searchBar(searchBar: SearchBar, didChange textField: UITextField, with text: String?) optional func searchBar(searchBar: SearchBar, didChange textField: UITextField, with text: String?)
/** /**
A delegation method that is executed when the textField will clear.
- Parameter searchBar: A SearchBar.
- Parameter willClear textField: A UITextField.
- Parameter with text: An optional String.
*/
@objc
optional func searchBar(searchBar: SearchBar, willClear textField: UITextField, with text: String?)
/**
A delegation method that is executed when the textField is cleared. A delegation method that is executed when the textField is cleared.
- Parameter searchBar: A SearchBar. - Parameter searchBar: A SearchBar.
- Parameter didClear textField: A UITextField. - Parameter didClear textField: A UITextField.
...@@ -175,8 +184,13 @@ open class SearchBar: Bar { ...@@ -175,8 +184,13 @@ open class SearchBar: Bar {
/// Clears the textField text. /// Clears the textField text.
@objc @objc
internal func handleClearButton() { internal func handleClearButton() {
delegate?.searchBar?(searchBar: self, didClear: textField, with: textField.text) let text = textField.text
delegate?.searchBar?(searchBar: self, willClear: textField, with: text)
textField.text = nil textField.text = nil
delegate?.searchBar?(searchBar: self, didClear: textField, with: text)
} }
// Live updates the search results. // Live updates the search results.
......
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