-
Notifications
You must be signed in to change notification settings - Fork 2
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
refactor(deriv_ui): [DERG-3500] return inputted amount based on the formatter in numpad #624
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,9 @@ class CurrencyDetail { | |
bool get isStableCurrency => | ||
stableCurrencies.contains(currencyType.toUpperCase()); | ||
|
||
/// This will give the final amount to do processing based on what type of currency it is like fiat or crypto currency. | ||
double get finalAmount => double.parse(formatter.format(amount)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sagar-deriv Can we name it like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please update the doc comments to reflect the updated name. |
||
|
||
/// Amount that is used to display for user. | ||
String get displayAmount { | ||
if (amount == 0.0) { | ||
|
@@ -54,9 +57,9 @@ class CurrencyDetail { | |
/// This will give a specific currency formatter based on what type of currency it is like fiat or crypto currency. | ||
NumberFormat get formatter { | ||
if (isFiat || isStableCurrency) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we update the getter name There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, that's better. I will push the changes. |
||
return NumberFormat.decimalPattern()..maximumFractionDigits = 2; | ||
return NumberFormat('#0.##', 'en_US'); | ||
} else { | ||
return NumberFormat.decimalPattern()..maximumFractionDigits = 8; | ||
return NumberFormat('#0.########', 'en_US'); | ||
} | ||
} | ||
|
||
|
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 rename the
double finalAmount() { ..
method toformattedAmount()
?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.
In this case
finalAmount
is okay, because this is the final amount returned to the user. I will make the change and push for the other one in theCurrencyDetail
class.