Skip to content
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

Add traitCollection input to LoginVM #959

Merged
merged 6 commits into from
Nov 23, 2019
Merged

Add traitCollection input to LoginVM #959

merged 6 commits into from
Nov 23, 2019

Conversation

robjaq
Copy link
Contributor

@robjaq robjaq commented Nov 20, 2019

Wazzzzzzaaaap! :P Here is a proposed solution.

📲 What

Issue #949

🤔 Why

Eye icon and secure text loses its style during orientation change.

🛠 How

Add a trait collection input to the LoginViewModel and fire an event from the LoginVC for a trait collection change.

👀 See

Issue #949

Copy link
Contributor

@justinswart justinswart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there @robjaq, thanks for your contribution! I hope you've found the codebase interesting to explore.

I've made some suggestions below and I will also look into the one failing job on our CircleCI, it looks like there is an environment variable missing in our configuration for builds running on forks.

@@ -42,6 +42,9 @@ public protocol LoginViewModelInputs {

/// Call when the view will appear.
func viewWillAppear()

/// Call when a trait collection is applied.
func traitCollectionApplied()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually like to keep the input names as close as possible to the way it's named outside of the view model, so in this case it would be:

You can rename the input along with its backed properties, etc.

/// Call when a trait collection did change.
func traitCollectionDidChange()

@@ -171,7 +174,10 @@ public final class LoginViewModel: LoginViewModelType, LoginViewModelInputs, Log
self.logIntoEnvironment
.observeValues { _ in AppEnvironment.current.koala.trackLoginSuccess(authType: Koala.AuthType.email) }

self.showHidePasswordButtonToggled = self.shouldShowPasswordProperty.signal
self.showHidePasswordButtonToggled = Signal.combineLatest(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case let's consider what we're wanting to express with the Signal. We're saying:

  1. Emit showHidePasswordButtonToggled when shouldShowPasswordProperty emits its value.
  2. Also emit that same value when traitCollectionDidChange emits.

So by using comineLatest here, we're requiring that both of the signals emit in order for showHidePasswordButtonToggled to emit, which isn't really necessary. Instead I think what we want is to merge like this:

let shouldShowPassword = self.shouldShowPasswordProperty.signal

self.showHidePasswordButtonToggled = Signal.merge(
  shouldShowPassword,
  shouldShowPassword.takeWhen(self.traitCollectionDidChangeProperty.signal)
)

This captures it a little more clearly by saying that we want to take the value of shouldShowPassword when self.traitCollectionDidChangeProperty.signal emits.

@@ -314,6 +314,7 @@ final class LoginViewModelTests: TestCase {
func testShowPassword() {
self.vm.inputs.viewWillAppear()
self.vm.inputs.viewDidLoad()
self.vm.inputs.traitCollectionApplied()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After you make the previous change I suggested then you won't need this in this particular test because we will have changed the combineLatest to a merge.

Please add an additional test which tests the traitCollectionDidChange input.

@justinswart
Copy link
Contributor

@robjaq thanks for addressing that feedback. I have opened another PR #964 which, once we've merged into this one, should hopefully get all of our workflows passing on your branch.

In the mean time, please run bin/format.sh . in the project root, that will format your code according to our formatting rules. It should just strip out some whitespace and move some parentheses around.

@robjaq
Copy link
Contributor Author

robjaq commented Nov 22, 2019

👌

@justinswart
Copy link
Contributor

@robjaq hey, please pull the latest from master and update your fork, i think that should get all of the jobs passing.

Copy link
Contributor

@justinswart justinswart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing! Feel free to merge 👍

Please use squash and merge :)

@robjaq
Copy link
Contributor Author

robjaq commented Nov 23, 2019

THat is the weekend!
yeahdawg
lol seriously no prob and thank you for the feedback and insight!

@justinswart Also feel free to merge it, since I do not have write access

@justinswart justinswart merged commit 12a5f50 into kickstarter:master Nov 23, 2019
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