-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NT-357][NT-358] Change Payment Method UI (#887)
* Updated validation * Fix snapshot tests, add submitButtonHidden * Add PledgeAmountSummaryViewController * Add updateButtonTapped * Add snapshot test and vm test * lol * Remove unused var * Rename signal, fix payment source ID comparison * Fix tests * Fix tests, simplify hiding of shipping location stackview * Fix snapshots * Commit the actual snapshots * Use local var * [NT-359] Integrate Updating Backing mutation (#893) * Wire up change payment method to mutation for payment source and Apple Pay * Remove payment method when backing with Apple Pay and vice versa * Update tests for apple pay sheet race condition fixes * Replace zip with simpler signals * Add Stripe token error test * Move signals around, improve tests
- Loading branch information
1 parent
be2137d
commit 7de27fa
Showing
40 changed files
with
1,567 additions
and
355 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
Kickstarter-iOS/Views/Controllers/PledgeAmountSummaryViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import KsApi | ||
import Library | ||
import Prelude | ||
import Prelude_UIKit | ||
import UIKit | ||
|
||
final class PledgeAmountSummaryViewController: UIViewController { | ||
// MARK: Properties | ||
|
||
private lazy var pledgeAmountLabel: UILabel = { UILabel(frame: .zero) }() | ||
private lazy var pledgeAmountStackView: UIStackView = { UIStackView(frame: .zero) }() | ||
private lazy var pledgeLabel: UILabel = { UILabel(frame: .zero) }() | ||
private lazy var rootStackView: UIStackView = { UIStackView(frame: .zero) }() | ||
private lazy var shippingAmountLabel: UILabel = { UILabel(frame: .zero) }() | ||
private lazy var shippingLocationLabel: UILabel = { UILabel(frame: .zero) }() | ||
private lazy var shippingLocationStackView: UIStackView = { UIStackView(frame: .zero) }() | ||
|
||
private let viewModel: PledgeAmountSummaryViewModelType = PledgeAmountSummaryViewModel() | ||
|
||
// MARK: Life cycle | ||
|
||
public func configureWith(_ project: Project) { | ||
self.viewModel.inputs.configureWith(project) | ||
} | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
self.configureSubviews() | ||
|
||
self.viewModel.inputs.viewDidLoad() | ||
} | ||
|
||
// MARK: Styles | ||
|
||
override func bindStyles() { | ||
super.bindStyles() | ||
|
||
let isAccessibilityCategory = self.traitCollection.preferredContentSizeCategory.isAccessibilityCategory | ||
|
||
_ = self.pledgeAmountStackView | ||
|> checkoutAdaptableStackViewStyle(isAccessibilityCategory) | ||
|
||
_ = self.rootStackView | ||
|> rootStackViewStyle | ||
|
||
_ = self.shippingLocationStackView | ||
|> checkoutAdaptableStackViewStyle(isAccessibilityCategory) | ||
|
||
_ = self.pledgeLabel | ||
|> pledgeLabelStyle | ||
|
||
_ = self.pledgeAmountLabel | ||
|> amountLabelStyle | ||
|
||
_ = self.shippingLocationLabel | ||
|> shippingLocationLabelStyle | ||
|
||
_ = self.shippingAmountLabel | ||
|> amountLabelStyle | ||
} | ||
|
||
// MARK: View model | ||
|
||
override func bindViewModel() { | ||
super.bindViewModel() | ||
|
||
self.pledgeAmountLabel.rac.attributedText = self.viewModel.outputs.pledgeAmountText | ||
self.shippingAmountLabel.rac.attributedText = self.viewModel.outputs.shippingAmountText | ||
self.shippingLocationLabel.rac.text = self.viewModel.outputs.shippingLocationText | ||
self.shippingLocationStackView.rac.hidden = self.viewModel.outputs.shippingLocationStackViewIsHidden | ||
} | ||
|
||
// MARK: Functions | ||
|
||
private func configureSubviews() { | ||
_ = (self.rootStackView, self.view) | ||
|> ksr_addSubviewToParent() | ||
|> ksr_constrainViewToEdgesInParent() | ||
|
||
_ = ([self.pledgeLabel, self.pledgeAmountLabel], self.pledgeAmountStackView) | ||
|> ksr_addArrangedSubviewsToStackView() | ||
|
||
_ = ([self.shippingLocationLabel, self.shippingAmountLabel], self.shippingLocationStackView) | ||
|> ksr_addArrangedSubviewsToStackView() | ||
|
||
_ = ([ | ||
self.pledgeAmountStackView, | ||
self.shippingLocationStackView | ||
], self.rootStackView) | ||
|> ksr_addArrangedSubviewsToStackView() | ||
} | ||
} | ||
|
||
// MARK: Styles | ||
|
||
private let amountLabelStyle: LabelStyle = { label in | ||
label | ||
|> \.adjustsFontForContentSizeCategory .~ true | ||
|> \.textAlignment .~ NSTextAlignment.right | ||
|> \.isAccessibilityElement .~ true | ||
|> \.minimumScaleFactor .~ 0.75 | ||
} | ||
|
||
private let pledgeLabelStyle: LabelStyle = { label in | ||
label | ||
|> \.textColor .~ UIColor.ksr_dark_grey_500 | ||
|> \.font .~ UIFont.ksr_subhead().bolded | ||
|> \.adjustsFontForContentSizeCategory .~ true | ||
|> \.text %~ { _ in Strings.Pledge() } | ||
} | ||
|
||
private let rootStackViewStyle: StackViewStyle = { stackView in | ||
stackView | ||
|> checkoutStackViewStyle | ||
|> \.spacing .~ Styles.grid(3) | ||
} | ||
|
||
private let shippingLocationLabelStyle: LabelStyle = { label in | ||
label | ||
|> \.textColor .~ UIColor.ksr_dark_grey_500 | ||
|> \.font .~ UIFont.ksr_subhead().bolded | ||
|> \.adjustsFontForContentSizeCategory .~ true | ||
|> \.numberOfLines .~ 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.