dev
dart 86 lines 2.69 KB
Raw
1 import 'package:cake_wallet/src/screens/base_page.dart';
2 import 'package:cake_wallet/src/widgets/cake_image_widget.dart';
3 import 'package:cake_wallet/src/widgets/gradient_background.dart';
4 import 'package:cake_wallet/src/widgets/primary_button.dart';
5 import 'package:cake_wallet/utils/responsive_layout_util.dart';
6 import 'package:flutter/material.dart';
7
8 abstract class InfoPage extends BasePage {
9 InfoPage({
10 this.imageLightPath = 'assets/images/pre_seed_light.png',
11 this.imageDarkPath = 'assets/images/pre_seed_dark.png',
12 });
13
14 final String imageLightPath;
15 final String imageDarkPath;
16
17 bool get onWillPop => true;
18 String get pageTitle;
19 String get pageDescription;
20 String get buttonText;
21 Key? get buttonKey;
22 void Function(BuildContext) get onPressed;
23
24 @override
25 bool get gradientBackground => true;
26
27 @override
28 Widget Function(BuildContext, Widget) get rootWrapper =>
29 (BuildContext context, Widget scaffold) => GradientBackground(scaffold: scaffold);
30
31 @override
32 Widget? leading(BuildContext context) => null;
33
34 @override
35 String get title => pageTitle;
36
37 @override
38 Widget body(BuildContext context) {
39 final image = currentTheme.isDark ? imageDarkPath : imageLightPath;
40
41 return PopScope(
42 canPop: onWillPop,
43 child: Container(
44 alignment: Alignment.center,
45 padding: EdgeInsets.all(24),
46 child: ConstrainedBox(
47 constraints:
48 BoxConstraints(maxWidth: ResponsiveLayoutUtilBase.kDesktopMaxWidthConstraint),
49 child: Column(
50 mainAxisAlignment: MainAxisAlignment.spaceBetween,
51 children: <Widget>[
52 Expanded(
53 child: ConstrainedBox(
54 constraints: BoxConstraints(
55 maxHeight: MediaQuery.of(context).size.height * 0.3,
56 ),
57 child: AspectRatio(
58 aspectRatio: 0.9,
59 child: CakeImageWidget(imageUrl: image),
60 ),
61 ),
62 ),
63 Expanded(
64 child: Padding(
65 padding: EdgeInsets.all(10),
66 child: Text(
67 pageDescription,
68 textAlign: TextAlign.center,
69 style: Theme.of(context).textTheme.bodyMedium?.copyWith(height: 1.6),
70 ),
71 ),
72 ),
73 PrimaryButton(
74 key: buttonKey,
75 onPressed: () => onPressed(context),
76 text: buttonText,
77 color: Theme.of(context).colorScheme.primary,
78 textColor: Theme.of(context).colorScheme.onPrimary,
79 ),
80 ],
81 ),
82 ),
83 ),
84 );
85 }
86 }