-
Notifications
You must be signed in to change notification settings - Fork 126
AnimatedTextInputFieldConfigurator -> added 'email' text input type & ability to change password type with or without disclosure #22
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,9 @@ public struct AnimatedTextInputFieldConfigurator { | |
|
|
||
| public enum AnimatedTextInputType { | ||
| case standard | ||
| case password | ||
| case passwordWithDisclosure | ||
| case passwordWithoutDisclosure | ||
| case email | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update your branch, there is an email case already in 0.4 |
||
| case numeric | ||
| case selection | ||
| case multiline | ||
|
|
@@ -15,8 +17,12 @@ public struct AnimatedTextInputFieldConfigurator { | |
| switch type { | ||
| case .standard: | ||
| return AnimatedTextInputTextConfigurator.generate() | ||
| case .password: | ||
| return AnimatedTextInputPasswordConfigurator.generate() | ||
| case .passwordWithDisclosure: | ||
| return AnimatedTextInputPasswordConfigurator.generateWithDisclosure(true) | ||
| case .passwordWithoutDisclosure: | ||
| return AnimatedTextInputPasswordConfigurator.generateWithDisclosure(false) | ||
| case .email: | ||
| return AnimatedTextInputEmailConfigurator.generate() | ||
| case .numeric: | ||
| return AnimatedTextInputNumericConfigurator.generate() | ||
| case .selection: | ||
|
|
@@ -38,25 +44,41 @@ private struct AnimatedTextInputTextConfigurator { | |
| } | ||
| } | ||
|
|
||
| private struct AnimatedTextInputEmailConfigurator { | ||
|
|
||
| static func generate() -> TextInput { | ||
| let textField = AnimatedTextField() | ||
| textField.keyboardType = .EmailAddress | ||
| textField.clearButtonMode = .WhileEditing | ||
| textField.autocapitalizationType = .None | ||
| textField.spellCheckingType = .No | ||
| textField.autocorrectionType = .No | ||
|
|
||
| return textField | ||
| } | ||
| } | ||
|
|
||
| private struct AnimatedTextInputPasswordConfigurator { | ||
|
|
||
| static func generate() -> TextInput { | ||
| static func generateWithDisclosure(visible: Bool = false) -> TextInput { | ||
| let textField = AnimatedTextField() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the default for visibility is false, you could call this as
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, but this configurator is private, so i don't think it's a big problem. Whatever it was this types was helpful in my product, suddenly someone else come in handy. |
||
| textField.rightViewMode = .WhileEditing | ||
| textField.secureTextEntry = true | ||
| let disclosureButton = UIButton(type: .Custom) | ||
| disclosureButton.frame = CGRect(origin: CGPoint.zero, size: CGSize(width: 20, height: 20)) | ||
| let bundle = NSBundle(path: NSBundle(forClass: AnimatedTextInput.self).pathForResource("AnimatedTextInput", ofType: "bundle")!) | ||
| let normalImage = UIImage(named: "cm_icon_input_eye_normal", inBundle: bundle, compatibleWithTraitCollection: nil) | ||
| let selectedImage = UIImage(named: "cm_icon_input_eye_selected", inBundle: bundle, compatibleWithTraitCollection: nil) | ||
| disclosureButton.setImage(normalImage, forState: .Normal) | ||
| disclosureButton.setImage(selectedImage, forState: .Selected) | ||
| textField.add(disclosureButton: disclosureButton) { | ||
| disclosureButton.selected = !disclosureButton.selected | ||
| textField.resignFirstResponder() | ||
| textField.secureTextEntry = !textField.secureTextEntry | ||
| textField.becomeFirstResponder() | ||
| if visible { | ||
| let disclosureButton = UIButton(type: .Custom) | ||
| disclosureButton.frame = CGRect(origin: CGPoint.zero, size: CGSize(width: 20, height: 20)) | ||
| let normalImage = UIImage(named: "cm_icon_input_eye_normal") | ||
| let selectedImage = UIImage(named: "cm_icon_input_eye_selected") | ||
| disclosureButton.setImage(normalImage, forState: .Normal) | ||
| disclosureButton.setImage(selectedImage, forState: .Selected) | ||
| textField.add(disclosureButton: disclosureButton) { | ||
| disclosureButton.selected = !disclosureButton.selected | ||
| textField.resignFirstResponder() | ||
| textField.secureTextEntry = !textField.secureTextEntry | ||
| textField.becomeFirstResponder() | ||
| } | ||
| } | ||
|
|
||
| return textField | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like to have the
passwordWithoutDisclosurecase, but leavepasswordas it was so we do not modify existing api