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-303] Pledge Button #847

Merged
merged 8 commits into from
Sep 23, 2019
Merged

[NT-303] Pledge Button #847

merged 8 commits into from
Sep 23, 2019

Conversation

ifbarrera
Copy link
Contributor

@ifbarrera ifbarrera commented Sep 19, 2019

📲 What

Adds a Pledge button below the list of stored payment methods. This button is initially disabled until the user selects a credit card. Once a card is selected, the button becomes enabled.

🤔 Why

To allow users to pledge, and to simplify the pledging experience.

🛠 How

Some things to keep in mind:

  • right now the experience is a bit jarring because the credit cards load in dynamically. This will be fixed with a loading state for the stored cards in a subsequent PR.
  • right now the pledge button is initially disabled until a card is selected. A future PR will address this and automatically select the first card in the list.
  • right now tapping Select on any of the cards will enable the Pledge button even though the card's selected state doesn't change. This is because toggling the card view's selected state is currently being worked on separately as part of another ticket

👀 See

8UpWVPUsVP

♿️ Accessibility

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

✅ Acceptance criteria

  • Signed in, with the Native Pledge Screen feature flag turned ON, navigate to any project and select any reward. Scroll down and you should see the Pledge button below the list of stored cards, and it should be disabled. Tap Select on any of the stored cards - the Pledge button should become enabled.


@objc private func applePayButtonTapped() {
self.viewModel.inputs.applePayButtonTapped()
}

func updatePledgeButton(_ enabled: Bool) {
self.viewModel.inputs.updatePledgeButtonEnabled(isEnabled: enabled)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The real "brains" of the pledge button enabled state is actually the PledgeViewModel. This is because we expect the pledge button's enabled state to be driven by a variety of factors: whether the reward minimum is met, whether a shipping location has been selected, etc. Since the PledgeViewModel is the only source of truth for this information, it needs to be the one to drive the pledge button's enabled state.

@@ -53,6 +62,9 @@ public final class PledgePaymentMethodsViewModel: PledgePaymentMethodsViewModelT
self.notifyDelegateLoadPaymentMethodsError = storedCardsEvent
.errors()
.map { $0.localizedDescription }

self.notifyDelegateCreditCardSelected = self.creditCardSelectedSignal
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now this is very simple - has a credit card been selected? An upcoming PR will add the rest of the requirements for the pledge button being enabled: reward minimum is met, shipping rule selected, etc.

@ifbarrera ifbarrera marked this pull request as ready for review September 19, 2019 22:44
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.

Cool cool, I think important to just note that there is payment method selection stuff being done in this PR and in #835, so we would want to align on that.

Also, the spacing here seems quite tight?

And a final thought - should this button be in PledgePaymentMethodsViewController or PledgeViewController as its own nested VC? 🤔 😱

@@ -3,18 +3,25 @@ import Library
import Prelude
import UIKit

protocol PledgeCreditCardViewDelegate: AnyObject {
func pledgeCreditCardViewSelected(
Copy link
Contributor

Choose a reason for hiding this comment

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

This might overlap with some of the work happening in #835.

private let expirationDateLabel: UILabel = { UILabel(frame: .zero) }()
private let imageView: UIImageView = { UIImageView(frame: .zero) }()
private let labelsStackView: UIStackView = { UIStackView(frame: .zero) }()
private let lastFourLabel: UILabel = { UILabel(frame: .zero) }()
private let rootStackView: UIStackView = { UIStackView(frame: .zero) }()
private let selectButton: UIButton = { UIButton(type: .custom) }()
private let viewModel: CreditCardCellViewModelType = CreditCardCellViewModel()
Copy link
Contributor

Choose a reason for hiding this comment

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

I mentioned in #835 that we should probably rename this 😬

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I agree - I really don't think we should have used the same view model as the one in the Settings screen at all though :\

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I had no idea it was being used in both places.

@ifbarrera
Copy link
Contributor Author

Cool cool, I think important to just note that there is payment method selection stuff being done in this PR and in #835, so we would want to align on that.

Also, the spacing here seems quite tight?

And a final thought - should this button be in PledgePaymentMethodsViewController or PledgeViewController as its own nested VC? 🤔 😱

  • the spacing is consistent with the spacing set on the root stack view. In this context I think it's ok because from the "information architecture" perspective, the "Pledge" button belongs in the same group as the credit cards and the Other payment methods label. Happy to double check with a designer though
  • I guess it could be it's own nested VC, but since all of the business logic around the pledge button's state is happening in the PledgeViewModel, it didn't seem necessary to create a new VC for such a simple view with no business logic of it's own. In the future if we wanted to reuse the Pledge button I could see a case for extracting it into it's own VC/VM pair, but at this stage it didn't seem necessary. Additionally, the visual positioning of the button needs to be part of the Other payment methods "group", and I felt that the easiest way to accomplish that would be to have them be part of the same root stack view.

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.

nice!

@ifbarrera ifbarrera merged commit 675b868 into master Sep 23, 2019
@ifbarrera ifbarrera deleted the pledge-button branch September 23, 2019 17:53
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.

2 participants