CAKE-114 | applied disclaimer page when user install wallet first time; applied route to disclaimer page as initial route (main.dart); change leading widget in the disclaimer page; applied call of welcome page when user press accept button in the disclaimer page

OleksandrSobol committed Oct 8, 2020 at 19:38 UTC f6e099eb0af22fd8d519a7a8340ef40bfbcea4d6
3 files changed +23 -30
lib/main.dart
+1 -1
@@ -120,7 +120,7 @@ class App extends StatelessWidget {
120 settingsStore.isDarkTheme ? Brightness.light : Brightness.dark;
121 final authenticationStore = getIt.get<AuthenticationStore>();
122 final initialRoute = authenticationStore.state == AuthenticationState.denied
123 - ? Routes.welcome
123 + ? Routes.disclaimer
124 : Routes.login;
125
126 SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
lib/src/screens/disclaimer/disclaimer_page.dart
+21 -28
@@ -1,5 +1,6 @@
1 import 'dart:ui';
2 import 'package:cake_wallet/palette.dart';
3 +import 'package:cake_wallet/routes.dart';
4 import 'package:cake_wallet/utils/show_pop_up.dart';
5 import 'package:flutter/material.dart';
6 import 'package:flutter/cupertino.dart';
@@ -19,26 +20,29 @@ class DisclaimerPage extends BasePage {
20 String get title => 'Terms of Use';
21
22 @override
22 - Widget body(BuildContext context) => DisclaimerPageBody(isReadOnly: true);
23 + Widget leading(BuildContext context) {
24 + return isReadOnly ? super.leading(context) : null;
25 + }
26 +
27 + @override
28 + Widget body(BuildContext context) => DisclaimerPageBody(isReadOnly: isReadOnly);
29 }
30
31 class DisclaimerPageBody extends StatefulWidget {
26 - DisclaimerPageBody({this.isReadOnly = true});
32 + DisclaimerPageBody({this.isReadOnly});
33
34 final bool isReadOnly;
35
36 @override
31 - DisclaimerBodyState createState() => DisclaimerBodyState(false);
37 + DisclaimerBodyState createState() => DisclaimerBodyState();
38 }
39
40 class DisclaimerBodyState extends State<DisclaimerPageBody> {
35 - DisclaimerBodyState(this._isAccepted);
41
42 static const xmrtoUrl = 'https://xmr.to/terms-of-service';
43 static const changenowUrl = 'https://changenow.io/terms-of-use';
44 static const morphUrl = 'http://morphtoken.com/terms';
45
41 - final bool _isAccepted;
46 bool _checked = false;
47 String _fileText = '';
48
@@ -70,7 +74,7 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
74 void initState() {
75 super.initState();
76 getFileLines();
73 - if (_isAccepted) WidgetsBinding.instance.addPostFrameCallback(_afterLayout);
77 + if (!widget.isReadOnly) WidgetsBinding.instance.addPostFrameCallback(_afterLayout);
78 }
79
80 @override
@@ -87,8 +91,7 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
91 padding: EdgeInsets.only(left: 24.0, right: 24.0),
92 child: Column(
93 children: <Widget>[
90 - !_isAccepted
91 - ? Row(
94 + Row(
95 children: <Widget>[
96 Expanded(
97 child: Text(
@@ -102,13 +105,10 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
105 ),
106 )
107 ],
105 - )
106 - : Offstage(),
107 - !_isAccepted
108 - ? SizedBox(
108 + ),
109 + SizedBox(
110 height: 20.0,
110 - )
111 - : Offstage(),
111 + ),
112 Row(
113 children: <Widget>[
114 Expanded(
@@ -254,8 +254,7 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
254 ],
255 )),
256 if (!widget.isReadOnly) ...[
257 - !_isAccepted
258 - ? Row(
257 + Row(
258 children: <Widget>[
259 Expanded(
260 child: Container(
@@ -303,25 +302,19 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
302 )),
303 ),
304 ],
306 - )
307 - : Offstage(),
308 - !_isAccepted
309 - ? Container(
305 + ),
306 + Container(
307 padding:
308 EdgeInsets.only(left: 24.0, right: 24.0, bottom: 24.0),
309 child: PrimaryButton(
313 - onPressed: _checked ? () {} : null,
310 + onPressed: _checked ? () =>
311 + Navigator.of(context).popAndPushNamed(Routes.welcome)
312 + : null,
313 text: 'Accept',
314 color: Colors.green,
315 textColor: Colors.white,
316 ),
318 - )
319 - : Offstage(),
320 - _isAccepted
321 - ? SizedBox(
322 - height: 24.0,
323 - )
324 - : Offstage()
317 + ),
318 ],
319 ],
320 ),
lib/view_model/settings/settings_view_model.dart
+1 -1
@@ -144,7 +144,7 @@ abstract class SettingsViewModelBase with Store {
144 RegularListItem(
145 title: S.current.settings_terms_and_conditions,
146 handler: (BuildContext context) =>
147 - Navigator.of(context).pushNamed(Routes.disclaimer),
147 + Navigator.of(context).pushNamed(Routes.readDisclaimer),
148 ),
149 RegularListItem(
150 title: S.current.faq,