dev
dart 202 lines 7.93 KB
Raw
1 import 'dart:ui';
2 import 'package:cake_wallet/routes.dart';
3 import 'package:flutter/material.dart';
4 import 'package:flutter/services.dart';
5 import 'package:cake_wallet/src/screens/base_page.dart';
6 import 'package:cake_wallet/src/widgets/primary_button.dart';
7 import 'package:cake_wallet/wallet_type_utils.dart';
8 import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
9
10 class DisclaimerPage extends BasePage {
11 DisclaimerPage({this.isReadOnly = false});
12
13 final bool isReadOnly;
14
15 @override
16 String get title => 'Terms of Use';
17
18 @override
19 Widget? leading(BuildContext context) => isReadOnly ? super.leading(context) : null;
20
21 @override
22 Widget body(BuildContext context) => DisclaimerPageBody(isReadOnly: isReadOnly);
23 }
24
25 class DisclaimerPageBody extends StatefulWidget {
26 DisclaimerPageBody({required this.isReadOnly});
27
28 final bool isReadOnly;
29
30 @override
31 DisclaimerBodyState createState() => DisclaimerBodyState();
32 }
33
34 class DisclaimerBodyState extends State<DisclaimerPageBody> {
35 bool _checked = false;
36 String _fileText = '';
37
38 void getFileLines() {
39 final fileName =
40 isMoneroOnly ? 'assets/text/Monerocom_Terms_of_Use.txt' : 'assets/text/Terms_of_Use.txt';
41 rootBundle.loadString(fileName).then((text) => setState(() => _fileText = text));
42 }
43
44 @override
45 void initState() {
46 super.initState();
47 getFileLines();
48 }
49
50 @override
51 Widget build(BuildContext context) {
52 return PopScope(
53 canPop: widget.isReadOnly,
54 child: Container(
55 color: Theme.of(context).colorScheme.surface,
56 child: Column(
57 children: <Widget>[
58 SizedBox(height: 10.0),
59 Expanded(
60 child: Stack(
61 children: <Widget>[
62 SingleChildScrollView(
63 controller: ModalScrollController.of(context),
64 physics: ClampingScrollPhysics(),
65 padding: EdgeInsets.only(left: 24.0, right: 24.0),
66 child: Column(
67 children: <Widget>[
68 Row(
69 children: <Widget>[
70 Expanded(
71 child: Text(
72 'Terms and conditions',
73 textAlign: TextAlign.center,
74 style: Theme.of(context).textTheme.titleLarge?.copyWith(
75 fontSize: 20.0,
76 fontWeight: FontWeight.bold,
77 color: Theme.of(context).colorScheme.onSurface),
78 ),
79 )
80 ],
81 ),
82 SizedBox(
83 height: 20.0,
84 ),
85 Row(
86 children: <Widget>[
87 Expanded(
88 child: Text(
89 'Legal Disclaimer\nAnd\nTerms of Use',
90 textAlign: TextAlign.center,
91 style: Theme.of(context).textTheme.bodySmall?.copyWith(
92 fontWeight: FontWeight.bold,
93 ),
94 ),
95 )
96 ],
97 ),
98 SizedBox(
99 height: 16.0,
100 ),
101 Row(
102 children: <Widget>[
103 Expanded(
104 child: Text(
105 _fileText,
106 style: Theme.of(context).textTheme.bodySmall,
107 ))
108 ],
109 ),
110 SizedBox(
111 height: 16.0,
112 ),
113 ],
114 ),
115 ),
116 Container(
117 alignment: Alignment.bottomCenter,
118 child: Container(
119 height: 12.0,
120 child: ClipRect(
121 child: BackdropFilter(
122 filter: ImageFilter.blur(sigmaX: 0.7, sigmaY: 0.7),
123 child: Container(
124 decoration: BoxDecoration(
125 gradient: LinearGradient(
126 colors: [
127 Theme.of(context).colorScheme.surface.withAlpha(0),
128 Theme.of(context).colorScheme.surface,
129 ],
130 begin: FractionalOffset.topCenter,
131 end: FractionalOffset.bottomCenter,
132 ),
133 ),
134 ),
135 ),
136 ),
137 ),
138 )
139 ],
140 )),
141 if (!widget.isReadOnly) ...[
142 Row(
143 children: <Widget>[
144 Expanded(
145 child: Container(
146 padding:
147 EdgeInsets.only(left: 24.0, top: 10.0, right: 24.0, bottom: 10.0),
148 child: InkWell(
149 key: ValueKey('disclaimer_check_key'),
150 onTap: () => setState(() => _checked = !_checked),
151 child: Row(
152 mainAxisAlignment: MainAxisAlignment.start,
153 children: <Widget>[
154 Container(
155 height: 24.0,
156 width: 24.0,
157 margin: EdgeInsets.only(
158 right: 10.0,
159 ),
160 decoration: BoxDecoration(
161 border: Border.all(
162 color: Theme.of(context).colorScheme.outline, width: 1.0),
163 borderRadius: BorderRadius.all(Radius.circular(8.0)),
164 color: Theme.of(context).colorScheme.surface),
165 child: _checked
166 ? Icon(
167 key: ValueKey('disclaimer_check_icon_key'),
168 Icons.check,
169 color: Theme.of(context).colorScheme.primary,
170 size: 20.0,
171 )
172 : null,
173 ),
174 Text(
175 'I agree to Terms of Use',
176 style: Theme.of(context).textTheme.bodyMedium?.copyWith(
177 fontWeight: FontWeight.bold,
178 ),
179 )
180 ],
181 ),
182 )),
183 ),
184 ],
185 ),
186 Container(
187 padding: EdgeInsets.only(left: 24.0, right: 24.0, bottom: 24.0),
188 child: PrimaryButton(
189 key: ValueKey('disclaimer_accept_button_key'),
190 onPressed: _checked
191 ? () => Navigator.of(context).popAndPushNamed(Routes.welcome)
192 : null,
193 text: 'Accept',
194 color: Theme.of(context).colorScheme.primary,
195 textColor: Theme.of(context).colorScheme.onPrimary),
196 ),
197 ],
198 ],
199 ),
200 ));
201 }
202 }