From f6e099eb0af22fd8d519a7a8340ef40bfbcea4d6 Mon Sep 17 00:00:00 2001 From: OleksandrSobol Date: Thu, 8 Oct 2020 19:38:33 +0300 Subject: [PATCH] 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 --- lib/main.dart | 2 +- .../screens/disclaimer/disclaimer_page.dart | 49 ++++++++----------- .../settings/settings_view_model.dart | 2 +- 3 files changed, 23 insertions(+), 30 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 6c73a5bc8..c2db950ad 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -120,7 +120,7 @@ class App extends StatelessWidget { settingsStore.isDarkTheme ? Brightness.light : Brightness.dark; final authenticationStore = getIt.get(); final initialRoute = authenticationStore.state == AuthenticationState.denied - ? Routes.welcome + ? Routes.disclaimer : Routes.login; SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( diff --git a/lib/src/screens/disclaimer/disclaimer_page.dart b/lib/src/screens/disclaimer/disclaimer_page.dart index b80a7a1fe..5ef14f012 100644 --- a/lib/src/screens/disclaimer/disclaimer_page.dart +++ b/lib/src/screens/disclaimer/disclaimer_page.dart @@ -1,5 +1,6 @@ import 'dart:ui'; import 'package:cake_wallet/palette.dart'; +import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; @@ -19,26 +20,29 @@ class DisclaimerPage extends BasePage { String get title => 'Terms of Use'; @override - Widget body(BuildContext context) => DisclaimerPageBody(isReadOnly: true); + Widget leading(BuildContext context) { + return isReadOnly ? super.leading(context) : null; + } + + @override + Widget body(BuildContext context) => DisclaimerPageBody(isReadOnly: isReadOnly); } class DisclaimerPageBody extends StatefulWidget { - DisclaimerPageBody({this.isReadOnly = true}); + DisclaimerPageBody({this.isReadOnly}); final bool isReadOnly; @override - DisclaimerBodyState createState() => DisclaimerBodyState(false); + DisclaimerBodyState createState() => DisclaimerBodyState(); } class DisclaimerBodyState extends State { - DisclaimerBodyState(this._isAccepted); static const xmrtoUrl = 'https://xmr.to/terms-of-service'; static const changenowUrl = 'https://changenow.io/terms-of-use'; static const morphUrl = 'http://morphtoken.com/terms'; - final bool _isAccepted; bool _checked = false; String _fileText = ''; @@ -70,7 +74,7 @@ class DisclaimerBodyState extends State { void initState() { super.initState(); getFileLines(); - if (_isAccepted) WidgetsBinding.instance.addPostFrameCallback(_afterLayout); + if (!widget.isReadOnly) WidgetsBinding.instance.addPostFrameCallback(_afterLayout); } @override @@ -87,8 +91,7 @@ class DisclaimerBodyState extends State { padding: EdgeInsets.only(left: 24.0, right: 24.0), child: Column( children: [ - !_isAccepted - ? Row( + Row( children: [ Expanded( child: Text( @@ -102,13 +105,10 @@ class DisclaimerBodyState extends State { ), ) ], - ) - : Offstage(), - !_isAccepted - ? SizedBox( + ), + SizedBox( height: 20.0, - ) - : Offstage(), + ), Row( children: [ Expanded( @@ -254,8 +254,7 @@ class DisclaimerBodyState extends State { ], )), if (!widget.isReadOnly) ...[ - !_isAccepted - ? Row( + Row( children: [ Expanded( child: Container( @@ -303,25 +302,19 @@ class DisclaimerBodyState extends State { )), ), ], - ) - : Offstage(), - !_isAccepted - ? Container( + ), + Container( padding: EdgeInsets.only(left: 24.0, right: 24.0, bottom: 24.0), child: PrimaryButton( - onPressed: _checked ? () {} : null, + onPressed: _checked ? () => + Navigator.of(context).popAndPushNamed(Routes.welcome) + : null, text: 'Accept', color: Colors.green, textColor: Colors.white, ), - ) - : Offstage(), - _isAccepted - ? SizedBox( - height: 24.0, - ) - : Offstage() + ), ], ], ), diff --git a/lib/view_model/settings/settings_view_model.dart b/lib/view_model/settings/settings_view_model.dart index e0ce07738..4050e807c 100644 --- a/lib/view_model/settings/settings_view_model.dart +++ b/lib/view_model/settings/settings_view_model.dart @@ -144,7 +144,7 @@ abstract class SettingsViewModelBase with Store { RegularListItem( title: S.current.settings_terms_and_conditions, handler: (BuildContext context) => - Navigator.of(context).pushNamed(Routes.disclaimer), + Navigator.of(context).pushNamed(Routes.readDisclaimer), ), RegularListItem( title: S.current.faq,