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-296] Round and format amount input based on some rules #857
Conversation
Generated by π« Danger |
@@ -77,13 +77,13 @@ final class PledgeAmountViewControllerTests: TestCase { | |||
} | |||
} | |||
|
|||
func testView_StepperIncrementButtonDisabled_WhenStepperValueSetToMaximum() { | |||
func testView_StepperIncrementButtonDisabled_WhenStepperValueSetToMaximumStepperValue() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed couple tests for better understanding of what min/max are we referring to (since there is stepper min/max value, pledge min/max value, etc.)
|
||
self.currency = project | ||
.map { currencySymbol(forCountry: $0.country).trimmed() } | ||
|
||
self.stepperMinValue = minValue.mapConst(0) | ||
self.stepperMaxValue = minValue.mapConst(Double.greatestFiniteMagnitude) | ||
self.stepperMaxValue = minValue.mapConst(1_000_000_000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure what to do about this...we have to set stepper.maxValue
since the default value is 100
but I'm not sure to what value. Since we allow inputs bellow pledge minimum, we should also allow inputs above pledge maximum in order to change the text color to red when the input is above that value and still allow stepper / text interactions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine... it's an arbitrarily high number.
@@ -122,19 +122,19 @@ internal final class PledgeAmountViewModelTests: TestCase { | |||
self.doneButtonIsEnabled.assertValues([true]) | |||
|
|||
self.vm.inputs.stepperValueChanged(2) | |||
self.doneButtonIsEnabled.assertValues([true, true]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly skipRepeats
for these signals...should have done that before, only noticed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
G2G!!π³π³π³
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks!
|
||
self.currency = project | ||
.map { currencySymbol(forCountry: $0.country).trimmed() } | ||
|
||
self.stepperMinValue = minValue.mapConst(0) | ||
self.stepperMaxValue = minValue.mapConst(Double.greatestFiniteMagnitude) | ||
self.stepperMaxValue = minValue.mapConst(1_000_000_000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is fine... it's an arbitrarily high number.
|
||
// MARK: - Functions | ||
|
||
private func maximumValue() -> Double { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we have this as a static property on an enum so that we can ensure it's shared between the tests and VM? Something like:
enum PledgeAmountStepperConstants {
static let min: Double = 0
static let max: Double = 1_000_000_000
}
π² What
What the title says
π€ Why
It was noticed that rounding was a bit off on the pledge amount field so this work should fix that.
π How
In order to provide great user experience we do have couple rules that we not only round the value but also update the input field
10.0
=> `10)This is so that users don't have to manually delete trailing zeros to change the value itself. As soon as there's a legit decimal number we keep it (since that one was most likely intended)
β Acceptance criteria
Live user input
min
value theDone
button on the keyboard is disabledmin
value the text color is changed to redmax
value theDone
button on the keyboard is disabledmax
value the text color is changed to redDismissing keyboard (either by tapping the
Done
button or tapping anywhere else on the screen) while entering this input results to the following output10
(or similar - test with other values) produces10
10.
(or similar - test with other values) produces10
10.0
(or similar - test with other values) produces10
10.00
(or similar - test with other values) produces10
10.000
(or similar - test with other values) produces10
10.1
(or similar - test with other values) produces10.10
10.01
(or similar - test with other values) produces10.01
10.99
(or similar - test with other values) produces10.99
10.999
(or similar - test with other values) produces11
10.129
(or similar - test with other values) produces10.13
10.123456789
(or similar - test with other values) produces10.12
Stepper
+
or-
button increments/decrements the value properly