Big work in progress in My wallet tab;
This commit is contained in:
parent
60c9d00c61
commit
056198587d
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:gecko/ui/myWallets.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:dubp/dubp.dart';
|
import 'package:dubp/dubp.dart';
|
||||||
|
@ -33,9 +34,78 @@ class _GenerateWalletState extends State<GenerateWalletScreen> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SafeArea(
|
return Scaffold(
|
||||||
|
floatingActionButton: Container(
|
||||||
|
height: 80.0,
|
||||||
|
width: 80.0,
|
||||||
|
child: FittedBox(
|
||||||
|
child: FloatingActionButton(
|
||||||
|
heroTag: "buttonGenerateWallet",
|
||||||
|
onPressed: () async {
|
||||||
|
await generateMnemonic();
|
||||||
|
// print(resultScan);
|
||||||
|
// if (resultScan != 'false') {
|
||||||
|
// onTabTapped(0);
|
||||||
|
// }
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
height: 40.0,
|
||||||
|
width: 40.0,
|
||||||
|
child: Icon(Icons.person_add_alt_1_rounded)),
|
||||||
|
backgroundColor: Color(
|
||||||
|
0xffEFEFBF), //Color(0xffFFD68E), //Color.fromARGB(500, 204, 255, 255),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: SafeArea(
|
||||||
child: Column(children: <Widget>[
|
child: Column(children: <Widget>[
|
||||||
|
FutureBuilder<bool>(
|
||||||
|
future: checkIfWalletExist(),
|
||||||
|
builder: (context, fSnapshot) {
|
||||||
|
if (fSnapshot.hasData)
|
||||||
|
return Visibility(
|
||||||
|
visible: (!fSnapshot.data && !walletIsGenerated),
|
||||||
|
child: Column(children: <Widget>[
|
||||||
|
SizedBox(height: 80),
|
||||||
|
Center(
|
||||||
|
child: Text(
|
||||||
|
"Vous n'avez encore généré aucun portefeuille.",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20, fontWeight: FontWeight.w500),
|
||||||
|
textAlign: TextAlign.center)),
|
||||||
|
SizedBox(height: 50),
|
||||||
|
RaisedButton(
|
||||||
|
color: Color(0xffFFD68E),
|
||||||
|
onPressed: () => generateMnemonic(),
|
||||||
|
child: Text('Générer un portefeuille',
|
||||||
|
style: TextStyle(fontSize: 20))),
|
||||||
|
SizedBox(height: 15),
|
||||||
|
Center(
|
||||||
|
child: Text("ou",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20, fontWeight: FontWeight.w500),
|
||||||
|
textAlign: TextAlign.center)),
|
||||||
|
SizedBox(height: 15),
|
||||||
|
RaisedButton(
|
||||||
|
color: Color(0xffFFD68E),
|
||||||
|
onPressed: () => importWallet(),
|
||||||
|
child: Text('Importer un portefeuille existant',
|
||||||
|
style: TextStyle(fontSize: 20))),
|
||||||
|
])); // WelcomeWalletScreen());
|
||||||
|
return Center(child: CircularProgressIndicator());
|
||||||
|
}),
|
||||||
|
FutureBuilder<bool>(
|
||||||
|
future: checkIfWalletExist(),
|
||||||
|
builder: (context, fSnapshot) {
|
||||||
|
if (fSnapshot.hasData)
|
||||||
|
return Visibility(
|
||||||
|
visible: fSnapshot.data, child: MyWalletsScreen());
|
||||||
|
return Center(child: CircularProgressIndicator());
|
||||||
|
}),
|
||||||
SizedBox(height: 8),
|
SizedBox(height: 8),
|
||||||
|
Visibility(
|
||||||
|
visible: walletIsGenerated,
|
||||||
|
child: Column(children: <Widget>[
|
||||||
Text(
|
Text(
|
||||||
'Clé publique:',
|
'Clé publique:',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
@ -55,7 +125,7 @@ class _GenerateWalletState extends State<GenerateWalletScreen> {
|
||||||
fontWeight: FontWeight.bold)),
|
fontWeight: FontWeight.bold)),
|
||||||
SizedBox(height: 8),
|
SizedBox(height: 8),
|
||||||
Text(
|
Text(
|
||||||
'Phrase secrète:',
|
'Phrase de restauration:',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 15.0,
|
fontSize: 15.0,
|
||||||
color: Colors.grey[600],
|
color: Colors.grey[600],
|
||||||
|
@ -75,7 +145,7 @@ class _GenerateWalletState extends State<GenerateWalletScreen> {
|
||||||
fontWeight: FontWeight.w400)),
|
fontWeight: FontWeight.w400)),
|
||||||
SizedBox(height: 8),
|
SizedBox(height: 8),
|
||||||
Text(
|
Text(
|
||||||
'Code PIN:',
|
'Code secret:',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 15.0,
|
fontSize: 15.0,
|
||||||
color: Colors.grey[600],
|
color: Colors.grey[600],
|
||||||
|
@ -92,15 +162,8 @@ class _GenerateWalletState extends State<GenerateWalletScreen> {
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
fontWeight: FontWeight.bold)),
|
fontWeight: FontWeight.bold)),
|
||||||
SizedBox(height: 12),
|
SizedBox(height: 12),
|
||||||
|
// Expanded(child: Align(alignment: Alignment.bottomCenter)),
|
||||||
new RaisedButton(
|
new RaisedButton(
|
||||||
color: Color(0xffFFD68E),
|
|
||||||
onPressed: () => generateMnemonic(),
|
|
||||||
child: Text('Générer un wallet', style: TextStyle(fontSize: 20))),
|
|
||||||
SizedBox(height: 30),
|
|
||||||
Expanded(
|
|
||||||
child: Align(
|
|
||||||
alignment: Alignment.bottomCenter,
|
|
||||||
child: new RaisedButton(
|
|
||||||
color: Color(0xffFFD68E),
|
color: Color(0xffFFD68E),
|
||||||
onPressed: walletIsGenerated
|
onPressed: walletIsGenerated
|
||||||
? () {
|
? () {
|
||||||
|
@ -112,6 +175,8 @@ class _GenerateWalletState extends State<GenerateWalletScreen> {
|
||||||
generatedWallet: this.actualWallet);
|
generatedWallet: this.actualWallet);
|
||||||
}),
|
}),
|
||||||
).then((value) => setState(() {
|
).then((value) => setState(() {
|
||||||
|
print(
|
||||||
|
'TODO: Fix error null boolean ?'); //TODO: Fix error null boolean
|
||||||
if (value) {
|
if (value) {
|
||||||
_pin.clear();
|
_pin.clear();
|
||||||
_mnemonicController.clear();
|
_mnemonicController.clear();
|
||||||
|
@ -124,9 +189,21 @@ class _GenerateWalletState extends State<GenerateWalletScreen> {
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
child: Text('Enregistrer ce wallet',
|
child: Text('Enregistrer ce wallet',
|
||||||
style: TextStyle(fontSize: 20))))),
|
style: TextStyle(fontSize: 20))),
|
||||||
SizedBox(height: 15)
|
SizedBox(height: 20)
|
||||||
]));
|
]),
|
||||||
|
// Visibility(
|
||||||
|
// visible: walletIsGenerated,
|
||||||
|
// child: Text("""
|
||||||
|
// Notez bien votre phrase de restauration sur un papier ou imprimez le, ainsi que votre code secret, que vous devrez retenir.
|
||||||
|
// Pour payer ou manipuler votre wallet, seul votre code secret vous sera nécessaire.
|
||||||
|
// Votre phrase de restauration quant à elle, constitué de 12 mots, vous permet de restaurer votre wallet sur un autre appareil. Gardez la précieusement, en lieu sûr.
|
||||||
|
// """,
|
||||||
|
// style: TextStyle(fontSize: 15, fontWeight: FontWeight.bold),
|
||||||
|
// textAlign: TextAlign.center),
|
||||||
|
// )
|
||||||
|
)
|
||||||
|
])));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future generateMnemonic() async {
|
Future generateMnemonic() async {
|
||||||
|
@ -144,13 +221,16 @@ class _GenerateWalletState extends State<GenerateWalletScreen> {
|
||||||
}
|
}
|
||||||
this.actualWallet = await generateWallet(this.generatedMnemonic);
|
this.actualWallet = await generateWallet(this.generatedMnemonic);
|
||||||
this.walletIsGenerated = true;
|
this.walletIsGenerated = true;
|
||||||
|
// await checkIfWalletExist();
|
||||||
return this.generatedMnemonic;
|
return this.generatedMnemonic;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future generateWallet(generatedMnemonic) async {
|
Future generateWallet(generatedMnemonic) async {
|
||||||
try {
|
try {
|
||||||
this.actualWallet = await DubpRust.genWalletFromMnemonic(
|
this.actualWallet = await DubpRust.genWalletFromMnemonic(
|
||||||
language: Language.french, mnemonic: generatedMnemonic);
|
language: Language.french,
|
||||||
|
mnemonic: generatedMnemonic,
|
||||||
|
secretCodeType: SecretCodeType.letters);
|
||||||
} catch (e, stack) {
|
} catch (e, stack) {
|
||||||
print(e);
|
print(e);
|
||||||
if (kReleaseMode) {
|
if (kReleaseMode) {
|
||||||
|
@ -169,8 +249,50 @@ class _GenerateWalletState extends State<GenerateWalletScreen> {
|
||||||
|
|
||||||
return actualWallet;
|
return actualWallet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> checkIfWalletExist() async {
|
||||||
|
// deleteWallet();
|
||||||
|
final _walletFile = await _localWallet;
|
||||||
|
// final isExist = File(_walletFile.toString()).existsSync();
|
||||||
|
print(_walletFile.path);
|
||||||
|
final isExist = await File(_walletFile.path).exists();
|
||||||
|
print('Wallet existe ? : ' + isExist.toString());
|
||||||
|
print('Is wallet generated ? : ' + walletIsGenerated.toString());
|
||||||
|
if (isExist == true) {
|
||||||
|
print('Un wallet existe !');
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future importWallet() async {}
|
||||||
|
|
||||||
|
Future<int> deleteWallet() async {
|
||||||
|
try {
|
||||||
|
final _walletFile = await _localWallet;
|
||||||
|
|
||||||
|
await _walletFile.delete();
|
||||||
|
} catch (e) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> get _localPath async {
|
||||||
|
final directory = await getApplicationDocumentsDirectory();
|
||||||
|
|
||||||
|
return directory.path;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<File> get _localWallet async {
|
||||||
|
// /data/user/0/com.example.gecko/app_flutter/wallet.dewif
|
||||||
|
final path = await _localPath;
|
||||||
|
return File('$path/wallet.dewif');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* *** ValidStoreWalletScreen Class *** */
|
||||||
|
|
||||||
class ValidStoreWalletScreen extends StatefulWidget {
|
class ValidStoreWalletScreen extends StatefulWidget {
|
||||||
final String generatedMnemonic;
|
final String generatedMnemonic;
|
||||||
final NewWallet generatedWallet;
|
final NewWallet generatedWallet;
|
||||||
|
@ -225,83 +347,14 @@ class _ValidStoreWalletScreen extends State<ValidStoreWalletScreen> {
|
||||||
fontWeight: FontWeight.bold)),
|
fontWeight: FontWeight.bold)),
|
||||||
new RaisedButton(
|
new RaisedButton(
|
||||||
color: Color(0xffFFD68E),
|
color: Color(0xffFFD68E),
|
||||||
onPressed: () => storeWallet(widget.generatedWallet),
|
onPressed: () => storeWallet(),
|
||||||
child: Text('Confirmer', style: TextStyle(fontSize: 20))),
|
child: Text('Confirmer', style: TextStyle(fontSize: 20))),
|
||||||
// Form(
|
|
||||||
// child: Padding(
|
|
||||||
// padding:
|
|
||||||
// const EdgeInsets.symmetric(vertical: 8.0, horizontal: 30),
|
|
||||||
// child: PinCodeTextField(
|
|
||||||
// appContext: context,
|
|
||||||
// pastedTextStyle: TextStyle(
|
|
||||||
// color: Colors.green.shade600,
|
|
||||||
// fontWeight: FontWeight.bold,
|
|
||||||
// ),
|
|
||||||
// length: 6,
|
|
||||||
// obscureText: false,
|
|
||||||
// obscuringCharacter: '*',
|
|
||||||
// animationType: AnimationType.fade,
|
|
||||||
// validator: (v) {
|
|
||||||
// if (v.length < 6) {
|
|
||||||
// return "Votre code PIN fait 6 caractères";
|
|
||||||
// } else {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// pinTheme: PinTheme(
|
|
||||||
// shape: PinCodeFieldShape.box,
|
|
||||||
// borderRadius: BorderRadius.circular(5),
|
|
||||||
// fieldHeight: 60,
|
|
||||||
// fieldWidth: 50,
|
|
||||||
// activeFillColor: hasError ? Colors.orange : Colors.white,
|
|
||||||
// ),
|
|
||||||
// cursorColor: Colors.black,
|
|
||||||
// animationDuration: Duration(milliseconds: 300),
|
|
||||||
// textStyle: TextStyle(fontSize: 20, height: 1.6),
|
|
||||||
// backgroundColor: pinColor,
|
|
||||||
// enableActiveFill: false,
|
|
||||||
// errorAnimationController: errorController,
|
|
||||||
// controller: _enterPin,
|
|
||||||
// keyboardType: TextInputType.text,
|
|
||||||
// boxShadows: [
|
|
||||||
// BoxShadow(
|
|
||||||
// offset: Offset(0, 1),
|
|
||||||
// color: Colors.black12,
|
|
||||||
// blurRadius: 10,
|
|
||||||
// )
|
|
||||||
// ],
|
|
||||||
// onCompleted: (v) async {
|
|
||||||
// print("Completed");
|
|
||||||
// final resultWallet = await readLocalWallet(v.toUpperCase());
|
|
||||||
// if (resultWallet == 'bad') {
|
|
||||||
// errorController.add(ErrorAnimationType
|
|
||||||
// .shake); // Triggering error shake animation
|
|
||||||
// setState(() {
|
|
||||||
// hasError = true;
|
|
||||||
// pinColor = Colors.red[200];
|
|
||||||
// });
|
|
||||||
// } else {
|
|
||||||
// setState(() {
|
|
||||||
// pinColor = Colors.green[200];
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// onChanged: (value) {
|
|
||||||
// if (pinColor != Colors.grey[300]) {
|
|
||||||
// setState(() {
|
|
||||||
// pinColor = Colors.grey[300];
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// print(value);
|
|
||||||
// },
|
|
||||||
// )),
|
|
||||||
// )
|
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future storeWallet(actualWallet) async {
|
Future storeWallet() async {
|
||||||
final walletFile = await _localWallet;
|
final walletFile = await _localWallet;
|
||||||
walletFile.writeAsString('${widget.generatedWallet.dewif}');
|
walletFile.writeAsString('${widget.generatedWallet.dewif}');
|
||||||
_pin.clear();
|
_pin.clear();
|
||||||
|
|
|
@ -63,7 +63,30 @@ class HistoryScreenState extends State<HistoryScreen> {
|
||||||
print('Build pubkey : ' + pubkey);
|
print('Build pubkey : ' + pubkey);
|
||||||
print('Build this.pubkey : ' + this.pubkey);
|
print('Build this.pubkey : ' + this.pubkey);
|
||||||
print('isBuilding: ' + isBuilding.toString());
|
print('isBuilding: ' + isBuilding.toString());
|
||||||
return Column(children: <Widget>[
|
return Scaffold(
|
||||||
|
floatingActionButton: Container(
|
||||||
|
height: 80.0,
|
||||||
|
width: 80.0,
|
||||||
|
child: FittedBox(
|
||||||
|
child: FloatingActionButton(
|
||||||
|
heroTag: "buttonScan",
|
||||||
|
onPressed: () async {
|
||||||
|
await scan();
|
||||||
|
// print(resultScan);
|
||||||
|
// if (resultScan != 'false') {
|
||||||
|
// onTabTapped(0);
|
||||||
|
// }
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
height: 40.0,
|
||||||
|
width: 40.0,
|
||||||
|
child: Image.asset('images/scanner.png')),
|
||||||
|
backgroundColor: Color(
|
||||||
|
0xffEFEFBF), //Color(0xffFFD68E), //Color.fromARGB(500, 204, 255, 255),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: Column(children: <Widget>[
|
||||||
SizedBox(height: 8),
|
SizedBox(height: 8),
|
||||||
TextField(
|
TextField(
|
||||||
// Entrée de la pubkey
|
// Entrée de la pubkey
|
||||||
|
@ -78,7 +101,8 @@ class HistoryScreenState extends State<HistoryScreen> {
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: 'Tappez/Collez une clé publique, ou scannez',
|
hintText: 'Tappez/Collez une clé publique, ou scannez',
|
||||||
hintStyle: TextStyle(fontSize: 14),
|
hintStyle: TextStyle(fontSize: 14),
|
||||||
contentPadding: EdgeInsets.symmetric(horizontal: 7, vertical: 15),
|
contentPadding:
|
||||||
|
EdgeInsets.symmetric(horizontal: 7, vertical: 15),
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
focusedBorder: InputBorder.none,
|
focusedBorder: InputBorder.none,
|
||||||
enabledBorder: InputBorder.none,
|
enabledBorder: InputBorder.none,
|
||||||
|
@ -87,7 +111,7 @@ class HistoryScreenState extends State<HistoryScreen> {
|
||||||
),
|
),
|
||||||
style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.bold)),
|
style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.bold)),
|
||||||
historyQuery(),
|
historyQuery(),
|
||||||
]);
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
historyQuery() {
|
historyQuery() {
|
||||||
|
|
|
@ -4,8 +4,6 @@ import 'package:flutter/material.dart';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'dart:ui';
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'myWallets.dart';
|
|
||||||
|
|
||||||
//ignore: must_be_immutable
|
//ignore: must_be_immutable
|
||||||
class HomeScreen extends StatefulWidget {
|
class HomeScreen extends StatefulWidget {
|
||||||
HomeScreen({this.screens});
|
HomeScreen({this.screens});
|
||||||
|
@ -41,31 +39,9 @@ class HomeScreenState extends State<HomeScreen> {
|
||||||
keyHistory: _keyHistory,
|
keyHistory: _keyHistory,
|
||||||
),
|
),
|
||||||
GenerateWalletScreen(),
|
GenerateWalletScreen(),
|
||||||
MyWalletsScreen(),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
floatingActionButton: Container(
|
|
||||||
height: 80.0,
|
|
||||||
width: 80.0,
|
|
||||||
child: FittedBox(
|
|
||||||
child: FloatingActionButton(
|
|
||||||
onPressed: () async {
|
|
||||||
final resultScan = await _keyHistory.currentState.scan();
|
|
||||||
print(resultScan);
|
|
||||||
if (resultScan != 'false') {
|
|
||||||
onTabTapped(0);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Container(
|
|
||||||
height: 40.0,
|
|
||||||
width: 40.0,
|
|
||||||
child: Image.asset('images/scanner.png')),
|
|
||||||
backgroundColor: Color(
|
|
||||||
0xffEFEFBF), //Color(0xffFFD68E), //Color.fromARGB(500, 204, 255, 255),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
bottomNavigationBar: BottomNavigationBar(
|
bottomNavigationBar: BottomNavigationBar(
|
||||||
backgroundColor: Color(0xffFFD68E),
|
backgroundColor: Color(0xffFFD68E),
|
||||||
fixedColor: Color(0xff855F2D),
|
fixedColor: Color(0xff855F2D),
|
||||||
|
@ -75,16 +51,13 @@ class HomeScreenState extends State<HomeScreen> {
|
||||||
currentIndex: currentIndex,
|
currentIndex: currentIndex,
|
||||||
items: [
|
items: [
|
||||||
BottomNavigationBarItem(
|
BottomNavigationBarItem(
|
||||||
icon: new Icon(Icons.format_list_bulleted),
|
icon: new Icon(Icons
|
||||||
|
.format_list_bulleted), //Icons.person_add_alt_1_rounded //Icons.lock
|
||||||
label: 'Accueil',
|
label: 'Accueil',
|
||||||
),
|
),
|
||||||
BottomNavigationBarItem(
|
|
||||||
icon: new Icon(Icons.person_add_alt_1_rounded),
|
|
||||||
label: 'Générer un wallet',
|
|
||||||
),
|
|
||||||
BottomNavigationBarItem(
|
BottomNavigationBarItem(
|
||||||
icon: new Icon(Icons.lock),
|
icon: new Icon(Icons.lock),
|
||||||
label: 'Mes wallets',
|
label: 'Mes portefeuilles',
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -32,7 +32,7 @@ flutter_icons:
|
||||||
android: "ic_launcher"
|
android: "ic_launcher"
|
||||||
ios: true
|
ios: true
|
||||||
image_path: "assets/icon/gecko5bduniter2.png"
|
image_path: "assets/icon/gecko5bduniter2.png"
|
||||||
# cupertino_icons: ^1.0.0
|
cupertino_icons: ^1.0.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
Loading…
Reference in New Issue