mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-10 21:04:53 +00:00
Adding IconButton to generate names for wallet names for new_wallet and restore_wallet
This commit is contained in:
parent
3bb338190e
commit
2b7d798253
3 changed files with 76 additions and 41 deletions
|
@ -20,5 +20,6 @@ Future<String> generateName() async {
|
||||||
final chosenNoun = nouns[randomThing.nextInt(nouns.length)];
|
final chosenNoun = nouns[randomThing.nextInt(nouns.length)];
|
||||||
final returnString =
|
final returnString =
|
||||||
chosenAdjective.capitalized() + ' ' + chosenNoun.capitalized();
|
chosenAdjective.capitalized() + ' ' + chosenNoun.capitalized();
|
||||||
|
|
||||||
return returnString;
|
return returnString;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:cake_wallet/entities/generate_name.dart';
|
||||||
import 'package:cake_wallet/routes.dart';
|
import 'package:cake_wallet/routes.dart';
|
||||||
import 'package:cake_wallet/themes/theme_base.dart';
|
import 'package:cake_wallet/themes/theme_base.dart';
|
||||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||||
|
@ -30,9 +31,11 @@ class NewWalletPage extends BasePage {
|
||||||
String get title => S.current.new_wallet;
|
String get title => S.current.new_wallet;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget body(BuildContext context) => WalletNameForm(_walletNewVM,
|
Widget body(BuildContext context) => WalletNameForm(
|
||||||
|
_walletNewVM,
|
||||||
currentTheme.type == ThemeType.dark
|
currentTheme.type == ThemeType.dark
|
||||||
? walletNameImage : walletNameLightImage);
|
? walletNameImage
|
||||||
|
: walletNameLightImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
class WalletNameForm extends StatefulWidget {
|
class WalletNameForm extends StatefulWidget {
|
||||||
|
@ -55,12 +58,15 @@ class _WalletNameFormState extends State<WalletNameForm> {
|
||||||
ReactionDisposer _stateReaction;
|
ReactionDisposer _stateReaction;
|
||||||
final WalletNewVM _walletNewVM;
|
final WalletNewVM _walletNewVM;
|
||||||
|
|
||||||
|
final TextEditingController _controller = TextEditingController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
_stateReaction ??=
|
_stateReaction ??=
|
||||||
reaction((_) => _walletNewVM.state, (ExecutionState state) {
|
reaction((_) => _walletNewVM.state, (ExecutionState state) {
|
||||||
if (state is ExecutedSuccessfullyState) {
|
if (state is ExecutedSuccessfullyState) {
|
||||||
Navigator.of(context).pushNamed(Routes.preSeed, arguments: _walletNewVM.type);
|
Navigator.of(context)
|
||||||
|
.pushNamed(Routes.preSeed, arguments: _walletNewVM.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state is FailureState) {
|
if (state is FailureState) {
|
||||||
|
@ -92,7 +98,8 @@ class _WalletNameFormState extends State<WalletNameForm> {
|
||||||
padding: EdgeInsets.only(left: 12, right: 12),
|
padding: EdgeInsets.only(left: 12, right: 12),
|
||||||
child: AspectRatio(
|
child: AspectRatio(
|
||||||
aspectRatio: aspectRatioImage,
|
aspectRatio: aspectRatioImage,
|
||||||
child: FittedBox(child: widget.walletImage, fit: BoxFit.fill)),
|
child:
|
||||||
|
FittedBox(child: widget.walletImage, fit: BoxFit.fill)),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(top: 24),
|
padding: EdgeInsets.only(top: 24),
|
||||||
|
@ -100,20 +107,30 @@ class _WalletNameFormState extends State<WalletNameForm> {
|
||||||
key: _formKey,
|
key: _formKey,
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
onChanged: (value) => _walletNewVM.name = value,
|
onChanged: (value) => _walletNewVM.name = value,
|
||||||
|
controller: _controller,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 20.0,
|
fontSize: 20.0,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color:
|
color: Theme.of(context).primaryTextTheme.title.color),
|
||||||
Theme.of(context).primaryTextTheme.title.color),
|
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
|
suffixIcon: IconButton(
|
||||||
|
onPressed: () async {
|
||||||
|
final String rName = await generateName();
|
||||||
|
|
||||||
|
print(rName);
|
||||||
|
setState(() {
|
||||||
|
_controller.text = rName;
|
||||||
|
_walletNewVM.name = rName;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
icon: Icon(Icons.refresh),
|
||||||
|
),
|
||||||
hintStyle: TextStyle(
|
hintStyle: TextStyle(
|
||||||
fontSize: 18.0,
|
fontSize: 18.0,
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: Theme.of(context)
|
color:
|
||||||
.accentTextTheme
|
Theme.of(context).accentTextTheme.display3.color),
|
||||||
.display3
|
|
||||||
.color),
|
|
||||||
hintText: S.of(context).wallet_name,
|
hintText: S.of(context).wallet_name,
|
||||||
focusedBorder: UnderlineInputBorder(
|
focusedBorder: UnderlineInputBorder(
|
||||||
borderSide: BorderSide(
|
borderSide: BorderSide(
|
||||||
|
@ -128,8 +145,12 @@ class _WalletNameFormState extends State<WalletNameForm> {
|
||||||
.accentTextTheme
|
.accentTextTheme
|
||||||
.display3
|
.display3
|
||||||
.decorationColor,
|
.decorationColor,
|
||||||
width: 1.0))),
|
width: 1.0),
|
||||||
validator: WalletNameValidator())),
|
),
|
||||||
|
),
|
||||||
|
validator: WalletNameValidator(),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
if (_walletNewVM.hasLanguageSelector) ...[
|
if (_walletNewVM.hasLanguageSelector) ...[
|
||||||
Padding(
|
Padding(
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:cake_wallet/entities/generate_name.dart';
|
||||||
import 'package:cw_core/wallet_type.dart';
|
import 'package:cw_core/wallet_type.dart';
|
||||||
import 'package:cake_wallet/view_model/wallet_restore_view_model.dart';
|
import 'package:cake_wallet/view_model/wallet_restore_view_model.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
@ -59,7 +60,19 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
|
||||||
BaseTextFormField(
|
BaseTextFormField(
|
||||||
controller: nameTextEditingController,
|
controller: nameTextEditingController,
|
||||||
hintText: S.of(context).wallet_name,
|
hintText: S.of(context).wallet_name,
|
||||||
validator: WalletNameValidator()),
|
validator: WalletNameValidator(),
|
||||||
|
suffixIcon: IconButton(
|
||||||
|
onPressed: () async {
|
||||||
|
final String rName = await generateName();
|
||||||
|
|
||||||
|
print(rName);
|
||||||
|
setState(() {
|
||||||
|
nameTextEditingController.text = rName;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
icon: Icon(Icons.refresh),
|
||||||
|
),
|
||||||
|
),
|
||||||
Container(height: 20),
|
Container(height: 20),
|
||||||
SeedWidget(
|
SeedWidget(
|
||||||
key: seedWidgetStateKey, language: language, type: widget.type),
|
key: seedWidgetStateKey, language: language, type: widget.type),
|
||||||
|
|
Loading…
Reference in a new issue