diff --git a/lib/src/screens/new_wallet/new_wallet_page.dart b/lib/src/screens/new_wallet/new_wallet_page.dart index 4d4156473..a4a0b32be 100644 --- a/lib/src/screens/new_wallet/new_wallet_page.dart +++ b/lib/src/screens/new_wallet/new_wallet_page.dart @@ -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'; @@ -57,6 +58,8 @@ class _WalletNameFormState extends State { ReactionDisposer _stateReaction; final WalletNewVM _walletNewVM; + final TextEditingController _controller = TextEditingController(); + @override void initState() { _stateReaction ??= @@ -101,39 +104,68 @@ class _WalletNameFormState extends State { 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 rName = await generateName(); + setState(() { + _controller.text = rName; + _walletNewVM.name = rName; + _controller.selection = TextSelection.fromPosition( + TextPosition(offset: _controller.text.length)); + }); + }, + icon: Container( + padding: const EdgeInsets.all(8), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(6.0), + color: Theme.of(context).hintColor, + ), + width: 34, + height: 34, + child: Image.asset( + 'assets/images/refresh_icon.png', + color: Theme.of(context) + .primaryTextTheme + .display1 + .decorationColor, + ), + ), + ), + 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( diff --git a/lib/src/screens/restore/wallet_restore_from_keys_form.dart b/lib/src/screens/restore/wallet_restore_from_keys_form.dart index 4ad9c25bc..36264aa95 100644 --- a/lib/src/screens/restore/wallet_restore_from_keys_form.dart +++ b/lib/src/screens/restore/wallet_restore_from_keys_form.dart @@ -7,12 +7,13 @@ import 'package:cake_wallet/src/widgets/base_text_form_field.dart'; import 'package:cake_wallet/src/widgets/base_text_form_field.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/core/validator.dart'; +import 'package:cake_wallet/entities/generate_name.dart'; class WalletRestoreFromKeysFrom extends StatefulWidget { WalletRestoreFromKeysFrom({Key key, this.onHeightOrDateEntered}) : super(key: key); - final Function (bool) onHeightOrDateEntered; + final Function(bool) onHeightOrDateEntered; @override WalletRestoreFromKeysFromState createState() => @@ -56,7 +57,34 @@ class WalletRestoreFromKeysFromState extends State { BaseTextFormField( controller: nameTextEditingController, hintText: S.of(context).wallet_name, - validator: WalletNameValidator()), + validator: WalletNameValidator(), + suffixIcon: Container( + width: 12, + height: 14, + margin: const EdgeInsets.only(bottom: 15, left: 13), + child: InkWell( + onTap: () async { + final rName = await generateName(); + setState(() { + nameTextEditingController.text = rName; + nameTextEditingController.selection = + TextSelection.fromPosition(TextPosition( + offset: nameTextEditingController.text.length)); + }); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + color: Theme.of(context).hintColor, + borderRadius: BorderRadius.all(Radius.circular(6))), + child: Image.asset('assets/images/refresh_icon.png', + color: Theme.of(context) + .primaryTextTheme + .display1 + .decorationColor)), + ), + ), + ), Container(height: 20), BaseTextFormField( controller: addressController, diff --git a/lib/src/screens/restore/wallet_restore_from_seed_form.dart b/lib/src/screens/restore/wallet_restore_from_seed_form.dart index bd37e672e..6e8c10f3c 100644 --- a/lib/src/screens/restore/wallet_restore_from_seed_form.dart +++ b/lib/src/screens/restore/wallet_restore_from_seed_form.dart @@ -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'; @@ -61,9 +62,36 @@ class WalletRestoreFromSeedFormState extends State { 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: Container( + width: 12, + height: 14, + margin: const EdgeInsets.only(bottom: 15, left: 13), + child: InkWell( + onTap: () async { + final rName = await generateName(); + setState(() { + nameTextEditingController.text = rName; + nameTextEditingController.selection = + TextSelection.fromPosition(TextPosition( + offset: nameTextEditingController.text.length)); + }); + }, + child: Container( + padding: EdgeInsets.all(8), + decoration: BoxDecoration( + color: Theme.of(context).hintColor, + borderRadius: BorderRadius.all(Radius.circular(6))), + child: Image.asset('assets/images/refresh_icon.png', + color: Theme.of(context) + .primaryTextTheme + .display1 + .decorationColor)), + ), + ), + ), Container(height: 20), SeedWidget( key: seedWidgetStateKey, diff --git a/lib/src/widgets/seed_widget.dart b/lib/src/widgets/seed_widget.dart index 6e3ef996d..ea67c5d6b 100644 --- a/lib/src/widgets/seed_widget.dart +++ b/lib/src/widgets/seed_widget.dart @@ -26,8 +26,7 @@ class SeedWidgetState extends State { SeedWidgetState(String language, this.type) : controller = TextEditingController(), focusNode = FocusNode(), - words = SeedValidator.getWordList( - type:type, language: language) { + words = SeedValidator.getWordList(type: type, language: language) { focusNode.addListener(() { setState(() { if (!focusNode.hasFocus && controller.text.isEmpty) { @@ -58,8 +57,7 @@ class SeedWidgetState extends State { void changeSeedLanguage(String language) { setState(() { - words = SeedValidator.getWordList( - type: type, language: language); + words = SeedValidator.getWordList(type: type, language: language); }); }