gecko/lib/providers/change_pin.dart

49 lines
1.5 KiB
Dart
Raw Normal View History

import 'package:durt/durt.dart';
import 'package:flutter/material.dart';
import 'package:gecko/globals.dart';
class ChangePinProvider with ChangeNotifier {
bool ischangedPin = false;
2021-11-14 19:21:20 +01:00
TextEditingController newPin = TextEditingController();
2021-12-23 12:36:09 +01:00
String? pinToGive;
2021-12-23 12:36:09 +01:00
NewWallet? get badWallet => null;
Future<NewWallet?> changePin(String _oldPin, {String? newCustomPin}) async {
final NewWallet newWalletFile;
try {
final _chest = chestBox.get(configBox.get('currentChest'))!;
if (_chest.isCesium!) {
newWalletFile = await Dewif().changeCesiumPassword(
dewif: _chest.dewif!,
oldPassword: _oldPin.toUpperCase(),
newPassword: newCustomPin);
} else {
newWalletFile = await Dewif().changePassword(
dewif: _chest.dewif!,
oldPassword: _oldPin.toUpperCase(),
newPassword: newCustomPin);
}
newPin.text = pinToGive = newWalletFile.password;
ischangedPin = true;
2021-12-20 21:33:03 +01:00
// notifyListeners();
return newWalletFile;
} catch (e) {
2021-12-20 21:33:03 +01:00
log.e('Impossible de changer le code PIN: $e');
return badWallet;
}
}
2021-11-18 02:37:46 +01:00
void storeNewPinChest(context, NewWallet _newWalletFile) {
// ChestData currentChest = chestBox.getAt(configBox.get('currentChest'));
// currentChest.dewif = _newWalletFile.dewif;
// await chestBox.add(currentChest);
2021-12-23 12:36:09 +01:00
chestBox.get(configBox.get('currentChest'))!.dewif = _newWalletFile.dewif;
2021-11-18 02:37:46 +01:00
Navigator.pop(context, pinToGive);
pinToGive = '';
}
}