use realAmount custom Amount class data in ui

This commit is contained in:
julian 2023-03-24 17:40:20 -06:00
parent 7c3b50552a
commit f4d61a9f58
4 changed files with 22 additions and 13 deletions

View file

@ -88,6 +88,7 @@ class Transaction {
@enumerated
late final TransactionSubType subType;
@Deprecated("May be inaccurate for large amounts (eth for example)")
late final int amount;
late String? amountString;

View file

@ -111,7 +111,8 @@ class _TransactionDetailsViewState extends ConsumerState<AllTransactionsView> {
return false;
}
if (filter.amount != null && filter.amount != tx.amount) {
if (filter.amount != null &&
BigInt.from(filter.amount!) != tx.realAmount.raw) {
return false;
}
@ -953,9 +954,13 @@ class _DesktopTransactionCardRowState
flex: 6,
child: Builder(
builder: (_) {
final amount = _transaction.amount;
final amount = _transaction.realAmount;
return Text(
"$prefix${Format.satoshiAmountToPrettyString(amount, locale, coin)} ${coin.ticker}",
"$prefix${Format.localizedStringAsFixed(
value: amount.decimal,
locale: locale,
decimalPlaces: coin.decimals,
)} ${coin.ticker}",
style: STextStyles.desktopTextExtraExtraSmall(context)
.copyWith(
color: Theme.of(context)
@ -972,12 +977,11 @@ class _DesktopTransactionCardRowState
flex: 4,
child: Builder(
builder: (_) {
int value = _transaction.amount;
final amount = _transaction.realAmount;
return Text(
"$prefix${Format.localizedStringAsFixed(
value: Format.satoshisToAmount(value, coin: coin) *
price,
value: amount.decimal * price,
locale: locale,
decimalPlaces: 2,
)} $baseCurrency",

View file

@ -78,7 +78,8 @@ class _TransactionDetailsViewState
walletId = widget.walletId;
coin = widget.coin;
amount = Format.satoshisToAmount(_transaction.amount, coin: coin);
amount = _transaction.realAmount
.decimal; //Format.satoshisToAmount(_transaction.amount, coin: coin);
fee = Format.satoshisToAmount(_transaction.fee, coin: coin);
if ((coin == Coin.firo || coin == Coin.firoTestNet) &&

View file

@ -221,9 +221,14 @@ class _TransactionCardState extends ConsumerState<TransactionCard> {
fit: BoxFit.scaleDown,
child: Builder(
builder: (_) {
final amount = _transaction.amount;
final amount = _transaction.realAmount;
return Text(
"$prefix${Format.satoshiAmountToPrettyString(amount, locale, coin)} ${coin.ticker}",
"$prefix${Format.localizedStringAsFixed(
value: amount.decimal,
locale: locale,
decimalPlaces: coin.decimals,
)} ${coin.ticker}",
style: STextStyles.itemSubtitle12(context),
);
},
@ -260,13 +265,11 @@ class _TransactionCardState extends ConsumerState<TransactionCard> {
fit: BoxFit.scaleDown,
child: Builder(
builder: (_) {
int value = _transaction.amount;
final amount = _transaction.realAmount;
return Text(
"$prefix${Format.localizedStringAsFixed(
value: Format.satoshisToAmount(value,
coin: coin) *
price,
value: amount.decimal * price,
locale: locale,
decimalPlaces: 2,
)} $baseCurrency",