-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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-327] Disable pledge button for invalid inputs #859
Conversation
… the pledge button to properly reflect enabled/disabled state
…nt and its validity
@@ -7,7 +7,7 @@ import UIKit | |||
protocol PledgeAmountViewControllerDelegate: AnyObject { | |||
func pledgeAmountViewController( | |||
_ viewController: PledgeAmountViewController, | |||
didUpdateAmount amount: Double | |||
didUpdate amount: (value: Double, isValid: Bool) |
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.
Using a tuple to wrap both value and its validity now
.takeWhen(self.selectButtonTappedProperty.signal) | ||
.map { $0.id } | ||
|
||
self.notifyDelegateOfCardSelected = Signal.merge( | ||
creditCardInitial, |
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.
We now make sure to notify delegate when payment methods get loaded initially and default card gets selected (if there's at least one card).
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.
This is also fixed in #856
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.
Good to know...I can see it looks slightly different to my approach...I can either way for the other PR to make it in or try reflecting those changes here.
.takeWhen(self.selectButtonTappedProperty.signal) | ||
.map { $0.id } | ||
|
||
self.notifyDelegateOfCardSelected = Signal.merge( | ||
creditCardInitial, |
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.
This is also fixed in #856
@@ -23,7 +23,7 @@ public protocol PledgeViewModelInputs { | |||
paymentData: (displayName: String?, network: String?, transactionIdentifier: String) | |||
) | |||
func paymentAuthorizationViewControllerDidFinish() | |||
func pledgeAmountDidUpdate(to amount: Double) | |||
func pledgeAmountDidUpdate(_ amount: (value: Double, isValid: Bool)) |
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.
Should we also update the parameter name here from amount
to maybe value
?
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.
Yeah, I'd be happy to...any ideas what to replace value
to?
pledgeAmountDidUPdate(_ value: (???: Double, isValid: Bool))
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 suppose if we introduced a typealias like:
typealias PledgeAmountData = (amount: Double, isValid: Bool)
Then that would allow us to change the delegate to something like:
func pledgeAmountViewController(
_ viewController: PledgeAmountViewController,
didUpdateWith data: PledgeAmountData
)
Then it'd also help name our VM input on PledgeViewModel
:
func pledgeAmountViewControllerDidUpdate(with data: PledgeAmountData)
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.
Looks pretty solid, just the one comment and merge conflict to resolve 👍
@@ -23,7 +23,7 @@ public protocol PledgeViewModelInputs { | |||
paymentData: (displayName: String?, network: String?, transactionIdentifier: String) | |||
) | |||
func paymentAuthorizationViewControllerDidFinish() | |||
func pledgeAmountDidUpdate(to amount: Double) | |||
func pledgeAmountDidUpdate(_ amount: (value: Double, isValid: Bool)) |
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 suppose if we introduced a typealias like:
typealias PledgeAmountData = (amount: Double, isValid: Bool)
Then that would allow us to change the delegate to something like:
func pledgeAmountViewController(
_ viewController: PledgeAmountViewController,
didUpdateWith data: PledgeAmountData
)
Then it'd also help name our VM input on PledgeViewModel
:
func pledgeAmountViewControllerDidUpdate(with data: PledgeAmountData)
📲 What
If the amount input is invalid (
<
min pledge value OR>
max pledge value) thePledge
button will be disabled.🤔 Why
This should reflect our UI/UX approach for validating data on this screen and further actions users can perform. They should not be able to try pledging if the input is locally invalid since this would only result in failed requests.
🛠 How
Small refactor has been done to not only report back amount value, but also it's validity within the
min
/max
bounds.In addition to that I've tweaked the way initial payment method is selected (which previously was not reporting back to the view model - and was only set visually in UI). Now when the user fetches payment methods and the first payment method is set (as the default option) the vm reports back which allows us to enable/disable the
Pledge
button.👀 See
✅ Acceptance criteria
Pledge
buttonPledge
buttonPledge
button (if it was previously disabled)Pledge
button is enabled initially if there is at least one payment method and that method is indicating of being selected