-
Notifications
You must be signed in to change notification settings - Fork 132
sprint #145
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: master
Are you sure you want to change the base?
sprint #145
Conversation
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 nice job on this sprint challenge, Ben! Your code was set up nice and clean, you constrained things well, functions were named great, and everything worked perfectly. While you didn't incorporate any stretch goals, I believe the quality of your code warrants a 3. Well done.
setupTitleLabel() | ||
setupTextField() | ||
setupPasswordStrengthViews() |
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 that you broke this out into smaller functions.
private func determineStrength(for password: String) { | ||
var newStrength: PasswordStrength | ||
|
||
switch password.count { | ||
case 0...5: | ||
newStrength = PasswordStrength.weak | ||
case 6...9: | ||
newStrength = PasswordStrength.medium | ||
default: | ||
newStrength = PasswordStrength.strong | ||
} | ||
|
||
if passwordStrength != newStrength { | ||
updatePasswordStrength(to: newStrength) | ||
} | ||
} | ||
|
||
private func updatePasswordStrength(to newStrength: PasswordStrength) { | ||
passwordStrength = newStrength | ||
strengthDescriptionLabel.text = passwordStrength.rawValue | ||
|
||
switch passwordStrength { | ||
case .weak: | ||
weakView.backgroundColor = weakColor | ||
mediumView.backgroundColor = unusedColor | ||
strongView.backgroundColor = unusedColor | ||
weakView.performFlare() | ||
case .medium: | ||
weakView.backgroundColor = weakColor | ||
mediumView.backgroundColor = mediumColor | ||
strongView.backgroundColor = unusedColor | ||
mediumView.performFlare() | ||
case .strong: | ||
weakView.backgroundColor = weakColor | ||
mediumView.backgroundColor = mediumColor | ||
strongView.backgroundColor = strongColor | ||
strongView.performFlare() | ||
} | ||
} |
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 that you separated out checking the strength and updating the ui into two functions.
private var passwordFieldStackView: UIStackView = UIStackView() | ||
private var passwordStrengthStackView: UIStackView = UIStackView() | ||
private var strengthColorsStackView: UIStackView = UIStackView() |
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.
Smart choice using stack views.
@swift-student