Commit 7c2198ec by Daniel Dahan

development: progression with TextField

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