gecko/lib/models/change_pin.dart

44 lines
1.2 KiB
Dart
Raw Normal View History

import 'package:dubp/dubp.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:gecko/globals.dart';
class ChangePinProvider with ChangeNotifier {
bool ischangedPin = false;
2021-11-14 19:21:20 +01:00
TextEditingController newPin = TextEditingController();
2021-11-18 02:37:46 +01:00
String pinToGive;
Future<NewWallet> get badWallet => null;
2021-11-18 02:37:46 +01:00
Future<NewWallet> changePin(String _oldPin) async {
try {
2021-11-09 04:22:04 +01:00
final _dewif = chestBox.get(configBox.get('currentChest')).dewif;
NewWallet newWalletFile = await DubpRust.changeDewifPin(
dewif: _dewif,
2021-11-18 02:37:46 +01:00
oldPin: _oldPin.toUpperCase(),
);
2021-11-18 02:37:46 +01:00
newPin.text = pinToGive = 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.');
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-11-18 02:37:46 +01:00
chestBox.get(configBox.get('currentChest')).dewif = _newWalletFile.dewif;
Navigator.pop(context, pinToGive);
pinToGive = '';
}
}