dev
dart 72 lines 2.24 KB
Raw
1 import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
2 import 'package:cake_wallet/src/widgets/evm_switcher.dart';
3 import 'package:cake_wallet/src/widgets/standard_switch.dart';
4 import 'package:flutter/material.dart';
5
6 class EvmSwitcherRow extends StatelessWidget {
7 const EvmSwitcherRow({
8 super.key,
9 required this.editMode,
10 required this.selected,
11 required this.data,
12 required this.onTap,
13 required this.animDuration,
14 required this.editSwitchValue,
15 });
16
17 final bool editMode;
18 final bool selected;
19 final EvmSwitcherDataItem data;
20 final VoidCallback onTap;
21 final Duration animDuration;
22 final bool editSwitchValue;
23
24 @override
25 Widget build(BuildContext context) {
26 final Color resolvedForegroundColor = editMode || selected
27 ? Theme.of(context).colorScheme.onSurface
28 : Theme.of(context).colorScheme.primary;
29
30 final Color resolvedBackgroundColor = !editMode && selected
31 ? Theme.of(context).colorScheme.surfaceContainerHighest
32 : Theme.of(context).colorScheme.surfaceContainerHighest.withAlpha(0);
33
34 return GestureDetector(
35 onTap: onTap,
36 child: AnimatedContainer(
37 duration: animDuration,
38 color: resolvedBackgroundColor,
39 child: Padding(
40 padding: const EdgeInsets.all(18.0),
41 child: Row(
42 mainAxisSize: MainAxisSize.max,
43 mainAxisAlignment: MainAxisAlignment.spaceBetween,
44 children: [
45 Row(
46 spacing: 8.0,
47 children: [
48 CakeImageWidget(
49 imageUrl: data.svgPath,
50 width: 16,
51 height: 16,
52 ),
53 Text(
54 data.name,
55 style: TextStyle(color: resolvedForegroundColor, fontSize: 14),
56 ),
57 if (selected && !editMode)
58 CakeImageWidget(
59 imageUrl: "assets/images/evm_switcher_checkmark.svg",
60 width: 18,
61 height: 18,
62 ),
63 ],
64 ),
65 if (editMode) StandardSwitch(value: editSwitchValue, onTapped: onTap)
66 ],
67 ),
68 ),
69 ),
70 );
71 }
72 }