dev
dart 157 lines 6.11 KB
Raw
1 import 'package:cake_wallet/generated/i18n.dart';
2 import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
3 import 'package:cw_core/currency.dart';
4 import 'package:flutter/material.dart';
5 import 'package:flutter/services.dart';
6
7 class AnonpayCurrencyInputField extends StatelessWidget {
8 const AnonpayCurrencyInputField(
9 {super.key,
10 required this.onTapPicker,
11 required this.selectedCurrency,
12 required this.focusNode,
13 required this.controller,
14 required this.minAmount,
15 required this.maxAmount});
16 final Function() onTapPicker;
17 final Currency selectedCurrency;
18 final FocusNode focusNode;
19 final TextEditingController controller;
20 final String minAmount;
21 final String maxAmount;
22
23 @override
24 Widget build(BuildContext context) {
25 final arrowBottomPurple = Image.asset(
26 'assets/images/arrow_bottom_purple_icon.png',
27 color: Theme.of(context).colorScheme.primary,
28 height: 8,
29 );
30
31 return Column(
32 children: [
33 Container(
34 child: Padding(
35 padding: EdgeInsets.only(top: 20),
36 child: Row(
37 children: [
38 Container(
39 padding: EdgeInsets.only(right: 8),
40 height: 32,
41 child: InkWell(
42 onTap: onTapPicker,
43 child: Row(
44 mainAxisAlignment: MainAxisAlignment.spaceBetween,
45 mainAxisSize: MainAxisSize.min,
46 children: <Widget>[
47 Padding(
48 padding: EdgeInsets.only(right: 5),
49 child: arrowBottomPurple,
50 ),
51 Text(
52 selectedCurrency.name.toUpperCase(),
53 style: Theme.of(context).textTheme.bodyLarge?.copyWith(
54 fontWeight: FontWeight.w600,
55 color: Theme.of(context).colorScheme.onSurface,
56 ),
57 ),
58 ],
59 ),
60 ),
61 ),
62 if (selectedCurrency.tag != null)
63 Padding(
64 padding: const EdgeInsets.only(right: 3.0),
65 child: Container(
66 height: 32,
67 decoration: BoxDecoration(
68 color: Theme.of(context).colorScheme.secondaryContainer,
69 borderRadius: BorderRadius.all(Radius.circular(6)),
70 ),
71 child: Center(
72 child: Padding(
73 padding: const EdgeInsets.all(6.0),
74 child: Text(
75 selectedCurrency.tag!,
76 style: Theme.of(context).textTheme.bodySmall?.copyWith(
77 fontWeight: FontWeight.bold,
78 color: Theme.of(context).colorScheme.onSecondaryContainer,
79 ),
80 ),
81 ),
82 ),
83 ),
84 ),
85 Padding(
86 padding: const EdgeInsets.only(right: 4.0),
87 child: Text(
88 ':',
89 style: Theme.of(context).textTheme.bodyLarge?.copyWith(
90 fontWeight: FontWeight.w600,
91 color: Theme.of(context).colorScheme.onSurface,
92 ),
93 ),
94 ),
95 Expanded(
96 child: Row(
97 mainAxisAlignment: MainAxisAlignment.spaceBetween,
98 children: [
99 Flexible(
100 child: BaseTextFormField(
101 hasUnderlineBorder: true,
102 borderWidth: 0.0,
103 focusNode: focusNode,
104 controller: controller,
105 textInputAction: TextInputAction.next,
106 enabled: true,
107 textAlign: TextAlign.left,
108 keyboardType:
109 TextInputType.numberWithOptions(signed: false, decimal: true),
110 inputFormatters: [FilteringTextInputFormatter.deny(RegExp('[\\-|\\ ]'))],
111 hintText: '0.0000',
112 textStyle: Theme.of(context).textTheme.bodyLarge?.copyWith(
113 fontWeight: FontWeight.w600,
114 color: Theme.of(context).colorScheme.onSurface,
115 ),
116 placeholderTextStyle: Theme.of(context).textTheme.bodyLarge?.copyWith(
117 fontWeight: FontWeight.w600,
118 color: Theme.of(context).colorScheme.onSurfaceVariant,
119 ),
120 validator: null,
121 ),
122 ),
123 ],
124 ),
125 ),
126 ],
127 ),
128 ),
129 ),
130 Divider(height: 1, color: Theme.of(context).colorScheme.outlineVariant),
131 Container(
132 height: 15,
133 child: Row(
134 mainAxisAlignment: MainAxisAlignment.start,
135 children: <Widget>[
136 Text(
137 S.of(context).min_value(minAmount, selectedCurrency.toString()),
138 style: Theme.of(context).textTheme.bodySmall?.copyWith(
139 height: 1.2,
140 color: Theme.of(context).colorScheme.onSurfaceVariant,
141 ),
142 ),
143 SizedBox(width: 10),
144 Text(
145 S.of(context).max_value(maxAmount, selectedCurrency.toString()),
146 style: Theme.of(context).textTheme.bodySmall?.copyWith(
147 height: 1.2,
148 color: Theme.of(context).colorScheme.onSurfaceVariant,
149 ),
150 ),
151 ],
152 ),
153 ),
154 ],
155 );
156 }
157 }