dev
dart 85 lines 2.52 KB
Raw
1 import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
2 import 'package:cw_core/generate_name.dart';
3 import 'package:flutter/material.dart';
4 import 'package:flutter_mobx/flutter_mobx.dart';
5
6 class NetworkPathPill extends StatelessWidget {
7 const NetworkPathPill({
8 required this.sourceChainName,
9 required this.destChainName,
10 this.showBackground = true,
11 });
12
13 final String sourceChainName;
14 final String destChainName;
15 final bool showBackground;
16
17 @override
18 Widget build(BuildContext context) {
19 final scheme = Theme.of(context).colorScheme;
20 final body = Row(
21 mainAxisAlignment: MainAxisAlignment.center,
22 mainAxisSize: MainAxisSize.min,
23 children: [
24 CakeImageWidget(
25 imageUrl: 'assets/new-ui/chain_badges/${sourceChainName.toLowerCase()}.svg',
26 width: 24,
27 height: 24,
28 color: scheme.onSurfaceVariant,
29 ),
30 const SizedBox(width: 8),
31 Text(
32 sourceChainName.capitalized(),
33 maxLines: 1,
34 overflow: TextOverflow.ellipsis,
35 style: Theme.of(context).textTheme.bodyLarge?.copyWith(
36 color: scheme.onSurface,
37 fontWeight: FontWeight.w400,
38 fontSize: 16,
39 letterSpacing: -0.08,
40 ),
41 ),
42 Padding(
43 padding: const EdgeInsets.symmetric(horizontal: 8),
44 child: Icon(
45 Icons.arrow_forward,
46 size: 16,
47 color: scheme.primary,
48 ),
49 ),
50 CakeImageWidget(
51 imageUrl: 'assets/new-ui/chain_badges/${destChainName.toLowerCase()}.svg',
52 width: 24,
53 height: 24,
54 color: scheme.onSurfaceVariant,
55 ),
56 const SizedBox(width: 8),
57 Text(
58 destChainName,
59 maxLines: 1,
60 overflow: TextOverflow.ellipsis,
61 style: Theme.of(context).textTheme.bodyLarge?.copyWith(
62 color: scheme.onSurface,
63 fontWeight: FontWeight.w400,
64 fontSize: 16,
65 letterSpacing: -0.08,
66 ),
67 ),
68 ],
69 );
70 return Observer(
71 builder: (_) {
72 return showBackground
73 ? Container(
74 padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
75 decoration: BoxDecoration(
76 color: scheme.surfaceContainer,
77 borderRadius: BorderRadius.circular(80),
78 ),
79 child: body,
80 )
81 : body;
82 },
83 );
84 }
85 }