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-204] Manage pledge payment method section #851

Merged
merged 23 commits into from
Oct 1, 2019

Conversation

Scollaco
Copy link
Contributor

@Scollaco Scollaco commented Sep 23, 2019

📲 What

  • Adds the selected payment method to the ManageViewPledgeViewController

Note

  • This PR doesn't include Apple Pay information. We don't have designs for that yet and this should be handled in a different PR

🤔 Why

  • This will allow the user, by visiting the Manage/View pledge screen, to see which payment method was used to back a project.

🛠 How

  • Created a new ManagePledgePaymentMethodView class
  • Added a new property paymentSource to the Backing model
  • Reused GraphUserCreditCard.CreditCard as paymentSource property type
  • Made the GraphUserCreditCard.CreditCard conform to Argo.Decodable. This was necessary in order to be able to reuse GraphUserCreditCard.CreditCard as paymentSource
  • Added and fixed tests

👀 See

Default 🐛 Dynamic type 🦋
Simulator Screen Shot - iPhone 8 - 2019-09-23 at 16 11 34 Simulator Screen Shot - iPhone 8 - 2019-09-23 at 16 11 55

♿️ Accessibility

  • Works with VoiceOver
  • Supports Dynamic Type

✅ Acceptance criteria

With Native Checkout Pledge View feature enabled:

  • Select a backed project and go Manage/View pledge screen. The Payment Method section should be visible
  • The Payment Method section should show the values of the card used to back the project

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.

Had a first pass...mostly looking good..couple suggestions plus some weirdness around a11y bellow

VoiceOver
I wasn't able to focus on any of the textual fields in the payments section using VoiceOver.

Dynamic Type
Looks like the title of the section does not allow multiple lines and therefore on smaller devices it gets trimmed (see the screenshot)

Screen Shot 2019-09-25 at 3 20 58 PM

@@ -102,6 +102,8 @@ final class PledgeCreditCardView: UIView {
|> checkoutCardStackViewStyle
}

// MARK: - View model
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also add // MARK: - Configuration??

private lazy var rootStackView: UIStackView = { UIStackView(frame: .zero) }()
private lazy var titleLabel: UILabel = { UILabel(frame: .zero) }()

private let viewModel = CreditCardCellViewModel()
Copy link
Contributor

Choose a reason for hiding this comment

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

We've been inconsistent in this lately but shouldn't we define vm as CreditCardCellViewModelTypebefore we initialize it? This way we will be told by the compiler if we try to access any variables directly (skippinginputs/outputs`).

Could you maybe also add refactoring ticket in JIRA to do the same for all the other 17 occurrences of let viewModel = where we let the compiler infer the type without being explicitly told so?


self.configureViews()
self.setupConstraints()
self.bindViewModel()
Copy link
Contributor

Choose a reason for hiding this comment

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

Any update on this @justinswart ? Thought we talked about swizzling some swizzlers to make this automatic :)


private func configureViews() {
_ = self
|> \.accessibilityElements .~ self.subviews
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 exclude the image view here?


self.expirationDateLabel.rac.text = self.viewModel.outputs.expirationDateText
self.lastFourLabel.rac.text = self.viewModel.outputs.cardNumberTextShortStyle
self.viewModel.outputs.cardImage
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add empty line here to separate rac and output signals?

Copy link
Contributor

Choose a reason for hiding this comment

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

On a second thought, would it be worth it adding reactive extension on the UIImageView to being able to bind image property? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good idea. I can create a ticket for that to be done in a different PR.

|> checkoutTitleLabelStyle
|> \.font .~ UIFont.ksr_caption1().bolded
|> \.adjustsFontForContentSizeCategory .~ true
|> \.textColor .~ .ksr_text_dark_grey_500
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we be explicit when defining styles and use full types? UIColor. this helps the compiler with the type inference and prevents from potential type-check warnings. This has been something we've mostly seen with styles so this should only be done when dealing with styles. We can be more on ease for other operations.

|> \.textColor .~ .ksr_text_dark_grey_500
}

private let cardLabelsStackViewStyle: StackViewStyle = { stackView in
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we simply use verticalStackViewStyle without defining a wrapper style?

|> \.textColor .~ UIColor.black
|> \.font .~ UIFont.ksr_subhead().bolded
|> \.adjustsFontForContentSizeCategory .~ true
|> \.text %~ { _ in Strings.Payment_method() }
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we'll also need to use numberOfLines .~ 0 here to prevent from trimming the title

@@ -114,7 +109,9 @@ final class ManageViewPledgeViewController: UIViewController {

self.viewModel.outputs.configurePaymentMethodView
.observeForUI()
.observeValues { _ in }
.observeValues { [weak self] in
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we name the closure variable for better readability? To better describe $0 in this case. Feel like we've been pretty consistent about that everywhere else.

@@ -77,7 +79,7 @@ public final class ManageViewPledgeViewModel:
self.viewDidLoadObserver.send(value: ())
}

public let configurePaymentMethodView: Signal<Project, Never>
public let configurePaymentMethodView: Signal<GraphUserCreditCard.CreditCard, Never>
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to my comment here #835 (comment)

Would communicate the change with Christella to prevent from merge conflicts

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 was the typealias created yet? I think that creating it in this PR will add a ton of new diffs, though.

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.

Still noticed couple things we should address plus I'm not sure if this is caused by this PR (I could not seem to find any traces of what it would cause)...but I'm unable to display the blue Manage CTA button when I go to live projects that I've backed...what's working on master isn't working on this branch..any ideas?

I only see this ¯_(ツ)_/¯

Screen Shot 2019-09-27 at 3 00 29 PM

label
|> checkoutTitleLabelStyle
|> \.font .~ UIFont.ksr_caption1().bolded
|> \.adjustsFontForContentSizeCategory .~ true
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate of checkoutTitleLabelStyle

Suggested change
|> \.adjustsFontForContentSizeCategory .~ true

label
|> checkoutTitleLabelStyle
|> \.font .~ UIFont.ksr_subhead().bolded
|> \.adjustsFontForContentSizeCategory .~ true
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate of checkoutTitleLabelStyle

Suggested change
|> \.adjustsFontForContentSizeCategory .~ true

let childViews: [UIView] = [
self.pledgeSummaryView,
self.paymentMethodView,
self.rewardReceivedViewController.view
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to add this not only to view hierarchy but to view-controller hierarchy as we do at other places (this is to ensure proper behavior fo the view-controller when being embedded in a parent VC.

self.addChild(viewController)
self.view.addSubview(viewController.view) // or using our functional helper
viewController.didMove(toParent: self)

private lazy var cardImageView: UIImageView = { UIImageView(frame: .zero) }()
private lazy var cardLabelsStackView: UIStackView = { UIStackView(frame: .zero) }()
private lazy var expirationDateLabel: UILabel = { UILabel(frame: .zero) }()
private lazy var lastFourLabel: UILabel = { UILabel(frame: .zero) }()
Copy link
Contributor

Choose a reason for hiding this comment

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

lastFour what? Should we be more explicit? Also the signal & the UI element do not match (not sure if this is again due to copy-pasting stuff around)?


private let cardExpirationDateLabelStyle: LabelStyle = { label in
label
|> checkoutTitleLabelStyle
Copy link
Contributor

Choose a reason for hiding this comment

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

Using checkoutTitleLabelStyle means we're giving it a headline trait...which we probably only want to do for the title section.

  1. Currently, title is missing headline trait

Screen Shot 2019-09-27 at 2 43 06 PM

  1. While the two labels do have it (they probably shouldn't)

Screen Shot 2019-09-27 at 2 42 53 PM

Screen Shot 2019-09-27 at 2 42 44 PM

@dusi dusi mentioned this pull request Sep 30, 2019
3 tasks
* Rename label and styles

* Refactor styles

* Add vc to parent properly

* Flatten the style
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.

Note: Since @Scollaco was away I've managed to address my own feedback and have it approved by @cdolm92

@dusi dusi merged commit 4d936fb into master Oct 1, 2019
@dusi dusi deleted the manage-pledge-payment-method-section branch October 1, 2019 16:46
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

2 participants