dynamic fee type checks

This commit is contained in:
julian 2023-04-11 13:14:34 -06:00
parent cefbc42715
commit cd6c057f8c
3 changed files with 59 additions and 44 deletions

View file

@ -359,10 +359,16 @@ class _ConfirmChangeNowSendViewState
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
"${(transactionInfo["fee"] as int).toAmountAsRaw(
fractionDigits: ref.watch(
managerProvider
.select((value) => value.coin.decimals),
"${(transactionInfo["fee"] is Amount ? transactionInfo["fee"] as Amount : (transactionInfo["fee"] as int).toAmountAsRaw(
fractionDigits: ref.watch(
managerProvider
.select((value) => value.coin.decimals),
),
)).localizedStringAsFixed(
locale: ref.watch(
localeServiceChangeNotifierProvider.select(
(value) => value.locale,
),
),
)} ${ref.watch(
managerProvider.select((value) => value.coin),
@ -401,10 +407,12 @@ class _ConfirmChangeNowSendViewState
final coin = ref.watch(
managerProvider.select((value) => value.coin),
);
final fee =
(transactionInfo["fee"] as int).toAmountAsRaw(
fractionDigits: coin.decimals,
);
final fee = transactionInfo["fee"] is Amount
? transactionInfo["fee"] as Amount
: (transactionInfo["fee"] as int)
.toAmountAsRaw(
fractionDigits: coin.decimals,
);
final amount =
transactionInfo["recipientAmt"] as Amount;
final total = amount + fee;
@ -637,17 +645,17 @@ class _ConfirmChangeNowSendViewState
style: STextStyles.smallMed12(context),
),
Text(
"${(transactionInfo["fee"] as int).toAmountAsRaw(fractionDigits: ref.watch(
managerProvider.select(
(value) => value.coin.decimals,
),
)).localizedStringAsFixed(
locale: ref.watch(
localeServiceChangeNotifierProvider.select(
(value) => value.locale,
),
),
)} ${ref.watch(
"${(transactionInfo["fee"] is Amount ? transactionInfo["fee"] as Amount : (transactionInfo["fee"] as int).toAmountAsRaw(fractionDigits: ref.watch(
managerProvider.select(
(value) => value.coin.decimals,
),
))).localizedStringAsFixed(
locale: ref.watch(
localeServiceChangeNotifierProvider.select(
(value) => value.locale,
),
),
)} ${ref.watch(
managerProvider.select((value) => value.coin),
).ticker}",
style: STextStyles.itemSubtitle12(context),
@ -733,10 +741,11 @@ class _ConfirmChangeNowSendViewState
final coin = ref.watch(
managerProvider.select((value) => value.coin),
);
final fee =
(transactionInfo["fee"] as int).toAmountAsRaw(
fractionDigits: coin.decimals,
);
final fee = transactionInfo["fee"] is Amount
? transactionInfo["fee"] as Amount
: (transactionInfo["fee"] as int).toAmountAsRaw(
fractionDigits: coin.decimals,
);
final amount =
transactionInfo["recipientAmt"] as Amount;
final total = amount + fee;

View file

@ -427,18 +427,18 @@ class _ConfirmTransactionViewState
style: STextStyles.smallMed12(context),
),
Text(
"${(transactionInfo["fee"] as int).toAmountAsRaw(
fractionDigits: ref.watch(
managerProvider.select(
(value) => value.coin.decimals,
),
"${(transactionInfo["fee"] is Amount ? transactionInfo["fee"] as Amount : (transactionInfo["fee"] as int).toAmountAsRaw(
fractionDigits: ref.watch(
managerProvider.select(
(value) => value.coin.decimals,
),
).localizedStringAsFixed(
locale: ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),
),
)} ${ref.watch(
),
)).localizedStringAsFixed(
locale: ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),
),
)} ${ref.watch(
managerProvider.select((value) => value.coin),
).ticker}",
style: STextStyles.itemSubtitle12(context),
@ -678,10 +678,12 @@ class _ConfirmTransactionViewState
value.getManager(walletId)))
.coin;
final fee = (transactionInfo["fee"] as int)
.toAmountAsRaw(
fractionDigits: coin.decimals,
);
final fee = transactionInfo["fee"] is Amount
? transactionInfo["fee"] as Amount
: (transactionInfo["fee"] as int)
.toAmountAsRaw(
fractionDigits: coin.decimals,
);
return Text(
"${fee.localizedStringAsFixed(
@ -857,9 +859,11 @@ class _ConfirmTransactionViewState
.select((value) => value.getManager(walletId)))
.coin;
final fee = (transactionInfo["fee"] as int).toAmountAsRaw(
fractionDigits: coin.decimals,
);
final fee = transactionInfo["fee"] is Amount
? transactionInfo["fee"] as Amount
: (transactionInfo["fee"] as int).toAmountAsRaw(
fractionDigits: coin.decimals,
);
return Text(
"${fee.localizedStringAsFixed(
@ -916,8 +920,10 @@ class _ConfirmTransactionViewState
Builder(builder: (context) {
final coin = ref.watch(walletsChangeNotifierProvider
.select((value) => value.getManager(walletId).coin));
final fee = (transactionInfo["fee"] as int)
.toAmountAsRaw(fractionDigits: coin.decimals);
final fee = transactionInfo["fee"] is Amount
? transactionInfo["fee"] as Amount
: (transactionInfo["fee"] as int)
.toAmountAsRaw(fractionDigits: coin.decimals);
final locale = ref.watch(
localeServiceChangeNotifierProvider
.select((value) => value.locale),

View file

@ -305,7 +305,7 @@ class _DesktopTokenSendState extends ConsumerState<DesktopTokenSend> {
padding: const EdgeInsets.only(
right: 32,
),
child: Text(
child: SelectableText(
e.toString(),
textAlign: TextAlign.left,
style: STextStyles.desktopTextExtraExtraSmall(context)