| 1 | import 'package:flutter/material.dart'; |
| 2 | import 'package:cake_wallet/src/screens/base_page.dart'; |
| 3 | import 'package:cake_wallet/generated/i18n.dart'; |
| 4 | import 'package:flutter/scheduler.dart'; |
| 5 | |
| 6 | class SweepingWalletPage extends BasePage { |
| 7 | SweepingWalletPage(); |
| 8 | |
| 9 | static const aspectRatioImage = 1.25; |
| 10 | final welcomeImageLight = Image.asset('assets/images/welcome_light.png'); |
| 11 | final welcomeImageDark = Image.asset('assets/images/welcome.png'); |
| 12 | |
| 13 | @override |
| 14 | Widget build(BuildContext context) { |
| 15 | return Scaffold( |
| 16 | backgroundColor: Theme.of(context).colorScheme.surface, |
| 17 | resizeToAvoidBottomInset: false, |
| 18 | body: body(context)); |
| 19 | } |
| 20 | |
| 21 | @override |
| 22 | Widget body(BuildContext context) { |
| 23 | final welcomeImage = currentTheme.isDark ? welcomeImageDark : welcomeImageLight; |
| 24 | |
| 25 | return SweepingWalletWidget( |
| 26 | aspectRatioImage: aspectRatioImage, |
| 27 | welcomeImage: welcomeImage, |
| 28 | ); |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | class SweepingWalletWidget extends StatefulWidget { |
| 33 | const SweepingWalletWidget({ |
| 34 | required this.aspectRatioImage, |
| 35 | required this.welcomeImage, |
| 36 | }); |
| 37 | |
| 38 | final double aspectRatioImage; |
| 39 | final Image welcomeImage; |
| 40 | |
| 41 | @override |
| 42 | State<SweepingWalletWidget> createState() => _SweepingWalletWidgetState(); |
| 43 | } |
| 44 | |
| 45 | class _SweepingWalletWidgetState extends State<SweepingWalletWidget> { |
| 46 | @override |
| 47 | void initState() { |
| 48 | SchedulerBinding.instance.addPostFrameCallback((_) async {}); |
| 49 | super.initState(); |
| 50 | } |
| 51 | |
| 52 | @override |
| 53 | Widget build(BuildContext context) { |
| 54 | return WillPopScope( |
| 55 | onWillPop: () async => false, |
| 56 | child: Container( |
| 57 | padding: EdgeInsets.only(top: 64, bottom: 24, left: 24, right: 24), |
| 58 | child: Column( |
| 59 | mainAxisAlignment: MainAxisAlignment.spaceBetween, |
| 60 | children: <Widget>[ |
| 61 | Flexible( |
| 62 | flex: 2, |
| 63 | child: AspectRatio( |
| 64 | aspectRatio: widget.aspectRatioImage, |
| 65 | child: FittedBox(child: widget.welcomeImage, fit: BoxFit.fill))), |
| 66 | Flexible( |
| 67 | flex: 3, |
| 68 | child: Column( |
| 69 | mainAxisAlignment: MainAxisAlignment.spaceBetween, |
| 70 | children: <Widget>[ |
| 71 | Column( |
| 72 | children: <Widget>[ |
| 73 | Padding( |
| 74 | padding: EdgeInsets.only(top: 24), |
| 75 | child: Text( |
| 76 | S.of(context).please_wait, |
| 77 | style: Theme.of(context).textTheme.bodyMedium!.copyWith( |
| 78 | fontSize: 18, |
| 79 | fontWeight: FontWeight.w500, |
| 80 | color: Theme.of(context).colorScheme.onSurfaceVariant, |
| 81 | ), |
| 82 | textAlign: TextAlign.center, |
| 83 | ), |
| 84 | ), |
| 85 | Padding( |
| 86 | padding: EdgeInsets.only(top: 5), |
| 87 | child: Text( |
| 88 | S.of(context).sweeping_wallet, |
| 89 | style: Theme.of(context).textTheme.bodyMedium!.copyWith( |
| 90 | fontSize: 36, |
| 91 | fontWeight: FontWeight.bold, |
| 92 | color: Theme.of(context).colorScheme.primary, |
| 93 | ), |
| 94 | textAlign: TextAlign.center, |
| 95 | ), |
| 96 | ), |
| 97 | Padding( |
| 98 | padding: EdgeInsets.only(top: 5), |
| 99 | child: Text( |
| 100 | S.of(context).sweeping_wallet_alert, |
| 101 | style: Theme.of(context).textTheme.bodyMedium!.copyWith( |
| 102 | fontSize: 16, |
| 103 | fontWeight: FontWeight.w500, |
| 104 | color: Theme.of(context).colorScheme.onSurfaceVariant, |
| 105 | ), |
| 106 | textAlign: TextAlign.center, |
| 107 | ), |
| 108 | ), |
| 109 | ], |
| 110 | ), |
| 111 | ], |
| 112 | )) |
| 113 | ], |
| 114 | ))); |
| 115 | } |
| 116 | } |