WIP: Simple wallet Unlocking
This commit is contained in:
parent
8f7397626c
commit
d96b184e0a
|
@ -6,7 +6,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:gecko/globals.dart';
|
||||
import 'package:gecko/models/home.dart';
|
||||
import 'package:gecko/screens/history.dart';
|
||||
import 'package:gecko/screens/myWallets/unlockingWallet.dart';
|
||||
import 'package:graphql_flutter/graphql_flutter.dart';
|
||||
import 'package:jdenticon_dart/jdenticon_dart.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
@ -49,9 +48,7 @@ class HistoryProvider with ChangeNotifier {
|
|||
return barcode;
|
||||
}
|
||||
|
||||
void pay(amount, comment) {
|
||||
UnlockingWallet();
|
||||
|
||||
void pay(context, amount, comment) {
|
||||
String dewif = File(walletsDirectory.path +
|
||||
'${defaultWallet.split(':')[0]}/wallet.dewif')
|
||||
.readAsLinesSync()[0];
|
||||
|
|
|
@ -84,6 +84,22 @@ class MyWalletsProvider with ChangeNotifier {
|
|||
return listWallets;
|
||||
}
|
||||
|
||||
int getDerivationNbr(String _id) {
|
||||
int chest = int.parse(_id.split(':')[0]);
|
||||
// int nbr = int.parse(_id.split(':')[1]);
|
||||
final _walletConfig = File('${walletsDirectory.path}/$chest/list.conf');
|
||||
|
||||
int derivation;
|
||||
|
||||
_walletConfig.readAsLinesSync().forEach((element) {
|
||||
if ("${element.split(':')[0]}:${element.split(':')[1]}" == _id) {
|
||||
derivation = int.parse(element.split(':')[3]);
|
||||
}
|
||||
});
|
||||
|
||||
return derivation;
|
||||
}
|
||||
|
||||
void getDefaultWallet() {
|
||||
defaultWalletFile = File('${appPath.path}/defaultWallet');
|
||||
|
||||
|
|
|
@ -381,7 +381,12 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
|
|||
// if (_formKey.currentState.validate()) {
|
||||
// _formKey.currentState.save();
|
||||
// }
|
||||
_historyProvider.pay(payAmount.text, payComment.text);
|
||||
// _historyProvider.pay(payAmount.text, payComment.text);
|
||||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
return UnlockingWallet(
|
||||
walletNbr: int.parse(defaultWallet));
|
||||
}));
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
|
|
|
@ -13,12 +13,10 @@ import 'package:provider/provider.dart';
|
|||
|
||||
// ignore: must_be_immutable
|
||||
class UnlockingWallet extends StatelessWidget {
|
||||
UnlockingWallet(
|
||||
{Key keyUnlockWallet,
|
||||
@required this.walletNbr,
|
||||
@required this.walletName,
|
||||
@required this.derivation})
|
||||
: super(key: keyUnlockWallet);
|
||||
UnlockingWallet({
|
||||
Key keyUnlockWallet,
|
||||
@required this.walletNbr,
|
||||
}) : super(key: keyUnlockWallet);
|
||||
int walletNbr;
|
||||
String walletName;
|
||||
int derivation;
|
||||
|
@ -146,10 +144,7 @@ class UnlockingWallet extends StatelessWidget {
|
|||
Navigator.push(
|
||||
formKey.currentContext,
|
||||
SmoothTransition(
|
||||
page: WalletOptions(
|
||||
walletNbr: walletNbr,
|
||||
walletName: walletName,
|
||||
derivation: derivation)));
|
||||
page: WalletOptions(walletNbr: walletNbr)));
|
||||
}
|
||||
},
|
||||
onChanged: (value) {
|
||||
|
|
|
@ -13,11 +13,7 @@ import 'package:flutter/services.dart';
|
|||
|
||||
// ignore: must_be_immutable
|
||||
class WalletOptions extends StatelessWidget {
|
||||
WalletOptions(
|
||||
{Key keyMyWallets,
|
||||
@required this.walletNbr,
|
||||
@required this.walletName,
|
||||
@required this.derivation})
|
||||
WalletOptions({Key keyMyWallets, @required this.walletNbr})
|
||||
: super(key: keyMyWallets);
|
||||
int walletNbr;
|
||||
String walletName;
|
||||
|
|
|
@ -108,9 +108,7 @@ class WalletsHome extends StatelessWidget {
|
|||
Navigator.push(context,
|
||||
MaterialPageRoute(builder: (context) {
|
||||
return UnlockingWallet(
|
||||
walletNbr: int.parse(_repository.split(':')[1]),
|
||||
walletName: _repository.split(':')[2],
|
||||
derivation: int.parse(_repository.split(':')[3]));
|
||||
walletNbr: int.parse(_repository.split(':')[1]));
|
||||
}));
|
||||
},
|
||||
child: ClipRRect(
|
||||
|
@ -165,10 +163,7 @@ class WalletsHome extends StatelessWidget {
|
|||
MaterialPageRoute(builder: (context) {
|
||||
return UnlockingWallet(
|
||||
walletNbr:
|
||||
int.parse(_repository.split(':')[1]),
|
||||
walletName: _repository.split(':')[2],
|
||||
derivation:
|
||||
int.parse(_repository.split(':')[3]));
|
||||
int.parse(_repository.split(':')[1]));
|
||||
}));
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue