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-526] Max pledge error handling polish #954

Merged
merged 5 commits into from
Nov 20, 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 @@ -220,4 +220,5 @@ private let maxPledgeAmountErrorLabelStyle: LabelStyle = { label in
|> \.font .~ UIFont.ksr_caption1()
|> \.numberOfLines .~ 0
|> \.textColor .~ UIColor.ksr_red_400
|> \.textAlignment .~ .right
}
12 changes: 5 additions & 7 deletions Library/ViewModels/PledgeAmountViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,12 @@ public final class PledgeAmountViewModel: PledgeAmountViewModelType,
.skipRepeats()

self.maxPledgeAmountErrorLabelText = updatedValue
.map { ($0.0, $0.1) }
.map(second)
.combineLatest(with: project)
.map(unpack)
.map { min, max, project in

Strings.Please_enter_a_pledge_amount_between_min_and_max(
min: Format.currency(min, country: project.country, omitCurrencyCode: false),
max: Format.currency(max, country: project.country, omitCurrencyCode: false)
.map { max, project in
Strings.The_maximum_pledge_is_max_pledge(
max_pledge:
Format.currency(max, country: project.country, omitCurrencyCode: false)
)
}
.skipRepeats()
Expand Down
6 changes: 3 additions & 3 deletions Library/ViewModels/PledgeAmountViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -891,14 +891,14 @@ internal final class PledgeAmountViewModelTests: TestCase {
self.vm.inputs.stepperValueChanged(10_100)

self.maxPledgeAmountErrorLabelText.assertValues([
"Please enter a pledge amount between US$Β 25 and US$Β 10,000."
"The maximum pledge is US$Β 10,000."
])

self.vm.inputs.selectedShippingAmountChanged(to: 30.0)

self.maxPledgeAmountErrorLabelText.assertValues([
"Please enter a pledge amount between US$Β 25 and US$Β 10,000.",
"Please enter a pledge amount between US$Β 25 and US$Β 9,970."
"The maximum pledge is US$Β 10,000.",
"The maximum pledge is US$Β 9,970."
])
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.