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