From 4c6404cfb22aa9432deac2134d52cd6f5b0de6e7 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 23 Oct 2023 11:42:45 -0600 Subject: [PATCH] fusion group details --- .../tx_v2/fusion_group_details_view.dart | 234 ++++++++++++++++++ .../tx_v2/fusion_tx_group_card.dart | 47 ++-- .../tx_v2/transaction_v2_list_item.dart | 1 - lib/route_generator.dart | 21 ++ 4 files changed, 280 insertions(+), 23 deletions(-) create mode 100644 lib/pages/wallet_view/transaction_views/tx_v2/fusion_group_details_view.dart diff --git a/lib/pages/wallet_view/transaction_views/tx_v2/fusion_group_details_view.dart b/lib/pages/wallet_view/transaction_views/tx_v2/fusion_group_details_view.dart new file mode 100644 index 000000000..5b9ded00e --- /dev/null +++ b/lib/pages/wallet_view/transaction_views/tx_v2/fusion_group_details_view.dart @@ -0,0 +1,234 @@ +/* + * This file is part of Stack Wallet. + * + * Copyright (c) 2023 Cypher Stack + * All Rights Reserved. + * The code is distributed under GPLv3 license, see LICENSE file for details. + * Generated by Cypher Stack on 2023-05-26 + * + */ + +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_list_item.dart'; +import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; +import 'package:stackwallet/themes/stack_colors.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/util.dart'; +import 'package:stackwallet/widgets/background.dart'; +import 'package:stackwallet/widgets/conditional_parent.dart'; +import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; +import 'package:stackwallet/widgets/rounded_white_container.dart'; + +class FusionGroupDetailsView extends ConsumerStatefulWidget { + const FusionGroupDetailsView({ + Key? key, + required this.transactions, + required this.walletId, + required this.coin, + }) : super(key: key); + + static const String routeName = "/fusionGroupDetailsView"; + + final List transactions; + final String walletId; + final Coin coin; + + @override + ConsumerState createState() => + _FusionGroupDetailsViewState(); +} + +class _FusionGroupDetailsViewState + extends ConsumerState { + late final bool isDesktop; + late final String walletId; + + BorderRadius get _borderRadiusFirst { + return BorderRadius.only( + topLeft: Radius.circular( + Constants.size.circularBorderRadius, + ), + topRight: Radius.circular( + Constants.size.circularBorderRadius, + ), + ); + } + + BorderRadius get _borderRadiusLast { + return BorderRadius.only( + bottomLeft: Radius.circular( + Constants.size.circularBorderRadius, + ), + bottomRight: Radius.circular( + Constants.size.circularBorderRadius, + ), + ); + } + + @override + void initState() { + isDesktop = Util.isDesktop; + walletId = widget.walletId; + + super.initState(); + } + + @override + Widget build(BuildContext context) { + return ConditionalParent( + condition: !isDesktop, + builder: (child) => Background( + child: child, + ), + child: Scaffold( + backgroundColor: isDesktop + ? Colors.transparent + : Theme.of(context).extension()!.background, + appBar: isDesktop + ? null + : AppBar( + backgroundColor: + Theme.of(context).extension()!.background, + leading: AppBarBackButton( + onPressed: () async { + Navigator.of(context).pop(); + }, + ), + title: Text( + "Fusion transactions", + style: STextStyles.navBarTitle(context), + ), + ), + body: Padding( + padding: isDesktop + ? const EdgeInsets.only(left: 32) + : const EdgeInsets.all(12), + child: Column( + children: [ + if (isDesktop) + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Fusion transactions", + style: STextStyles.desktopH3(context), + ), + const DesktopDialogCloseButton(), + ], + ), + Flexible( + child: Padding( + padding: isDesktop + ? const EdgeInsets.only( + right: 32, + bottom: 32, + ) + : const EdgeInsets.all(0), + child: ConditionalParent( + condition: isDesktop, + builder: (child) { + return RoundedWhiteContainer( + borderColor: isDesktop + ? Theme.of(context) + .extension()! + .backgroundAppBar + : null, + padding: const EdgeInsets.all(0), + child: child, + ); + }, + child: SingleChildScrollView( + primary: isDesktop ? false : null, + child: Padding( + padding: isDesktop + ? const EdgeInsets.all(0) + : const EdgeInsets.all(4), + child: Util.isDesktop + ? ListView.separated( + shrinkWrap: true, + itemBuilder: (context, index) { + BorderRadius? radius; + if (widget.transactions.length == 1) { + radius = BorderRadius.circular( + Constants.size.circularBorderRadius, + ); + } else if (index == + widget.transactions.length - 1) { + radius = _borderRadiusLast; + } else if (index == 0) { + radius = _borderRadiusFirst; + } + final tx = widget.transactions[index]; + return TxListItem( + tx: tx, + coin: widget.coin, + radius: radius, + ); + }, + separatorBuilder: (context, index) { + return Container( + width: double.infinity, + height: 1.2, + color: Theme.of(context) + .extension()! + .background, + ); + }, + itemCount: widget.transactions.length, + ) + : ListView.builder( + itemCount: widget.transactions.length, + itemBuilder: (context, index) { + BorderRadius? radius; + bool shouldWrap = false; + if (widget.transactions.length == 1) { + radius = BorderRadius.circular( + Constants.size.circularBorderRadius, + ); + } else if (index == + widget.transactions.length - 1) { + radius = _borderRadiusLast; + shouldWrap = true; + } else if (index == 0) { + radius = _borderRadiusFirst; + } + final tx = widget.transactions[index]; + if (shouldWrap) { + return Column( + children: [ + TxListItem( + tx: tx, + coin: widget.coin, + radius: radius, + ), + const SizedBox( + height: WalletView.navBarHeight + 14, + ), + ], + ); + } else { + return TxListItem( + tx: tx, + coin: widget.coin, + radius: radius, + ); + } + }, + ), + ), + ), + ), + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/wallet_view/transaction_views/tx_v2/fusion_tx_group_card.dart b/lib/pages/wallet_view/transaction_views/tx_v2/fusion_tx_group_card.dart index 0197ea15c..aad00fa1e 100644 --- a/lib/pages/wallet_view/transaction_views/tx_v2/fusion_tx_group_card.dart +++ b/lib/pages/wallet_view/transaction_views/tx_v2/fusion_tx_group_card.dart @@ -1,13 +1,17 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart'; +import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/fusion_group_details_view.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/themes/stack_colors.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; class FusionTxGroup { final List transactions; @@ -46,29 +50,28 @@ class FusionTxGroupCard extends ConsumerWidget { ), onPressed: () async { if (Util.isDesktop) { - // await showDialog( - // context: context, - // builder: (context) => DesktopDialog( - // maxHeight: MediaQuery.of(context).size.height - 64, - // maxWidth: 580, - // child: TransactionV2DetailsView( - // transaction: _transaction, - // coin: coin, - // walletId: walletId, - // ), - // ), - // ); + await showDialog( + context: context, + builder: (context) => DesktopDialog( + maxWidth: 580, + child: FusionGroupDetailsView( + transactions: group.transactions, + coin: coin, + walletId: walletId, + ), + ), + ); } else { - // unawaited( - // Navigator.of(context).pushNamed( - // TransactionV2DetailsView.routeName, - // arguments: ( - // tx: _transaction, - // coin: coin, - // walletId: walletId, - // ), - // ), - // ); + unawaited( + Navigator.of(context).pushNamed( + FusionGroupDetailsView.routeName, + arguments: ( + transactions: group.transactions, + coin: coin, + walletId: walletId, + ), + ), + ); } }, child: Padding( diff --git a/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_list_item.dart b/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_list_item.dart index 6780f7e49..b0171c950 100644 --- a/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_list_item.dart +++ b/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_list_item.dart @@ -171,7 +171,6 @@ class TxListItem extends ConsumerWidget { borderRadius: radius, ), child: FusionTxGroupCard( - // this may mess with combined firo transactions key: UniqueKey(), group: group, ), diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 85dab0310..7978d6d8d 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -132,6 +132,7 @@ import 'package:stackwallet/pages/wallet_view/transaction_views/all_transactions import 'package:stackwallet/pages/wallet_view/transaction_views/edit_note_view.dart'; import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_search_filter_view.dart'; +import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/fusion_group_details_view.dart'; import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart'; import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; import 'package:stackwallet/pages/wallets_view/wallets_overview.dart'; @@ -1277,6 +1278,26 @@ class RouteGenerator { } return _routeError("${settings.name} invalid args: ${args.toString()}"); + case FusionGroupDetailsView.routeName: + if (args is ({ + List transactions, + Coin coin, + String walletId + })) { + return getRoute( + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => FusionGroupDetailsView( + transactions: args.transactions, + coin: args.coin, + walletId: args.walletId, + ), + settings: RouteSettings( + name: settings.name, + ), + ); + } + return _routeError("${settings.name} invalid args: ${args.toString()}"); + case AllTransactionsView.routeName: if (args is ({String walletId, bool isTokens})) { return getRoute(