-
Notifications
You must be signed in to change notification settings - Fork 0
Text field refactor/richie #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
vinnie4k
left a comment
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 just glanced over it but make sure you change [self] to [unowned self] to prevent memory leaks when using a reference of self inside of a closure. Otherwise good to go.
| setupTitle(name: "About you") | ||
|
|
||
| nextAction = UIAction { _ in | ||
| nextAction = UIAction { [self] _ in |
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.
Change [self] to [unowned self]
|
|
||
| return | ||
| } | ||
| nextAction = UIAction { [self] _ in |
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.
Change [self] to [unowned self]
|
|
||
| guard let phoneNumber = self.numberTextField.textField.text, self.validateNumber(value: phoneNumber) else { | ||
| self.presentErrorAlert(title: "Error", message: "Please enter a valid phone number.") | ||
| self.numberTextField.displayError() |
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.
Make sure you retain an [unowned self]
| // MARK: Using OnboardingViewController's views | ||
|
|
||
| nextAction = UIAction { _ in | ||
| nextAction = UIAction { [self] _ in |
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.
Change to [unowned self]
| guard let arrival = arrivalTextField.textField.text, !arrival.isEmpty, | ||
| let departure = departureTextField.textField.text, !departure.isEmpty, | ||
| studentDriverButton.isSelected || taxiButton.isSelected | ||
| else { return } |
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.
Put else on the line above
|
|
||
| func textFieldShouldReturn(_ textField: UITextField) -> Bool { | ||
| textField.endEditing(true) | ||
| } |
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.
New line below
| text = placeholder | ||
| } | ||
|
|
||
| if let error = error { |
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.
if let error {
tiffany-pann
left a comment
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.
Very very nice ( •̀ ω •́ )✧
| func setup(title: String, placeholder: String? = nil) { | ||
| func setup(title: String, placeholder: String? = nil, error: String? = nil) { | ||
| var text = title | ||
| var errorText = "Please complete this field." |
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.
let errorText =
Overview
Changes Made
LabeledTextField Added Finite States: (View FSM Below)
a. Has Text: Show label in black, border is black color and border width 1px
b. No Text: Show label in mutedGrey, border is mutedGrey color and displays placeholder text, border width 1px
Refactored and updated interactivity for textFields in the following VCs
Screenshots (delete if not applicable)
Error States:

