mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-10 12:54:38 +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 returnString =
|
||||
chosenAdjective.capitalized() + ' ' + chosenNoun.capitalized();
|
||||
|
||||
return returnString;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:cake_wallet/entities/generate_name.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/themes/theme_base.dart';
|
||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||
|
@ -24,15 +25,17 @@ class NewWalletPage extends BasePage {
|
|||
final walletNameImage = Image.asset('assets/images/wallet_name.png');
|
||||
|
||||
final walletNameLightImage =
|
||||
Image.asset('assets/images/wallet_name_light.png');
|
||||
Image.asset('assets/images/wallet_name_light.png');
|
||||
|
||||
@override
|
||||
String get title => S.current.new_wallet;
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) => WalletNameForm(_walletNewVM,
|
||||
Widget body(BuildContext context) => WalletNameForm(
|
||||
_walletNewVM,
|
||||
currentTheme.type == ThemeType.dark
|
||||
? walletNameImage : walletNameLightImage);
|
||||
? walletNameImage
|
||||
: walletNameLightImage);
|
||||
}
|
||||
|
||||
class WalletNameForm extends StatefulWidget {
|
||||
|
@ -55,12 +58,15 @@ class _WalletNameFormState extends State<WalletNameForm> {
|
|||
ReactionDisposer _stateReaction;
|
||||
final WalletNewVM _walletNewVM;
|
||||
|
||||
final TextEditingController _controller = TextEditingController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_stateReaction ??=
|
||||
reaction((_) => _walletNewVM.state, (ExecutionState state) {
|
||||
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) {
|
||||
|
@ -92,44 +98,59 @@ class _WalletNameFormState extends State<WalletNameForm> {
|
|||
padding: EdgeInsets.only(left: 12, right: 12),
|
||||
child: AspectRatio(
|
||||
aspectRatio: aspectRatioImage,
|
||||
child: FittedBox(child: widget.walletImage, fit: BoxFit.fill)),
|
||||
child:
|
||||
FittedBox(child: widget.walletImage, fit: BoxFit.fill)),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 24),
|
||||
child: Form(
|
||||
key: _formKey,
|
||||
child: TextFormField(
|
||||
onChanged: (value) => _walletNewVM.name = value,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 20.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
color:
|
||||
Theme.of(context).primaryTextTheme.title.color),
|
||||
decoration: InputDecoration(
|
||||
hintStyle: TextStyle(
|
||||
fontSize: 18.0,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context)
|
||||
.accentTextTheme
|
||||
.display3
|
||||
.color),
|
||||
hintText: S.of(context).wallet_name,
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context)
|
||||
.accentTextTheme
|
||||
.display3
|
||||
.decorationColor,
|
||||
width: 1.0)),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context)
|
||||
.accentTextTheme
|
||||
.display3
|
||||
.decorationColor,
|
||||
width: 1.0))),
|
||||
validator: WalletNameValidator())),
|
||||
key: _formKey,
|
||||
child: TextFormField(
|
||||
onChanged: (value) => _walletNewVM.name = value,
|
||||
controller: _controller,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 20.0,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: Theme.of(context).primaryTextTheme.title.color),
|
||||
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(
|
||||
fontSize: 18.0,
|
||||
fontWeight: FontWeight.w500,
|
||||
color:
|
||||
Theme.of(context).accentTextTheme.display3.color),
|
||||
hintText: S.of(context).wallet_name,
|
||||
focusedBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context)
|
||||
.accentTextTheme
|
||||
.display3
|
||||
.decorationColor,
|
||||
width: 1.0)),
|
||||
enabledBorder: UnderlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Theme.of(context)
|
||||
.accentTextTheme
|
||||
.display3
|
||||
.decorationColor,
|
||||
width: 1.0),
|
||||
),
|
||||
),
|
||||
validator: WalletNameValidator(),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_walletNewVM.hasLanguageSelector) ...[
|
||||
Padding(
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:cake_wallet/entities/generate_name.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_restore_view_model.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
@ -57,9 +58,21 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
|
|||
padding: EdgeInsets.only(left: 24, right: 24),
|
||||
child: Column(children: [
|
||||
BaseTextFormField(
|
||||
controller: nameTextEditingController,
|
||||
hintText: S.of(context).wallet_name,
|
||||
validator: WalletNameValidator()),
|
||||
controller: nameTextEditingController,
|
||||
hintText: S.of(context).wallet_name,
|
||||
validator: WalletNameValidator(),
|
||||
suffixIcon: IconButton(
|
||||
onPressed: () async {
|
||||
final String rName = await generateName();
|
||||
|
||||
print(rName);
|
||||
setState(() {
|
||||
nameTextEditingController.text = rName;
|
||||
});
|
||||
},
|
||||
icon: Icon(Icons.refresh),
|
||||
),
|
||||
),
|
||||
Container(height: 20),
|
||||
SeedWidget(
|
||||
key: seedWidgetStateKey, language: language, type: widget.type),
|
||||
|
|
Loading…
Reference in a new issue