Skip to content

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

ben-e-james
Copy link

Copy link

@swift-student swift-student left a 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.

Comment on lines +68 to +70
setupTitleLabel()
setupTextField()
setupPasswordStrengthViews()

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.

Comment on lines +175 to +213
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()
}
}

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.

Comment on lines +50 to +52
private var passwordFieldStackView: UIStackView = UIStackView()
private var passwordStrengthStackView: UIStackView = UIStackView()
private var strengthColorsStackView: UIStackView = UIStackView()

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants