Settings: Add button to import Cesium wallet, and button to generate new keystore
This commit is contained in:
parent
f5d4e2507b
commit
1522c46256
|
@ -41,7 +41,12 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
|
|
||||||
Future storeWallet(NewWallet wallet, String _name, BuildContext context,
|
Future storeWallet(NewWallet wallet, String _name, BuildContext context,
|
||||||
{bool isHD = false}) async {
|
{bool isHD = false}) async {
|
||||||
int nbrWallet = 0;
|
int nbrWallet;
|
||||||
|
if (isHD) {
|
||||||
|
nbrWallet = 0;
|
||||||
|
} else {
|
||||||
|
nbrWallet = 1;
|
||||||
|
}
|
||||||
Directory walletNbrDirectory;
|
Directory walletNbrDirectory;
|
||||||
do {
|
do {
|
||||||
nbrWallet++;
|
nbrWallet++;
|
||||||
|
@ -65,6 +70,7 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
|
|
||||||
await configFile
|
await configFile
|
||||||
.writeAsString('$nbrWallet:$_name:$_derivationNbr:$_pubkey');
|
.writeAsString('$nbrWallet:$_name:$_derivationNbr:$_pubkey');
|
||||||
|
Navigator.pop(context, true);
|
||||||
} else {
|
} else {
|
||||||
final int _derivationNbr = -1;
|
final int _derivationNbr = -1;
|
||||||
String _pubkey = await DubpRust.getDewifPublicKey(
|
String _pubkey = await DubpRust.getDewifPublicKey(
|
||||||
|
@ -76,10 +82,6 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
Navigator.pop(context, true);
|
Navigator.pop(context, true);
|
||||||
if (isHD) {
|
|
||||||
Navigator.pop(context, true);
|
|
||||||
}
|
|
||||||
// notifyListeners();
|
|
||||||
|
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
@ -182,14 +184,17 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
return this.actualWallet;
|
return this.actualWallet;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> changePinCode() async {
|
Future<void> changePinCode({bool reload}) async {
|
||||||
actualWallet = await DubpRust.changeDewifPin(
|
actualWallet = await DubpRust.changeDewifPin(
|
||||||
dewif: actualWallet.dewif,
|
dewif: actualWallet.dewif,
|
||||||
oldPin: actualWallet.pin,
|
oldPin: actualWallet.pin,
|
||||||
);
|
);
|
||||||
|
|
||||||
pin.text = actualWallet.pin;
|
pin.text = actualWallet.pin;
|
||||||
notifyListeners();
|
isPinChanged = true;
|
||||||
|
if (reload) {
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Uint8List> printWallet(String _title) async {
|
Future<Uint8List> printWallet(String _title) async {
|
||||||
|
@ -238,8 +243,6 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
salt: _cesiumID, password: _cesiumPWD);
|
salt: _cesiumID, password: _cesiumPWD);
|
||||||
|
|
||||||
cesiumPubkey.text = _walletPubkey;
|
cesiumPubkey.text = _walletPubkey;
|
||||||
// changePinCode();
|
|
||||||
// notifyListeners();
|
|
||||||
print(_walletPubkey);
|
print(_walletPubkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,14 +253,14 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
omission: "...", position: TruncatePosition.end);
|
omission: "...", position: TruncatePosition.end);
|
||||||
await storeWallet(
|
await storeWallet(
|
||||||
actualWallet, 'Portefeuille Cesium - $shortPubkey', context);
|
actualWallet, 'Portefeuille Cesium - $shortPubkey', context);
|
||||||
print('taaaaaaaaaaaaaaaaa');
|
|
||||||
print(actualWallet.pin);
|
|
||||||
cesiumID.text = '';
|
cesiumID.text = '';
|
||||||
cesiumPWD.text = '';
|
cesiumPWD.text = '';
|
||||||
cesiumPubkey.text = '';
|
cesiumPubkey.text = '';
|
||||||
canImport = false;
|
canImport = false;
|
||||||
isPinChanged = false;
|
isPinChanged = false;
|
||||||
pin.text = '';
|
pin.text = '';
|
||||||
|
isCesiumIDVisible = false;
|
||||||
|
isCesiumPWDVisible = false;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,6 +274,13 @@ class GenerateWalletsProvider with ChangeNotifier {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void showPinIfEmpty() {
|
||||||
|
if (!isPinChanged) {
|
||||||
|
changePinCode(reload: true);
|
||||||
|
isPinChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void reloadBuild() {
|
void reloadBuild() {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,8 @@ class GenerateWalletsScreen extends StatelessWidget {
|
||||||
icon: Icon(Icons.replay),
|
icon: Icon(Icons.replay),
|
||||||
color: Color(0xffD28928),
|
color: Color(0xffD28928),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_generateWalletProvider.changePinCode();
|
_generateWalletProvider.changePinCode(
|
||||||
|
reload: false);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
import 'package:gecko/models/generateWallets.dart';
|
import 'package:gecko/models/generateWallets.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:gecko/models/myWallets.dart';
|
import 'package:gecko/models/myWallets.dart';
|
||||||
|
import 'package:gecko/models/walletOptions.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class ImportWalletScreen extends StatelessWidget {
|
class ImportWalletScreen extends StatelessWidget {
|
||||||
|
@ -13,6 +15,10 @@ class ImportWalletScreen extends StatelessWidget {
|
||||||
Provider.of<GenerateWalletsProvider>(context);
|
Provider.of<GenerateWalletsProvider>(context);
|
||||||
MyWalletsProvider _myWalletProvider =
|
MyWalletsProvider _myWalletProvider =
|
||||||
Provider.of<MyWalletsProvider>(context);
|
Provider.of<MyWalletsProvider>(context);
|
||||||
|
WalletOptionsProvider _walletOptions =
|
||||||
|
Provider.of<WalletOptionsProvider>(context);
|
||||||
|
|
||||||
|
_generateWalletProvider.showPinIfEmpty();
|
||||||
|
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
onWillPop: () {
|
onWillPop: () {
|
||||||
|
@ -22,6 +28,9 @@ class ImportWalletScreen extends StatelessWidget {
|
||||||
_generateWalletProvider.pin.text = '';
|
_generateWalletProvider.pin.text = '';
|
||||||
_generateWalletProvider.canImport = false;
|
_generateWalletProvider.canImport = false;
|
||||||
_generateWalletProvider.isPinChanged = false;
|
_generateWalletProvider.isPinChanged = false;
|
||||||
|
_generateWalletProvider.isCesiumIDVisible = false;
|
||||||
|
_generateWalletProvider.isCesiumPWDVisible = false;
|
||||||
|
_generateWalletProvider.reloadBuild();
|
||||||
return Future<bool>.value(true);
|
return Future<bool>.value(true);
|
||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
|
@ -35,6 +44,9 @@ class ImportWalletScreen extends StatelessWidget {
|
||||||
_generateWalletProvider.pin.text = '';
|
_generateWalletProvider.pin.text = '';
|
||||||
_generateWalletProvider.canImport = false;
|
_generateWalletProvider.canImport = false;
|
||||||
_generateWalletProvider.isPinChanged = false;
|
_generateWalletProvider.isPinChanged = false;
|
||||||
|
_generateWalletProvider.isCesiumIDVisible = false;
|
||||||
|
_generateWalletProvider.isCesiumPWDVisible = false;
|
||||||
|
_generateWalletProvider.reloadBuild();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
}),
|
}),
|
||||||
title: SizedBox(
|
title: SizedBox(
|
||||||
|
@ -122,14 +134,21 @@ class ImportWalletScreen extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SizedBox(height: 15),
|
SizedBox(height: 15),
|
||||||
Text(
|
GestureDetector(
|
||||||
_generateWalletProvider.cesiumPubkey.text,
|
onTap: () {
|
||||||
style: TextStyle(
|
Clipboard.setData(ClipboardData(
|
||||||
fontSize: 14.0,
|
text: _generateWalletProvider
|
||||||
color: Colors.black,
|
.cesiumPubkey.text));
|
||||||
fontWeight: FontWeight.bold,
|
_walletOptions.snackCopyKey(ctx);
|
||||||
fontFamily: 'Monospace'),
|
},
|
||||||
),
|
child: Text(
|
||||||
|
_generateWalletProvider.cesiumPubkey.text,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14.0,
|
||||||
|
color: Colors.black,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontFamily: 'Monospace'),
|
||||||
|
)),
|
||||||
SizedBox(height: 20),
|
SizedBox(height: 20),
|
||||||
toolTips(_toolTipSecret, 'Code secret:',
|
toolTips(_toolTipSecret, 'Code secret:',
|
||||||
"Retenez bien votre code secret, il vous sera demandé à chaque paiement, ainsi que pour configurer votre portefeuille"),
|
"Retenez bien votre code secret, il vous sera demandé à chaque paiement, ainsi que pour configurer votre portefeuille"),
|
||||||
|
@ -151,8 +170,8 @@ class ImportWalletScreen extends StatelessWidget {
|
||||||
icon: Icon(Icons.replay),
|
icon: Icon(Icons.replay),
|
||||||
color: Color(0xffD28928),
|
color: Color(0xffD28928),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_generateWalletProvider.changePinCode();
|
_generateWalletProvider.changePinCode(
|
||||||
_generateWalletProvider.isPinChanged = true;
|
reload: true);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:dubp/dubp.dart';
|
import 'package:dubp/dubp.dart';
|
||||||
import 'package:gecko/models/myWallets.dart';
|
import 'package:gecko/models/myWallets.dart';
|
||||||
|
import 'package:gecko/screens/myWallets/generateWallets.dart';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:gecko/screens/myWallets/importWallet.dart';
|
||||||
|
|
||||||
// ignore: must_be_immutable
|
// ignore: must_be_immutable
|
||||||
class SettingsScreen extends StatelessWidget {
|
class SettingsScreen extends StatelessWidget {
|
||||||
String generatedMnemonic;
|
String generatedMnemonic;
|
||||||
|
@ -28,18 +31,56 @@ class SettingsScreen extends StatelessWidget {
|
||||||
child: Text('Paramètres'),
|
child: Text('Paramètres'),
|
||||||
)),
|
)),
|
||||||
body: Column(children: <Widget>[
|
body: Column(children: <Widget>[
|
||||||
|
SizedBox(height: 40),
|
||||||
|
SizedBox(
|
||||||
|
height: 50,
|
||||||
|
width: 500,
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
elevation: 5,
|
||||||
|
primary: Color(0xFFFFCA6F), // background
|
||||||
|
onPrimary: Colors.black, // foreground
|
||||||
|
),
|
||||||
|
onPressed: () => Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) {
|
||||||
|
return ImportWalletScreen();
|
||||||
|
}),
|
||||||
|
).then((value) => {
|
||||||
|
if (value == true) {Navigator.pop(context)}
|
||||||
|
}),
|
||||||
|
child: Text("Importer un portefeuille Cesium",
|
||||||
|
style: TextStyle(fontSize: 15)))),
|
||||||
SizedBox(height: 20),
|
SizedBox(height: 20),
|
||||||
|
SizedBox(
|
||||||
|
height: 50,
|
||||||
|
width: 500,
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
elevation: 5,
|
||||||
|
primary: Color(0xFFFFCA6F), // background
|
||||||
|
onPrimary: Colors.black, // foreground
|
||||||
|
),
|
||||||
|
onPressed: () => Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) {
|
||||||
|
return GenerateWalletsScreen();
|
||||||
|
}),
|
||||||
|
).then((value) => {
|
||||||
|
if (value == true) {Navigator.pop(context)}
|
||||||
|
}),
|
||||||
|
child: Text("Générer un nouveau trousseau",
|
||||||
|
style: TextStyle(fontSize: 15)))),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.bottomCenter,
|
alignment: Alignment.bottomCenter,
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 100,
|
height: 100,
|
||||||
width: 1000,
|
width: 500,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
elevation: 5,
|
elevation: 5,
|
||||||
primary: Colors
|
primary: Colors.redAccent, // background
|
||||||
.redAccent, //Color(0xffFFD68E), // background
|
|
||||||
onPrimary: Colors.black, // foreground
|
onPrimary: Colors.black, // foreground
|
||||||
),
|
),
|
||||||
onPressed: () async => {
|
onPressed: () async => {
|
||||||
|
|
|
@ -5,7 +5,7 @@ description: A new Flutter project.
|
||||||
# pub.dev using `pub publish`. This is preferred for private packages.
|
# pub.dev using `pub publish`. This is preferred for private packages.
|
||||||
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||||
|
|
||||||
version: 0.0.1+4
|
version: 0.0.1+5
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.7.0 <3.0.0"
|
sdk: ">=2.7.0 <3.0.0"
|
||||||
|
|
Loading…
Reference in New Issue