refacto: new WalletName Widget
This commit is contained in:
parent
c50aa53f38
commit
4ef5f77888
|
@ -14,6 +14,7 @@ import 'package:gecko/providers/substrate_sdk.dart';
|
|||
import 'package:gecko/providers/wallet_options.dart';
|
||||
import 'package:gecko/providers/wallets_profiles.dart';
|
||||
import 'package:gecko/screens/wallet_view.dart';
|
||||
import 'package:gecko/widgets/wallet_name_controller.dart';
|
||||
import 'package:graphql_flutter/graphql_flutter.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:truncate/truncate.dart';
|
||||
|
@ -172,7 +173,7 @@ class DuniterIndexer with ChangeNotifier {
|
|||
if (canEdit) {
|
||||
return walletOptions.walletName(context, wallet, size, color);
|
||||
} else {
|
||||
return walletOptions.walletNameController(context, wallet, size);
|
||||
return WalletNameController(wallet: wallet, size: size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -224,8 +225,7 @@ class DuniterIndexer with ChangeNotifier {
|
|||
if (canEdit) {
|
||||
return walletOptions.walletName(context, wallet, size, color);
|
||||
} else {
|
||||
return walletOptions.walletNameController(
|
||||
context, wallet, size);
|
||||
return WalletNameController(wallet: wallet, size: size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
TextEditingController newPin = TextEditingController();
|
||||
bool isEditing = false;
|
||||
bool isBalanceBlur = false;
|
||||
FocusNode walletNameFocus = FocusNode();
|
||||
TextEditingController nameController = TextEditingController();
|
||||
late bool isDefaultWallet;
|
||||
bool canValidateNameBool = false;
|
||||
|
@ -392,60 +391,6 @@ class WalletOptionsProvider with ChangeNotifier {
|
|||
return addressGet;
|
||||
}
|
||||
|
||||
Widget walletNameController(BuildContext context, WalletData wallet,
|
||||
[double size = 20]) {
|
||||
nameController.text = wallet.name!;
|
||||
|
||||
return SizedBox(
|
||||
width: 260,
|
||||
child: Stack(children: <Widget>[
|
||||
TextField(
|
||||
key: keyWalletName,
|
||||
autofocus: false,
|
||||
focusNode: walletNameFocus,
|
||||
enabled: isEditing,
|
||||
controller: nameController,
|
||||
minLines: 1,
|
||||
maxLines: 3,
|
||||
textAlign: TextAlign.center,
|
||||
decoration: const InputDecoration(
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
contentPadding: EdgeInsets.all(15.0),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: isTall ? size : size * 0.9,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 0,
|
||||
child: InkWell(
|
||||
key: keyRenameWallet,
|
||||
onTap: () async {
|
||||
// _isNewNameValid =
|
||||
// walletProvider.editWalletName(wallet.id(), isCesium: false);
|
||||
await editWalletName(context, wallet.id());
|
||||
await Future.delayed(const Duration(milliseconds: 30));
|
||||
walletNameFocus.requestFocus();
|
||||
},
|
||||
child: ClipRRect(
|
||||
child: Image.asset(
|
||||
isEditing
|
||||
? 'assets/walletOptions/android-checkmark.png'
|
||||
: 'assets/walletOptions/edit.png',
|
||||
width: 25,
|
||||
height: 25),
|
||||
),
|
||||
),
|
||||
),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
Widget walletName(BuildContext context, WalletData wallet,
|
||||
[double size = 20, Color color = Colors.black]) {
|
||||
double newSize = wallet.name!.length <= 15 ? size : size - 2;
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:gecko/providers/substrate_sdk.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class TemplateWidget extends StatelessWidget {
|
||||
const TemplateWidget(
|
||||
{Key? key, required this.address, this.color = Colors.black})
|
||||
: super(key: key);
|
||||
final String address;
|
||||
final Color color;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<SubstrateSdk>(builder: (context, sub, _) {
|
||||
return const Text('Hello Widget');
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:gecko/globals.dart';
|
||||
import 'package:gecko/models/wallet_data.dart';
|
||||
import 'package:gecko/models/widgets_keys.dart';
|
||||
import 'package:gecko/providers/wallet_options.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class WalletNameController extends StatelessWidget {
|
||||
const WalletNameController({Key? key, required this.wallet, this.size = 20})
|
||||
: super(key: key);
|
||||
final WalletData wallet;
|
||||
final double size;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final walletOptions =
|
||||
Provider.of<WalletOptionsProvider>(context, listen: false);
|
||||
walletOptions.nameController.text = wallet.name!;
|
||||
final walletNameFocus = FocusNode();
|
||||
|
||||
return SizedBox(
|
||||
width: 260,
|
||||
child: Stack(children: <Widget>[
|
||||
TextField(
|
||||
key: keyWalletName,
|
||||
autofocus: false,
|
||||
focusNode: walletNameFocus,
|
||||
enabled: walletOptions.isEditing,
|
||||
controller: walletOptions.nameController,
|
||||
minLines: 1,
|
||||
maxLines: 3,
|
||||
textAlign: TextAlign.center,
|
||||
decoration: const InputDecoration(
|
||||
border: InputBorder.none,
|
||||
focusedBorder: InputBorder.none,
|
||||
enabledBorder: InputBorder.none,
|
||||
disabledBorder: InputBorder.none,
|
||||
contentPadding: EdgeInsets.all(15.0),
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: isTall ? size : size * 0.9,
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.w400,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
right: 0,
|
||||
child: InkWell(
|
||||
key: keyRenameWallet,
|
||||
onTap: () async {
|
||||
// _isNewNameValid =
|
||||
// walletProvider.editWalletName(wallet.id(), isCesium: false);
|
||||
await walletOptions.editWalletName(context, wallet.id());
|
||||
await Future.delayed(const Duration(milliseconds: 30));
|
||||
walletNameFocus.requestFocus();
|
||||
},
|
||||
child: ClipRRect(
|
||||
child: Image.asset(
|
||||
walletOptions.isEditing
|
||||
? 'assets/walletOptions/android-checkmark.png'
|
||||
: 'assets/walletOptions/edit.png',
|
||||
width: 25,
|
||||
height: 25),
|
||||
),
|
||||
),
|
||||
),
|
||||
]),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue