Fix bad rebuild view when change default wallet
This commit is contained in:
parent
687e14de3f
commit
420daa229c
|
@ -9,7 +9,7 @@ class MyWalletsProvider with ChangeNotifier {
|
||||||
String listWallets;
|
String listWallets;
|
||||||
|
|
||||||
Future initWalletFolder() async {
|
Future initWalletFolder() async {
|
||||||
await getDefaultWallet();
|
getDefaultWallet();
|
||||||
|
|
||||||
final bool isWalletFolderExist = await walletsDirectory.exists();
|
final bool isWalletFolderExist = await walletsDirectory.exists();
|
||||||
if (!isWalletFolderExist) {
|
if (!isWalletFolderExist) {
|
||||||
|
@ -84,17 +84,17 @@ class MyWalletsProvider with ChangeNotifier {
|
||||||
return listWallets;
|
return listWallets;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future getDefaultWallet() async {
|
void getDefaultWallet() {
|
||||||
defaultWalletFile = File('${appPath.path}/defaultWallet');
|
defaultWalletFile = File('${appPath.path}/defaultWallet');
|
||||||
|
|
||||||
bool isdefaultWalletFile = await defaultWalletFile.exists();
|
bool isdefaultWalletFile = defaultWalletFile.existsSync();
|
||||||
|
|
||||||
if (!isdefaultWalletFile) {
|
if (!isdefaultWalletFile) {
|
||||||
await File(defaultWalletFile.path).create();
|
File(defaultWalletFile.path).createSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
defaultWallet = await defaultWalletFile.readAsString();
|
defaultWallet = defaultWalletFile.readAsStringSync();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
defaultWallet = '0:0';
|
defaultWallet = '0:0';
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
FocusNode walletNameFocus = FocusNode();
|
FocusNode walletNameFocus = FocusNode();
|
||||||
TextEditingController nameController = TextEditingController();
|
TextEditingController nameController = TextEditingController();
|
||||||
String walletID;
|
String walletID;
|
||||||
|
bool isDefaultWallet;
|
||||||
|
|
||||||
Future<NewWallet> get badWallet => null;
|
Future<NewWallet> get badWallet => null;
|
||||||
|
|
||||||
|
@ -356,12 +357,11 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
return await scanner.generateBarCode(_pubkey);
|
return await scanner.generateBarCode(_pubkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future defAsDefaultWallet(String _id) async {
|
void defAsDefaultWallet(String _id) {
|
||||||
await defaultWalletFile.delete();
|
defaultWalletFile.deleteSync();
|
||||||
await defaultWalletFile.create();
|
defaultWalletFile.createSync();
|
||||||
await defaultWalletFile
|
defaultWalletFile.writeAsStringSync(_id);
|
||||||
.writeAsString(_id)
|
notifyListeners();
|
||||||
.then((value) => notifyListeners());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future changeAvatar() async {
|
Future changeAvatar() async {
|
||||||
|
|
|
@ -24,7 +24,6 @@ class WalletOptions extends StatelessWidget {
|
||||||
int derivation;
|
int derivation;
|
||||||
int _nbrLinesName = 1;
|
int _nbrLinesName = 1;
|
||||||
bool _isNewNameValid = false;
|
bool _isNewNameValid = false;
|
||||||
bool isDefaultWallet;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -46,7 +45,6 @@ class WalletOptions extends StatelessWidget {
|
||||||
} else {
|
} else {
|
||||||
walletName = _walletOptions.nameController.text;
|
walletName = _walletOptions.nameController.text;
|
||||||
}
|
}
|
||||||
_walletOptions.walletID = '0:$walletNbr';
|
|
||||||
|
|
||||||
_walletOptions.nameController.text.length >= 15
|
_walletOptions.nameController.text.length >= 15
|
||||||
? _nbrLinesName = 2
|
? _nbrLinesName = 2
|
||||||
|
@ -54,9 +52,13 @@ class WalletOptions extends StatelessWidget {
|
||||||
if (_walletOptions.nameController.text.length >= 26 && isTall)
|
if (_walletOptions.nameController.text.length >= 26 && isTall)
|
||||||
_nbrLinesName = 3;
|
_nbrLinesName = 3;
|
||||||
|
|
||||||
|
_walletOptions.walletID = '0:$walletNbr';
|
||||||
|
|
||||||
|
_myWalletProvider.getDefaultWallet();
|
||||||
|
|
||||||
defaultWallet == _walletOptions.walletID
|
defaultWallet == _walletOptions.walletID
|
||||||
? isDefaultWallet = true
|
? _walletOptions.isDefaultWallet = true
|
||||||
: isDefaultWallet = false;
|
: _walletOptions.isDefaultWallet = false;
|
||||||
|
|
||||||
// print(_walletOptions.generateQRcode(_walletOptions.pubkey.text));
|
// print(_walletOptions.generateQRcode(_walletOptions.pubkey.text));
|
||||||
|
|
||||||
|
@ -172,7 +174,6 @@ class WalletOptions extends StatelessWidget {
|
||||||
return Text('Loading');
|
return Text('Loading');
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: catch links errors
|
|
||||||
print(result);
|
print(result);
|
||||||
|
|
||||||
// List repositories = result.data['viewer']['repositories']['nodes'];
|
// List repositories = result.data['viewer']['repositories']['nodes'];
|
||||||
|
@ -366,15 +367,12 @@ class WalletOptions extends StatelessWidget {
|
||||||
]))),
|
]))),
|
||||||
SizedBox(height: 12 * ratio),
|
SizedBox(height: 12 * ratio),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: !isDefaultWallet
|
onTap: !_walletOptions.isDefaultWallet
|
||||||
? () async {
|
? () {
|
||||||
await _walletOptions
|
defaultWallet = '0:$walletNbr';
|
||||||
.defAsDefaultWallet(_walletOptions.walletID)
|
_walletOptions
|
||||||
.then((value) => {
|
.defAsDefaultWallet(_walletOptions.walletID);
|
||||||
_myWalletProvider
|
_myWalletProvider.getAllWalletsNames(_currentChest);
|
||||||
.getAllWalletsNames(_currentChest),
|
|
||||||
_myWalletProvider.rebuildWidget()
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
|
@ -382,19 +380,19 @@ class WalletOptions extends StatelessWidget {
|
||||||
child: Row(children: <Widget>[
|
child: Row(children: <Widget>[
|
||||||
SizedBox(width: 31),
|
SizedBox(width: 31),
|
||||||
CircleAvatar(
|
CircleAvatar(
|
||||||
backgroundColor:
|
backgroundColor: Colors.grey[
|
||||||
Colors.grey[isDefaultWallet ? 300 : 500],
|
_walletOptions.isDefaultWallet ? 300 : 500],
|
||||||
child: Image.asset(
|
child: Image.asset(
|
||||||
'assets/walletOptions/android-checkmark.png',
|
'assets/walletOptions/android-checkmark.png',
|
||||||
)),
|
)),
|
||||||
SizedBox(width: 12),
|
SizedBox(width: 12),
|
||||||
Text(
|
Text(
|
||||||
isDefaultWallet
|
_walletOptions.isDefaultWallet
|
||||||
? 'Ce portefeuille est celui par defaut'
|
? 'Ce portefeuille est celui par defaut'
|
||||||
: 'Définir comme portefeuille par défaut',
|
: 'Définir comme portefeuille par défaut',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
color: isDefaultWallet
|
color: _walletOptions.isDefaultWallet
|
||||||
? Colors.grey[500]
|
? Colors.grey[500]
|
||||||
: Colors.black)),
|
: Colors.black)),
|
||||||
]))),
|
]))),
|
||||||
|
|
Loading…
Reference in New Issue