Skip to content

Commit

Permalink
Merge pull request #32 from Foundation-Devices/ENV-230-btc-amount-zeroes
Browse files Browse the repository at this point in the history
ENV-230: show BTC amount with trailing zeros
  • Loading branch information
icota authored Sep 12, 2022
2 parents bf48f38 + 90f9831 commit 3dc20e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/ui/amount.dart
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,11 @@ class NumpadButton extends StatelessWidget {
}
}

String convertSatsToBtcString(int amountSats) {
String convertSatsToBtcString(int amountSats, {bool trailingZeroes: false}) {
final amountBtc = amountSats / 100000000;

NumberFormat formatter = NumberFormat();
formatter.minimumFractionDigits = 0;
formatter.minimumFractionDigits = trailingZeroes ? 8 : 0;
formatter.maximumFractionDigits = 8;

return formatter.format(amountBtc);
Expand All @@ -307,7 +307,8 @@ String getFormattedAmount(int amountSats, {bool includeUnit: false}) {
NumberFormat satsFormatter = NumberFormat("###,###,###,###,###,###,###");

String text = Settings().displayUnit == DisplayUnit.btc
? convertSatsToBtcString(amountSats) + (includeUnit ? " BTC" : "")
? convertSatsToBtcString(amountSats, trailingZeroes: true) +
(includeUnit ? " BTC" : "")
: satsFormatter.format(amountSats) + (includeUnit ? " SATS" : "");

return text;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.6+18
version: 1.0.6+19

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down

0 comments on commit 3dc20e4

Please sign in to comment.