CAKE-345 | fixed send_card.dart

OleksandrSobol committed Aug 11, 2021 at 17:42 UTC 383d2abcc51315e3d3488d66091671e7cc9a6bc4
1 file changed +352 -348
lib/src/screens/send/widgets/send_card.dart
+352 -348
@@ -63,72 +63,250 @@ class SendCardState extends State<SendCard>
63 super.build(context);
64 _setEffects(context);
65
66 - return KeyboardActions(
67 - config: KeyboardActionsConfig(
68 - keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
69 - keyboardBarColor: Theme.of(context).accentTextTheme.body2
70 - .backgroundColor,
71 - nextFocus: false,
72 - actions: [
73 - KeyboardActionsItem(
74 - focusNode: cryptoAmountFocus,
75 - toolbarButtons: [(_) => KeyboardDoneButton()],
76 - ),
77 - KeyboardActionsItem(
78 - focusNode: fiatAmountFocus,
79 - toolbarButtons: [(_) => KeyboardDoneButton()],
80 - )
81 - ]),
82 - child: Container(
83 - height: 0,
84 - color: Theme.of(context).backgroundColor,
85 - child: Container(
86 - height: sendViewModel.isElectrumWallet ? 470 : 445,
87 - decoration: BoxDecoration(
88 - borderRadius: BorderRadius.only(
89 - bottomLeft: Radius.circular(24),
90 - bottomRight: Radius.circular(24)),
91 - gradient: LinearGradient(colors: [
92 - Theme.of(context).primaryTextTheme.subhead.color,
93 - Theme.of(context)
94 - .primaryTextTheme
95 - .subhead
96 - .decorationColor,
97 - ], begin: Alignment.topLeft, end: Alignment.bottomRight),
98 - ),
99 - child: Padding(
100 - padding: EdgeInsets.fromLTRB(24, 80, 24, 32),
101 - child: SingleChildScrollView(
102 - child: Column(
103 - mainAxisSize: MainAxisSize.min,
104 - children: <Widget>[
105 - AddressTextField(
106 - focusNode: addressFocusNode,
107 - controller: addressController,
108 - onURIScanned: (uri) {
109 - var address = '';
110 - var amount = '';
111 -
112 - if (uri != null) {
113 - address = uri.path;
114 - amount = uri.queryParameters['tx_amount'] ??
115 - uri.queryParameters['amount'];
116 - } else {
117 - address = uri.toString();
118 - }
119 -
120 - addressController.text = address;
121 - cryptoAmountController.text = amount;
122 - },
123 - options: [
124 - AddressTextFieldOption.paste,
125 - AddressTextFieldOption.qrCode,
126 - AddressTextFieldOption.addressBook
127 - ],
128 - buttonColor: Theme.of(context)
129 - .primaryTextTheme
130 - .display1
131 - .color,
66 + return Stack(
67 + children: [
68 + KeyboardActions(
69 + config: KeyboardActionsConfig(
70 + keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
71 + keyboardBarColor: Theme.of(context).accentTextTheme.body2
72 + .backgroundColor,
73 + nextFocus: false,
74 + actions: [
75 + KeyboardActionsItem(
76 + focusNode: cryptoAmountFocus,
77 + toolbarButtons: [(_) => KeyboardDoneButton()],
78 + ),
79 + KeyboardActionsItem(
80 + focusNode: fiatAmountFocus,
81 + toolbarButtons: [(_) => KeyboardDoneButton()],
82 + )
83 + ]),
84 + child: Container(
85 + height: 0,
86 + color: Colors.transparent,
87 + )),
88 + Container(
89 + height: sendViewModel.isElectrumWallet ? 470 : 445,
90 + decoration: BoxDecoration(
91 + borderRadius: BorderRadius.only(
92 + bottomLeft: Radius.circular(24),
93 + bottomRight: Radius.circular(24)),
94 + gradient: LinearGradient(colors: [
95 + Theme.of(context).primaryTextTheme.subhead.color,
96 + Theme.of(context)
97 + .primaryTextTheme
98 + .subhead
99 + .decorationColor,
100 + ], begin: Alignment.topLeft, end: Alignment.bottomRight),
101 + ),
102 + child: Padding(
103 + padding: EdgeInsets.fromLTRB(24, 80, 24, 32),
104 + child: SingleChildScrollView(
105 + child: Column(
106 + mainAxisSize: MainAxisSize.min,
107 + children: <Widget>[
108 + AddressTextField(
109 + focusNode: addressFocusNode,
110 + controller: addressController,
111 + onURIScanned: (uri) {
112 + var address = '';
113 + var amount = '';
114 +
115 + if (uri != null) {
116 + address = uri.path;
117 + amount = uri.queryParameters['tx_amount'] ??
118 + uri.queryParameters['amount'];
119 + } else {
120 + address = uri.toString();
121 + }
122 +
123 + addressController.text = address;
124 + cryptoAmountController.text = amount;
125 + },
126 + options: [
127 + AddressTextFieldOption.paste,
128 + AddressTextFieldOption.qrCode,
129 + AddressTextFieldOption.addressBook
130 + ],
131 + buttonColor: Theme.of(context)
132 + .primaryTextTheme
133 + .display1
134 + .color,
135 + borderColor: Theme.of(context)
136 + .primaryTextTheme
137 + .headline
138 + .color,
139 + textStyle: TextStyle(
140 + fontSize: 14,
141 + fontWeight: FontWeight.w500,
142 + color: Colors.white),
143 + hintStyle: TextStyle(
144 + fontSize: 14,
145 + fontWeight: FontWeight.w500,
146 + color: Theme.of(context)
147 + .primaryTextTheme
148 + .headline
149 + .decorationColor),
150 + onPushPasteButton: (context) async {
151 + final parsedAddress =
152 + await output.applyOpenaliasOrUnstoppableDomains();
153 + showAddressAlert(context, parsedAddress);
154 + },
155 + validator: sendViewModel.addressValidator,
156 + ),
157 + Observer(
158 + builder: (_) => Padding(
159 + padding: const EdgeInsets.only(top: 20),
160 + child: Stack(
161 + children: [
162 + BaseTextFormField(
163 + focusNode: cryptoAmountFocus,
164 + controller: cryptoAmountController,
165 + keyboardType:
166 + TextInputType.numberWithOptions(
167 + signed: false, decimal: true),
168 + prefixIcon: Padding(
169 + padding: EdgeInsets.only(top: 9),
170 + child: Text(
171 + sendViewModel.currency.title +
172 + ':',
173 + style: TextStyle(
174 + fontSize: 16,
175 + fontWeight: FontWeight.w600,
176 + color: Colors.white,
177 + )),
178 + ),
179 + suffixIcon: SizedBox(
180 + width: prefixIconWidth,
181 + ),
182 + hintText: '0.0000',
183 + borderColor: Theme.of(context)
184 + .primaryTextTheme
185 + .headline
186 + .color,
187 + textStyle: TextStyle(
188 + fontSize: 14,
189 + fontWeight: FontWeight.w500,
190 + color: Colors.white),
191 + placeholderTextStyle: TextStyle(
192 + color: Theme.of(context)
193 + .primaryTextTheme
194 + .headline
195 + .decorationColor,
196 + fontWeight: FontWeight.w500,
197 + fontSize: 14),
198 + validator: output.sendAll
199 + ? sendViewModel.allAmountValidator
200 + : sendViewModel
201 + .amountValidator),
202 + if (!sendViewModel.isBatchSending) Positioned(
203 + top: 2,
204 + right: 0,
205 + child: Container(
206 + width: prefixIconWidth,
207 + height: prefixIconHeight,
208 + child: InkWell(
209 + onTap: () async =>
210 + output.setSendAll(),
211 + child: Container(
212 + decoration: BoxDecoration(
213 + color: Theme.of(context)
214 + .primaryTextTheme
215 + .display1
216 + .color,
217 + borderRadius:
218 + BorderRadius.all(
219 + Radius.circular(6))),
220 + child: Center(
221 + child: Text(
222 + S.of(context).all,
223 + textAlign:
224 + TextAlign.center,
225 + style: TextStyle(
226 + fontSize: 12,
227 + fontWeight:
228 + FontWeight.bold,
229 + color:
230 + Theme.of(context)
231 + .primaryTextTheme
232 + .display1
233 + .decorationColor))),
234 + ))))])
235 + )),
236 + Observer(
237 + builder: (_) => Padding(
238 + padding: EdgeInsets.only(top: 10),
239 + child: Row(
240 + mainAxisSize: MainAxisSize.max,
241 + mainAxisAlignment:
242 + MainAxisAlignment.spaceBetween,
243 + children: <Widget>[
244 + Expanded(
245 + child: Text(
246 + S.of(context).available_balance +
247 + ':',
248 + style: TextStyle(
249 + fontSize: 12,
250 + fontWeight: FontWeight.w600,
251 + color: Theme.of(context)
252 + .primaryTextTheme
253 + .headline
254 + .decorationColor),
255 + )),
256 + Text(
257 + sendViewModel.balance,
258 + style: TextStyle(
259 + fontSize: 12,
260 + fontWeight: FontWeight.w600,
261 + color: Theme.of(context)
262 + .primaryTextTheme
263 + .headline
264 + .decorationColor),
265 + )
266 + ],
267 + ),
268 + )),
269 + Padding(
270 + padding: const EdgeInsets.only(top: 20),
271 + child: BaseTextFormField(
272 + focusNode: fiatAmountFocus,
273 + controller: fiatAmountController,
274 + keyboardType:
275 + TextInputType.numberWithOptions(
276 + signed: false, decimal: true),
277 + prefixIcon: Padding(
278 + padding: EdgeInsets.only(top: 9),
279 + child:
280 + Text(sendViewModel.fiat.title + ':',
281 + style: TextStyle(
282 + fontSize: 16,
283 + fontWeight: FontWeight.w600,
284 + color: Colors.white,
285 + )),
286 + ),
287 + hintText: '0.00',
288 + borderColor: Theme.of(context)
289 + .primaryTextTheme
290 + .headline
291 + .color,
292 + textStyle: TextStyle(
293 + fontSize: 14,
294 + fontWeight: FontWeight.w500,
295 + color: Colors.white),
296 + placeholderTextStyle: TextStyle(
297 + color: Theme.of(context)
298 + .primaryTextTheme
299 + .headline
300 + .decorationColor,
301 + fontWeight: FontWeight.w500,
302 + fontSize: 14),
303 + )),
304 + Padding(
305 + padding: EdgeInsets.only(top: 20),
306 + child: BaseTextFormField(
307 + controller: noteController,
308 + keyboardType: TextInputType.multiline,
309 + maxLines: null,
310 borderColor: Theme.of(context)
311 .primaryTextTheme
312 .headline
@@ -137,305 +315,131 @@ class SendCardState extends State<SendCard>
315 fontSize: 14,
316 fontWeight: FontWeight.w500,
317 color: Colors.white),
140 - hintStyle: TextStyle(
318 + hintText: S.of(context).note_optional,
319 + placeholderTextStyle: TextStyle(
320 fontSize: 14,
321 fontWeight: FontWeight.w500,
322 color: Theme.of(context)
323 .primaryTextTheme
324 .headline
325 .decorationColor),
147 - onPushPasteButton: (context) async {
148 - final parsedAddress =
149 - await output.applyOpenaliasOrUnstoppableDomains();
150 - showAddressAlert(context, parsedAddress);
151 - },
152 - validator: sendViewModel.addressValidator,
326 ),
154 - Observer(
155 - builder: (_) => Padding(
156 - padding: const EdgeInsets.only(top: 20),
157 - child: Stack(
158 - children: [
159 - BaseTextFormField(
160 - focusNode: cryptoAmountFocus,
161 - controller: cryptoAmountController,
162 - keyboardType:
163 - TextInputType.numberWithOptions(
164 - signed: false, decimal: true),
165 - prefixIcon: Padding(
166 - padding: EdgeInsets.only(top: 9),
167 - child: Text(
168 - sendViewModel.currency.title +
169 - ':',
170 - style: TextStyle(
171 - fontSize: 16,
172 - fontWeight: FontWeight.w600,
173 - color: Colors.white,
174 - )),
175 - ),
176 - suffixIcon: SizedBox(
177 - width: prefixIconWidth,
178 - ),
179 - hintText: '0.0000',
180 - borderColor: Theme.of(context)
181 - .primaryTextTheme
182 - .headline
183 - .color,
184 - textStyle: TextStyle(
185 - fontSize: 14,
186 - fontWeight: FontWeight.w500,
187 - color: Colors.white),
188 - placeholderTextStyle: TextStyle(
189 - color: Theme.of(context)
190 - .primaryTextTheme
191 - .headline
192 - .decorationColor,
193 - fontWeight: FontWeight.w500,
194 - fontSize: 14),
195 - validator: output.sendAll
196 - ? sendViewModel.allAmountValidator
197 - : sendViewModel
198 - .amountValidator),
199 - if (!sendViewModel.isBatchSending) Positioned(
200 - top: 2,
201 - right: 0,
202 - child: Container(
203 - width: prefixIconWidth,
204 - height: prefixIconHeight,
205 - child: InkWell(
206 - onTap: () async =>
207 - output.setSendAll(),
208 - child: Container(
209 - decoration: BoxDecoration(
210 - color: Theme.of(context)
211 - .primaryTextTheme
212 - .display1
213 - .color,
214 - borderRadius:
215 - BorderRadius.all(
216 - Radius.circular(6))),
217 - child: Center(
218 - child: Text(
219 - S.of(context).all,
220 - textAlign:
221 - TextAlign.center,
222 - style: TextStyle(
223 - fontSize: 12,
224 - fontWeight:
225 - FontWeight.bold,
226 - color:
227 - Theme.of(context)
228 - .primaryTextTheme
229 - .display1
230 - .decorationColor))),
231 - ))))])
232 - )),
233 - Observer(
234 - builder: (_) => Padding(
235 - padding: EdgeInsets.only(top: 10),
327 + ),
328 + Observer(
329 + builder: (_) => GestureDetector(
330 + onTap: () =>
331 + _setTransactionPriority(context),
332 + child: Container(
333 + padding: EdgeInsets.only(top: 24),
334 child: Row(
237 - mainAxisSize: MainAxisSize.max,
335 mainAxisAlignment:
336 MainAxisAlignment.spaceBetween,
337 + crossAxisAlignment: CrossAxisAlignment.start,
338 children: <Widget>[
241 - Expanded(
242 - child: Text(
243 - S.of(context).available_balance +
244 - ':',
245 - style: TextStyle(
246 - fontSize: 12,
247 - fontWeight: FontWeight.w600,
248 - color: Theme.of(context)
249 - .primaryTextTheme
250 - .headline
251 - .decorationColor),
252 - )),
339 Text(
254 - sendViewModel.balance,
255 - style: TextStyle(
256 - fontSize: 12,
257 - fontWeight: FontWeight.w600,
258 - color: Theme.of(context)
259 - .primaryTextTheme
260 - .headline
261 - .decorationColor),
340 + S
341 + .of(context)
342 + .send_estimated_fee,
343 + style: TextStyle(
344 + fontSize: 12,
345 + fontWeight:
346 + FontWeight.w500,
347 + //color: Theme.of(context).primaryTextTheme.display2.color,
348 + color: Colors.white)),
349 + Container(
350 + child: Row(
351 + crossAxisAlignment: CrossAxisAlignment.start,
352 + children: <Widget>[
353 + Column(
354 + mainAxisAlignment: MainAxisAlignment.start,
355 + crossAxisAlignment: CrossAxisAlignment.end,
356 + children: [
357 + Text(
358 + output
359 + .estimatedFee
360 + .toString() +
361 + ' ' +
362 + sendViewModel
363 + .currency.title,
364 + style: TextStyle(
365 + fontSize: 12,
366 + fontWeight:
367 + FontWeight.w600,
368 + //color: Theme.of(context).primaryTextTheme.display2.color,
369 + color:
370 + Colors.white)),
371 + Padding(
372 + padding:
373 + EdgeInsets.only(top: 5),
374 + child: Text(
375 + output
376 + .estimatedFeeFiatAmount
377 + + ' ' +
378 + sendViewModel
379 + .fiat.title,
380 + style: TextStyle(
381 + fontSize: 12,
382 + fontWeight:
383 + FontWeight.w600,
384 + color: Theme
385 + .of(context)
386 + .primaryTextTheme
387 + .headline
388 + .decorationColor))
389 + ),
390 + ],
391 + ),
392 + Padding(
393 + padding: EdgeInsets.only(
394 + top: 2,
395 + left: 5),
396 + child: Icon(
397 + Icons.arrow_forward_ios,
398 + size: 12,
399 + color: Colors.white,
400 + ),
401 + )
402 + ],
403 + ),
404 )
405 ],
406 ),
265 - )),
266 - Padding(
267 - padding: const EdgeInsets.only(top: 20),
268 - child: BaseTextFormField(
269 - focusNode: fiatAmountFocus,
270 - controller: fiatAmountController,
271 - keyboardType:
272 - TextInputType.numberWithOptions(
273 - signed: false, decimal: true),
274 - prefixIcon: Padding(
275 - padding: EdgeInsets.only(top: 9),
276 - child:
277 - Text(sendViewModel.fiat.title + ':',
278 - style: TextStyle(
279 - fontSize: 16,
280 - fontWeight: FontWeight.w600,
281 - color: Colors.white,
282 - )),
283 - ),
284 - hintText: '0.00',
285 - borderColor: Theme.of(context)
286 - .primaryTextTheme
287 - .headline
288 - .color,
289 - textStyle: TextStyle(
290 - fontSize: 14,
291 - fontWeight: FontWeight.w500,
292 - color: Colors.white),
293 - placeholderTextStyle: TextStyle(
294 - color: Theme.of(context)
295 - .primaryTextTheme
296 - .headline
297 - .decorationColor,
298 - fontWeight: FontWeight.w500,
299 - fontSize: 14),
300 - )),
301 - Padding(
302 - padding: EdgeInsets.only(top: 20),
303 - child: BaseTextFormField(
304 - controller: noteController,
305 - keyboardType: TextInputType.multiline,
306 - maxLines: null,
307 - borderColor: Theme.of(context)
308 - .primaryTextTheme
309 - .headline
310 - .color,
311 - textStyle: TextStyle(
312 - fontSize: 14,
313 - fontWeight: FontWeight.w500,
314 - color: Colors.white),
315 - hintText: S.of(context).note_optional,
316 - placeholderTextStyle: TextStyle(
317 - fontSize: 14,
318 - fontWeight: FontWeight.w500,
319 - color: Theme.of(context)
320 - .primaryTextTheme
321 - .headline
322 - .decorationColor),
323 - ),
324 - ),
325 - Observer(
326 - builder: (_) => GestureDetector(
327 - onTap: () =>
328 - _setTransactionPriority(context),
407 + ),
408 + )),
409 + if (sendViewModel.isElectrumWallet) Padding(
410 + padding: EdgeInsets.only(top: 6),
411 + child: GestureDetector(
412 + onTap: () => Navigator.of(context)
413 + .pushNamed(Routes.unspentCoinsList),
414 child: Container(
330 - padding: EdgeInsets.only(top: 24),
331 - child: Row(
332 - mainAxisAlignment:
333 - MainAxisAlignment.spaceBetween,
334 - crossAxisAlignment: CrossAxisAlignment.start,
335 - children: <Widget>[
336 - Text(
337 - S
338 - .of(context)
339 - .send_estimated_fee,
340 - style: TextStyle(
341 - fontSize: 12,
342 - fontWeight:
343 - FontWeight.w500,
344 - //color: Theme.of(context).primaryTextTheme.display2.color,
345 - color: Colors.white)),
346 - Container(
347 - child: Row(
348 - crossAxisAlignment: CrossAxisAlignment.start,
349 - children: <Widget>[
350 - Column(
351 - mainAxisAlignment: MainAxisAlignment.start,
352 - crossAxisAlignment: CrossAxisAlignment.end,
353 - children: [
354 - Text(
355 - output
356 - .estimatedFee
357 - .toString() +
358 - ' ' +
359 - sendViewModel
360 - .currency.title,
361 - style: TextStyle(
362 - fontSize: 12,
363 - fontWeight:
364 - FontWeight.w600,
365 - //color: Theme.of(context).primaryTextTheme.display2.color,
366 - color:
367 - Colors.white)),
368 - Padding(
369 - padding:
370 - EdgeInsets.only(top: 5),
371 - child: Text(
372 - output
373 - .estimatedFeeFiatAmount
374 - + ' ' +
375 - sendViewModel
376 - .fiat.title,
377 - style: TextStyle(
378 - fontSize: 12,
379 - fontWeight:
380 - FontWeight.w600,
381 - color: Theme
382 - .of(context)
383 - .primaryTextTheme
384 - .headline
385 - .decorationColor))
386 - ),
387 - ],
388 - ),
389 - Padding(
390 - padding: EdgeInsets.only(
391 - top: 2,
392 - left: 5),
393 - child: Icon(
394 - Icons.arrow_forward_ios,
395 - size: 12,
396 - color: Colors.white,
397 - ),
398 - )
399 - ],
400 - ),
401 - )
402 - ],
403 - ),
404 - ),
405 - )),
406 - if (sendViewModel.isElectrumWallet) Padding(
407 - padding: EdgeInsets.only(top: 6),
408 - child: GestureDetector(
409 - onTap: () => Navigator.of(context)
410 - .pushNamed(Routes.unspentCoinsList),
411 - child: Container(
412 - color: Colors.transparent,
413 - child: Row(
414 - mainAxisAlignment:
415 - MainAxisAlignment.spaceBetween,
416 - children: [
417 - Text(
418 - S.of(context).coin_control,
419 - style: TextStyle(
420 - fontSize: 12,
421 - fontWeight: FontWeight.w600,
422 - color: Colors.white)),
423 - Icon(
424 - Icons.arrow_forward_ios,
425 - size: 12,
426 - color: Colors.white,
427 - )
428 - ],
429 - )
430 - )
431 - )
432 - )
433 - ],
434 - )
435 - ),
415 + color: Colors.transparent,
416 + child: Row(
417 + mainAxisAlignment:
418 + MainAxisAlignment.spaceBetween,
419 + children: [
420 + Text(
421 + S.of(context).coin_control,
422 + style: TextStyle(
423 + fontSize: 12,
424 + fontWeight: FontWeight.w600,
425 + color: Colors.white)),
426 + Icon(
427 + Icons.arrow_forward_ios,
428 + size: 12,
429 + color: Colors.white,
430 + )
431 + ],
432 + )
433 + )
434 + )
435 + )
436 + ],
437 + )
438 ),
437 - )
438 - ));
439 + ),
440 + )
441 + ],
442 + );
443 }
444
445 void _setEffects(BuildContext context) {