added fucntion to WalletCreationVMBase to generate random wallet names. Wallet name generator follows this format <ADJECTIVE><space><NOUN>

This commit is contained in:
Tanner Silva 2020-10-19 12:21:53 -05:00
parent 210a8a06c4
commit d7f829042b
3 changed files with 214 additions and 178 deletions

View file

@ -1 +1 @@
4dc2ef1ba73deeed13cd85894dacb10b f88b397cc50258e916c86427fe071d09

View file

@ -24,7 +24,8 @@ class DisclaimerPage extends BasePage {
isReadOnly ? super.leading(context) : null; isReadOnly ? super.leading(context) : null;
@override @override
Widget body(BuildContext context) => DisclaimerPageBody(isReadOnly: isReadOnly); Widget body(BuildContext context) =>
DisclaimerPageBody(isReadOnly: isReadOnly);
} }
class DisclaimerPageBody extends StatefulWidget { class DisclaimerPageBody extends StatefulWidget {
@ -37,7 +38,6 @@ class DisclaimerPageBody extends StatefulWidget {
} }
class DisclaimerBodyState extends State<DisclaimerPageBody> { class DisclaimerBodyState extends State<DisclaimerPageBody> {
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';
@ -83,8 +83,10 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
style: TextStyle( style: TextStyle(
fontSize: 20.0, fontSize: 20.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: Theme.of(context).primaryTextTheme.title.color color: Theme.of(context)
), .primaryTextTheme
.title
.color),
), ),
) )
], ],
@ -101,8 +103,10 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
style: TextStyle( style: TextStyle(
fontSize: 12.0, fontSize: 12.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: Theme.of(context).primaryTextTheme.title.color color: Theme.of(context)
), .primaryTextTheme
.title
.color),
), ),
) )
], ],
@ -118,8 +122,10 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
style: TextStyle( style: TextStyle(
fontSize: 12.0, fontSize: 12.0,
fontWeight: FontWeight.normal, fontWeight: FontWeight.normal,
color: Theme.of(context).primaryTextTheme.title.color color: Theme.of(context)
), .primaryTextTheme
.title
.color),
)) ))
], ],
), ),
@ -136,8 +142,10 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
style: TextStyle( style: TextStyle(
fontSize: 14.0, fontSize: 14.0,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
color: Theme.of(context).primaryTextTheme.title.color color: Theme.of(context)
), .primaryTextTheme
.title
.color),
), ),
) )
], ],
@ -222,7 +230,9 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
colors: [ colors: [
Theme.of(context).backgroundColor.withOpacity(0.0), Theme.of(context)
.backgroundColor
.withOpacity(0.0),
Theme.of(context).backgroundColor, Theme.of(context).backgroundColor,
], ],
begin: FractionalOffset.topCenter, begin: FractionalOffset.topCenter,
@ -260,9 +270,13 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all( border: Border.all(
color: Theme.of(context).primaryTextTheme.caption.color, width: 1.0), color: Theme.of(context)
borderRadius: BorderRadius.all( .primaryTextTheme
Radius.circular(8.0)), .caption
.color,
width: 1.0),
borderRadius:
BorderRadius.all(Radius.circular(8.0)),
color: Theme.of(context).backgroundColor), color: Theme.of(context).backgroundColor),
child: _checked child: _checked
? Icon( ? Icon(
@ -277,8 +291,10 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
style: TextStyle( style: TextStyle(
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
fontSize: 14.0, fontSize: 14.0,
color: Theme.of(context).primaryTextTheme.title.color color: Theme.of(context)
), .primaryTextTheme
.title
.color),
) )
], ],
), ),
@ -287,10 +303,10 @@ class DisclaimerBodyState extends State<DisclaimerPageBody> {
], ],
), ),
Container( 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 ? () => onPressed: _checked
? () =>
Navigator.of(context).popAndPushNamed(Routes.welcome) Navigator.of(context).popAndPushNamed(Routes.welcome)
: null, : null,
text: 'Accept', text: 'Accept',

View file

@ -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_info.dart';
import 'package:cake_wallet/entities/wallet_type.dart'; import 'package:cake_wallet/entities/wallet_type.dart';
import 'package:cake_wallet/store/app_store.dart'; import 'package:cake_wallet/store/app_store.dart';
import 'package:flutter/services.dart';
import 'dart:math';
part 'wallet_creation_vm.g.dart'; part 'wallet_creation_vm.g.dart';
@ -31,6 +33,24 @@ abstract class WalletCreationVMBase with Store {
final Box<WalletInfo> _walletInfoSource; final Box<WalletInfo> _walletInfoSource;
final AppStore _appStore; final AppStore _appStore;
Future<String> 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<String>.from(adjectiveStringRaw.split("\n"));
final nouns = new List<String>.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<void> create({dynamic options}) async { Future<void> create({dynamic options}) async {
try { try {
state = IsExecutingState(); state = IsExecutingState();