Merge pull request #120 from cake-tech/CAKE-114-add-terms-and-conditions

Cake 114 add terms and conditions
This commit is contained in:
M 2020-10-09 21:35:19 +03:00
commit b57febe164
3 changed files with 21 additions and 45 deletions

View file

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

View file

@ -1,5 +1,6 @@
import 'dart:ui'; import 'dart:ui';
import 'package:cake_wallet/palette.dart'; import 'package:cake_wallet/palette.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
@ -19,26 +20,28 @@ class DisclaimerPage extends BasePage {
String get title => 'Terms of Use'; String get title => 'Terms of Use';
@override @override
Widget body(BuildContext context) => DisclaimerPageBody(isReadOnly: true); Widget leading(BuildContext context) =>
isReadOnly ? super.leading(context) : null;
@override
Widget body(BuildContext context) => DisclaimerPageBody(isReadOnly: isReadOnly);
} }
class DisclaimerPageBody extends StatefulWidget { class DisclaimerPageBody extends StatefulWidget {
DisclaimerPageBody({this.isReadOnly = true}); DisclaimerPageBody({this.isReadOnly});
final bool isReadOnly; final bool isReadOnly;
@override @override
DisclaimerBodyState createState() => DisclaimerBodyState(false); DisclaimerBodyState createState() => DisclaimerBodyState();
} }
class DisclaimerBodyState extends State<DisclaimerPageBody> { class DisclaimerBodyState extends State<DisclaimerPageBody> {
DisclaimerBodyState(this._isAccepted);
static const xmrtoUrl = 'https://xmr.to/terms-of-service'; static const xmrtoUrl = 'https://xmr.to/terms-of-service';
static const changenowUrl = 'https://changenow.io/terms-of-use'; static const changenowUrl = 'https://changenow.io/terms-of-use';
static const morphUrl = 'http://morphtoken.com/terms'; static const morphUrl = 'http://morphtoken.com/terms';
final bool _isAccepted;
bool _checked = false; bool _checked = false;
String _fileText = ''; String _fileText = '';
@ -51,26 +54,10 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
setState(() {}); setState(() {});
} }
Future<void> _showAlertDialog(BuildContext context) async {
await showPopUp<void>(
context: context,
builder: (BuildContext context) {
return AlertWithOneAction(
alertTitle: 'Terms and conditions',
alertContent: 'By using this app, you agree to the Terms of Agreement set forth to below',
buttonText: S.of(context).ok,
buttonAction: () => Navigator.of(context).pop()
);
});
}
void _afterLayout(Duration _) => _showAlertDialog(context);
@override @override
void initState() { void initState() {
super.initState(); super.initState();
getFileLines(); getFileLines();
if (_isAccepted) WidgetsBinding.instance.addPostFrameCallback(_afterLayout);
} }
@override @override
@ -87,8 +74,7 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
padding: EdgeInsets.only(left: 24.0, right: 24.0), padding: EdgeInsets.only(left: 24.0, right: 24.0),
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
!_isAccepted Row(
? Row(
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: Text( child: Text(
@ -102,13 +88,10 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
), ),
) )
], ],
) ),
: Offstage(), SizedBox(
!_isAccepted
? SizedBox(
height: 20.0, height: 20.0,
) ),
: Offstage(),
Row( Row(
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
@ -254,8 +237,7 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
], ],
)), )),
if (!widget.isReadOnly) ...[ if (!widget.isReadOnly) ...[
!_isAccepted Row(
? Row(
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: Container( child: Container(
@ -303,25 +285,19 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
)), )),
), ),
], ],
) ),
: Offstage(), Container(
!_isAccepted
? Container(
padding: padding:
EdgeInsets.only(left: 24.0, right: 24.0, bottom: 24.0), EdgeInsets.only(left: 24.0, right: 24.0, bottom: 24.0),
child: PrimaryButton( child: PrimaryButton(
onPressed: _checked ? () {} : null, onPressed: _checked ? () =>
Navigator.of(context).popAndPushNamed(Routes.welcome)
: null,
text: 'Accept', text: 'Accept',
color: Colors.green, color: Colors.green,
textColor: Colors.white, textColor: Colors.white,
), ),
) ),
: Offstage(),
_isAccepted
? SizedBox(
height: 24.0,
)
: Offstage()
], ],
], ],
), ),

View file

@ -144,7 +144,7 @@ abstract class SettingsViewModelBase with Store {
RegularListItem( RegularListItem(
title: S.current.settings_terms_and_conditions, title: S.current.settings_terms_and_conditions,
handler: (BuildContext context) => handler: (BuildContext context) =>
Navigator.of(context).pushNamed(Routes.disclaimer), Navigator.of(context).pushNamed(Routes.readDisclaimer),
), ),
RegularListItem( RegularListItem(
title: S.current.faq, title: S.current.faq,