diff --git a/lib/pages/wallets_sheet/wallets_sheet.dart b/lib/pages/wallets_sheet/wallets_sheet.dart deleted file mode 100644 index dbbe371f1..000000000 --- a/lib/pages/wallets_sheet/wallets_sheet.dart +++ /dev/null @@ -1,101 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/providers.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/widgets/wallet_card.dart'; - -class WalletsSheet extends ConsumerWidget { - const WalletsSheet({ - Key? key, - required this.coin, - }) : super(key: key); - - final Coin coin; - - @override - Widget build(BuildContext context, WidgetRef ref) { - final providers = ref - .watch(walletsChangeNotifierProvider - .select((value) => value.getManagerProvidersByCoin())) - .where((e) => e.item1 == coin) - .map((e) => e.item2) - .expand((e) => e) - .toList(); - - final maxHeight = MediaQuery.of(context).size.height * 0.60; - - return Container( - decoration: BoxDecoration( - color: Theme.of(context).extension()!.popupBG, - borderRadius: const BorderRadius.vertical( - top: Radius.circular(20), - ), - ), - child: LimitedBox( - maxHeight: maxHeight, - child: Padding( - padding: const EdgeInsets.only( - left: 24, - right: 24, - top: 10, - bottom: 0, - ), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Center( - child: Container( - decoration: BoxDecoration( - color: Theme.of(context) - .extension()! - .textFieldDefaultBG, - borderRadius: BorderRadius.circular( - Constants.size.circularBorderRadius, - ), - ), - width: 60, - height: 4, - ), - ), - const SizedBox( - height: 36, - ), - Text( - "${coin.prettyName} (${coin.ticker}) wallets", - style: STextStyles.pageTitleH2(context), - textAlign: TextAlign.left, - ), - const SizedBox( - height: 16, - ), - Flexible( - child: ListView.builder( - shrinkWrap: true, - itemCount: providers.length, - itemBuilder: (builderContext, index) { - final walletId = ref.watch( - providers[index].select((value) => value.walletId)); - return Padding( - padding: const EdgeInsets.symmetric(vertical: 4), - child: WalletSheetCard( - walletId: walletId, - popPrevious: true, - ), - ); - }, - ), - ), - const SizedBox( - height: 24, - ), - ], - ), - ), - ), - ); - } -} diff --git a/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart b/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart index ac4c6fb85..851d2445f 100644 --- a/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart +++ b/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart @@ -4,8 +4,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; -import 'package:stackwallet/pages/wallets_sheet/wallets_sheet.dart'; -import 'package:stackwallet/pages/wallets_view/eth_wallets_overview.dart'; +import 'package:stackwallet/pages/wallets_view/wallets_overview.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; import 'package:stackwallet/utilities/assets.dart'; @@ -46,13 +45,7 @@ class WalletListItem extends ConsumerWidget { BorderRadius.circular(Constants.size.circularBorderRadius), ), onPressed: () async { - if (coin == Coin.ethereum) { - unawaited( - Navigator.of(context).pushNamed( - EthWalletsOverview.routeName, - ), - ); - } else if (walletCount == 1) { + if (walletCount == 1 && coin != Coin.ethereum) { final providersByCoin = ref .watch(walletsChangeNotifierProvider .select((value) => value.getManagerProvidersByCoin())) @@ -77,15 +70,9 @@ class WalletListItem extends ConsumerWidget { } } else { unawaited( - showModalBottomSheet( - backgroundColor: Colors.transparent, - context: context, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.vertical( - top: Radius.circular(20), - ), - ), - builder: (_) => WalletsSheet(coin: coin), + Navigator.of(context).pushNamed( + WalletsOverview.routeName, + arguments: coin, ), ); } diff --git a/lib/pages/wallets_view/eth_wallets_overview.dart b/lib/pages/wallets_view/wallets_overview.dart similarity index 64% rename from lib/pages/wallets_view/eth_wallets_overview.dart rename to lib/pages/wallets_view/wallets_overview.dart index 35e1b4411..e79c13383 100644 --- a/lib/pages/wallets_view/eth_wallets_overview.dart +++ b/lib/pages/wallets_view/wallets_overview.dart @@ -9,29 +9,35 @@ 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/master_wallet_card.dart'; +import 'package:stackwallet/widgets/wallet_card.dart'; -class EthWalletsOverview extends ConsumerStatefulWidget { - const EthWalletsOverview({Key? key}) : super(key: key); +class WalletsOverview extends ConsumerStatefulWidget { + const WalletsOverview({ + Key? key, + required this.coin, + }) : super(key: key); + + final Coin coin; static const routeName = "/ethWalletsOverview"; @override - ConsumerState createState() => _EthWalletsOverviewState(); + ConsumerState createState() => _EthWalletsOverviewState(); } -class _EthWalletsOverviewState extends ConsumerState { +class _EthWalletsOverviewState extends ConsumerState { final isDesktop = Util.isDesktop; - final List ethWalletIds = []; + final List walletIds = []; @override void initState() { final walletsData = ref.read(walletsServiceChangeNotifierProvider).fetchWalletsData(); - walletsData.removeWhere((key, value) => value.coin != Coin.ethereum); - ethWalletIds.clear(); + walletsData.removeWhere((key, value) => value.coin != widget.coin); + walletIds.clear(); - ethWalletIds.addAll(walletsData.values.map((e) => e.walletId)); + walletIds.addAll(walletsData.values.map((e) => e.walletId)); super.initState(); } @@ -47,7 +53,7 @@ class _EthWalletsOverviewState extends ConsumerState { appBar: AppBar( leading: const AppBarBackButton(), title: Text( - "Ethereum (ETH) wallets", + "${widget.coin.prettyName} (${widget.coin.ticker}) wallets", style: STextStyles.navBarTitle(context), ), ), @@ -59,13 +65,17 @@ class _EthWalletsOverviewState extends ConsumerState { ), ), child: ListView.separated( - itemCount: ethWalletIds.length, + itemCount: walletIds.length, separatorBuilder: (_, __) => const SizedBox( height: 8, ), - itemBuilder: (_, index) => MasterWalletCard( - walletId: ethWalletIds[index], - ), + itemBuilder: (_, index) => widget.coin == Coin.ethereum + ? MasterWalletCard( + walletId: walletIds[index], + ) + : WalletSheetCard( + walletId: walletIds[index], + ), ), ), ); diff --git a/lib/route_generator.dart b/lib/route_generator.dart index db3a7450c..4031e425e 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -106,7 +106,7 @@ import 'package:stackwallet/pages/wallet_view/transaction_views/edit_note_view.d 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/wallet_view.dart'; -import 'package:stackwallet/pages/wallets_view/eth_wallets_overview.dart'; +import 'package:stackwallet/pages/wallets_view/wallets_overview.dart'; import 'package:stackwallet/pages/wallets_view/wallets_view.dart'; import 'package:stackwallet/pages_desktop_specific/address_book_view/desktop_address_book.dart'; import 'package:stackwallet/pages_desktop_specific/addresses/desktop_wallet_addresses_view.dart'; @@ -280,14 +280,19 @@ class RouteGenerator { ), ); - case EthWalletsOverview.routeName: - return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const EthWalletsOverview(), - settings: RouteSettings( - name: settings.name, - ), - ); + case WalletsOverview.routeName: + if (args is Coin) { + return getRoute( + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => WalletsOverview( + coin: args, + ), + settings: RouteSettings( + name: settings.name, + ), + ); + } + return _routeError("${settings.name} invalid args: ${args.toString()}"); case TokenContractDetailsView.routeName: if (args is Tuple2) {