From f8c6a17fa782cd7902c600bbf4172c8ce3c595e3 Mon Sep 17 00:00:00 2001 From: julian Date: Wed, 11 Jan 2023 22:26:38 -0600 Subject: [PATCH] update wallet ui to handle new data models --- .../exchange_view/trade_details_view.dart | 3 +- .../sub_widgets/transactions_list.dart | 401 ++++-------------- .../wallet_view/sub_widgets/tx_icon.dart | 73 +--- .../wallet_balance_toggle_sheet.dart | 11 +- .../sub_widgets/wallet_summary_info.dart | 16 +- .../all_transactions_view.dart | 63 +-- .../transaction_details_view.dart | 88 ++-- .../wallet_view/sub_widgets/desktop_send.dart | 161 ++++--- .../sub_widgets/desktop_wallet_summary.dart | 18 +- lib/widgets/transaction_card.dart | 305 ++----------- 10 files changed, 318 insertions(+), 821 deletions(-) diff --git a/lib/pages/exchange_view/trade_details_view.dart b/lib/pages/exchange_view/trade_details_view.dart index 479600569..b5f2bda6e 100644 --- a/lib/pages/exchange_view/trade_details_view.dart +++ b/lib/pages/exchange_view/trade_details_view.dart @@ -7,7 +7,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/exchange_view/edit_trade_note_view.dart'; import 'package:stackwallet/pages/exchange_view/send_from_view.dart'; @@ -23,7 +23,6 @@ import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/clipboard_interface.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/flush_bar_type.dart'; import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; diff --git a/lib/pages/wallet_view/sub_widgets/transactions_list.dart b/lib/pages/wallet_view/sub_widgets/transactions_list.dart index ea78984b9..0834b0d8d 100644 --- a/lib/pages/wallet_view/sub_widgets/transactions_list.dart +++ b/lib/pages/wallet_view/sub_widgets/transactions_list.dart @@ -4,7 +4,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart' as old; import 'package:stackwallet/pages/exchange_view/trade_details_view.dart'; import 'package:stackwallet/pages/wallet_view/sub_widgets/no_transactions_found.dart'; import 'package:stackwallet/providers/blockchain/dogecoin/current_height_provider.dart'; @@ -14,7 +13,6 @@ import 'package:stackwallet/route_generator.dart'; import 'package:stackwallet/services/coins/dogecoin/dogecoin_wallet.dart'; import 'package:stackwallet/services/coins/manager.dart'; import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.dart'; @@ -42,20 +40,10 @@ class TransactionsList extends ConsumerStatefulWidget { class _TransactionsListState extends ConsumerState { // bool _hasLoaded = false; - Map _transactions = {}; List _transactions2 = []; late final ChangeNotifierProvider managerProvider; - void updateTransactions(old.TransactionData newData) { - _transactions = {}; - final newTransactions = - newData.txChunks.expand((element) => element.transactions); - for (final tx in newTransactions) { - _transactions[tx.txid] = tx; - } - } - BorderRadius get _borderRadiusFirst { return BorderRadius.only( topLeft: Radius.circular( @@ -80,14 +68,14 @@ class _TransactionsListState extends ConsumerState { Widget itemBuilder( BuildContext context, - old.Transaction tx, + Transaction tx, BorderRadius? radius, ) { final matchingTrades = ref .read(tradesServiceProvider) .trades .where((e) => e.payInTxid == tx.txid || e.payOutTxid == tx.txid); - if (tx.txType == "Sent" && matchingTrades.isNotEmpty) { + if (tx.type == TransactionType.outgoing && matchingTrades.isNotEmpty) { final trade = matchingTrades.first; return Container( decoration: BoxDecoration( @@ -199,127 +187,6 @@ class _TransactionsListState extends ConsumerState { } } - Widget itemBuilder2( - BuildContext context, - Transaction tx, - BorderRadius? radius, - ) { - final matchingTrades = ref - .read(tradesServiceProvider) - .trades - .where((e) => e.payInTxid == tx.txid || e.payOutTxid == tx.txid); - if (tx.type == TransactionType.outgoing && matchingTrades.isNotEmpty) { - final trade = matchingTrades.first; - return Container( - decoration: BoxDecoration( - color: Theme.of(context).extension()!.popupBG, - borderRadius: radius, - ), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - TransactionCard2( - // this may mess with combined firo transactions - key: Key(tx.toString()), // - transaction: tx, - walletId: widget.walletId, - ), - TradeCard( - // this may mess with combined firo transactions - key: Key(tx.toString() + trade.uuid), // - trade: trade, - onTap: () async { - if (Util.isDesktop) { - // await showDialog( - // context: context, - // builder: (context) => Navigator( - // initialRoute: TradeDetailsView.routeName, - // onGenerateRoute: RouteGenerator.generateRoute, - // onGenerateInitialRoutes: (_, __) { - // return [ - // FadePageRoute( - // DesktopDialog( - // maxHeight: null, - // maxWidth: 580, - // child: Column( - // mainAxisSize: MainAxisSize.min, - // children: [ - // Padding( - // padding: const EdgeInsets.only( - // left: 32, - // bottom: 16, - // ), - // child: Row( - // mainAxisAlignment: - // MainAxisAlignment.spaceBetween, - // children: [ - // Text( - // "Trade details", - // style: STextStyles.desktopH3(context), - // ), - // DesktopDialogCloseButton( - // onPressedOverride: Navigator.of( - // context, - // rootNavigator: true, - // ).pop, - // ), - // ], - // ), - // ), - // Flexible( - // child: TradeDetailsView( - // tradeId: trade.tradeId, - // transactionIfSentFromStack: tx, - // walletName: - // ref.read(managerProvider).walletName, - // walletId: widget.walletId, - // ), - // ), - // ], - // ), - // ), - // const RouteSettings( - // name: TradeDetailsView.routeName, - // ), - // ), - // ]; - // }, - // ), - // ); - } else { - unawaited( - Navigator.of(context).pushNamed( - TradeDetailsView.routeName, - arguments: Tuple4( - trade.tradeId, - tx, - widget.walletId, - ref.read(managerProvider).walletName, - ), - ), - ); - } - }, - ) - ], - ), - ); - } else { - return Container( - decoration: BoxDecoration( - color: Theme.of(context).extension()!.popupBG, - borderRadius: radius, - ), - child: TransactionCard2( - // this may mess with combined firo transactions - key: Key(tx.toString()), // - transaction: tx, - walletId: widget.walletId, - ), - ); - } - } - void updateHeightProvider(Manager manager) { WidgetsBinding.instance.addPostFrameCallback((timeStamp) { ref.read(currentHeightProvider(manager.coin).state).state = @@ -342,186 +209,94 @@ class _TransactionsListState extends ConsumerState { final manager = ref.watch(walletsChangeNotifierProvider .select((value) => value.getManager(widget.walletId))); - if (manager.coin == Coin.dogecoinTestNet) { - updateHeightProvider(manager); - final wallet = manager.wallet as DogecoinWallet; - return FutureBuilder( - future: wallet.isar.transactions.where().findAll(), - builder: (fbContext, AsyncSnapshot> snapshot) { - if (snapshot.connectionState == ConnectionState.done && - snapshot.hasData) { - _transactions2 = snapshot.data!; - _hasLoaded = true; - } - if (!_hasLoaded) { - return Column( - children: const [ - Spacer(), - Center( - child: LoadingIndicator( - height: 50, - width: 50, - ), + updateHeightProvider(manager); + final wallet = manager.wallet as DogecoinWallet; + return FutureBuilder( + future: wallet.isar.transactions.where().findAll(), + builder: (fbContext, AsyncSnapshot> snapshot) { + if (snapshot.connectionState == ConnectionState.done && + snapshot.hasData) { + _transactions2 = snapshot.data!; + _hasLoaded = true; + } + if (!_hasLoaded) { + return Column( + children: const [ + Spacer(), + Center( + child: LoadingIndicator( + height: 50, + width: 50, ), - Spacer( - flex: 4, - ), - ], - ); - } - if (_transactions2.isEmpty) { - return const NoTransActionsFound(); - } else { - _transactions2.sort((a, b) => b.timestamp - a.timestamp); - return RefreshIndicator( - onRefresh: () async { - //todo: check if print needed - // debugPrint("pulled down to refresh on transaction list"); - final managerProvider = ref - .read(walletsChangeNotifierProvider) - .getManagerProvider(widget.walletId); - if (!ref.read(managerProvider).isRefreshing) { - unawaited(ref.read(managerProvider).refresh()); - } - }, - child: Util.isDesktop - ? ListView.separated( - itemBuilder: (context, index) { - BorderRadius? radius; - if (_transactions2.length == 1) { - radius = BorderRadius.circular( - Constants.size.circularBorderRadius, - ); - } else if (index == _transactions2.length - 1) { - radius = _borderRadiusLast; - } else if (index == 0) { - radius = _borderRadiusFirst; - } - final tx = _transactions2[index]; - return itemBuilder2(context, tx, radius); - }, - separatorBuilder: (context, index) { - return Container( - width: double.infinity, - height: 2, - color: Theme.of(context) - .extension()! - .background, + ), + Spacer( + flex: 4, + ), + ], + ); + } + if (_transactions2.isEmpty) { + return const NoTransActionsFound(); + } else { + _transactions2.sort((a, b) => b.timestamp - a.timestamp); + return RefreshIndicator( + onRefresh: () async { + //todo: check if print needed + // debugPrint("pulled down to refresh on transaction list"); + final managerProvider = ref + .read(walletsChangeNotifierProvider) + .getManagerProvider(widget.walletId); + if (!ref.read(managerProvider).isRefreshing) { + unawaited(ref.read(managerProvider).refresh()); + } + }, + child: Util.isDesktop + ? ListView.separated( + itemBuilder: (context, index) { + BorderRadius? radius; + if (_transactions2.length == 1) { + radius = BorderRadius.circular( + Constants.size.circularBorderRadius, ); - }, - itemCount: _transactions2.length, - ) - : ListView.builder( - itemCount: _transactions2.length, - itemBuilder: (context, index) { - BorderRadius? radius; - if (_transactions2.length == 1) { - radius = BorderRadius.circular( - Constants.size.circularBorderRadius, - ); - } else if (index == _transactions2.length - 1) { - radius = _borderRadiusLast; - } else if (index == 0) { - radius = _borderRadiusFirst; - } - final tx = _transactions2[index]; - return itemBuilder2(context, tx, radius); - }, - ), - ); - } - }, - ); - } else { - return FutureBuilder( - future: - ref.watch(managerProvider.select((value) => value.transactionData)), - builder: (fbContext, AsyncSnapshot snapshot) { - if (snapshot.connectionState == ConnectionState.done && - snapshot.hasData) { - updateTransactions(snapshot.data!); - _hasLoaded = true; - } - if (!_hasLoaded) { - return Column( - children: const [ - Spacer(), - Center( - child: LoadingIndicator( - height: 50, - width: 50, - ), - ), - Spacer( - flex: 4, - ), - ], - ); - } - if (_transactions.isEmpty) { - return const NoTransActionsFound(); - } else { - final list = _transactions.values.toList(growable: false); - list.sort((a, b) => b.timestamp - a.timestamp); - return RefreshIndicator( - onRefresh: () async { - //todo: check if print needed - // debugPrint("pulled down to refresh on transaction list"); - final managerProvider = ref - .read(walletsChangeNotifierProvider) - .getManagerProvider(widget.walletId); - if (!ref.read(managerProvider).isRefreshing) { - unawaited(ref.read(managerProvider).refresh()); - } - }, - child: Util.isDesktop - ? ListView.separated( - itemBuilder: (context, index) { - BorderRadius? radius; - if (list.length == 1) { - radius = BorderRadius.circular( - Constants.size.circularBorderRadius, - ); - } else if (index == list.length - 1) { - radius = _borderRadiusLast; - } else if (index == 0) { - radius = _borderRadiusFirst; - } - final tx = list[index]; - return itemBuilder(context, tx, radius); - }, - separatorBuilder: (context, index) { - return Container( - width: double.infinity, - height: 2, - color: Theme.of(context) - .extension()! - .background, + } else if (index == _transactions2.length - 1) { + radius = _borderRadiusLast; + } else if (index == 0) { + radius = _borderRadiusFirst; + } + final tx = _transactions2[index]; + return itemBuilder(context, tx, radius); + }, + separatorBuilder: (context, index) { + return Container( + width: double.infinity, + height: 2, + color: Theme.of(context) + .extension()! + .background, + ); + }, + itemCount: _transactions2.length, + ) + : ListView.builder( + itemCount: _transactions2.length, + itemBuilder: (context, index) { + BorderRadius? radius; + if (_transactions2.length == 1) { + radius = BorderRadius.circular( + Constants.size.circularBorderRadius, ); - }, - itemCount: list.length, - ) - : ListView.builder( - itemCount: list.length, - itemBuilder: (context, index) { - BorderRadius? radius; - if (list.length == 1) { - radius = BorderRadius.circular( - Constants.size.circularBorderRadius, - ); - } else if (index == list.length - 1) { - radius = _borderRadiusLast; - } else if (index == 0) { - radius = _borderRadiusFirst; - } - final tx = list[index]; - return itemBuilder(context, tx, radius); - }, - ), - ); - } - }, - ); - } + } else if (index == _transactions2.length - 1) { + radius = _borderRadiusLast; + } else if (index == 0) { + radius = _borderRadiusFirst; + } + final tx = _transactions2[index]; + return itemBuilder(context, tx, radius); + }, + ), + ); + } + }, + ); } } diff --git a/lib/pages/wallet_view/sub_widgets/tx_icon.dart b/lib/pages/wallet_view/sub_widgets/tx_icon.dart index e0983bd47..ee3b1b115 100644 --- a/lib/pages/wallet_view/sub_widgets/tx_icon.dart +++ b/lib/pages/wallet_view/sub_widgets/tx_icon.dart @@ -1,79 +1,18 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; -import 'package:stackwallet/models/paymint/transactions_model.dart' as old; +import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; class TxIcon extends StatelessWidget { - const TxIcon({Key? key, required this.transaction}) : super(key: key); - final old.Transaction transaction; - - static const Size size = Size(32, 32); - - String _getAssetName( - bool isCancelled, bool isReceived, bool isPending, BuildContext context) { - if (!isReceived && transaction.subType == "mint") { - if (isCancelled) { - return Assets.svg.anonymizeFailed; - } - if (isPending) { - return Assets.svg.anonymizePending; - } - return Assets.svg.anonymize; - } - - if (isReceived) { - if (isCancelled) { - return Assets.svg.receiveCancelled(context); - } - if (isPending) { - return Assets.svg.receivePending(context); - } - return Assets.svg.receive(context); - } else { - if (isCancelled) { - return Assets.svg.sendCancelled(context); - } - if (isPending) { - return Assets.svg.sendPending(context); - } - return Assets.svg.send(context); - } - } - - @override - Widget build(BuildContext context) { - final txIsReceived = transaction.txType == "Received"; - - return SizedBox( - width: size.width, - height: size.height, - child: Center( - child: SvgPicture.asset( - _getAssetName( - transaction.isCancelled, - txIsReceived, - !transaction.confirmedStatus, - context, - ), - width: size.width, - height: size.height, - ), - ), - ); - } -} - -class TxIcon2 extends StatelessWidget { - const TxIcon2({ + const TxIcon({ Key? key, required this.transaction, required this.currentHeight, required this.coin, }) : super(key: key); - final isar_models.Transaction transaction; + final Transaction transaction; final int currentHeight; final Coin coin; @@ -81,8 +20,7 @@ class TxIcon2 extends StatelessWidget { String _getAssetName( bool isCancelled, bool isReceived, bool isPending, BuildContext context) { - if (!isReceived && - transaction.subType == isar_models.TransactionSubType.mint) { + if (!isReceived && transaction.subType == TransactionSubType.mint) { if (isCancelled) { return Assets.svg.anonymizeFailed; } @@ -113,8 +51,7 @@ class TxIcon2 extends StatelessWidget { @override Widget build(BuildContext context) { - final txIsReceived = - transaction.type == isar_models.TransactionType.incoming; + final txIsReceived = transaction.type == TransactionType.incoming; return SizedBox( width: size.width, diff --git a/lib/pages/wallet_view/sub_widgets/wallet_balance_toggle_sheet.dart b/lib/pages/wallet_view/sub_widgets/wallet_balance_toggle_sheet.dart index 74308f2e8..7686bc3ab 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_balance_toggle_sheet.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_balance_toggle_sheet.dart @@ -32,13 +32,14 @@ class WalletBalanceToggleSheet extends ConsumerWidget { .watch(walletsChangeNotifierProvider .select((value) => value.getManager(walletId))) .wallet as FiroWallet; - totalBalanceFuture = firoWallet.availablePublicBalance(); - availableBalanceFuture = firoWallet.availablePrivateBalance(); + totalBalanceFuture = Future(() => firoWallet.balance.getSpendable()); + availableBalanceFuture = + Future(() => firoWallet.balancePrivate.getSpendable()); } else { - final wallet = ref.watch(walletsChangeNotifierProvider + final manager = ref.watch(walletsChangeNotifierProvider .select((value) => value.getManager(walletId))); - totalBalanceFuture = wallet.totalBalance; - availableBalanceFuture = wallet.availableBalance; + totalBalanceFuture = Future(() => manager.balance.getTotal()); + availableBalanceFuture = Future(() => manager.balance.getSpendable()); } return Container( diff --git a/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart b/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart index d38e17a6a..66e47440b 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart @@ -79,14 +79,16 @@ class _WalletSummaryInfoState extends State { final firoWallet = ref.watch(managerProvider.select((value) => value.wallet)) as FiroWallet; - totalBalanceFuture = firoWallet.availablePublicBalance(); - availableBalanceFuture = firoWallet.availablePrivateBalance(); + totalBalanceFuture = + Future(() => firoWallet.balance.getSpendable()); + availableBalanceFuture = + Future(() => firoWallet.balancePrivate.getSpendable()); } else { - totalBalanceFuture = ref.watch( - managerProvider.select((value) => value.totalBalance)); - - availableBalanceFuture = ref.watch( - managerProvider.select((value) => value.availableBalance)); + final manager = ref.watch(walletsChangeNotifierProvider + .select((value) => value.getManager(walletId))); + totalBalanceFuture = Future(() => manager.balance.getTotal()); + availableBalanceFuture = + Future(() => manager.balance.getSpendable()); } final locale = ref.watch(localeServiceChangeNotifierProvider diff --git a/lib/pages/wallet_view/transaction_views/all_transactions_view.dart b/lib/pages/wallet_view/transaction_views/all_transactions_view.dart index 27bb36331..4ff070712 100644 --- a/lib/pages/wallet_view/transaction_views/all_transactions_view.dart +++ b/lib/pages/wallet_view/transaction_views/all_transactions_view.dart @@ -4,7 +4,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/models/contact.dart'; -import 'package:stackwallet/models/paymint/transactions_model.dart'; import 'package:stackwallet/models/transaction_filter.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart'; @@ -34,6 +33,9 @@ import 'package:stackwallet/widgets/textfield_icon_button.dart'; import 'package:stackwallet/widgets/transaction_card.dart'; import 'package:tuple/tuple.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../providers/blockchain/dogecoin/current_height_provider.dart'; + class AllTransactionsView extends ConsumerStatefulWidget { const AllTransactionsView({ Key? key, @@ -89,11 +91,15 @@ class _TransactionDetailsViewState extends ConsumerState { return false; } - if (filter.received && !filter.sent && tx.txType == "Sent") { + if (filter.received && + !filter.sent && + tx.type == TransactionType.outgoing) { return false; } - if (filter.sent && !filter.received && tx.txType == "Received") { + if (filter.sent && + !filter.received && + tx.type == TransactionType.incoming) { return false; } @@ -141,11 +147,10 @@ class _TransactionDetailsViewState extends ConsumerState { contains |= tx.txid.toLowerCase().contains(keyword); // check if subType contains - contains |= - tx.subType.isNotEmpty && tx.subType.toLowerCase().contains(keyword); + contains |= tx.subType.name.toLowerCase().contains(keyword); // check if txType contains - contains |= tx.txType.toLowerCase().contains(keyword); + contains |= tx.type.name.toLowerCase().contains(keyword); // check if date contains contains |= @@ -454,17 +459,13 @@ class _TransactionDetailsViewState extends ConsumerState { // debugPrint("Consumer build called"); return FutureBuilder( - future: ref.watch(managerProvider - .select((value) => value.transactionData)), - builder: (_, AsyncSnapshot snapshot) { + future: ref.watch( + managerProvider.select((value) => value.transactions)), + builder: (_, AsyncSnapshot> snapshot) { if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) { final filtered = filter( - transactions: snapshot.data! - .getAllTransactions() - .values - .toList(), - filter: criteria); + transactions: snapshot.data!, filter: criteria); final searched = search(_searchString, filtered); @@ -787,33 +788,33 @@ class _DesktopTransactionCardRowState late final Transaction _transaction; late final String walletId; - String whatIsIt(String type, Coin coin) { + String whatIsIt(TransactionType type, Coin coin, int height) { if (coin == Coin.epicCash && _transaction.slateId == null) { return "Restored Funds"; } - if (_transaction.subType == "mint") { - if (_transaction.confirmedStatus) { + if (_transaction.subType == TransactionSubType.mint) { + if (_transaction.isConfirmed(height, coin.requiredConfirmations)) { return "Anonymized"; } else { return "Anonymizing"; } } - if (type == "Received") { - if (_transaction.confirmedStatus) { + if (type == TransactionType.incoming) { + if (_transaction.isConfirmed(height, coin.requiredConfirmations)) { return "Received"; } else { return "Receiving"; } - } else if (type == "Sent") { - if (_transaction.confirmedStatus) { + } else if (type == TransactionType.outgoing) { + if (_transaction.isConfirmed(height, coin.requiredConfirmations)) { return "Sent"; } else { return "Sending"; } } else { - return type; + return type.name; } } @@ -843,15 +844,17 @@ class _DesktopTransactionCardRowState late final String prefix; if (Util.isDesktop) { - if (_transaction.txType == "Sent") { + if (_transaction.type == TransactionType.outgoing) { prefix = "-"; - } else if (_transaction.txType == "Received") { + } else if (_transaction.type == TransactionType.incoming) { prefix = "+"; } } else { prefix = ""; } + final currentHeight = ref.watch(currentHeightProvider(coin).state).state; + return Material( color: Theme.of(context).extension()!.popupBG, elevation: 0, @@ -911,7 +914,11 @@ class _DesktopTransactionCardRowState ), child: Row( children: [ - TxIcon(transaction: _transaction), + TxIcon( + transaction: _transaction, + currentHeight: currentHeight, + coin: coin, + ), const SizedBox( width: 12, ), @@ -920,7 +927,11 @@ class _DesktopTransactionCardRowState child: Text( _transaction.isCancelled ? "Cancelled" - : whatIsIt(_transaction.txType, coin), + : whatIsIt( + _transaction.type, + coin, + currentHeight, + ), style: STextStyles.desktopTextExtraExtraSmall(context).copyWith( color: Theme.of(context).extension()!.textDark, diff --git a/lib/pages/wallet_view/transaction_views/transaction_details_view.dart b/lib/pages/wallet_view/transaction_views/transaction_details_view.dart index a5967934a..fec0721d9 100644 --- a/lib/pages/wallet_view/transaction_views/transaction_details_view.dart +++ b/lib/pages/wallet_view/transaction_views/transaction_details_view.dart @@ -5,12 +5,13 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/models/models.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart'; import 'package:stackwallet/pages/wallet_view/transaction_views/dialogs/cancelling_transaction_progress_dialog.dart'; import 'package:stackwallet/pages/wallet_view/transaction_views/edit_note_view.dart'; import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; +import 'package:stackwallet/providers/blockchain/dogecoin/current_height_provider.dart'; import 'package:stackwallet/providers/global/address_book_service_provider.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/services/coins/epiccash/epiccash_wallet.dart'; @@ -19,7 +20,6 @@ import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/block_explorers.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/flush_bar_type.dart'; import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/text_styles.dart'; @@ -80,13 +80,13 @@ class _TransactionDetailsViewState coin = widget.coin; amount = Format.satoshisToAmount(_transaction.amount, coin: coin); - fee = Format.satoshisToAmount(_transaction.fees, coin: coin); + fee = Format.satoshisToAmount(_transaction.fee, coin: coin); if ((coin == Coin.firo || coin == Coin.firoTestNet) && - _transaction.subType == "mint") { + _transaction.subType == TransactionSubType.mint) { amountPrefix = ""; } else { - amountPrefix = _transaction.txType.toLowerCase() == "sent" ? "-" : "+"; + amountPrefix = _transaction.type == TransactionType.outgoing ? "-" : "+"; } // if (coin == Coin.firo || coin == Coin.firoTestNet) { @@ -102,10 +102,10 @@ class _TransactionDetailsViewState super.dispose(); } - String whatIsIt(String type) { + String whatIsIt(TransactionType type, int height) { if (coin == Coin.firo || coin == Coin.firoTestNet) { - if (_transaction.subType == "mint") { - if (_transaction.confirmedStatus) { + if (_transaction.subType == TransactionSubType.mint) { + if (_transaction.isConfirmed(height, coin.requiredConfirmations)) { return "Minted"; } else { return "Minting"; @@ -113,23 +113,23 @@ class _TransactionDetailsViewState } } - if (type == "Received") { + if (type == TransactionType.incoming) { // if (_transaction.isMinting) { // return "Minting"; // } else - if (_transaction.confirmedStatus) { + if (_transaction.isConfirmed(height, coin.requiredConfirmations)) { return "Received"; } else { return "Receiving"; } - } else if (type == "Sent") { - if (_transaction.confirmedStatus) { + } else if (type == TransactionType.outgoing) { + if (_transaction.isConfirmed(height, coin.requiredConfirmations)) { return "Sent"; } else { return "Sending"; } } else { - return type; + return type.name; } } @@ -298,6 +298,8 @@ class _TransactionDetailsViewState @override Widget build(BuildContext context) { + final currentHeight = ref.watch(currentHeightProvider(coin).state).state; + return ConditionalParent( condition: !isDesktop, builder: (child) => Background( @@ -403,6 +405,8 @@ class _TransactionDetailsViewState children: [ TxIcon( transaction: _transaction, + currentHeight: currentHeight, + coin: coin, ), const SizedBox( width: 16, @@ -411,7 +415,9 @@ class _TransactionDetailsViewState _transaction.isCancelled ? "Cancelled" : whatIsIt( - _transaction.txType), + _transaction.type, + currentHeight, + ), style: STextStyles.desktopTextMedium( context), @@ -489,6 +495,8 @@ class _TransactionDetailsViewState if (!isDesktop) TxIcon( transaction: _transaction, + currentHeight: currentHeight, + coin: coin, ), ], ), @@ -523,13 +531,17 @@ class _TransactionDetailsViewState SelectableText( _transaction.isCancelled ? "Cancelled" - : whatIsIt(_transaction.txType), + : whatIsIt( + _transaction.type, + currentHeight, + ), style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( context) .copyWith( - color: _transaction.txType == "Sent" + color: _transaction.type == + TransactionType.outgoing ? Theme.of(context) .extension()! .accentColorOrange @@ -546,11 +558,12 @@ class _TransactionDetailsViewState ), if (!((coin == Coin.monero || coin == Coin.wownero) && - _transaction.txType.toLowerCase() == - "sent") && + _transaction.type == + TransactionType.outgoing) && !((coin == Coin.firo || coin == Coin.firoTestNet) && - _transaction.subType == "mint")) + _transaction.subType == + TransactionSubType.mint)) isDesktop ? const _Divider() : const SizedBox( @@ -558,11 +571,12 @@ class _TransactionDetailsViewState ), if (!((coin == Coin.monero || coin == Coin.wownero) && - _transaction.txType.toLowerCase() == - "sent") && + _transaction.type == + TransactionType.outgoing) && !((coin == Coin.firo || coin == Coin.firoTestNet) && - _transaction.subType == "mint")) + _transaction.subType == + TransactionSubType.mint)) RoundedWhiteContainer( padding: isDesktop ? const EdgeInsets.all(16) @@ -578,8 +592,8 @@ class _TransactionDetailsViewState CrossAxisAlignment.start, children: [ Text( - _transaction.txType.toLowerCase() == - "sent" + _transaction.type == + TransactionType.outgoing ? "Sent to" : "Receiving address", style: isDesktop @@ -592,8 +606,8 @@ class _TransactionDetailsViewState const SizedBox( height: 8, ), - _transaction.txType.toLowerCase() == - "received" + _transaction.type == + TransactionType.incoming ? FutureBuilder( future: fetchContactNameFor( _transaction.address), @@ -855,7 +869,10 @@ class _TransactionDetailsViewState : const EdgeInsets.all(12), child: Builder(builder: (context) { final feeString = showFeePending - ? _transaction.confirmedStatus + ? _transaction.isConfirmed( + currentHeight, + coin.requiredConfirmations, + ) ? Format.localizedStringAsFixed( value: fee, locale: ref.watch( @@ -947,9 +964,14 @@ class _TransactionDetailsViewState : const EdgeInsets.all(12), child: Builder(builder: (context) { final height = widget.coin != Coin.epicCash && - _transaction.confirmedStatus + _transaction.isConfirmed( + currentHeight, + coin.requiredConfirmations, + ) ? "${_transaction.height == 0 ? "Unknown" : _transaction.height}" - : _transaction.confirmations > 0 + : _transaction.getConfirmations( + currentHeight) > + 0 ? "${_transaction.height}" : "Pending"; @@ -1297,9 +1319,13 @@ class _TransactionDetailsViewState ), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, floatingActionButton: (coin == Coin.epicCash && - _transaction.confirmedStatus == false && + _transaction.isConfirmed( + currentHeight, + coin.requiredConfirmations, + ) == + false && _transaction.isCancelled == false && - _transaction.txType == "Sent") + _transaction.type == TransactionType.outgoing) ? SizedBox( width: MediaQuery.of(context).size.width - 32, child: TextButton( 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 c5d682c60..c4f7eee34 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 @@ -97,73 +97,73 @@ class _DesktopSendState extends ConsumerState { final manager = ref.read(walletsChangeNotifierProvider).getManager(walletId); - // TODO: remove the need for this!! - final bool isOwnAddress = await manager.isOwnAddress(_address!); - if (isOwnAddress) { - await showDialog( - context: context, - useSafeArea: false, - barrierDismissible: true, - builder: (context) { - return DesktopDialog( - maxWidth: 400, - maxHeight: double.infinity, - child: Padding( - padding: const EdgeInsets.only( - left: 32, - bottom: 32, - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Transaction failed", - style: STextStyles.desktopH3(context), - ), - const DesktopDialogCloseButton(), - ], - ), - const SizedBox( - height: 12, - ), - Text( - "Sending to self is currently disabled", - textAlign: TextAlign.left, - style: STextStyles.desktopTextExtraExtraSmall(context) - .copyWith( - fontSize: 18, - ), - ), - const SizedBox( - height: 40, - ), - Row( - children: [ - Expanded( - child: SecondaryButton( - buttonHeight: ButtonHeight.l, - label: "Ok", - onPressed: () { - Navigator.of(context).pop(); - }, - ), - ), - const SizedBox( - width: 32, - ), - ], - ), - ], - ), - ), - ); - }, - ); - return; - } + // // TODO: remove the need for this!! + // final bool isOwnAddress = await manager.isOwnAddress(_address!); + // if (isOwnAddress) { + // await showDialog( + // context: context, + // useSafeArea: false, + // barrierDismissible: true, + // builder: (context) { + // return DesktopDialog( + // maxWidth: 400, + // maxHeight: double.infinity, + // child: Padding( + // padding: const EdgeInsets.only( + // left: 32, + // bottom: 32, + // ), + // child: Column( + // crossAxisAlignment: CrossAxisAlignment.start, + // children: [ + // Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // Text( + // "Transaction failed", + // style: STextStyles.desktopH3(context), + // ), + // const DesktopDialogCloseButton(), + // ], + // ), + // const SizedBox( + // height: 12, + // ), + // Text( + // "Sending to self is currently disabled", + // textAlign: TextAlign.left, + // style: STextStyles.desktopTextExtraExtraSmall(context) + // .copyWith( + // fontSize: 18, + // ), + // ), + // const SizedBox( + // height: 40, + // ), + // Row( + // children: [ + // Expanded( + // child: SecondaryButton( + // buttonHeight: ButtonHeight.l, + // label: "Ok", + // onPressed: () { + // Navigator.of(context).pop(); + // }, + // ), + // ), + // const SizedBox( + // width: 32, + // ), + // ], + // ), + // ], + // ), + // ), + // ); + // }, + // ); + // return; + // } final amount = Format.decimalAmountToSatoshis(_amountToSend!, coin); int availableBalance; @@ -171,16 +171,14 @@ class _DesktopSendState extends ConsumerState { if (ref.read(publicPrivateBalanceStateProvider.state).state == "Private") { availableBalance = Format.decimalAmountToSatoshis( - await (manager.wallet as FiroWallet).availablePrivateBalance(), - coin); + (manager.wallet as FiroWallet).availablePrivateBalance(), coin); } else { availableBalance = Format.decimalAmountToSatoshis( - await (manager.wallet as FiroWallet).availablePublicBalance(), - coin); + (manager.wallet as FiroWallet).availablePublicBalance(), coin); } } else { availableBalance = - Format.decimalAmountToSatoshis(await manager.availableBalance, coin); + Format.decimalAmountToSatoshis(manager.balance.getSpendable(), coin); } // confirm send all @@ -568,9 +566,9 @@ class _DesktopSendState extends ConsumerState { if (wallet != null) { Decimal? balance; if (private) { - balance = await wallet.availablePrivateBalance(); + balance = wallet.availablePrivateBalance(); } else { - balance = await wallet.availablePublicBalance(); + balance = wallet.availablePublicBalance(); } return Format.localizedStringAsFixed( @@ -757,19 +755,18 @@ class _DesktopSendState extends ConsumerState { .wallet as FiroWallet; if (ref.read(publicPrivateBalanceStateProvider.state).state == "Private") { - cryptoAmountController.text = - (await firoWallet.availablePrivateBalance()) - .toStringAsFixed(Constants.decimalPlacesForCoin(coin)); + cryptoAmountController.text = (firoWallet.availablePrivateBalance()) + .toStringAsFixed(Constants.decimalPlacesForCoin(coin)); } else { - cryptoAmountController.text = - (await firoWallet.availablePublicBalance()) - .toStringAsFixed(Constants.decimalPlacesForCoin(coin)); + cryptoAmountController.text = (firoWallet.availablePublicBalance()) + .toStringAsFixed(Constants.decimalPlacesForCoin(coin)); } } else { - cryptoAmountController.text = (await ref + cryptoAmountController.text = (ref .read(walletsChangeNotifierProvider) .getManager(walletId) - .availableBalance) + .balance + .getSpendable()) .toStringAsFixed(Constants.decimalPlacesForCoin(coin)); } } diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart index 8291c35d3..f56e2160a 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart @@ -68,15 +68,17 @@ class _WDesktopWalletSummaryState extends State { final firoWallet = ref.watch( managerProvider.select((value) => value.wallet)) as FiroWallet; - totalBalanceFuture = firoWallet.availablePublicBalance(); - availableBalanceFuture = - firoWallet.availablePrivateBalance(); + totalBalanceFuture = + Future(() => firoWallet.balance.getSpendable()); + availableBalanceFuture = Future( + () => firoWallet.balancePrivate.getSpendable()); } else { - totalBalanceFuture = ref.watch(managerProvider - .select((value) => value.totalBalance)); - - availableBalanceFuture = ref.watch(managerProvider - .select((value) => value.availableBalance)); + final manager = ref.watch(walletsChangeNotifierProvider + .select((value) => value.getManager(walletId))); + totalBalanceFuture = + Future(() => manager.balance.getTotal()); + availableBalanceFuture = + Future(() => manager.balance.getSpendable()); } final locale = ref.watch(localeServiceChangeNotifierProvider diff --git a/lib/widgets/transaction_card.dart b/lib/widgets/transaction_card.dart index 531d7abb9..6eb48e7da 100644 --- a/lib/widgets/transaction_card.dart +++ b/lib/widgets/transaction_card.dart @@ -2,11 +2,11 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; -import 'package:stackwallet/models/paymint/transactions_model.dart' as old; +import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/notifications/show_flush_bar.dart'; import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart'; import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; +import 'package:stackwallet/providers/blockchain/dogecoin/current_height_provider.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; @@ -17,8 +17,6 @@ import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; import 'package:tuple/tuple.dart'; -import '../providers/blockchain/dogecoin/current_height_provider.dart'; - class TransactionCard extends ConsumerStatefulWidget { const TransactionCard({ Key? key, @@ -26,7 +24,7 @@ class TransactionCard extends ConsumerStatefulWidget { required this.walletId, }) : super(key: key); - final old.Transaction transaction; + final Transaction transaction; final String walletId; @override @@ -34,17 +32,26 @@ class TransactionCard extends ConsumerStatefulWidget { } class _TransactionCardState extends ConsumerState { - late final old.Transaction _transaction; + late final Transaction _transaction; late final String walletId; - String whatIsIt(String type, Coin coin) { + String whatIsIt( + TransactionType type, + Coin coin, + int currentHeight, + ) { if (coin == Coin.epicCash && _transaction.slateId == null) { return "Restored Funds"; } - if (_transaction.subType == "mint") { + final confirmedStatus = _transaction.isConfirmed( + currentHeight, + coin.requiredConfirmations, + ); + + if (_transaction.subType == TransactionSubType.mint) { // if (type == "Received") { - if (_transaction.confirmedStatus) { + if (confirmedStatus) { return "Anonymized"; } else { return "Anonymizing"; @@ -60,23 +67,23 @@ class _TransactionCardState extends ConsumerState { // } } - if (type == "Received") { + if (type == TransactionType.incoming) { // if (_transaction.isMinting) { // return "Minting"; // } else - if (_transaction.confirmedStatus) { + if (confirmedStatus) { return "Received"; } else { return "Receiving"; } - } else if (type == "Sent") { - if (_transaction.confirmedStatus) { + } else if (type == TransactionType.outgoing) { + if (confirmedStatus) { return "Sent"; } else { return "Sending"; } } else { - return type; + return type.name; } } @@ -106,13 +113,15 @@ class _TransactionCardState extends ConsumerState { String prefix = ""; if (Util.isDesktop) { - if (_transaction.txType == "Sent") { + if (_transaction.type == TransactionType.outgoing) { prefix = "-"; - } else if (_transaction.txType == "Received") { + } else if (_transaction.type == TransactionType.incoming) { prefix = "+"; } } + final currentHeight = ref.watch(currentHeightProvider(coin).state).state; + return Material( color: Theme.of(context).extension()!.popupBG, elevation: 0, @@ -169,269 +178,7 @@ class _TransactionCardState extends ConsumerState { padding: const EdgeInsets.all(8), child: Row( children: [ - TxIcon(transaction: _transaction), - const SizedBox( - width: 14, - ), - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - // crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Flexible( - child: FittedBox( - fit: BoxFit.scaleDown, - child: Text( - _transaction.isCancelled - ? "Cancelled" - : whatIsIt(_transaction.txType, coin), - style: STextStyles.itemSubtitle12(context), - ), - ), - ), - const SizedBox( - width: 10, - ), - Flexible( - child: FittedBox( - fit: BoxFit.scaleDown, - child: Builder( - builder: (_) { - final amount = _transaction.amount; - return Text( - "$prefix${Format.satoshiAmountToPrettyString(amount, locale, coin)} ${coin.ticker}", - style: - STextStyles.itemSubtitle12_600(context), - ); - }, - ), - ), - ), - ], - ), - const SizedBox( - height: 4, - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - // crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Flexible( - child: FittedBox( - fit: BoxFit.scaleDown, - child: Text( - Format.extractDateFrom(_transaction.timestamp), - style: STextStyles.label(context), - ), - ), - ), - if (ref.watch(prefsChangeNotifierProvider - .select((value) => value.externalCalls))) - const SizedBox( - width: 10, - ), - if (ref.watch(prefsChangeNotifierProvider - .select((value) => value.externalCalls))) - Flexible( - child: FittedBox( - fit: BoxFit.scaleDown, - child: Builder( - builder: (_) { - int value = _transaction.amount; - - return Text( - "$prefix${Format.localizedStringAsFixed( - value: Format.satoshisToAmount(value, - coin: coin) * - price, - locale: locale, - decimalPlaces: 2, - )} $baseCurrency", - style: STextStyles.label(context), - ); - }, - ), - ), - ), - ], - ), - ], - ), - ), - ], - ), - ), - ), - ), - ); - } -} - -class TransactionCard2 extends ConsumerStatefulWidget { - const TransactionCard2({ - Key? key, - required this.transaction, - required this.walletId, - }) : super(key: key); - - final isar_models.Transaction transaction; - final String walletId; - - @override - ConsumerState createState() => _TransactionCardState2(); -} - -class _TransactionCardState2 extends ConsumerState { - late final isar_models.Transaction _transaction; - late final String walletId; - - String whatIsIt( - isar_models.TransactionType type, - Coin coin, - int currentHeight, - ) { - if (coin == Coin.epicCash && _transaction.slateId == null) { - return "Restored Funds"; - } - - final confirmedStatus = _transaction.isConfirmed( - currentHeight, - coin.requiredConfirmations, - ); - - if (_transaction.subType == isar_models.TransactionSubType.mint) { - // if (type == "Received") { - if (confirmedStatus) { - return "Anonymized"; - } else { - return "Anonymizing"; - } - // } else if (type == "Sent") { - // if (_transaction.confirmedStatus) { - // return "Sent MINT"; - // } else { - // return "Sending MINT"; - // } - // } else { - // return type; - // } - } - - if (type == isar_models.TransactionType.incoming) { - // if (_transaction.isMinting) { - // return "Minting"; - // } else - if (confirmedStatus) { - return "Received"; - } else { - return "Receiving"; - } - } else if (type == isar_models.TransactionType.outgoing) { - if (confirmedStatus) { - return "Sent"; - } else { - return "Sending"; - } - } else { - return type.name; - } - } - - @override - void initState() { - walletId = widget.walletId; - _transaction = widget.transaction; - super.initState(); - } - - @override - Widget build(BuildContext context) { - final locale = ref.watch( - localeServiceChangeNotifierProvider.select((value) => value.locale)); - final manager = ref.watch(walletsChangeNotifierProvider - .select((value) => value.getManager(walletId))); - - final baseCurrency = ref - .watch(prefsChangeNotifierProvider.select((value) => value.currency)); - - final coin = manager.coin; - - final price = ref - .watch(priceAnd24hChangeNotifierProvider - .select((value) => value.getPrice(coin))) - .item1; - - String prefix = ""; - if (Util.isDesktop) { - if (_transaction.type == isar_models.TransactionType.outgoing) { - prefix = "-"; - } else if (_transaction.type == isar_models.TransactionType.incoming) { - prefix = "+"; - } - } - - final currentHeight = ref.watch(currentHeightProvider(coin).state).state; - - return Material( - color: Theme.of(context).extension()!.popupBG, - elevation: 0, - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.circular(Constants.size.circularBorderRadius), - ), - child: Padding( - padding: const EdgeInsets.all(6), - child: RawMaterialButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular( - Constants.size.circularBorderRadius, - ), - ), - onPressed: () async { - if (coin == Coin.epicCash && _transaction.slateId == null) { - unawaited(showFloatingFlushBar( - context: context, - message: - "Restored Epic funds from your Seed have no Data.\nUse Stack Backup to keep your transaction history.", - type: FlushBarType.warning, - duration: const Duration(seconds: 5), - )); - return; - } - if (Util.isDesktop) { - // await showDialog( - // context: context, - // builder: (context) => DesktopDialog( - // maxHeight: MediaQuery.of(context).size.height - 64, - // maxWidth: 580, - // child: TransactionDetailsView( - // transaction: _transaction, - // coin: coin, - // walletId: walletId, - // ), - // ), - // ); - } else { - unawaited( - Navigator.of(context).pushNamed( - TransactionDetailsView.routeName, - arguments: Tuple3( - _transaction, - coin, - walletId, - ), - ), - ); - } - }, - child: Padding( - padding: const EdgeInsets.all(8), - child: Row( - children: [ - TxIcon2( + TxIcon( transaction: _transaction, coin: ref.watch(walletsChangeNotifierProvider.select( (value) => value.getManager(widget.walletId).coin)),