Can change chest on unloncking screen

This commit is contained in:
poka 2021-11-15 03:55:08 +01:00
parent f15306e083
commit 162bd0a730
5 changed files with 43 additions and 11 deletions

View File

@ -76,7 +76,7 @@ class WalletOptionsProvider with ChangeNotifier {
context, WalletData _wallet, String _pin, int _pinLenght) async { context, WalletData _wallet, String _pin, int _pinLenght) async {
isWalletUnlock = false; isWalletUnlock = false;
try { try {
String _localDewif = chestBox.get(configBox.get('currentChest')).dewif; String _localDewif = chestBox.get(_wallet.chest).dewif;
String _localPubkey; String _localPubkey;
if ((_localPubkey = await _getPubkeyFromDewif( if ((_localPubkey = await _getPubkeyFromDewif(
@ -113,7 +113,7 @@ class WalletOptionsProvider with ChangeNotifier {
int getPinLenght(_walletNbr) { int getPinLenght(_walletNbr) {
String _localDewif; String _localDewif;
if (_walletNbr is int) { if (_walletNbr is int || _walletNbr == null) {
_localDewif = chestBox.get(configBox.get('currentChest')).dewif; _localDewif = chestBox.get(configBox.get('currentChest')).dewif;
} else { } else {
_localDewif = _walletNbr; _localDewif = _walletNbr;

View File

@ -87,6 +87,7 @@ class HomeScreen extends StatelessWidget {
), ),
), ),
appBar: AppBar( appBar: AppBar(
toolbarHeight: 60 * ratio,
leading: Builder( leading: Builder(
builder: (context) => IconButton( builder: (context) => IconButton(
key: const Key('drawerMenu'), key: const Key('drawerMenu'),

View File

@ -58,6 +58,7 @@ class _ChooseChestState extends State<ChooseChest> {
return Column(children: <Widget>[ return Column(children: <Widget>[
Image.asset( Image.asset(
'assets/chests/${i.value.imageName}', 'assets/chests/${i.value.imageName}',
height: 150,
), ),
const SizedBox(height: 30), const SizedBox(height: 30),
Text( Text(
@ -102,8 +103,8 @@ class _ChooseChestState extends State<ChooseChest> {
), ),
onPressed: () { onPressed: () {
configBox.put('currentChest', currentChest); configBox.put('currentChest', currentChest);
WalletData defaultWallet = _myWalletProvider WalletData defaultWallet =
.getDefaultWallet(configBox.get('currentChest')); _myWalletProvider.getDefaultWallet(currentChest);
_myWalletProvider.rebuildWidget(); _myWalletProvider.rebuildWidget();
Navigator.pushAndRemoveUntil(context, Navigator.pushAndRemoveUntil(context,
MaterialPageRoute(builder: (context) { MaterialPageRoute(builder: (context) {

View File

@ -7,6 +7,7 @@ import 'package:gecko/models/my_wallets.dart';
import 'package:gecko/models/wallet_data.dart'; import 'package:gecko/models/wallet_data.dart';
import 'package:gecko/models/wallet_options.dart'; import 'package:gecko/models/wallet_options.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:gecko/screens/myWallets/choose_chest.dart';
import 'package:pin_code_fields/pin_code_fields.dart'; import 'package:pin_code_fields/pin_code_fields.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:gecko/globals.dart'; import 'package:gecko/globals.dart';
@ -35,10 +36,17 @@ class UnlockingWallet extends StatelessWidget {
WalletOptionsProvider _walletOptions = WalletOptionsProvider _walletOptions =
Provider.of<WalletOptionsProvider>(context); Provider.of<WalletOptionsProvider>(context);
// log.d("defaultWallet: " + defaultWallet.toString()); int _pinLenght;
final int _pinLenght = _walletOptions.getPinLenght(wallet.number);
ChestData currentChest = chestBox.get(configBox.get('currentChest'));
if (currentChest.isCesium) {
_pinLenght = _walletOptions.getPinLenght(currentChest.dewif);
wallet = WalletData(derivation: -1, chest: currentChest.key);
} else {
_pinLenght = _walletOptions.getPinLenght(wallet.number);
}
errorController = StreamController<ErrorAnimationType>(); errorController = StreamController<ErrorAnimationType>();
ChestData currentChest = chestBox.get(wallet.chest);
return Scaffold( return Scaffold(
// backgroundColor: Colors.brown[600], // backgroundColor: Colors.brown[600],
@ -51,6 +59,7 @@ class UnlockingWallet extends StatelessWidget {
Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
Image.asset( Image.asset(
'assets/chests/${currentChest.imageName}', 'assets/chests/${currentChest.imageName}',
height: 150,
), ),
const SizedBox(width: 5), const SizedBox(width: 5),
SizedBox( SizedBox(
@ -75,14 +84,35 @@ class UnlockingWallet extends StatelessWidget {
fontWeight: FontWeight.w400), fontWeight: FontWeight.w400),
)), )),
const SizedBox(height: 50), const SizedBox(height: 50),
pinForm(context, _pinLenght, wallet.number, wallet.derivation), pinForm(context, _pinLenght),
const SizedBox(height: 5),
InkWell(
key: const Key('chooseChest'),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return const ChooseChest();
}),
);
},
child: SizedBox(
width: 400,
height: 70,
child: Center(
child: Text('Changer de coffre',
style: TextStyle(
fontSize: 22,
color: orangeC,
fontWeight: FontWeight.w600))),
)),
]), ]),
), ),
]), ]),
)); ));
} }
Widget pinForm(context, _pinLenght, int _walletNbr, int _derivation) { Widget pinForm(context, _pinLenght) {
// var _walletPin = ''; // var _walletPin = '';
// ignore: close_sinks // ignore: close_sinks
StreamController<ErrorAnimationType> errorController = StreamController<ErrorAnimationType> errorController =
@ -143,7 +173,7 @@ class UnlockingWallet extends StatelessWidget {
onCompleted: (_pin) async { onCompleted: (_pin) async {
log.d("Completed"); log.d("Completed");
_myWalletProvider.pinCode = _pin; _myWalletProvider.pinCode = _pin;
final resultWallet = await _walletOptions.readLocalWallet( final String resultWallet = await _walletOptions.readLocalWallet(
context, wallet, _pin.toUpperCase(), _pinLenght); context, wallet, _pin.toUpperCase(), _pinLenght);
// _myWalletProvider.pinCode = _pin.toUpperCase(); // _myWalletProvider.pinCode = _pin.toUpperCase();
_myWalletProvider.pinLenght = _pinLenght; _myWalletProvider.pinLenght = _pinLenght;

View File

@ -31,8 +31,8 @@ class WalletsHome extends StatelessWidget {
if (!_currentChest.isCesium) { if (!_currentChest.isCesium) {
myWalletProvider.listWallets = myWalletProvider.listWallets =
myWalletProvider.readAllWallets(_currentChestNumber); myWalletProvider.readAllWallets(_currentChestNumber);
isWalletsExists = myWalletProvider.checkIfWalletExist();
} }
isWalletsExists = myWalletProvider.checkIfWalletExist();
return WillPopScope( return WillPopScope(
onWillPop: () { onWillPop: () {