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-456] Apple pay voice over #942

Merged
merged 6 commits into from
Nov 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ final class ManagePledgePaymentMethodView: UIView {
// MARK: - Properties

private lazy var cardLabelsStackView: UIStackView = { UIStackView(frame: .zero) }()
private lazy var cardNumberLabel: UILabel = { UILabel(frame: .zero) }()
private lazy var expirationDateLabel: UILabel = { UILabel(frame: .zero) }()
private lazy var lastFourDigitsLabel: UILabel = { UILabel(frame: .zero) }()
private lazy var paymentMethodAdaptableStackView: UIStackView = { UIStackView(frame: .zero) }()
private lazy var paymentMethodImageView: UIImageView = { UIImageView(frame: .zero) }()
private lazy var rootStackView: UIStackView = { UIStackView(frame: .zero) }()
Expand Down Expand Up @@ -37,7 +37,7 @@ final class ManagePledgePaymentMethodView: UIView {
}

private func configureViews() {
_ = ([self.lastFourDigitsLabel, self.expirationDateLabel], self.cardLabelsStackView)
_ = ([self.cardNumberLabel, self.expirationDateLabel], self.cardLabelsStackView)
|> ksr_addArrangedSubviewsToStackView()

_ = ([self.paymentMethodImageView, self.cardLabelsStackView], self.paymentMethodAdaptableStackView)
Expand All @@ -55,14 +55,13 @@ final class ManagePledgePaymentMethodView: UIView {

override func bindStyles() {
super.bindStyles()

_ = self.cardLabelsStackView
|> cardLabelsStackViewStyle

_ = self.expirationDateLabel
|> expirationDateLabelStyle

_ = self.lastFourDigitsLabel
_ = self.cardNumberLabel
|> lastFourDigitsLabelStyle

_ = self.paymentMethodAdaptableStackView
Expand All @@ -88,7 +87,8 @@ final class ManagePledgePaymentMethodView: UIView {
super.bindViewModel()

self.expirationDateLabel.rac.text = self.viewModel.outputs.expirationDateText
self.lastFourDigitsLabel.rac.text = self.viewModel.outputs.cardNumberTextShortStyle
self.cardNumberLabel.rac.text = self.viewModel.outputs.cardNumberTextShortStyle
self.cardNumberLabel.rac.accessibilityLabel = self.viewModel.outputs.cardNumberAccessibilityLabel

self.viewModel.outputs.cardImageName
.observeForUI()
Expand Down
11 changes: 11 additions & 0 deletions KsApi/models/Backing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ public struct Backing {
case applePay = "APPLE_PAY"
case creditCard = "CREDIT_CARD"
case googlePay = "ANDROID_PAY"

public var accessibilityLabel: String? {
switch self {
case .applePay:
return "Apple Pay"
case .googlePay:
return "Google Pay"
case .creditCard:
return nil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If PaymentType is .creditCard, voice over doesn't need to say anything.

}
}
}

public enum Status: String, CaseIterable {
Expand Down
10 changes: 7 additions & 3 deletions Library/ViewModels/ManagePledgePaymentMethodViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ public final class ManagePledgePaymentMethodViewModel: ManagePledgePaymentMethod
.map(imageName(for:))
.skipNil()

let type = self.paymentSourceSignal
let paymentType = self.paymentSourceSignal
.map { $0.paymentType }

let cardType = self.paymentSourceSignal
.map { $0.type }
.skipNil()

Expand All @@ -43,11 +46,12 @@ public final class ManagePledgePaymentMethodViewModel: ManagePledgePaymentMethod
.skipNil()

self.cardNumberAccessibilityLabel = Signal.combineLatest(
type,
paymentType,
cardType,
lastFour
)
.map {
[$0.0.description, Strings.Card_ending_in_last_four(last_four: $0.1)]
[$0.0.accessibilityLabel, $0.1.description, Strings.Card_ending_in_last_four(last_four: $0.2)]
.compact()
.joined(separator: ", ")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ final class ManagePledgePaymentMethodViewModelTests: TestCase {
self.vm.inputs.configureWith(value: Backing.PaymentSource.applePay)

self.cardImageName.assertValue("icon--apple-pay")
self.cardNumberAccessibilityLabel.assertLastValue("Visa, Card ending in 1111")
self.cardNumberAccessibilityLabel.assertLastValue("Apple Pay, Visa, Card ending in 1111")
self.cardNumberTextShortStyle.assertLastValue("Ending in 1111")
self.expirationDateText.assertValue("Expires 10/2019")
}
Expand All @@ -44,7 +44,7 @@ final class ManagePledgePaymentMethodViewModelTests: TestCase {
self.vm.inputs.configureWith(value: Backing.PaymentSource.googlePay)

self.cardImageName.assertValue("icon--google-pay")
self.cardNumberAccessibilityLabel.assertLastValue("Visa, Card ending in 4111")
self.cardNumberAccessibilityLabel.assertLastValue("Google Pay, Visa, Card ending in 4111")
self.cardNumberTextShortStyle.assertLastValue("Ending in 4111")
self.expirationDateText.assertValue("Expires 10/2019")
}
Expand Down