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-262] Remember this card UI #848

Merged
merged 8 commits into from
Sep 24, 2019
Merged

[NT-262] Remember this card UI #848

merged 8 commits into from
Sep 24, 2019

Conversation

justinswart
Copy link
Contributor

@justinswart justinswart commented Sep 20, 2019

πŸ“² What

Adds a Remember this card switch to AddNewCardViewController when being presented from PledgeViewController.

Note: VM binding and GraphQL requests will be added in upcoming PR.

πŸ€” Why

This allows the user to indicate that a card used during checkout should be stored for future backings.

πŸ›  How

  • Added AddNewCardIntent.
  • Show and hide the reusable card switch based on this value.

πŸ‘€ See

Settings PledgeViewController
image image

♿️ Accessibility

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

βœ… Acceptance criteria

  • Switch is shown when AddNewCardViewController is presented from PledgeViewController.
  • Switch is hidden when AddNewCardViewController is presented from Settings.

⏰ TODO

  • VM bindings and GraphQL mutations in upcoming PR.

Copy link
Contributor

@dusi dusi 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 couple comments and noticed that Dynamic Type isn't supported ... I remember us chatting about it offline. One suggestion that maybe we should consider ... I've been working on ToggleViewController that would be easily reused here + it supports Dynamic Type.

@@ -22,6 +22,10 @@ internal final class AddNewCardViewController: UIViewController,
@IBOutlet private var creditCardTextField: STPPaymentCardTextField!
@IBOutlet private var creditCardValidationErrorLabel: UILabel!
@IBOutlet private var creditCardValidationErrorContainer: UIView!
@IBOutlet private var reusableCardStackViewContainer: UIView!
Copy link
Contributor

Choose a reason for hiding this comment

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

Ooooh, good old storyboard thingys 🍿

|> \.alignment .~ .center

_ = self.reusableCardSwitch
|> baseSwitchControlStyle
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally we would only have 1 accessible element (the toggle - whose focus area would be the whole cell) but because we're faking a table view cell here we don't get that functionality...so because of that I think we should also add VoiceOver label on the switch that will simply duplicate the label but since it's a UISwitch it will also use double tap to toggle hint by default.

Suggested change
|> baseSwitchControlStyle
|> baseSwitchControlStyle
|> \.accessibilityLabel %~ { _ in Strings.Remember_this_card() }

(not sure if this will pass SwiftFormat)

Copy link
Contributor

Choose a reason for hiding this comment

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

Also note that there seems to be an issue with UISwitch and right alignment..I've ran into it in my PR - #850

Basically even if you align right edges the switch still overlaps a little. Checked this out in view inspector.

Screen Shot 2019-09-23 at 11 09 36 AM

Basically what helped was to align left edge of the switch to the right edge of superview minus the switch width.

}

override func bindViewModel() {
super.bindViewModel()

self.reusableCardStackViewContainer.rac.hidden = self.viewModel.outputs.reusableCardSwitchIsHidden
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we order this alphabetically (so before the saveButtonIsEnabled signal)?

import Foundation

public enum AddNewCardIntent: Equatable {
case pledgeView
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we even need the View suffix? Simply just pledge πŸ€”

@@ -36,6 +37,7 @@ public protocol AddNewCardViewModelOutputs {
var dismissKeyboard: Signal<Void, Never> { get }
var paymentDetails: Signal<PaymentDetails, Never> { get }
var paymentDetailsBecomeFirstResponder: Signal<Void, Never> { get }
var reusableCardSwitchIsHidden: Signal<Bool, Never> { get }
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this name not match reusableCardStackViewContainer intentionally for it being too long?

Copy link
Contributor

@cdolm92 cdolm92 left a comment

Choose a reason for hiding this comment

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

Awesome job on this! Left minor comments on alphabetizing, this PR meets all required ACs, you can merge after taking @dusi's suggestions :) πŸ›³πŸ›³πŸ›³

@@ -22,6 +22,10 @@ internal final class AddNewCardViewController: UIViewController,
@IBOutlet private var creditCardTextField: STPPaymentCardTextField!
@IBOutlet private var creditCardValidationErrorLabel: UILabel!
@IBOutlet private var creditCardValidationErrorContainer: UIView!
Copy link
Contributor

Choose a reason for hiding this comment

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

alphabetize

@@ -23,7 +23,7 @@ internal final class PaymentMethodsViewModelTests: TestCase {

self.vm.outputs.editButtonIsEnabled.observe(self.editButtonIsEnabled.observer)
self.vm.outputs.editButtonTitle.observe(self.editButtonTitle.observer)
self.vm.outputs.goToAddCardScreen.observe(self.goToAddCardScreen.observer)
self.vm.outputs.goToAddCardScreenWithIntent.observe(self.goToAddCardScreenWithIntent.observer)
Copy link
Contributor

Choose a reason for hiding this comment

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

alphabetize

@justinswart justinswart merged commit 2d9d475 into master Sep 24, 2019
@justinswart justinswart deleted the remember_this_card_ui branch September 24, 2019 16:55
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.

None yet

3 participants