rework templates on exchange screen
Godwin Asuquo committed
Jan 31, 2022 at 14:17 UTC
63016825e23c4b68134ef98f358b8524364a13ad
1 file changed
+110
-125
lib/src/screens/exchange/exchange_page.dart
+110
-125
@@ -317,131 +317,11 @@ class ExchangePage extends BasePage {
317
],
318
),
319
),
320
- Padding(
321
- padding: EdgeInsets.only(top: 30, left: 24, bottom: 24),
322
- child: Row(
323
- mainAxisAlignment: MainAxisAlignment.start,
324
- children: <Widget>[
325
- Text(
326
- S.of(context).send_templates,
327
- style: TextStyle(
328
- fontSize: 18,
329
- fontWeight: FontWeight.w600,
330
- color: Theme.of(context)
331
- .primaryTextTheme
332
- .display4
333
- .color),
334
- )
335
- ],
336
- ),
337
- ),
338
- Container(
339
- height: 40,
340
- width: double.infinity,
341
- padding: EdgeInsets.only(left: 24),
342
- child: SingleChildScrollView(
343
- scrollDirection: Axis.horizontal,
344
- child: Row(
345
- children: <Widget>[
346
- GestureDetector(
347
- onTap: () => Navigator.of(context)
348
- .pushNamed(Routes.exchangeTemplate),
349
- child: Container(
350
- padding:
351
- EdgeInsets.only(left: 1, right: 10),
352
- child: DottedBorder(
353
- borderType: BorderType.RRect,
354
- dashPattern: [6, 4],
355
- color: Theme.of(context)
356
- .primaryTextTheme
357
- .display2
358
- .decorationColor,
359
- strokeWidth: 2,
360
- radius: Radius.circular(20),
361
- child: Container(
362
- height: 34,
363
- width: 75,
364
- padding: EdgeInsets.only(
365
- left: 10, right: 10),
366
- alignment: Alignment.center,
367
- decoration: BoxDecoration(
368
- borderRadius: BorderRadius.all(
369
- Radius.circular(20)),
370
- color: Colors.transparent,
371
- ),
372
- child: Text(
373
- S.of(context).send_new,
374
- style: TextStyle(
375
- fontSize: 14,
376
- fontWeight: FontWeight.w600,
377
- color: Theme.of(context)
378
- .primaryTextTheme
379
- .display3
380
- .color),
381
- ),
382
- )),
383
- ),
384
- ),
385
- Observer(builder: (_) {
386
- final templates = exchangeViewModel.templates;
387
- final itemCount = templates.length;
388
-
389
- return ListView.builder(
390
- scrollDirection: Axis.horizontal,
391
- shrinkWrap: true,
392
- physics: NeverScrollableScrollPhysics(),
393
- itemCount: itemCount,
394
- itemBuilder: (context, index) {
395
- final template = templates[index];
396
-
397
- return TemplateTile(
398
- key: UniqueKey(),
399
- amount: template.amount,
400
- from: template.depositCurrency,
401
- to: template.receiveCurrency,
402
- onTap: () {
403
- applyTemplate(context,
404
- exchangeViewModel, template);
405
- },
406
- onRemove: () {
407
- showPopUp<void>(
408
- context: context,
409
- builder: (dialogContext) {
410
- return AlertWithTwoActions(
411
- alertTitle: S
412
- .of(context)
413
- .template,
414
- alertContent: S
415
- .of(context)
416
- .confirm_delete_template,
417
- rightButtonText:
418
- S.of(context).delete,
419
- leftButtonText:
420
- S.of(context).cancel,
421
- actionRightButton: () {
422
- Navigator.of(
423
- dialogContext)
424
- .pop();
425
- exchangeViewModel
426
- .removeTemplate(
427
- template:
428
- template);
429
- exchangeViewModel
430
- .updateTemplate();
431
- },
432
- actionLeftButton: () =>
433
- Navigator.of(
434
- dialogContext)
435
- .pop());
436
- });
437
- },
438
- );
439
- });
440
- }),
441
- ],
442
- )))
443
- ],
444
- )),
320
+ SizedBox(height: 30),
321
+ _buildTemplateSection(context)
322
+ ],
323
+ ),
324
+ ),
325
bottomSectionPadding:
326
EdgeInsets.only(left: 24, right: 24, bottom: 24),
327
bottomSection: Column(children: <Widget>[
@@ -501,6 +381,111 @@ class ExchangePage extends BasePage {
381
));
382
}
383
384
+ Widget _buildTemplateSection(BuildContext context) {
385
+ return Container(
386
+ height: 40,
387
+ width: double.infinity,
388
+ padding: EdgeInsets.only(left: 24),
389
+ child: SingleChildScrollView(
390
+ scrollDirection: Axis.horizontal,
391
+ child: Observer(
392
+ builder: (_) {
393
+ final templates = exchangeViewModel.templates;
394
+ final itemCount = templates.length;
395
+ return Row(
396
+ children: <Widget>[
397
+ GestureDetector(
398
+ onTap: () =>
399
+ Navigator.of(context).pushNamed(Routes.exchangeTemplate),
400
+ child: Container(
401
+ padding: EdgeInsets.only(left: 1, right: 10),
402
+ child: DottedBorder(
403
+ borderType: BorderType.RRect,
404
+ dashPattern: [6, 4],
405
+ color: Theme.of(context)
406
+ .primaryTextTheme
407
+ .display2
408
+ .decorationColor,
409
+ strokeWidth: 2,
410
+ radius: Radius.circular(20),
411
+ child: Container(
412
+ height: 34,
413
+ padding: EdgeInsets.only(left: 10, right: 10),
414
+ alignment: Alignment.center,
415
+ decoration: BoxDecoration(
416
+ borderRadius: BorderRadius.all(Radius.circular(20)),
417
+ color: Colors.transparent,
418
+ ),
419
+ child: templates.length >= 1
420
+ ? Icon(
421
+ Icons.add,
422
+ color: Theme.of(context)
423
+ .primaryTextTheme
424
+ .display3
425
+ .color,
426
+ )
427
+ : Text(
428
+ S.of(context).new_template,
429
+ style: TextStyle(
430
+ fontSize: 14,
431
+ fontWeight: FontWeight.w600,
432
+ color: Theme.of(context)
433
+ .primaryTextTheme
434
+ .display3
435
+ .color,
436
+ ),
437
+ ),
438
+ ),
439
+ ),
440
+ ),
441
+ ),
442
+ ListView.builder(
443
+ scrollDirection: Axis.horizontal,
444
+ shrinkWrap: true,
445
+ physics: NeverScrollableScrollPhysics(),
446
+ itemCount: itemCount,
447
+ itemBuilder: (context, index) {
448
+ final template = templates[index];
449
+
450
+ return TemplateTile(
451
+ key: UniqueKey(),
452
+ amount: template.amount,
453
+ from: template.depositCurrency,
454
+ to: template.receiveCurrency,
455
+ onTap: () {
456
+ applyTemplate(context, exchangeViewModel, template);
457
+ },
458
+ onRemove: () {
459
+ showPopUp<void>(
460
+ context: context,
461
+ builder: (dialogContext) {
462
+ return AlertWithTwoActions(
463
+ alertTitle: S.of(context).template,
464
+ alertContent:
465
+ S.of(context).confirm_delete_template,
466
+ rightButtonText: S.of(context).delete,
467
+ leftButtonText: S.of(context).cancel,
468
+ actionRightButton: () {
469
+ Navigator.of(dialogContext).pop();
470
+ exchangeViewModel.removeTemplate(
471
+ template: template);
472
+ exchangeViewModel.updateTemplate();
473
+ },
474
+ actionLeftButton: () =>
475
+ Navigator.of(dialogContext).pop());
476
+ });
477
+ },
478
+ );
479
+ },
480
+ ),
481
+ ],
482
+ );
483
+ },
484
+ ),
485
+ ),
486
+ );
487
+ }
488
+
489
void applyTemplate(BuildContext context,
490
ExchangeViewModel exchangeViewModel, ExchangeTemplate template) async {
491
exchangeViewModel.changeDepositCurrency(