From 9f4df0368ae3c9ea8408609d40851b4a57c0f65f Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 9 May 2024 16:12:22 -0600 Subject: [PATCH] add extra info to spark transaction generating dialog and some linter clean up --- .../exchange_step_views/step_4_view.dart | 53 ++- lib/pages/exchange_view/send_from_view.dart | 82 ++-- lib/pages/send_view/send_view.dart | 434 ++++++++++-------- .../building_transaction_dialog.dart | 49 +- lib/pages/send_view/token_send_view.dart | 185 +++++--- .../wallet_view/sub_widgets/desktop_send.dart | 137 +++--- .../sub_widgets/desktop_token_send.dart | 87 ++-- 7 files changed, 620 insertions(+), 407 deletions(-) diff --git a/lib/pages/exchange_view/exchange_step_views/step_4_view.dart b/lib/pages/exchange_view/exchange_step_views/step_4_view.dart index c36e88bbf..8fa0eedc6 100644 --- a/lib/pages/exchange_view/exchange_step_views/step_4_view.dart +++ b/lib/pages/exchange_view/exchange_step_views/step_4_view.dart @@ -225,6 +225,7 @@ class _Step4ViewState extends ConsumerState { builder: (context) { return BuildingTransactionDialog( coin: wallet.info.coin, + isSpark: wallet is FiroWallet && !firoPublicSend, onCancel: () { wasCancelled = true; }, @@ -249,7 +250,7 @@ class _Step4ViewState extends ConsumerState { address: address, amount: amount, isChange: false, - ) + ), ], note: "${model.trade!.payInCurrency.toUpperCase()}/" "${model.trade!.payOutCurrency.toUpperCase()} exchange", @@ -472,10 +473,10 @@ class _Step4ViewState extends ConsumerState { GestureDetector( onTap: () async { final data = ClipboardData( - text: - model.sendAmount.toString()); + text: model.sendAmount.toString(), + ); await clipboard.setData(data); - if (mounted) { + if (context.mounted) { unawaited( showFloatingFlushBar( type: FlushBarType.info, @@ -535,9 +536,10 @@ class _Step4ViewState extends ConsumerState { GestureDetector( onTap: () async { final data = ClipboardData( - text: model.trade!.payInAddress); + text: model.trade!.payInAddress, + ); await clipboard.setData(data); - if (mounted) { + if (context.mounted) { unawaited( showFloatingFlushBar( type: FlushBarType.info, @@ -598,10 +600,10 @@ class _Step4ViewState extends ConsumerState { GestureDetector( onTap: () async { final data = ClipboardData( - text: - model.trade!.payInExtraId); + text: model.trade!.payInExtraId, + ); await clipboard.setData(data); - if (mounted) { + if (context.mounted) { unawaited( showFloatingFlushBar( type: FlushBarType.info, @@ -670,9 +672,10 @@ class _Step4ViewState extends ConsumerState { GestureDetector( onTap: () async { final data = ClipboardData( - text: model.trade!.tradeId); + text: model.trade!.tradeId, + ); await clipboard.setData(data); - if (mounted) { + if (context.mounted) { unawaited( showFloatingFlushBar( type: FlushBarType.info, @@ -689,9 +692,9 @@ class _Step4ViewState extends ConsumerState { .infoItemIcons, width: 12, ), - ) + ), ], - ) + ), ], ), ), @@ -739,7 +742,8 @@ class _Step4ViewState extends ConsumerState { child: Text( "Send ${model.sendTicker} to this address", style: STextStyles.pageTitleH2( - context), + context, + ), ), ), const SizedBox( @@ -773,12 +777,13 @@ class _Step4ViewState extends ConsumerState { style: Theme.of(context) .extension()! .getSecondaryEnabledButtonStyle( - context), + context, + ), child: Text( "Cancel", style: STextStyles.button( - context) - .copyWith( + context, + ).copyWith( color: Theme.of(context) .extension< StackColors>()! @@ -788,7 +793,7 @@ class _Step4ViewState extends ConsumerState { ), ), ], - ) + ), ], ), ); @@ -814,8 +819,9 @@ class _Step4ViewState extends ConsumerState { final tuple = ref .read( - exchangeSendFromWalletIdStateProvider - .state) + exchangeSendFromWalletIdStateProvider + .state, + ) .state; if (tuple != null && model.sendTicker.toLowerCase() == @@ -845,8 +851,8 @@ class _Step4ViewState extends ConsumerState { (BuildContext context) { final coin = coinFromTickerCaseInsensitive( - model.trade! - .payInCurrency); + model.trade!.payInCurrency, + ); return SendFromView( coin: coin, amount: model.sendAmount @@ -868,7 +874,8 @@ class _Step4ViewState extends ConsumerState { style: Theme.of(context) .extension()! .getSecondaryEnabledButtonStyle( - context), + context, + ), child: Text( buttonTitle, style: diff --git a/lib/pages/exchange_view/send_from_view.dart b/lib/pages/exchange_view/send_from_view.dart index 655f2afe7..a97b94a28 100644 --- a/lib/pages/exchange_view/send_from_view.dart +++ b/lib/pages/exchange_view/send_from_view.dart @@ -205,13 +205,13 @@ class _SendFromViewState extends ConsumerState { class SendFromCard extends ConsumerStatefulWidget { const SendFromCard({ - Key? key, + super.key, required this.walletId, required this.amount, required this.address, required this.trade, this.fromDesktopStep4 = false, - }) : super(key: key); + }); final String walletId; final Amount amount; @@ -235,6 +235,8 @@ class _SendFromCardState extends ConsumerState { try { bool wasCancelled = false; + final wallet = ref.read(pWallets).getWallet(walletId); + unawaited( showDialog( context: context, @@ -253,6 +255,8 @@ class _SendFromCardState extends ConsumerState { ), child: BuildingTransactionDialog( coin: coin, + isSpark: + wallet is FiroWallet && shouldSendPublicFiroFunds != true, onCancel: () { wasCancelled = true; @@ -273,8 +277,6 @@ class _SendFromCardState extends ConsumerState { TxData txData; Future txDataFuture; - final wallet = ref.read(pWallets).getWallet(walletId); - // if not firo then do normal send if (shouldSendPublicFiroFunds == null) { final memo = coin == Coin.stellar || coin == Coin.stellarTestnet @@ -371,38 +373,38 @@ class _SendFromCardState extends ConsumerState { } } } catch (e) { - // if (mounted) { - // pop building dialog - Navigator.of(context).pop(); + if (mounted) { + // pop building dialog + Navigator.of(context).pop(); - await showDialog( - context: context, - useSafeArea: false, - barrierDismissible: true, - builder: (context) { - return StackDialog( - title: "Transaction failed", - message: e.toString(), - rightButton: TextButton( - style: Theme.of(context) - .extension()! - .getSecondaryEnabledButtonStyle(context), - child: Text( - "Ok", - style: STextStyles.button(context).copyWith( - color: Theme.of(context) - .extension()! - .buttonTextSecondary, + await showDialog( + context: context, + useSafeArea: false, + barrierDismissible: true, + builder: (context) { + return StackDialog( + title: "Transaction failed", + message: e.toString(), + rightButton: TextButton( + style: Theme.of(context) + .extension()! + .getSecondaryEnabledButtonStyle(context), + child: Text( + "Ok", + style: STextStyles.button(context).copyWith( + color: Theme.of(context) + .extension()! + .buttonTextSecondary, + ), ), + onPressed: () { + Navigator.of(context).pop(); + }, ), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ); - }, - ); - // } + ); + }, + ); + } } } @@ -420,7 +422,8 @@ class _SendFromCardState extends ConsumerState { final wallet = ref.watch(pWallets).getWallet(walletId); final locale = ref.watch( - localeServiceChangeNotifierProvider.select((value) => value.locale)); + localeServiceChangeNotifierProvider.select((value) => value.locale), + ); final coin = ref.watch(pWalletCoin(walletId)); @@ -483,9 +486,11 @@ class _SendFromCardState extends ConsumerState { style: STextStyles.itemSubtitle(context), ), Text( - ref.watch(pAmountFormatter(coin)).format(ref - .watch(pWalletBalanceTertiary(walletId)) - .spendable), + ref.watch(pAmountFormatter(coin)).format( + ref + .watch(pWalletBalanceTertiary(walletId)) + .spendable, + ), style: STextStyles.itemSubtitle(context), ), ], @@ -637,7 +642,8 @@ class _SendFromCardState extends ConsumerState { if (!isFiro) Text( ref.watch(pAmountFormatter(coin)).format( - ref.watch(pWalletBalance(walletId)).spendable), + ref.watch(pWalletBalance(walletId)).spendable, + ), style: STextStyles.itemSubtitle(context), ), ], diff --git a/lib/pages/send_view/send_view.dart b/lib/pages/send_view/send_view.dart index 07cdcfd8a..fc0b89dc3 100644 --- a/lib/pages/send_view/send_view.dart +++ b/lib/pages/send_view/send_view.dart @@ -154,8 +154,10 @@ class _SendViewState extends ConsumerState { // .state = true, // ); - Logging.instance.log("qrResult content: ${qrResult.rawContent}", - level: LogLevel.Info); + Logging.instance.log( + "qrResult content: ${qrResult.rawContent}", + level: LogLevel.Info, + ); final results = AddressUtils.parseUri(qrResult.rawContent); @@ -213,8 +215,9 @@ class _SendViewState extends ConsumerState { // here we ignore the exception caused by not giving permission // to use the camera to scan a qr code Logging.instance.log( - "Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s", - level: LogLevel.Warning); + "Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s", + level: LogLevel.Warning, + ); } } @@ -280,8 +283,10 @@ class _SendViewState extends ConsumerState { return; } _cachedAmountToSend = amount; - Logging.instance.log("it changed $amount $_cachedAmountToSend", - level: LogLevel.Info); + Logging.instance.log( + "it changed $amount $_cachedAmountToSend", + level: LogLevel.Info, + ); final price = ref.read(priceAnd24hChangeNotifierProvider).getPrice(coin).item1; @@ -572,9 +577,10 @@ class _SendViewState extends ConsumerState { child: Text( "Cancel", style: STextStyles.button(context).copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + color: Theme.of(context) + .extension()! + .accentColorDark, + ), ), onPressed: () { Navigator.of(context).pop(false); @@ -616,6 +622,9 @@ class _SendViewState extends ConsumerState { builder: (context) { return BuildingTransactionDialog( coin: wallet.info.coin, + isSpark: wallet is FiroWallet && + ref.read(publicPrivateBalanceStateProvider.state).state == + FiroType.spark, onCancel: () { wasCancelled = true; @@ -645,7 +654,7 @@ class _SendViewState extends ConsumerState { address: widget.accountLite!.code, amount: amount, isChange: false, - ) + ), ], satsPerVByte: isCustomFee ? customFeeRate : null, feeRateType: feeRate, @@ -668,7 +677,7 @@ class _SendViewState extends ConsumerState { amount: amount, memo: memoController.text, isChange: false, - ) + ), ], feeRateType: ref.read(feeRateTypeStateProvider), satsPerVByte: isCustomFee ? customFeeRate : null, @@ -687,7 +696,7 @@ class _SendViewState extends ConsumerState { address: _address!, amount: amount, isChange: false, - ) + ), ], feeRateType: ref.read(feeRateTypeStateProvider), satsPerVByte: isCustomFee ? customFeeRate : null, @@ -709,7 +718,7 @@ class _SendViewState extends ConsumerState { address: _address!, amount: amount, isChange: false, - ) + ), ], ), ); @@ -725,7 +734,7 @@ class _SendViewState extends ConsumerState { address: _address!, amount: amount, isChange: false, - ) + ), ], sparkRecipients: ref.read(pValidSparkSendToAddress) ? [ @@ -734,7 +743,7 @@ class _SendViewState extends ConsumerState { amount: amount, memo: memoController.text, isChange: false, - ) + ), ] : null, ), @@ -752,7 +761,7 @@ class _SendViewState extends ConsumerState { address: _address!, amount: amount, isChange: false, - ) + ), ], memo: memo, feeRateType: ref.read(feeRateTypeStateProvider), @@ -827,9 +836,10 @@ class _SendViewState extends ConsumerState { child: Text( "Ok", style: STextStyles.button(context).copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + color: Theme.of(context) + .extension()! + .accentColorDark, + ), ), onPressed: () { Navigator.of(context).pop(); @@ -981,7 +991,8 @@ class _SendViewState extends ConsumerState { debugPrint("BUILD: $runtimeType"); final wallet = ref.watch(pWallets).getWallet(walletId); final String locale = ref.watch( - localeServiceChangeNotifierProvider.select((value) => value.locale)); + localeServiceChangeNotifierProvider.select((value) => value.locale), + ); final showCoinControl = wallet is CoinControlInterface && ref.watch( @@ -1033,7 +1044,7 @@ class _SendViewState extends ConsumerState { FocusScope.of(context).unfocus(); await Future.delayed(const Duration(milliseconds: 50)); } - if (mounted) { + if (context.mounted) { Navigator.of(context).pop(); } }, @@ -1118,82 +1129,93 @@ class _SendViewState extends ConsumerState { ], ), const Spacer(), - Builder(builder: (context) { - final Amount amount; - if (isFiro) { - switch (ref - .watch( + Builder( + builder: (context) { + final Amount amount; + if (isFiro) { + switch (ref + .watch( publicPrivateBalanceStateProvider - .state) - .state) { - case FiroType.public: - amount = ref - .read(pWalletBalance(walletId)) - .spendable; - break; - case FiroType.lelantus: - amount = ref - .read(pWalletBalanceSecondary( - walletId)) - .spendable; - break; - case FiroType.spark: - amount = ref - .read(pWalletBalanceTertiary( - walletId)) - .spendable; - break; - } - } else { - amount = ref - .read(pWalletBalance(walletId)) - .spendable; - } - - return GestureDetector( - onTap: () { - cryptoAmountController.text = ref - .read(pAmountFormatter(coin)) - .format( - amount, - withUnitName: false, - ); - }, - child: Container( - color: Colors.transparent, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.end, - children: [ - Text( - ref - .watch(pAmountFormatter(coin)) - .format(amount), - style: STextStyles.titleBold12( - context) - .copyWith( - fontSize: 10, - ), - textAlign: TextAlign.right, - ), - Text( - "${(amount.decimal * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getPrice(coin).item1))).toAmount( - fractionDigits: 2, - ).fiatString( - locale: locale, - )} ${ref.watch(prefsChangeNotifierProvider.select((value) => value.currency))}", - style: - STextStyles.subtitle(context) - .copyWith( - fontSize: 8, - ), - textAlign: TextAlign.right, + .state, ) - ], + .state) { + case FiroType.public: + amount = ref + .read(pWalletBalance(walletId)) + .spendable; + break; + case FiroType.lelantus: + amount = ref + .read( + pWalletBalanceSecondary( + walletId, + ), + ) + .spendable; + break; + case FiroType.spark: + amount = ref + .read( + pWalletBalanceTertiary( + walletId, + ), + ) + .spendable; + break; + } + } else { + amount = ref + .read(pWalletBalance(walletId)) + .spendable; + } + + return GestureDetector( + onTap: () { + cryptoAmountController.text = ref + .read(pAmountFormatter(coin)) + .format( + amount, + withUnitName: false, + ); + }, + child: Container( + color: Colors.transparent, + child: Column( + crossAxisAlignment: + CrossAxisAlignment.end, + children: [ + Text( + ref + .watch( + pAmountFormatter(coin), + ) + .format(amount), + style: STextStyles.titleBold12( + context, + ).copyWith( + fontSize: 10, + ), + textAlign: TextAlign.right, + ), + Text( + "${(amount.decimal * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getPrice(coin).item1))).toAmount( + fractionDigits: 2, + ).fiatString( + locale: locale, + )} ${ref.watch(prefsChangeNotifierProvider.select((value) => value.currency))}", + style: STextStyles.subtitle( + context, + ).copyWith( + fontSize: 8, + ), + textAlign: TextAlign.right, + ), + ], + ), ), - ), - ); - }), + ); + }, + ), ], ), ), @@ -1295,12 +1317,14 @@ class _SendViewState extends ConsumerState { semanticsLabel: "Clear Button. Clears The Address Field Input.", key: const Key( - "sendViewClearAddressFieldButtonKey"), + "sendViewClearAddressFieldButtonKey", + ), onTap: () { sendToController.text = ""; _address = ""; _setValidAddressProviders( - _address); + _address, + ); setState(() { _addressToggleFlag = false; @@ -1312,12 +1336,13 @@ class _SendViewState extends ConsumerState { semanticsLabel: "Paste Button. Pastes From Clipboard To Address Field Input.", key: const Key( - "sendViewPasteAddressFieldButtonKey"), + "sendViewPasteAddressFieldButtonKey", + ), onTap: () async { final ClipboardData? data = await clipboard.getData( - Clipboard - .kTextPlain); + Clipboard.kTextPlain, + ); if (data?.text != null && data! .text!.isNotEmpty) { @@ -1327,23 +1352,27 @@ class _SendViewState extends ConsumerState { .contains("\n")) { content = content.substring( - 0, - content.indexOf( - "\n")); + 0, + content.indexOf( + "\n", + ), + ); } if (coin == Coin.epicCash) { // strip http:// and https:// if content contains @ content = formatAddress( - content); + content, + ); } sendToController.text = content.trim(); _address = content.trim(); _setValidAddressProviders( - _address); + _address, + ); setState(() { _addressToggleFlag = sendToController @@ -1362,7 +1391,8 @@ class _SendViewState extends ConsumerState { semanticsLabel: "Address Book Button. Opens Address Book For Address Field.", key: const Key( - "sendViewAddressBookButtonKey"), + "sendViewAddressBookButtonKey", + ), onTap: () { Navigator.of(context).pushNamed( AddressBookView.routeName, @@ -1376,7 +1406,8 @@ class _SendViewState extends ConsumerState { semanticsLabel: "Scan QR Button. Opens Camera For Scanning QR Code.", key: const Key( - "sendViewScanQrButtonKey"), + "sendViewScanQrButtonKey", + ), onTap: _scanQr, child: const QrCodeIcon(), ), @@ -1393,7 +1424,8 @@ class _SendViewState extends ConsumerState { if (isStellar || (ref.watch(pValidSparkSendToAddress) && ref.watch( - publicPrivateBalanceStateProvider) != + publicPrivateBalanceStateProvider, + ) != FiroType.lelantus)) ClipRRect( borderRadius: BorderRadius.circular( @@ -1440,7 +1472,8 @@ class _SendViewState extends ConsumerState { semanticsLabel: "Clear Button. Clears The Memo Field Input.", key: const Key( - "sendViewClearMemoFieldButtonKey"), + "sendViewClearMemoFieldButtonKey", + ), onTap: () { memoController.text = ""; setState(() {}); @@ -1451,16 +1484,17 @@ class _SendViewState extends ConsumerState { semanticsLabel: "Paste Button. Pastes From Clipboard To Memo Field Input.", key: const Key( - "sendViewPasteMemoFieldButtonKey"), + "sendViewPasteMemoFieldButtonKey", + ), onTap: () async { final ClipboardData? data = await clipboard.getData( - Clipboard - .kTextPlain); + Clipboard.kTextPlain, + ); if (data?.text != null && data! .text!.isNotEmpty) { - String content = + final String content = data.text!.trim(); memoController.text = @@ -1486,13 +1520,15 @@ class _SendViewState extends ConsumerState { error = null; } else if (isFiro) { if (ref.watch( - publicPrivateBalanceStateProvider) == + publicPrivateBalanceStateProvider, + ) == FiroType.lelantus) { if (_data != null && _data!.contactLabel == _address) { error = SparkInterface.validateSparkAddress( - address: _data!.address, - isTestNet: coin.isTestNet) + address: _data!.address, + isTestNet: coin.isTestNet, + ) ? "Unsupported" : null; } else if (ref @@ -1611,51 +1647,65 @@ class _SendViewState extends ConsumerState { Text( "${ref.watch(publicPrivateBalanceStateProvider.state).state.name.capitalize()} balance", style: STextStyles.itemSubtitle12( - context), + context, + ), ), const SizedBox( width: 10, ), - Builder(builder: (_) { - final Amount amount; - switch (ref - .read( + Builder( + builder: (_) { + final Amount amount; + switch (ref + .read( publicPrivateBalanceStateProvider - .state) - .state) { - case FiroType.public: - amount = ref - .watch(pWalletBalance( - walletId)) - .spendable; - break; - case FiroType.lelantus: - amount = ref - .watch( + .state, + ) + .state) { + case FiroType.public: + amount = ref + .watch( + pWalletBalance( + walletId, + ), + ) + .spendable; + break; + case FiroType.lelantus: + amount = ref + .watch( pWalletBalanceSecondary( - walletId)) - .spendable; - break; - case FiroType.spark: - amount = ref - .watch( + walletId, + ), + ) + .spendable; + break; + case FiroType.spark: + amount = ref + .watch( pWalletBalanceTertiary( - walletId)) - .spendable; - break; - } + walletId, + ), + ) + .spendable; + break; + } - return Text( - ref - .watch( - pAmountFormatter(coin)) - .format( - amount, - ), - style: STextStyles.itemSubtitle( - context), - ); - }), + return Text( + ref + .watch( + pAmountFormatter(coin), + ) + .format( + amount, + ), + style: + STextStyles.itemSubtitle( + context, + ), + ); + }, + ), ], ), SvgPicture.asset( @@ -1669,7 +1719,7 @@ class _SendViewState extends ConsumerState { ], ), ), - ) + ), ], ), const SizedBox( @@ -1691,8 +1741,9 @@ class _SendViewState extends ConsumerState { final Amount amount; switch (ref .read( - publicPrivateBalanceStateProvider - .state) + publicPrivateBalanceStateProvider + .state, + ) .state) { case FiroType.public: amount = ref @@ -1701,14 +1752,20 @@ class _SendViewState extends ConsumerState { break; case FiroType.lelantus: amount = ref - .read(pWalletBalanceSecondary( - walletId)) + .read( + pWalletBalanceSecondary( + walletId, + ), + ) .spendable; break; case FiroType.spark: amount = ref - .read(pWalletBalanceTertiary( - walletId)) + .read( + pWalletBalanceTertiary( + walletId, + ), + ) .spendable; break; } @@ -1793,9 +1850,10 @@ class _SendViewState extends ConsumerState { .unitForCoin(coin), style: STextStyles.smallMed14(context) .copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + color: Theme.of(context) + .extension()! + .accentColorDark, + ), ), ), ), @@ -1855,13 +1913,16 @@ class _SendViewState extends ConsumerState { child: Padding( padding: const EdgeInsets.all(12), child: Text( - ref.watch(prefsChangeNotifierProvider - .select((value) => value.currency)), + ref.watch( + prefsChangeNotifierProvider + .select((value) => value.currency), + ), style: STextStyles.smallMed14(context) .copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + color: Theme.of(context) + .extension()! + .accentColorDark, + ), ), ), ), @@ -1898,7 +1959,7 @@ class _SendViewState extends ConsumerState { ); } - if (mounted) { + if (context.mounted) { final spendable = ref .read(pWalletBalance(walletId)) .spendable; @@ -2096,8 +2157,9 @@ class _SendViewState extends ConsumerState { onPressed: isFiro && ref .watch( - publicPrivateBalanceStateProvider - .state) + publicPrivateBalanceStateProvider + .state, + ) .state != FiroType.public ? null @@ -2117,8 +2179,9 @@ class _SendViewState extends ConsumerState { TransactionFeeSelectionSheet( walletId: walletId, amount: (Decimal.tryParse( - cryptoAmountController - .text) ?? + cryptoAmountController + .text, + ) ?? ref .watch(pSendAmount) ?.decimal ?? @@ -2154,8 +2217,9 @@ class _SendViewState extends ConsumerState { child: (isFiro && ref .watch( - publicPrivateBalanceStateProvider - .state) + publicPrivateBalanceStateProvider + .state, + ) .state != FiroType.public) ? Row( @@ -2175,7 +2239,8 @@ class _SendViewState extends ConsumerState { "~${snapshot.data!}", style: STextStyles .itemSubtitle( - context), + context, + ), ); } else { return AnimatedText( @@ -2187,7 +2252,8 @@ class _SendViewState extends ConsumerState { ], style: STextStyles .itemSubtitle( - context), + context, + ), ); } }, @@ -2203,13 +2269,15 @@ class _SendViewState extends ConsumerState { Text( ref .watch( - feeRateTypeStateProvider - .state) + feeRateTypeStateProvider + .state, + ) .state .prettyName, style: STextStyles .itemSubtitle12( - context), + context, + ), ), const SizedBox( width: 10, @@ -2233,7 +2301,8 @@ class _SendViewState extends ConsumerState { : "~${snapshot.data!}", style: STextStyles .itemSubtitle( - context), + context, + ), ); } else { return AnimatedText( @@ -2245,7 +2314,8 @@ class _SendViewState extends ConsumerState { ], style: STextStyles .itemSubtitle( - context), + context, + ), ); } }, @@ -2263,7 +2333,7 @@ class _SendViewState extends ConsumerState { ], ), ), - ) + ), ], ), if (isCustomFee) diff --git a/lib/pages/send_view/sub_widgets/building_transaction_dialog.dart b/lib/pages/send_view/sub_widgets/building_transaction_dialog.dart index a8dfe643b..8529925d6 100644 --- a/lib/pages/send_view/sub_widgets/building_transaction_dialog.dart +++ b/lib/pages/send_view/sub_widgets/building_transaction_dialog.dart @@ -12,8 +12,8 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/themes/coin_image_provider.dart'; +import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/util.dart'; @@ -23,13 +23,15 @@ import 'package:stackwallet/widgets/stack_dialog.dart'; class BuildingTransactionDialog extends ConsumerStatefulWidget { const BuildingTransactionDialog({ - Key? key, + super.key, required this.onCancel, required this.coin, - }) : super(key: key); + required this.isSpark, + }); final VoidCallback onCancel; final Coin coin; + final bool isSpark; @override ConsumerState createState() => @@ -62,13 +64,24 @@ class _RestoringDialogState extends ConsumerState { "Generating transaction", style: STextStyles.desktopH3(context), ), + if (widget.isSpark) + const SizedBox( + height: 16, + ), + if (widget.isSpark) + Text( + "This may take a few minutes...", + style: STextStyles.desktopSubtitleH2(context), + ), const SizedBox( height: 40, ), assetPath.endsWith(".gif") - ? Image.file(File( - assetPath, - )) + ? Image.file( + File( + assetPath, + ), + ) : const RotatingArrows( width: 40, height: 40, @@ -82,7 +95,7 @@ class _RestoringDialogState extends ConsumerState { onPressed: () { onCancel.call(); }, - ) + ), ], ); } else { @@ -96,14 +109,26 @@ class _RestoringDialogState extends ConsumerState { crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisSize: MainAxisSize.min, children: [ - Image.file(File( - assetPath, - )), + Image.file( + File( + assetPath, + ), + ), Text( "Generating transaction", textAlign: TextAlign.center, style: STextStyles.pageTitleH2(context), ), + if (widget.isSpark) + const SizedBox( + height: 12, + ), + if (widget.isSpark) + Text( + "This may take a few minutes...", + textAlign: TextAlign.center, + style: STextStyles.w500_16(context), + ), const SizedBox( height: 32, ), @@ -124,7 +149,7 @@ class _RestoringDialogState extends ConsumerState { onCancel.call(); }, ), - ) + ), ], ), ], @@ -132,6 +157,8 @@ class _RestoringDialogState extends ConsumerState { ) : StackDialog( title: "Generating transaction", + message: + widget.isSpark ? "This may take a few minutes..." : null, icon: const RotatingArrows( width: 24, height: 24, diff --git a/lib/pages/send_view/token_send_view.dart b/lib/pages/send_view/token_send_view.dart index 0cba2bf17..028538d63 100644 --- a/lib/pages/send_view/token_send_view.dart +++ b/lib/pages/send_view/token_send_view.dart @@ -58,14 +58,14 @@ import 'package:stackwallet/widgets/textfield_icon_button.dart'; class TokenSendView extends ConsumerStatefulWidget { const TokenSendView({ - Key? key, + super.key, required this.walletId, required this.coin, required this.tokenContract, this.autoFillData, this.clipboard = const ClipboardWrapper(), this.barcodeScanner = const BarcodeScannerWrapper(), - }) : super(key: key); + }); static const String routeName = "/tokenSendView"; @@ -156,8 +156,10 @@ class _TokenSendViewState extends ConsumerState { // .state = true, // ); - Logging.instance.log("qrResult content: ${qrResult.rawContent}", - level: LogLevel.Info); + Logging.instance.log( + "qrResult content: ${qrResult.rawContent}", + level: LogLevel.Info, + ); final results = AddressUtils.parseUri(qrResult.rawContent); @@ -216,8 +218,9 @@ class _TokenSendViewState extends ConsumerState { // here we ignore the exception caused by not giving permission // to use the camera to scan a qr code Logging.instance.log( - "Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s", - level: LogLevel.Warning); + "Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s", + level: LogLevel.Warning, + ); } } @@ -239,15 +242,19 @@ class _TokenSendViewState extends ConsumerState { ? Amount.zero : Amount.fromDecimal( (baseAmount.decimal / _price).toDecimal( - scaleOnInfinitePrecision: tokenContract.decimals), - fractionDigits: tokenContract.decimals); + scaleOnInfinitePrecision: tokenContract.decimals, + ), + fractionDigits: tokenContract.decimals, + ); } if (_cachedAmountToSend != null && _cachedAmountToSend == _amountToSend) { return; } _cachedAmountToSend = _amountToSend; - Logging.instance.log("it changed $_amountToSend $_cachedAmountToSend", - level: LogLevel.Info); + Logging.instance.log( + "it changed $_amountToSend $_cachedAmountToSend", + level: LogLevel.Info, + ); _cryptoAmountChangeLock = true; cryptoAmountController.text = ref.read(pAmountFormatter(coin)).format( @@ -282,8 +289,10 @@ class _TokenSendViewState extends ConsumerState { return; } _cachedAmountToSend = _amountToSend; - Logging.instance.log("it changed $_amountToSend $_cachedAmountToSend", - level: LogLevel.Info); + Logging.instance.log( + "it changed $_amountToSend $_cachedAmountToSend", + level: LogLevel.Info, + ); final price = ref .read(priceAnd24hChangeNotifierProvider) @@ -457,6 +466,7 @@ class _TokenSendViewState extends ConsumerState { builder: (context) { return BuildingTransactionDialog( coin: wallet.info.coin, + isSpark: false, onCancel: () { wasCancelled = true; @@ -484,7 +494,7 @@ class _TokenSendViewState extends ConsumerState { address: _address!, amount: amount, isChange: false, - ) + ), ], feeRateType: ref.read(feeRateTypeStateProvider), note: noteController.text, @@ -502,20 +512,22 @@ class _TokenSendViewState extends ConsumerState { // pop building dialog Navigator.of(context).pop(); - unawaited(Navigator.of(context).push( - RouteGenerator.getRoute( - shouldUseMaterialRoute: RouteGenerator.useMaterialPageRoute, - builder: (_) => ConfirmTransactionView( - txData: txData, - walletId: walletId, - isTokenTx: true, - onSuccess: clearSendForm, - ), - settings: const RouteSettings( - name: ConfirmTransactionView.routeName, + unawaited( + Navigator.of(context).push( + RouteGenerator.getRoute( + shouldUseMaterialRoute: RouteGenerator.useMaterialPageRoute, + builder: (_) => ConfirmTransactionView( + txData: txData, + walletId: walletId, + isTokenTx: true, + onSuccess: clearSendForm, + ), + settings: const RouteSettings( + name: ConfirmTransactionView.routeName, + ), ), ), - )); + ); } } catch (e) { if (mounted) { @@ -538,9 +550,10 @@ class _TokenSendViewState extends ConsumerState { child: Text( "Ok", style: STextStyles.button(context).copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + color: Theme.of(context) + .extension()! + .accentColorDark, + ), ), onPressed: () { Navigator.of(context).pop(); @@ -626,7 +639,8 @@ class _TokenSendViewState extends ConsumerState { Widget build(BuildContext context) { debugPrint("BUILD: $runtimeType"); final String locale = ref.watch( - localeServiceChangeNotifierProvider.select((value) => value.locale)); + localeServiceChangeNotifierProvider.select((value) => value.locale), + ); return Background( child: Scaffold( @@ -638,7 +652,7 @@ class _TokenSendViewState extends ConsumerState { FocusScope.of(context).unfocus(); await Future.delayed(const Duration(milliseconds: 50)); } - if (mounted) { + if (context.mounted) { Navigator.of(context).pop(); } }, @@ -712,11 +726,15 @@ class _TokenSendViewState extends ConsumerState { .watch(pAmountFormatter(coin)) .format( ref - .read(pTokenBalance(( - walletId: widget.walletId, - contractAddress: - tokenContract.address, - ))) + .read( + pTokenBalance( + ( + walletId: widget.walletId, + contractAddress: + tokenContract.address, + ), + ), + ) .spendable, ethContract: tokenContract, withUnitName: false, @@ -734,13 +752,17 @@ class _TokenSendViewState extends ConsumerState { .watch(pAmountFormatter(coin)) .format( ref - .watch(pTokenBalance(( - walletId: - widget.walletId, - contractAddress: - tokenContract - .address, - ))) + .watch( + pTokenBalance( + ( + walletId: + widget.walletId, + contractAddress: + tokenContract + .address, + ), + ), + ) .spendable, ethContract: tokenContract, ), @@ -752,13 +774,17 @@ class _TokenSendViewState extends ConsumerState { textAlign: TextAlign.right, ), Text( - "${(ref.watch(pTokenBalance(( + "${(ref.watch( + pTokenBalance( + ( walletId: widget.walletId, contractAddress: tokenContract .address, - ))).spendable.decimal * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getTokenPrice(tokenContract.address).item1))).toAmount( + ), + ), + ).spendable.decimal * ref.watch(priceAnd24hChangeNotifierProvider.select((value) => value.getTokenPrice(tokenContract.address).item1))).toAmount( fractionDigits: 2, ).fiatString( locale: locale, @@ -768,7 +794,7 @@ class _TokenSendViewState extends ConsumerState { fontSize: 8, ), textAlign: TextAlign.right, - ) + ), ], ), ), @@ -807,7 +833,9 @@ class _TokenSendViewState extends ConsumerState { onChanged: (newValue) { _address = newValue.trim(); _updatePreviewButtonState( - _address, _amountToSend); + _address, + _amountToSend, + ); setState(() { _addressToggleFlag = newValue.isNotEmpty; @@ -838,12 +866,15 @@ class _TokenSendViewState extends ConsumerState { _addressToggleFlag ? TextFieldIconButton( key: const Key( - "tokenSendViewClearAddressFieldButtonKey"), + "tokenSendViewClearAddressFieldButtonKey", + ), onTap: () { sendToController.text = ""; _address = ""; _updatePreviewButtonState( - _address, _amountToSend); + _address, + _amountToSend, + ); setState(() { _addressToggleFlag = false; }); @@ -852,7 +883,8 @@ class _TokenSendViewState extends ConsumerState { ) : TextFieldIconButton( key: const Key( - "tokenSendViewPasteAddressFieldButtonKey"), + "tokenSendViewPasteAddressFieldButtonKey", + ), onTap: _onTokenSendViewPasteAddressFieldButtonPressed, child: sendToController @@ -863,7 +895,8 @@ class _TokenSendViewState extends ConsumerState { if (sendToController.text.isEmpty) TextFieldIconButton( key: const Key( - "sendViewAddressBookButtonKey"), + "sendViewAddressBookButtonKey", + ), onTap: () { Navigator.of(context).pushNamed( AddressBookView.routeName, @@ -875,11 +908,12 @@ class _TokenSendViewState extends ConsumerState { if (sendToController.text.isEmpty) TextFieldIconButton( key: const Key( - "sendViewScanQrButtonKey"), + "sendViewScanQrButtonKey", + ), onTap: _onTokenSendViewScanQrButtonPressed, child: const QrCodeIcon(), - ) + ), ], ), ), @@ -997,9 +1031,10 @@ class _TokenSendViewState extends ConsumerState { tokenContract.symbol, style: STextStyles.smallMed14(context) .copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + color: Theme.of(context) + .extension()! + .accentColorDark, + ), ), ), ), @@ -1058,13 +1093,16 @@ class _TokenSendViewState extends ConsumerState { child: Padding( padding: const EdgeInsets.all(12), child: Text( - ref.watch(prefsChangeNotifierProvider - .select((value) => value.currency)), + ref.watch( + prefsChangeNotifierProvider + .select((value) => value.currency), + ), style: STextStyles.smallMed14(context) .copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + color: Theme.of(context) + .extension()! + .accentColorDark, + ), ), ), ), @@ -1169,8 +1207,8 @@ class _TokenSendViewState extends ConsumerState { walletId: walletId, isToken: true, amount: (Decimal.tryParse( - cryptoAmountController - .text) ?? + cryptoAmountController.text, + ) ?? Decimal.zero) .toAmount( fractionDigits: @@ -1193,12 +1231,15 @@ class _TokenSendViewState extends ConsumerState { children: [ Text( ref - .watch(feeRateTypeStateProvider - .state) + .watch( + feeRateTypeStateProvider + .state, + ) .state .prettyName, style: STextStyles.itemSubtitle12( - context), + context, + ), ), const SizedBox( width: 10, @@ -1213,7 +1254,8 @@ class _TokenSendViewState extends ConsumerState { "~${snapshot.data!}", style: STextStyles.itemSubtitle( - context), + context, + ), ); } else { return AnimatedText( @@ -1225,7 +1267,8 @@ class _TokenSendViewState extends ConsumerState { ], style: STextStyles.itemSubtitle( - context), + context, + ), ); } }, @@ -1243,7 +1286,7 @@ class _TokenSendViewState extends ConsumerState { ], ), ), - ) + ), ], ), const Spacer(), @@ -1253,13 +1296,15 @@ class _TokenSendViewState extends ConsumerState { TextButton( onPressed: ref .watch( - previewTokenTxButtonStateProvider.state) + previewTokenTxButtonStateProvider.state, + ) .state ? _previewTransaction : null, style: ref .watch( - previewTokenTxButtonStateProvider.state) + previewTokenTxButtonStateProvider.state, + ) .state ? Theme.of(context) .extension()! diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart index 160de0367..2614a58d4 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart @@ -272,6 +272,11 @@ class _DesktopSendState extends ConsumerState { padding: const EdgeInsets.all(32), child: BuildingTransactionDialog( coin: wallet.info.coin, + isSpark: wallet is FiroWallet && + ref + .read(publicPrivateBalanceStateProvider.state) + .state == + FiroType.spark, onCancel: () { wasCancelled = true; @@ -306,7 +311,7 @@ class _DesktopSendState extends ConsumerState { address: widget.accountLite!.code, amount: amount, isChange: false, - ) + ), ], satsPerVByte: isCustomFee ? customFeeRate : null, feeRateType: feeRate, @@ -329,7 +334,7 @@ class _DesktopSendState extends ConsumerState { amount: amount, memo: memoController.text, isChange: false, - ) + ), ], feeRateType: ref.read(feeRateTypeStateProvider), satsPerVByte: isCustomFee ? customFeeRate : null, @@ -348,7 +353,7 @@ class _DesktopSendState extends ConsumerState { address: _address!, amount: amount, isChange: false, - ) + ), ], feeRateType: ref.read(feeRateTypeStateProvider), satsPerVByte: isCustomFee ? customFeeRate : null, @@ -370,7 +375,7 @@ class _DesktopSendState extends ConsumerState { address: _address!, amount: amount, isChange: false, - ) + ), ], ), ); @@ -386,7 +391,7 @@ class _DesktopSendState extends ConsumerState { address: _address!, amount: amount, isChange: false, - ) + ), ], sparkRecipients: ref.read(pValidSparkSendToAddress) ? [ @@ -395,7 +400,7 @@ class _DesktopSendState extends ConsumerState { amount: amount, memo: memoController.text, isChange: false, - ) + ), ] : null, ), @@ -411,7 +416,7 @@ class _DesktopSendState extends ConsumerState { address: _address!, amount: amount, isChange: false, - ) + ), ], memo: memo, feeRateType: ref.read(feeRateTypeStateProvider), @@ -577,8 +582,10 @@ class _DesktopSendState extends ConsumerState { if (_cachedAmountToSend != null && _cachedAmountToSend == amount) { return; } - Logging.instance.log("it changed $amount $_cachedAmountToSend", - level: LogLevel.Info); + Logging.instance.log( + "it changed $amount $_cachedAmountToSend", + level: LogLevel.Info, + ); _cachedAmountToSend = amount; final price = @@ -627,8 +634,10 @@ class _DesktopSendState extends ConsumerState { final qrResult = await scanner.scan(); - Logging.instance.log("qrResult content: ${qrResult.rawContent}", - level: LogLevel.Info); + Logging.instance.log( + "qrResult content: ${qrResult.rawContent}", + level: LogLevel.Info, + ); final results = AddressUtils.parseUri(qrResult.rawContent); @@ -679,8 +688,9 @@ class _DesktopSendState extends ConsumerState { // here we ignore the exception caused by not giving permission // to use the camera to scan a qr code Logging.instance.log( - "Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s", - level: LogLevel.Warning); + "Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s", + level: LogLevel.Warning, + ); } } @@ -734,7 +744,7 @@ class _DesktopSendState extends ConsumerState { } else { final ClipboardData? data = await clipboard.getData(Clipboard.kTextPlain); if (data?.text != null && data!.text!.isNotEmpty) { - String content = data.text!.trim(); + final String content = data.text!.trim(); setState(() { memoController.text = content; @@ -865,7 +875,8 @@ class _DesktopSendState extends ConsumerState { if (isPaynymSend) { sendToController.text = widget.accountLite!.nymName; WidgetsBinding.instance.addPostFrameCallback( - (_) => _setValidAddressProviders(sendToController.text)); + (_) => _setValidAddressProviders(sendToController.text), + ); } _cryptoFocus.addListener(() { @@ -912,7 +923,8 @@ class _DesktopSendState extends ConsumerState { Widget build(BuildContext context) { debugPrint("BUILD: $runtimeType"); final String locale = ref.watch( - localeServiceChangeNotifierProvider.select((value) => value.locale)); + localeServiceChangeNotifierProvider.select((value) => value.locale), + ); // add listener for epic cash to strip http:// and https:// prefixes if the address also ocntains an @ symbol (indicating an epicbox address) if (coin == Coin.epicCash) { @@ -975,9 +987,11 @@ class _DesktopSendState extends ConsumerState { width: 10, ), Text( - ref.watch(pAmountFormatter(coin)).format(ref - .watch(pWalletBalanceTertiary(walletId)) - .spendable), + ref.watch(pAmountFormatter(coin)).format( + ref + .watch(pWalletBalanceTertiary(walletId)) + .spendable, + ), style: STextStyles.itemSubtitle(context), ), ], @@ -995,9 +1009,11 @@ class _DesktopSendState extends ConsumerState { width: 10, ), Text( - ref.watch(pAmountFormatter(coin)).format(ref - .watch(pWalletBalanceSecondary(walletId)) - .spendable), + ref.watch(pAmountFormatter(coin)).format( + ref + .watch(pWalletBalanceSecondary(walletId)) + .spendable, + ), style: STextStyles.itemSubtitle(context), ), ], @@ -1016,7 +1032,8 @@ class _DesktopSendState extends ConsumerState { ), Text( ref.watch(pAmountFormatter(coin)).format( - ref.watch(pWalletBalance(walletId)).spendable), + ref.watch(pWalletBalance(walletId)).spendable, + ), style: STextStyles.itemSubtitle(context), ), ], @@ -1164,9 +1181,10 @@ class _DesktopSendState extends ConsumerState { child: Text( ref.watch(pAmountUnit(coin)).unitForCoin(coin), style: STextStyles.smallMed14(context).copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + color: Theme.of(context) + .extension()! + .accentColorDark, + ), ), ), ), @@ -1223,12 +1241,15 @@ class _DesktopSendState extends ConsumerState { child: Padding( padding: const EdgeInsets.all(12), child: Text( - ref.watch(prefsChangeNotifierProvider - .select((value) => value.currency)), + ref.watch( + prefsChangeNotifierProvider + .select((value) => value.currency), + ), style: STextStyles.smallMed14(context).copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + color: Theme.of(context) + .extension()! + .accentColorDark, + ), ), ), ), @@ -1337,7 +1358,8 @@ class _DesktopSendState extends ConsumerState { _addressToggleFlag ? TextFieldIconButton( key: const Key( - "sendViewClearAddressFieldButtonKey"), + "sendViewClearAddressFieldButtonKey", + ), onTap: () { sendToController.text = ""; _address = ""; @@ -1350,7 +1372,8 @@ class _DesktopSendState extends ConsumerState { ) : TextFieldIconButton( key: const Key( - "sendViewPasteAddressFieldButtonKey"), + "sendViewPasteAddressFieldButtonKey", + ), onTap: pasteAddress, child: sendToController.text.isEmpty ? const ClipboardIcon() @@ -1380,7 +1403,8 @@ class _DesktopSendState extends ConsumerState { child: Text( "Address book", style: STextStyles.desktopH3( - context), + context, + ), ), ), const DesktopDialogCloseButton(), @@ -1436,7 +1460,9 @@ class _DesktopSendState extends ConsumerState { FiroType.lelantus) { if (_data != null && _data!.contactLabel == _address) { error = SparkInterface.validateSparkAddress( - address: _data!.address, isTestNet: coin.isTestNet) + address: _data!.address, + isTestNet: coin.isTestNet, + ) ? "Lelantus to Spark not supported" : null; } else if (ref.watch(pValidSparkSendToAddress)) { @@ -1662,8 +1688,9 @@ class _DesktopSendState extends ConsumerState { if (coin == Coin.monero || coin == Coin.wownero) { final fee = await wallet.estimateFeeFor( - amount, - MoneroTransactionPriority.regular.raw!); + amount, + MoneroTransactionPriority.regular.raw!, + ); ref .read(feeSheetSessionCacheProvider) .average[amount] = fee; @@ -1671,16 +1698,18 @@ class _DesktopSendState extends ConsumerState { coin == Coin.firoTestNet) && ref .read( - publicPrivateBalanceStateProvider - .state) + publicPrivateBalanceStateProvider + .state, + ) .state != FiroType.public) { final firoWallet = wallet as FiroWallet; if (ref .read( - publicPrivateBalanceStateProvider - .state) + publicPrivateBalanceStateProvider + .state, + ) .state == FiroType.lelantus) { ref @@ -1690,8 +1719,9 @@ class _DesktopSendState extends ConsumerState { .estimateFeeForLelantus(amount); } else if (ref .read( - publicPrivateBalanceStateProvider - .state) + publicPrivateBalanceStateProvider + .state, + ) .state == FiroType.spark) { ref @@ -1705,7 +1735,9 @@ class _DesktopSendState extends ConsumerState { .read(feeSheetSessionCacheProvider) .average[amount] = await wallet.estimateFeeFor( - amount, feeRate); + amount, + feeRate, + ); } } return ref @@ -1720,8 +1752,8 @@ class _DesktopSendState extends ConsumerState { AnimatedText( stringsToLoopThrough: stringsToLoopThrough, style: STextStyles.desktopTextExtraExtraSmall( - context) - .copyWith( + context, + ).copyWith( color: Theme.of(context) .extension()! .textFieldActiveText, @@ -1735,7 +1767,8 @@ class _DesktopSendState extends ConsumerState { : (coin == Coin.firo || coin == Coin.firoTestNet) && ref .watch( - publicPrivateBalanceStateProvider.state) + publicPrivateBalanceStateProvider.state, + ) .state == FiroType.lelantus ? Text( @@ -1760,8 +1793,8 @@ class _DesktopSendState extends ConsumerState { Text( feeSelectionResult?.$2 ?? "", style: STextStyles.desktopTextExtraExtraSmall( - context) - .copyWith( + context, + ).copyWith( color: Theme.of(context) .extension()! .textFieldActiveText, @@ -1771,8 +1804,8 @@ class _DesktopSendState extends ConsumerState { Text( feeSelectionResult?.$3 ?? "", style: STextStyles.desktopTextExtraExtraSmall( - context) - .copyWith( + context, + ).copyWith( color: Theme.of(context) .extension()! .textFieldActiveSearchIconRight, @@ -1803,7 +1836,7 @@ class _DesktopSendState extends ConsumerState { enabled: ref.watch(pPreviewTxButtonEnabled(coin)), onPressed: ref.watch(pPreviewTxButtonEnabled(coin)) ? previewSend : null, - ) + ), ], ); } diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_token_send.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_token_send.dart index 0887036a6..eef67e694 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_token_send.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_token_send.dart @@ -56,13 +56,13 @@ import 'package:stackwallet/widgets/textfield_icon_button.dart'; class DesktopTokenSend extends ConsumerStatefulWidget { const DesktopTokenSend({ - Key? key, + super.key, required this.walletId, this.autoFillData, this.clipboard = const ClipboardWrapper(), this.barcodeScanner = const BarcodeScannerWrapper(), this.accountLite, - }) : super(key: key); + }); final String walletId; final SendViewAutoFillData? autoFillData; @@ -108,10 +108,14 @@ class _DesktopTokenSendState extends ConsumerState { final Amount amount = _amountToSend!; final Amount availableBalance = ref - .read(pTokenBalance(( - walletId: walletId, - contractAddress: tokenWallet.tokenContract.address - ))) + .read( + pTokenBalance( + ( + walletId: walletId, + contractAddress: tokenWallet.tokenContract.address + ), + ), + ) .spendable; // confirm send all @@ -221,6 +225,7 @@ class _DesktopTokenSendState extends ConsumerState { padding: const EdgeInsets.all(32), child: BuildingTransactionDialog( coin: tokenWallet.cryptoCurrency.coin, + isSpark: false, onCancel: () { wasCancelled = true; @@ -250,7 +255,7 @@ class _DesktopTokenSendState extends ConsumerState { address: _address!, amount: amount, isChange: false, - ) + ), ], feeRateType: ref.read(feeRateTypeStateProvider), nonce: int.tryParse(nonceController.text), @@ -405,8 +410,10 @@ class _DesktopTokenSendState extends ConsumerState { _cachedAmountToSend == _amountToSend) { return; } - Logging.instance.log("it changed $_amountToSend $_cachedAmountToSend", - level: LogLevel.Info); + Logging.instance.log( + "it changed $_amountToSend $_cachedAmountToSend", + level: LogLevel.Info, + ); _cachedAmountToSend = _amountToSend; final price = ref @@ -468,8 +475,10 @@ class _DesktopTokenSendState extends ConsumerState { final qrResult = await scanner.scan(); - Logging.instance.log("qrResult content: ${qrResult.rawContent}", - level: LogLevel.Info); + Logging.instance.log( + "qrResult content: ${qrResult.rawContent}", + level: LogLevel.Info, + ); final results = AddressUtils.parseUri(qrResult.rawContent); @@ -524,8 +533,9 @@ class _DesktopTokenSendState extends ConsumerState { // here we ignore the exception caused by not giving permission // to use the camera to scan a qr code Logging.instance.log( - "Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s", - level: LogLevel.Warning); + "Failed to get camera permissions while trying to scan qr code in SendView: $e\n$s", + level: LogLevel.Warning, + ); } } @@ -579,8 +589,10 @@ class _DesktopTokenSendState extends ConsumerState { return; } _cachedAmountToSend = _amountToSend; - Logging.instance.log("it changed $_amountToSend $_cachedAmountToSend", - level: LogLevel.Info); + Logging.instance.log( + "it changed $_amountToSend $_cachedAmountToSend", + level: LogLevel.Info, + ); final amountString = ref.read(pAmountFormatter(coin)).format( _amountToSend!, @@ -603,10 +615,15 @@ class _DesktopTokenSendState extends ConsumerState { Future sendAllTapped() async { cryptoAmountController.text = ref - .read(pTokenBalance(( - walletId: walletId, - contractAddress: ref.read(pCurrentTokenWallet)!.tokenContract.address - ))) + .read( + pTokenBalance( + ( + walletId: walletId, + contractAddress: + ref.read(pCurrentTokenWallet)!.tokenContract.address + ), + ), + ) .spendable .decimal .toStringAsFixed( @@ -788,9 +805,10 @@ class _DesktopTokenSendState extends ConsumerState { child: Text( tokenContract.symbol, style: STextStyles.smallMed14(context).copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + color: Theme.of(context) + .extension()! + .accentColorDark, + ), ), ), ), @@ -850,12 +868,15 @@ class _DesktopTokenSendState extends ConsumerState { child: Padding( padding: const EdgeInsets.all(12), child: Text( - ref.watch(prefsChangeNotifierProvider - .select((value) => value.currency)), + ref.watch( + prefsChangeNotifierProvider + .select((value) => value.currency), + ), style: STextStyles.smallMed14(context).copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + color: Theme.of(context) + .extension()! + .accentColorDark, + ), ), ), ), @@ -936,12 +957,15 @@ class _DesktopTokenSendState extends ConsumerState { _addressToggleFlag ? TextFieldIconButton( key: const Key( - "sendTokenViewClearAddressFieldButtonKey"), + "sendTokenViewClearAddressFieldButtonKey", + ), onTap: () { sendToController.text = ""; _address = ""; _updatePreviewButtonState( - _address, _amountToSend); + _address, + _amountToSend, + ); setState(() { _addressToggleFlag = false; }); @@ -950,7 +974,8 @@ class _DesktopTokenSendState extends ConsumerState { ) : TextFieldIconButton( key: const Key( - "sendTokenViewPasteAddressFieldButtonKey"), + "sendTokenViewPasteAddressFieldButtonKey", + ), onTap: pasteAddress, child: sendToController.text.isEmpty ? const ClipboardIcon() @@ -1129,7 +1154,7 @@ class _DesktopTokenSendState extends ConsumerState { onPressed: ref.watch(previewTokenTxButtonStateProvider.state).state ? previewSend : null, - ) + ), ], ); }