| 1 | import "package:cake_wallet/generated/i18n.dart"; |
| 2 | import "package:cake_wallet/new-ui/widgets/receive_page/receive_top_bar.dart"; |
| 3 | import "package:cake_wallet/new-ui/widgets/send_page/l2_action_wallet_selector.dart"; |
| 4 | import "package:cake_wallet/src/widgets/cake_image_widget.dart"; |
| 5 | import "package:cw_core/currency_for_wallet_type.dart"; |
| 6 | import "package:cw_core/wallet_info.dart"; |
| 7 | import "package:flutter/cupertino.dart"; |
| 8 | import "package:flutter/material.dart"; |
| 9 | |
| 10 | class SwitchNetworkWalletPage extends StatelessWidget { |
| 11 | const SwitchNetworkWalletPage({ |
| 12 | required this.wallets, |
| 13 | required this.networkName, |
| 14 | required this.destinationIconPath, |
| 15 | super.key, |
| 16 | }); |
| 17 | |
| 18 | final String networkName; |
| 19 | final String destinationIconPath; |
| 20 | final List<WalletInfo> wallets; |
| 21 | |
| 22 | static Future<WalletInfo?> push({ |
| 23 | required BuildContext context, |
| 24 | required String networkName, |
| 25 | required String targetIconPath, |
| 26 | required List<WalletInfo> wallets, |
| 27 | }) => |
| 28 | Navigator.of(context).push<WalletInfo>( |
| 29 | CupertinoPageRoute( |
| 30 | builder: (_) => SwitchNetworkWalletPage( |
| 31 | networkName: networkName, |
| 32 | destinationIconPath: targetIconPath, |
| 33 | wallets: wallets, |
| 34 | ), |
| 35 | ), |
| 36 | ); |
| 37 | |
| 38 | @override |
| 39 | Widget build(BuildContext context) { |
| 40 | final colors = Theme.of(context).colorScheme; |
| 41 | return Material( |
| 42 | color: colors.surface, |
| 43 | child: SafeArea( |
| 44 | child: Column( |
| 45 | mainAxisAlignment: MainAxisAlignment.center, |
| 46 | children: [ |
| 47 | ModalTopBar( |
| 48 | title: "", |
| 49 | leadingIcon: const Icon(Icons.arrow_back_ios_new), |
| 50 | leadingSemanticLabel: S.of(context).seed_alert_back, |
| 51 | onLeadingPressed: () => Navigator.of(context).maybePop(), |
| 52 | ), |
| 53 | const SizedBox(height: 124), |
| 54 | Row( |
| 55 | mainAxisSize: MainAxisSize.min, |
| 56 | mainAxisAlignment: MainAxisAlignment.center, |
| 57 | children: [ |
| 58 | Icon(Icons.arrow_forward, color: colors.primary, size: 32), |
| 59 | const SizedBox(width: 8), |
| 60 | CakeImageWidget( |
| 61 | imageUrl: destinationIconPath, |
| 62 | width: 50, |
| 63 | height: 50, |
| 64 | fit: BoxFit.contain, |
| 65 | color: isMonochromeSymbolIcon(destinationIconPath) ? colors.primary : null, |
| 66 | ), |
| 67 | ], |
| 68 | ), |
| 69 | const SizedBox(height: 24), |
| 70 | Text( |
| 71 | S.of(context).switch_to_x_wallet(networkName), |
| 72 | textAlign: TextAlign.center, |
| 73 | style: Theme.of(context) |
| 74 | .textTheme |
| 75 | .titleLarge |
| 76 | ?.copyWith(fontSize: 20, fontWeight: FontWeight.w500, letterSpacing: -0.1), |
| 77 | ), |
| 78 | const SizedBox(height: 24), |
| 79 | Text( |
| 80 | S.of(context).select_compatible_wallet, |
| 81 | textAlign: TextAlign.center, |
| 82 | style: Theme.of(context) |
| 83 | .textTheme |
| 84 | .bodyMedium |
| 85 | ?.copyWith(color: colors.onSurfaceVariant, letterSpacing: -0.07), |
| 86 | ), |
| 87 | const SizedBox(height: 24), |
| 88 | Expanded( |
| 89 | child: ListView.separated( |
| 90 | padding: const EdgeInsets.symmetric(horizontal: 16), |
| 91 | itemCount: wallets.length, |
| 92 | separatorBuilder: (_, __) => const SizedBox(height: 12), |
| 93 | itemBuilder: (_, index) { |
| 94 | final wallet = wallets[index]; |
| 95 | return WalletRow( |
| 96 | currencyIconPath: getCryptoCurrencyIconForWalletListItem(wallet.type), |
| 97 | walletName: wallet.name, |
| 98 | onTap: () => Navigator.of(context).pop(wallet), |
| 99 | ); |
| 100 | }, |
| 101 | ), |
| 102 | ), |
| 103 | ], |
| 104 | ), |
| 105 | ), |
| 106 | ); |
| 107 | } |
| 108 | } |