dev
dart 100 lines 3.53 KB
Raw
1 import 'package:cake_wallet/themes/core/theme_extension.dart';
2 import 'package:flutter/material.dart';
3
4 class OptionTile extends StatelessWidget {
5 const OptionTile({
6 required this.onPressed,
7 this.image,
8 this.icon,
9 required this.title,
10 required this.description,
11 this.tag,
12 super.key,
13 }) : assert(image != null || icon != null);
14
15 final VoidCallback onPressed;
16 final Widget? image;
17 final Icon? icon;
18 final String title;
19 final String description;
20 final String? tag;
21
22 @override
23 Widget build(BuildContext context) {
24 return Container(
25 width: double.infinity,
26 alignment: Alignment.center,
27 decoration: ShapeDecoration(
28 gradient: LinearGradient(
29 colors: [
30 context.customColors.cardGradientColorPrimary,
31 context.customColors.cardGradientColorSecondary,
32 ],
33 begin: Alignment.topCenter,
34 end: Alignment.bottomCenter,
35 ),
36 shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
37 ),
38 child: TextButton(
39 style: TextButton.styleFrom(
40 side: BorderSide(width: 1.25, color: Theme.of(context).colorScheme.surfaceContainerHigh),
41 backgroundColor: Colors.transparent,
42 shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(15)),
43 padding: EdgeInsets.all(24),
44 ),
45 onPressed: onPressed,
46 child: Row(
47 mainAxisSize: MainAxisSize.max,
48 mainAxisAlignment: MainAxisAlignment.center,
49 crossAxisAlignment: CrossAxisAlignment.start,
50 children: <Widget>[
51 icon ?? image!,
52 Expanded(
53 child: Padding(
54 padding: EdgeInsets.only(left: 20),
55 child: Column(
56 mainAxisSize: MainAxisSize.max,
57 mainAxisAlignment: MainAxisAlignment.start,
58 crossAxisAlignment: CrossAxisAlignment.start,
59 children: <Widget>[
60 Row(
61 children: [
62 ConstrainedBox(
63 constraints: BoxConstraints(maxWidth: 220),
64 child: Text(title, style: Theme.of(context).textTheme.titleMedium),
65 ),
66 if (tag != null)
67 Container(
68 decoration: BoxDecoration(
69 border: Border.all(style: BorderStyle.none),
70 borderRadius: BorderRadius.circular(20),
71 color: Theme.of(context).colorScheme.onSurfaceVariant,
72 ),
73 padding: EdgeInsets.symmetric(horizontal: 5),
74 margin: EdgeInsets.only(left: 5),
75 child: Text(
76 tag!,
77 style: TextStyle(color: Theme.of(context).colorScheme.onPrimary),
78 ),
79 )
80 ],
81 ),
82 Padding(
83 padding: EdgeInsets.only(top: 5),
84 child: Text(
85 description,
86 style: Theme.of(context).textTheme.bodySmall!.copyWith(
87 color: Theme.of(context).colorScheme.onSurfaceVariant,
88 ),
89 ),
90 )
91 ],
92 ),
93 ),
94 )
95 ],
96 ),
97 ),
98 );
99 }
100 }