2021-02-08 13:36:50 +01:00
|
|
|
import 'package:dubp/dubp.dart';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'dart:async';
|
|
|
|
import 'package:gecko/globals.dart';
|
2021-11-14 19:21:20 +01:00
|
|
|
import 'package:gecko/models/chest_data.dart';
|
2021-02-08 13:36:50 +01:00
|
|
|
|
|
|
|
class ChangePinProvider with ChangeNotifier {
|
|
|
|
bool ischangedPin = false;
|
2021-11-14 19:21:20 +01:00
|
|
|
TextEditingController newPin = TextEditingController();
|
2021-02-08 13:36:50 +01:00
|
|
|
|
|
|
|
Future<NewWallet> get badWallet => null;
|
|
|
|
|
|
|
|
Future<NewWallet> changePin(_name, _oldPin) async {
|
|
|
|
try {
|
2021-11-09 04:22:04 +01:00
|
|
|
final _dewif = chestBox.get(configBox.get('currentChest')).dewif;
|
2021-02-08 13:36:50 +01:00
|
|
|
|
|
|
|
NewWallet newWalletFile = await DubpRust.changeDewifPin(
|
|
|
|
dewif: _dewif,
|
|
|
|
oldPin: _oldPin,
|
|
|
|
);
|
|
|
|
|
|
|
|
newPin.text = newWalletFile.pin;
|
|
|
|
ischangedPin = true;
|
|
|
|
notifyListeners();
|
|
|
|
return newWalletFile;
|
|
|
|
} catch (e) {
|
2021-04-02 12:05:37 +02:00
|
|
|
log.e('Impossible de changer le code PIN.');
|
2021-02-08 13:36:50 +01:00
|
|
|
return badWallet;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-09 04:22:04 +01:00
|
|
|
Future storeNewPinChest(context, NewWallet _newWalletFile) async {
|
|
|
|
ChestData currentChest = chestBox.getAt(configBox.get('currentChest'));
|
|
|
|
currentChest.dewif = _newWalletFile.dewif;
|
|
|
|
// currentChest.name = _name;
|
|
|
|
chestBox.add(currentChest);
|
2021-02-08 13:36:50 +01:00
|
|
|
|
|
|
|
Navigator.pop(context);
|
|
|
|
}
|
|
|
|
}
|