gecko/lib/models/change_pin.dart

43 lines
1.3 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;
2021-12-23 12:36:09 +01:00
NewWallet? changePin(String _oldPin, {String? newCustomPin}) {
try {
2021-12-23 12:36:09 +01:00
final _dewif = chestBox.get(configBox.get('currentChest'))!.dewif!;
// TODO: Durt: Detect if CesiumWallet
NewWallet newWalletFile = Dewif().changePassword(
2021-12-20 21:33:03 +01:00
dewif: _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 = '';
}
}