dev
dart 118 lines 3.9 KB
Raw
1 import "package:cake_wallet/generated/i18n.dart";
2 import "package:cake_wallet/src/widgets/cake_image_widget.dart";
3 import "package:flutter/material.dart";
4
5 class SwapSourceSelector extends StatelessWidget {
6 const SwapSourceSelector({
7 required this.currencyIconPath,
8 required this.currencyLabel,
9 required this.availableBalance,
10 required this.onTap,
11 this.chainIconPath,
12 this.walletName,
13 super.key,
14 });
15
16 final String currencyIconPath;
17 final String currencyLabel;
18 final String availableBalance;
19 final VoidCallback onTap;
20 final String? chainIconPath;
21 final String? walletName;
22
23 @override
24 Widget build(BuildContext context) {
25 final colors = Theme.of(context).colorScheme;
26 final chainIcon = chainIconPath;
27
28 return Column(
29 spacing: 12,
30 crossAxisAlignment: CrossAxisAlignment.start,
31 children: [
32 GestureDetector(
33 onTap: onTap,
34 child: Container(
35 height: 52,
36 padding: const EdgeInsets.symmetric(horizontal: 12),
37 decoration: BoxDecoration(
38 color: colors.surfaceContainer,
39 borderRadius: BorderRadius.circular(18),
40 ),
41 child: Row(
42 children: [
43 CakeImageWidget(
44 imageUrl: currencyIconPath,
45 width: 24,
46 height: 24,
47 ),
48 const SizedBox(width: 8),
49 Text(
50 currencyLabel,
51 style: Theme.of(context).textTheme.bodyLarge?.copyWith(letterSpacing: -0.08),
52 ),
53 if (chainIcon != null && chainIcon.isNotEmpty) ...[
54 const SizedBox(width: 4),
55 CakeImageWidget(
56 imageUrl: chainIcon,
57 width: 12,
58 height: 12,
59 colorFilter: ColorFilter.mode(colors.onSurfaceVariant, BlendMode.srcIn),
60 ),
61 ],
62 const Spacer(),
63 CakeImageWidget(
64 imageUrl: "assets/new-ui/chooser.svg",
65 width: 12,
66 height: 12,
67 colorFilter: ColorFilter.mode(colors.onSurfaceVariant, BlendMode.srcIn),
68 ),
69 ],
70 ),
71 ),
72 ),
73 Padding(
74 padding: const EdgeInsets.symmetric(horizontal: 16),
75 child: Row(
76 mainAxisAlignment: MainAxisAlignment.spaceBetween,
77 children: [
78 Flexible(
79 child: Row(
80 mainAxisSize: MainAxisSize.min,
81 children: [
82 CakeImageWidget(
83 imageUrl: "assets/new-ui/wallet_filled.svg",
84 width: 16,
85 height: 16,
86 colorFilter: ColorFilter.mode(colors.onSurfaceVariant, BlendMode.srcIn),
87 ),
88 const SizedBox(width: 4),
89 Flexible(
90 child: Text(
91 walletName ?? "",
92 overflow: TextOverflow.ellipsis,
93 style: Theme.of(context).textTheme.bodySmall?.copyWith(
94 fontWeight: FontWeight.w500,
95 letterSpacing: -0.06,
96 color: colors.onSurfaceVariant,
97 ),
98 ),
99 ),
100 ],
101 ),
102 ),
103 const SizedBox(width: 8),
104 Text(
105 S.of(context).available_balance_short(availableBalance),
106 style: Theme.of(context).textTheme.bodySmall?.copyWith(
107 fontWeight: FontWeight.w500,
108 letterSpacing: -0.06,
109 color: colors.primary,
110 ),
111 ),
112 ],
113 ),
114 ),
115 ],
116 );
117 }
118 }