From d7f829042be9b120b3269614cd7aeaf1e368b27d Mon Sep 17 00:00:00 2001 From: Tanner Silva Date: Mon, 19 Oct 2020 12:21:53 -0500 Subject: [PATCH] added fucntion to WalletCreationVMBase to generate random wallet names. Wallet name generator follows this format --- ios/Flutter/.last_build_id | 2 +- .../screens/disclaimer/disclaimer_page.dart | 370 +++++++++--------- lib/view_model/wallet_creation_vm.dart | 20 + 3 files changed, 214 insertions(+), 178 deletions(-) diff --git a/ios/Flutter/.last_build_id b/ios/Flutter/.last_build_id index 0c913ed64..7f8f760fa 100644 --- a/ios/Flutter/.last_build_id +++ b/ios/Flutter/.last_build_id @@ -1 +1 @@ -4dc2ef1ba73deeed13cd85894dacb10b \ No newline at end of file +f88b397cc50258e916c86427fe071d09 \ No newline at end of file diff --git a/lib/src/screens/disclaimer/disclaimer_page.dart b/lib/src/screens/disclaimer/disclaimer_page.dart index 935de9612..d7d2cb599 100644 --- a/lib/src/screens/disclaimer/disclaimer_page.dart +++ b/lib/src/screens/disclaimer/disclaimer_page.dart @@ -24,7 +24,8 @@ class DisclaimerPage extends BasePage { isReadOnly ? super.leading(context) : null; @override - Widget body(BuildContext context) => DisclaimerPageBody(isReadOnly: isReadOnly); + Widget body(BuildContext context) => + DisclaimerPageBody(isReadOnly: isReadOnly); } class DisclaimerPageBody extends StatefulWidget { @@ -37,7 +38,6 @@ class DisclaimerPageBody extends StatefulWidget { } class DisclaimerBodyState extends State { - 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'; @@ -69,173 +69,183 @@ class DisclaimerBodyState extends State { SizedBox(height: 10.0), Expanded( child: Stack( - children: [ - SingleChildScrollView( - padding: EdgeInsets.only(left: 24.0, right: 24.0), - child: Column( + children: [ + SingleChildScrollView( + padding: EdgeInsets.only(left: 24.0, right: 24.0), + child: Column( + children: [ + Row( children: [ - Row( - children: [ - Expanded( - child: Text( - 'Terms and conditions', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 20.0, - fontWeight: FontWeight.bold, - color: Theme.of(context).primaryTextTheme.title.color - ), - ), - ) - ], - ), - SizedBox( - height: 20.0, - ), - Row( - children: [ - Expanded( - child: Text( - 'Legal Disclaimer\nAnd\nTerms of Use', - textAlign: TextAlign.center, - style: TextStyle( - fontSize: 12.0, - fontWeight: FontWeight.bold, - color: Theme.of(context).primaryTextTheme.title.color - ), - ), - ) - ], - ), - SizedBox( - height: 16.0, - ), - Row( - children: [ - Expanded( - child: Text( - _fileText, - style: TextStyle( - fontSize: 12.0, - fontWeight: FontWeight.normal, - color: Theme.of(context).primaryTextTheme.title.color - ), - )) - ], - ), - SizedBox( - height: 16.0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - child: Text( - 'Other Terms and Conditions', - textAlign: TextAlign.left, - style: TextStyle( - fontSize: 14.0, - fontWeight: FontWeight.bold, - color: Theme.of(context).primaryTextTheme.title.color - ), - ), - ) - ], - ), - SizedBox( - height: 16.0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - child: GestureDetector( - onTap: () => launchUrl(xmrtoUrl), - child: Text( - xmrtoUrl, - textAlign: TextAlign.left, - style: TextStyle( - color: Palette.blueCraiola, - fontSize: 14.0, - fontWeight: FontWeight.normal, - decoration: TextDecoration.underline), - ), - )) - ], - ), - SizedBox( - height: 16.0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - child: GestureDetector( - onTap: () => launchUrl(changenowUrl), - child: Text( - changenowUrl, - textAlign: TextAlign.left, - style: TextStyle( - color: Palette.blueCraiola, - fontSize: 14.0, - fontWeight: FontWeight.normal, - decoration: TextDecoration.underline), - ), - )) - ], - ), - SizedBox( - height: 16.0, - ), - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - child: GestureDetector( - onTap: () => launchUrl(morphUrl), - child: Text( - morphUrl, - textAlign: TextAlign.left, - style: TextStyle( - color: Palette.blueCraiola, - fontSize: 14.0, - fontWeight: FontWeight.normal, - decoration: TextDecoration.underline), - ), - )) - ], - ), - SizedBox( - height: 16.0, + Expanded( + child: Text( + 'Terms and conditions', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 20.0, + fontWeight: FontWeight.bold, + color: Theme.of(context) + .primaryTextTheme + .title + .color), + ), ) ], ), - ), - Container( - alignment: Alignment.bottomCenter, - child: Container( - height: 12.0, - child: ClipRect( - child: BackdropFilter( - filter: ImageFilter.blur(sigmaX: 0.7, sigmaY: 0.7), - child: Container( - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [ - Theme.of(context).backgroundColor.withOpacity(0.0), - Theme.of(context).backgroundColor, - ], - begin: FractionalOffset.topCenter, - end: FractionalOffset.bottomCenter, - ), - ), + SizedBox( + height: 20.0, + ), + Row( + children: [ + Expanded( + child: Text( + 'Legal Disclaimer\nAnd\nTerms of Use', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 12.0, + fontWeight: FontWeight.bold, + color: Theme.of(context) + .primaryTextTheme + .title + .color), + ), + ) + ], + ), + SizedBox( + height: 16.0, + ), + Row( + children: [ + Expanded( + child: Text( + _fileText, + style: TextStyle( + fontSize: 12.0, + fontWeight: FontWeight.normal, + color: Theme.of(context) + .primaryTextTheme + .title + .color), + )) + ], + ), + SizedBox( + height: 16.0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: Text( + 'Other Terms and Conditions', + textAlign: TextAlign.left, + style: TextStyle( + fontSize: 14.0, + fontWeight: FontWeight.bold, + color: Theme.of(context) + .primaryTextTheme + .title + .color), + ), + ) + ], + ), + SizedBox( + height: 16.0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: GestureDetector( + onTap: () => launchUrl(xmrtoUrl), + child: Text( + xmrtoUrl, + textAlign: TextAlign.left, + style: TextStyle( + color: Palette.blueCraiola, + fontSize: 14.0, + fontWeight: FontWeight.normal, + decoration: TextDecoration.underline), + ), + )) + ], + ), + SizedBox( + height: 16.0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: GestureDetector( + onTap: () => launchUrl(changenowUrl), + child: Text( + changenowUrl, + textAlign: TextAlign.left, + style: TextStyle( + color: Palette.blueCraiola, + fontSize: 14.0, + fontWeight: FontWeight.normal, + decoration: TextDecoration.underline), + ), + )) + ], + ), + SizedBox( + height: 16.0, + ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: GestureDetector( + onTap: () => launchUrl(morphUrl), + child: Text( + morphUrl, + textAlign: TextAlign.left, + style: TextStyle( + color: Palette.blueCraiola, + fontSize: 14.0, + fontWeight: FontWeight.normal, + decoration: TextDecoration.underline), + ), + )) + ], + ), + SizedBox( + height: 16.0, + ) + ], + ), + ), + Container( + alignment: Alignment.bottomCenter, + child: Container( + height: 12.0, + child: ClipRect( + child: BackdropFilter( + filter: ImageFilter.blur(sigmaX: 0.7, sigmaY: 0.7), + child: Container( + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + Theme.of(context) + .backgroundColor + .withOpacity(0.0), + Theme.of(context).backgroundColor, + ], + begin: FractionalOffset.topCenter, + end: FractionalOffset.bottomCenter, ), ), ), ), - ) - ], - )), + ), + ), + ) + ], + )), if (!widget.isReadOnly) ...[ Row( children: [ @@ -260,25 +270,31 @@ class DisclaimerBodyState extends State { ), decoration: BoxDecoration( border: Border.all( - color: Theme.of(context).primaryTextTheme.caption.color, width: 1.0), - borderRadius: BorderRadius.all( - Radius.circular(8.0)), + color: Theme.of(context) + .primaryTextTheme + .caption + .color, + width: 1.0), + borderRadius: + BorderRadius.all(Radius.circular(8.0)), color: Theme.of(context).backgroundColor), child: _checked - ? Icon( - Icons.check, - color: Colors.blue, - size: 20.0, - ) - : null, + ? Icon( + Icons.check, + color: Colors.blue, + size: 20.0, + ) + : null, ), Text( 'I agree to Terms of Use', style: TextStyle( fontWeight: FontWeight.bold, fontSize: 14.0, - color: Theme.of(context).primaryTextTheme.title.color - ), + color: Theme.of(context) + .primaryTextTheme + .title + .color), ) ], ), @@ -287,12 +303,12 @@ class DisclaimerBodyState extends State { ], ), Container( - padding: - EdgeInsets.only(left: 24.0, right: 24.0, bottom: 24.0), + padding: EdgeInsets.only(left: 24.0, right: 24.0, bottom: 24.0), child: PrimaryButton( - onPressed: _checked ? () => - Navigator.of(context).popAndPushNamed(Routes.welcome) - : null, + onPressed: _checked + ? () => + Navigator.of(context).popAndPushNamed(Routes.welcome) + : null, text: 'Accept', color: Colors.green, textColor: Colors.white, diff --git a/lib/view_model/wallet_creation_vm.dart b/lib/view_model/wallet_creation_vm.dart index dce3ecc00..4c8ba6772 100644 --- a/lib/view_model/wallet_creation_vm.dart +++ b/lib/view_model/wallet_creation_vm.dart @@ -8,6 +8,8 @@ import 'package:cake_wallet/entities/pathForWallet.dart'; import 'package:cake_wallet/entities/wallet_info.dart'; import 'package:cake_wallet/entities/wallet_type.dart'; import 'package:cake_wallet/store/app_store.dart'; +import 'package:flutter/services.dart'; +import 'dart:math'; part 'wallet_creation_vm.g.dart'; @@ -31,6 +33,24 @@ abstract class WalletCreationVMBase with Store { final Box _walletInfoSource; final AppStore _appStore; + Future generateName() async { + final adjectiveStringRaw = + await rootBundle.loadString('assets/text/Wallet_Adjectives.txt'); + final nounStringRaw = + await rootBundle.loadString('assets/text/Wallet_Nouns.txt'); + + final randomThing = new Random(); + + final adjectives = new List.from(adjectiveStringRaw.split("\n")); + final nouns = new List.from(nounStringRaw.split("\n")); + + final chosenAdjective = adjectives[randomThing.nextInt(adjectives.length)]; + final chosenNoun = nouns[randomThing.nextInt(nouns.length)]; + + final returnString = chosenAdjective + " " + chosenNoun; + return returnString; + } + Future create({dynamic options}) async { try { state = IsExecutingState();