Merge pull request #241 from cake-tech/CW-7

Adding IconButton to generate names for wallet names for new_wallet a…
wownero
mkyq 2 years ago committed by GitHub
commit 24ac8d61f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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<WalletNameForm> {
ReactionDisposer _stateReaction;
final WalletNewVM _walletNewVM;
final TextEditingController _controller = TextEditingController();
@override
void initState() {
_stateReaction ??=
@ -101,39 +104,68 @@ class _WalletNameFormState extends State<WalletNameForm> {
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(

@ -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<WalletRestoreFromKeysFrom> {
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,

@ -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<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: 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,

@ -26,8 +26,7 @@ class SeedWidgetState extends State<SeedWidget> {
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<SeedWidget> {
void changeSeedLanguage(String language) {
setState(() {
words = SeedValidator.getWordList(
type: type, language: language);
words = SeedValidator.getWordList(type: type, language: language);
});
}

Loading…
Cancel
Save