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

This commit is contained in:
OleksandrSobol 2020-10-08 19:38:33 +03:00
parent a8695cc560
commit f6e099eb0a
3 changed files with 23 additions and 30 deletions

View file

@ -120,7 +120,7 @@ class App extends StatelessWidget {
settingsStore.isDarkTheme ? Brightness.light : Brightness.dark;
final authenticationStore = getIt.get<AuthenticationStore>();
final initialRoute = authenticationStore.state == AuthenticationState.denied
? Routes.welcome
? Routes.disclaimer
: Routes.login;
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(

View file

@ -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<DisclaimerPageBody> {
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<DisclaimerPageBody> {
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<DisclaimerPageBody> {
padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Column(
children: <Widget>[
!_isAccepted
? Row(
Row(
children: <Widget>[
Expanded(
child: Text(
@ -102,13 +105,10 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
),
)
],
)
: Offstage(),
!_isAccepted
? SizedBox(
),
SizedBox(
height: 20.0,
)
: Offstage(),
),
Row(
children: <Widget>[
Expanded(
@ -254,8 +254,7 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
],
)),
if (!widget.isReadOnly) ...[
!_isAccepted
? Row(
Row(
children: <Widget>[
Expanded(
child: Container(
@ -303,25 +302,19 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
)),
),
],
)
: 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()
),
],
],
),

View file

@ -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,