dev
dart 131 lines 4.17 KB
Raw
1 import "package:cake_wallet/generated/i18n.dart";
2 import "package:cake_wallet/new-ui/widgets/anypay/select_recipient_network_sheet.dart";
3 import "package:cake_wallet/new-ui/widgets/receive_page/receive_top_bar.dart";
4 import "package:cake_wallet/src/widgets/cake_image_widget.dart";
5 import "package:flutter/material.dart";
6
7 class EvmAddressDetectedSheet extends StatelessWidget {
8 const EvmAddressDetectedSheet({super.key, required this.networks});
9
10 final List<RecipientNetworkItem> networks;
11
12 static Future<int?> show({
13 required BuildContext context,
14 required List<RecipientNetworkItem> networks,
15 }) {
16 return showModalBottomSheet<int>(
17 context: context,
18 isScrollControlled: true,
19 useSafeArea: true,
20 backgroundColor: Colors.transparent,
21 builder: (_) => EvmAddressDetectedSheet(networks: networks),
22 );
23 }
24
25 @override
26 Widget build(BuildContext context) {
27 final colors = Theme.of(context).colorScheme;
28 return Container(
29 decoration: BoxDecoration(
30 borderRadius: const BorderRadius.vertical(top: Radius.circular(24)),
31 color: colors.surface,
32 ),
33 child: SafeArea(
34 top: false,
35 child: Column(
36 children: [
37 ModalTopBar(
38 title: "",
39 trailingIcon: const Icon(Icons.close),
40 onTrailingPressed: () => Navigator.of(context).maybePop(),
41 ),
42 const SizedBox(height: 32),
43 StackedNetworkIcons(iconPaths: networks.map((n) => n.iconPath).toList()),
44 const SizedBox(height: 24),
45 Text(
46 S.of(context).evm_address_detected,
47 textAlign: TextAlign.center,
48 style: Theme.of(context)
49 .textTheme
50 .titleLarge
51 ?.copyWith(fontSize: 20, fontWeight: FontWeight.w500, letterSpacing: -0.1),
52 ),
53 const SizedBox(height: 24),
54 Padding(
55 padding: const EdgeInsets.symmetric(horizontal: 32),
56 child: Text(
57 S.of(context).select_recipient_network_for_tx,
58 textAlign: TextAlign.center,
59 style: Theme.of(context)
60 .textTheme
61 .bodyMedium
62 ?.copyWith(color: colors.onSurfaceVariant, letterSpacing: -0.07),
63 ),
64 ),
65 const SizedBox(height: 64),
66 Flexible(
67 child: SingleChildScrollView(
68 padding: const EdgeInsets.symmetric(horizontal: 16),
69 child: NetworkListCard(
70 rows: [
71 for (final network in networks)
72 RecipientNetworkListRow(
73 item: network,
74 imageOverride: network.chainBadgeIconPath,
75 onTap: () => Navigator.of(context).pop(network.chainId),
76 ),
77 ],
78 ),
79 ),
80 ),
81 const SizedBox(height: 16),
82 ],
83 ),
84 ),
85 );
86 }
87 }
88
89 class StackedNetworkIcons extends StatelessWidget {
90 const StackedNetworkIcons({
91 required this.iconPaths,
92 this.size = 50,
93 this.step = 34,
94 });
95
96 final List<String> iconPaths;
97 final double size;
98 final double step;
99
100 @override
101 Widget build(BuildContext context) {
102 if (iconPaths.isEmpty) return const SizedBox.shrink();
103
104 final colors = Theme.of(context).colorScheme;
105 final width = size + (iconPaths.length - 1) * step;
106
107 return SizedBox(
108 height: size,
109 width: width,
110 child: Stack(
111 children: [
112 for (int i = 0; i < iconPaths.length; i++)
113 Positioned(
114 left: i * step,
115 child: Container(
116 width: size,
117 height: size,
118 padding: const EdgeInsets.all(2),
119 decoration: BoxDecoration(
120 shape: BoxShape.circle,
121 color: colors.surfaceContainer,
122 border: Border.all(color: colors.surface, width: 2),
123 ),
124 child: CakeImageWidget(imageUrl: iconPaths[i], fit: BoxFit.contain),
125 ),
126 ),
127 ],
128 ),
129 );
130 }
131 }