dev
dart 174 lines 5.84 KB
Raw
1 import "package:cake_wallet/generated/i18n.dart";
2 import "package:cake_wallet/new-ui/widgets/new_primary_button.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:cw_core/currency_for_wallet_type.dart";
6 import "package:flutter/material.dart";
7
8 class NetworkDecisionPage extends StatelessWidget {
9 const NetworkDecisionPage({
10 required this.title,
11 required this.description,
12 required this.destinationIconPath,
13 required this.primaryText,
14 required this.onPrimary,
15 required this.secondaryText,
16 this.currentIconPath,
17 this.primaryIconPath,
18 this.secondaryIconPath,
19 this.onSecondary,
20 super.key,
21 });
22
23 final String title;
24 final String description;
25 final String destinationIconPath;
26 final String? currentIconPath;
27 final String primaryText;
28 final VoidCallback onPrimary;
29 final String? primaryIconPath;
30 final String secondaryText;
31 final String? secondaryIconPath;
32 final VoidCallback? onSecondary;
33
34 @override
35 Widget build(BuildContext context) {
36 final colors = Theme.of(context).colorScheme;
37 final primaryIcon = primaryIconPath;
38 final secondaryIcon = secondaryIconPath;
39 return Material(
40 color: colors.surface,
41 child: SafeArea(
42 child: Column(
43 children: [
44 ModalTopBar(
45 title: "",
46 leadingIcon: const Icon(Icons.arrow_back_ios_new),
47 leadingSemanticLabel: S.of(context).seed_alert_back,
48 onLeadingPressed: () => Navigator.of(context).maybePop(),
49 ),
50 Expanded(
51 child: Center(
52 child: Padding(
53 padding: const EdgeInsets.symmetric(horizontal: 24),
54 child: Column(
55 mainAxisSize: MainAxisSize.min,
56 children: [
57 ExcludeSemantics(
58 child: _DecisionHeader(
59 destinationIconPath: destinationIconPath,
60 currentIconPath: currentIconPath,
61 ),
62 ),
63 const SizedBox(height: 24),
64 Text(
65 title,
66 textAlign: TextAlign.center,
67 style: Theme.of(context).textTheme.titleLarge?.copyWith(
68 fontSize: 20,
69 fontWeight: FontWeight.w500,
70 letterSpacing: -0.1,
71 ),
72 ),
73 const SizedBox(height: 16),
74 Text(
75 description,
76 textAlign: TextAlign.center,
77 style: Theme.of(context)
78 .textTheme
79 .bodyMedium
80 ?.copyWith(color: colors.onSurfaceVariant, letterSpacing: -0.07),
81 ),
82 ],
83 ),
84 ),
85 ),
86 ),
87 Padding(
88 padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
89 child: Column(
90 mainAxisSize: MainAxisSize.min,
91 children: [
92 NewPrimaryButton(
93 onPressed: onPrimary,
94 image: primaryIcon != null
95 ? CakeImageWidget(
96 imageUrl: primaryIcon,
97 width: 24,
98 height: 24,
99 colorFilter: ColorFilter.mode(colors.onPrimary, BlendMode.srcIn),
100 )
101 : null,
102 text: primaryText,
103 color: colors.primary,
104 textColor: colors.onPrimary,
105 ),
106 const SizedBox(height: 12),
107 NewPrimaryButton(
108 onPressed: onSecondary ?? () => Navigator.of(context).maybePop(),
109 image: secondaryIcon != null
110 ? CakeImageWidget(
111 imageUrl: secondaryIcon,
112 width: 24,
113 height: 24,
114 colorFilter: ColorFilter.mode(colors.primary, BlendMode.srcIn),
115 )
116 : null,
117 text: secondaryText,
118 color: colors.surfaceContainer,
119 textColor: colors.primary,
120 ),
121 ],
122 ),
123 ),
124 ],
125 ),
126 ),
127 );
128 }
129 }
130
131 class _DecisionHeader extends StatelessWidget {
132 const _DecisionHeader({required this.destinationIconPath, this.currentIconPath});
133
134 final String destinationIconPath;
135 final String? currentIconPath;
136
137 @override
138 Widget build(BuildContext context) {
139 final colors = Theme.of(context).colorScheme;
140 final current = currentIconPath;
141
142 if (current == null) {
143 return CakeImageWidget(
144 imageUrl: destinationIconPath,
145 width: 75,
146 height: 75,
147 fit: BoxFit.contain,
148 color: isMonochromeSymbolIcon(destinationIconPath) ? colors.primary : null,
149 );
150 }
151
152 return Row(
153 mainAxisSize: MainAxisSize.min,
154 spacing: 12,
155 children: [
156 CakeImageWidget(
157 imageUrl: current,
158 width: 50,
159 height: 50,
160 fit: BoxFit.contain,
161 color: isMonochromeSymbolIcon(current) ? colors.primary : null,
162 ),
163 Icon(Icons.arrow_forward, color: colors.primary, size: 28),
164 CakeImageWidget(
165 imageUrl: destinationIconPath,
166 width: 50,
167 height: 50,
168 fit: BoxFit.contain,
169 color: isMonochromeSymbolIcon(destinationIconPath) ? colors.primary : null,
170 ),
171 ],
172 );
173 }
174 }