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

[NT-995] Settings account header for Apple users #1160

Merged
merged 13 commits into from
Apr 17, 2020

Conversation

ifbarrera
Copy link
Contributor

@ifbarrera ifbarrera commented Apr 14, 2020

📲 What

Adds a header to the Settings account screen for Apple connected users, and hides the Change Password and Change Email functionality.

🤔 Why

Apple connected users will not be able to change their Kickstarter email, and they will not have a password. We want to prevent these users from accessing these features.

🛠 How

  • added SettingsAccountHeader that displays the user's email and some messaging about how to update their Apple account
  • updated the logic that hides the change email/password section to hide it for apple connected users
  • renamed UserCurrency.swift to GraphUser.swift and added tests
  • added isAppleConnected to the User schema, and updated the account query to include the isAppleConnected field
  • fixed a .combineLatest bug where the reloadData output was firing multiple times after the first load.
  • added a bunch of missing VM tests

👀 See

Trello, screenshots, external resources?

iPhone 8 iPad
Simulator Screen Shot - iPhone 8 - 2020-04-13 at 16 03 58 Simulator Screen Shot - iPad Pro (9 7-inch) - 2020-04-14 at 10 33 20

♿️ Accessibility

  • Tap targets use minimum of 44x44 pts dimensions
  • Works with VoiceOver
  • Supports Dynamic Type

✅ Acceptance criteria

Using Charles Proxy, enable breakpoints to intercept the response from the GraphQL endpoint. Modify your payload by setting isAppleConnected to true, to see the Apple-connected user treatment.

  • Navigate to the account section, and modify your response payload by setting isAppleConnected to true. You should see the new Apple header displaying your email.

⏰ TODO

  • update strings

self.vm.inputs.viewWillAppear()
self.reloadDataShouldHideWarningIcon.assertValueCount(1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This wasn't even testing the thing that the test name says it's testing 😢

self.vm.inputs.viewWillAppear()
self.reloadDataShouldHideWarningIcon.assertValueCount(1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was also not even testing what the value of reloadDataShouldHideWarningIcon was, which meant it could have been the opposite of what was expected and this test would have passed :\

Copy link
Contributor

Choose a reason for hiding this comment

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

🙈

@@ -15,3 +15,14 @@ public func ksr_setCustomSpacing(_ spacing: CGFloat) -> ((UIView, UIStackView) -
return stackView
}
}

public func ksr_setBackgroundColor(_ color: UIColor) -> ((UIStackView) -> (UIStackView)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

✨ new ✨ so that we can set a background color on UIStackViews

Copy link
Contributor

Choose a reason for hiding this comment

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

Handy as this may be 😄 If we're calling this in bindStyles() we may end up with many background views? 🤔 I would suggest this as an extension on UIStackView with an associated object to track any existing background views perhaps and, if one exists, just update its backgroundColor. Another fairly rudimentary way could be to use UIView's tag property and just set some sentinel value that you can check for.

Calling it again in the test shows that it's not idempotent:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh good catch!

@nativeksr
Copy link
Collaborator

1 Warning
⚠️ Big PR

Generated by 🚫 Danger

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.

Looks good! had some thoughts/questions.

@@ -9,11 +9,17 @@ final class SettingsAccountDataSource: ValueCellDataSource {
func configureRows(
Copy link
Contributor

@justinswart justinswart Apr 14, 2020

Choose a reason for hiding this comment

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

Seems like this can rather be a single type SettingsAccountRowData which should make it easier to modify when needed. Perhaps not as part of this PR 🤷‍♂️

private lazy var emailLabel = { UILabel(frame: .zero) }()
private lazy var manageThisAccountLabel = {
UILabel(frame: .zero)
|> UILabel.lens.translatesAutoresizingMaskIntoConstraints .~ false
Copy link
Contributor

Choose a reason for hiding this comment

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

Worth noting that our constraint helper functions automatically set this and it's also redundant when a view is added to a stackview.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So actually this label is not constrained using our helper functions, nor added to a stack view, which is why it needs this to be set.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah apologies!

|> UILabel.lens.translatesAutoresizingMaskIntoConstraints .~ false
}()

private lazy var stackView = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Think we've mostly standardized on rootStackView for the top-most stack.

}
"""

guard let data = jsonString.data(using: .utf8) else {
Copy link
Contributor

Choose a reason for hiding this comment

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

Saves a guard statement if we use the non-failable Data initializer:

let data = Data(jsonString.utf8)

@@ -15,3 +15,14 @@ public func ksr_setCustomSpacing(_ spacing: CGFloat) -> ((UIView, UIStackView) -
return stackView
}
}

public func ksr_setBackgroundColor(_ color: UIColor) -> ((UIStackView) -> (UIStackView)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Handy as this may be 😄 If we're calling this in bindStyles() we may end up with many background views? 🤔 I would suggest this as an extension on UIStackView with an associated object to track any existing background views perhaps and, if one exists, just update its backgroundColor. Another fairly rudimentary way could be to use UIView's tag property and just set some sentinel value that you can check for.

Calling it again in the test shows that it's not idempotent:

image

label
|> settingsDescriptionLabelStyle
|> \.text %~ { _ in localizedString(
key: "manage_this_account",
Copy link
Contributor

Choose a reason for hiding this comment

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

Here too. Not sure if these are legacy.

@@ -2,6 +2,11 @@ import KsApi
import Prelude
import ReactiveSwift

public typealias SettingsAccountData = (
currency: Currency, email: String,
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we put each label on new line?

return true
}

guard let isEmailVerified = user.isEmailVerified,
Copy link
Contributor

@justinswart justinswart Apr 15, 2020

Choose a reason for hiding this comment

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

For your consideration:

if [user.isEmailVerified, user.isDeliverable]
  .map({ $0 ?? false })
  .allSatisfy(isTrue) {
  return true
}

Not sure how much it really adds for readability, just less guard lets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm yeah I'm not sure the extra mental overhead is worth it here 😅

self.vm.inputs.viewWillAppear()
self.reloadDataShouldHideWarningIcon.assertValueCount(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

🙈

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.

🚢

@ifbarrera ifbarrera merged commit a95db3d into master Apr 17, 2020
@ifbarrera ifbarrera deleted the NT-995-apple-account-header branch April 17, 2020 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants