dev
dart 167 lines 5.66 KB
Raw
1 import 'package:auto_size_text/auto_size_text.dart';
2
3 import 'package:cake_wallet/utils/image_utill.dart';
4
5 import 'package:cake_wallet/routes.dart';
6 import 'package:flutter/gestures.dart';
7
8 import 'package:flutter/material.dart';
9
10 import 'base_bottom_sheet_widget.dart';
11
12 class LoadingBottomSheet extends BaseBottomSheet {
13 LoadingBottomSheet({required String titleText, String? titleIconPath})
14 : super(
15 titleText: titleText,
16 titleIconPath: titleIconPath,
17 footerType: FooterType.none,
18 maxHeight: 900);
19
20 @override
21 Widget contentWidget(BuildContext context) {
22 return SizedBox(
23 height: 300,
24 child: Center(child: CircularProgressIndicator()),
25 );
26 }
27 }
28
29 class InfoBottomSheet extends BaseBottomSheet {
30 InfoBottomSheet({
31 required String titleText,
32 String? titleIconPath,
33 required this.footerType,
34 this.contentImage,
35 this.contentImageColor,
36 this.contentImageSize,
37 this.height = 200,
38 this.content,
39 this.bottomActionPanel,
40 this.singleActionButtonText,
41 this.onSingleActionButtonPressed,
42 this.singleActionButtonKey,
43 this.doubleActionLeftButtonText,
44 this.doubleActionRightButtonText,
45 this.onLeftActionButtonPressed,
46 this.onRightActionButtonPressed,
47 this.leftActionButtonKey,
48 this.rightActionButtonKey,
49 this.showDisclaimerText = false,
50 Key? key,
51 }) : super(
52 titleText: titleText,
53 titleIconPath: titleIconPath,
54 maxHeight: 900,
55 footerType: footerType,
56 singleActionButtonText: singleActionButtonText,
57 onSingleActionButtonPressed: onSingleActionButtonPressed,
58 singleActionButtonKey: singleActionButtonKey,
59 doubleActionLeftButtonText: doubleActionLeftButtonText,
60 doubleActionRightButtonText: doubleActionRightButtonText,
61 onLeftActionButtonPressed: onLeftActionButtonPressed,
62 onRightActionButtonPressed: onRightActionButtonPressed,
63 leftActionButtonKey: leftActionButtonKey,
64 rightActionButtonKey: rightActionButtonKey,
65 key: key);
66
67 final FooterType footerType;
68 final String? contentImage;
69 final Color? contentImageColor;
70 final String? content;
71 final Widget? bottomActionPanel;
72 final String? singleActionButtonText;
73 final VoidCallback? onSingleActionButtonPressed;
74 final Key? singleActionButtonKey;
75 final String? doubleActionLeftButtonText;
76 final String? doubleActionRightButtonText;
77 final VoidCallback? onLeftActionButtonPressed;
78 final VoidCallback? onRightActionButtonPressed;
79 final Key? rightActionButtonKey;
80 final Key? leftActionButtonKey;
81 final double height;
82 final double? contentImageSize;
83 final bool showDisclaimerText;
84
85 @override
86 Widget contentWidget(BuildContext context) {
87 return SizedBox(
88 height: height,
89 child: Column(
90 children: [
91 if (contentImage != null)
92 Expanded(
93 flex: 4,
94 child: ImageUtil.getImageFromPath(
95 imagePath: contentImage!,
96 svgImageColor: contentImageColor,
97 fit: BoxFit.contain,
98 borderRadius: 10,
99 ),
100 )
101 else
102 Container(),
103 SizedBox(
104 height: 24,
105 ),
106 if (content != null)
107 Expanded(
108 flex: 2,
109 child: Row(
110 crossAxisAlignment: CrossAxisAlignment.start,
111 children: [
112 const Spacer(flex: 2),
113 Expanded(
114 flex: 6,
115 child: AutoSizeText(
116 content!,
117 textAlign: TextAlign.center,
118 style: Theme.of(context).textTheme.bodyMedium!.copyWith(
119 fontSize: 16,
120 fontWeight: FontWeight.w500,
121 color: Theme.of(context).colorScheme.onSurfaceVariant,
122 decoration: TextDecoration.none,
123 ),
124 ),
125 ),
126 const Spacer(flex: 2),
127 ],
128 ),
129 ),
130 bottomActionPanel ?? const SizedBox(),
131 if (showDisclaimerText)
132 Padding(
133 padding: const EdgeInsets.only(top: 20, bottom: 10),
134 child: RichText(
135 textAlign: TextAlign.center,
136 text: TextSpan(
137 style: Theme.of(context).textTheme.bodyMedium?.copyWith(
138 color: Theme.of(context).colorScheme.onSurfaceVariant,
139 ),
140 children: [
141 TextSpan(
142 text: 'By continuing you agree to this ',
143 style: Theme.of(context).textTheme.bodyMedium?.copyWith(
144 color: Theme.of(context).colorScheme.onSurfaceVariant,
145 fontWeight: FontWeight.w500,
146 ),
147 ),
148 TextSpan(
149 text: 'disclaimer',
150 style: Theme.of(context).textTheme.bodyMedium?.copyWith(
151 color: Theme.of(context).colorScheme.onSurfaceVariant,
152 decoration: TextDecoration.underline,
153 fontWeight: FontWeight.w700,
154 ),
155 recognizer: TapGestureRecognizer()
156 ..onTap =
157 () => Navigator.pushNamed(context, Routes.readThirdPartyDisclaimer),
158 ),
159 ],
160 ),
161 ),
162 ),
163 ],
164 ),
165 );
166 }
167 }