Big improve on theme; Genral App Bar with settings menu; Option for delete all wallets on device

This commit is contained in:
poka 2021-01-16 03:32:41 +01:00
parent f8063f67f5
commit 63dfee0ebf
43 changed files with 307 additions and 38 deletions

View File

@ -11,7 +11,7 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application <application
android:name="io.flutter.app.FlutterApplication" android:name="io.flutter.app.FlutterApplication"
android:label="gecko"> android:label="Ğecko">
<!-- android:icon="@mipmap/ic_launcher"> --> <!-- android:icon="@mipmap/ic_launcher"> -->
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.6 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 KiB

BIN
assets/icon/gecko_final.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 242 KiB

After

Width:  |  Height:  |  Size: 230 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.5 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -93,8 +93,8 @@ class Gecko extends StatelessWidget {
return MaterialApp( return MaterialApp(
title: 'Ğecko', title: 'Ğecko',
theme: ThemeData( theme: ThemeData(
primaryColor: Color(0xffD28928), primaryColor: Color(0xffFFD58D),
accentColor: Color(0xffFFD68E), accentColor: Colors.grey[850],
textTheme: TextTheme( textTheme: TextTheme(
bodyText1: TextStyle(), bodyText1: TextStyle(),
bodyText2: TextStyle(), bodyText2: TextStyle(),

View File

@ -1,8 +1,9 @@
import 'package:gecko/ui/historyScreen.dart'; import 'package:gecko/ui/historyScreen.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'dart:typed_data';
import 'dart:ui'; import 'dart:ui';
import 'package:gecko/ui/myWallets/walletsHome.dart'; import 'package:gecko/ui/myWallets/walletsHome.dart';
import 'package:gecko/ui/settingsScreen.dart';
import 'package:package_info/package_info.dart';
//ignore: must_be_immutable //ignore: must_be_immutable
class HomeScreen extends StatefulWidget { class HomeScreen extends StatefulWidget {
@ -18,6 +19,14 @@ class HomeScreenState extends State<HomeScreen> {
int currentIndex = 0; int currentIndex = 0;
Widget currentScreen; Widget currentScreen;
String appName;
String version;
String buildNumber;
void initState() {
super.initState();
getAppVersion();
}
void onTabTapped(int index) { void onTabTapped(int index) {
setState(() { setState(() {
@ -25,11 +34,68 @@ class HomeScreenState extends State<HomeScreen> {
}); });
} }
Uint8List bytes = Uint8List(0);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
drawer: Drawer(
child: Column(
children: <Widget>[
Expanded(
child: ListView(padding: EdgeInsets.zero, children: <Widget>[
DrawerHeader(
child: Column(children: <Widget>[
SizedBox(height: 0),
Image(
image: AssetImage('assets/icon/gecko_final.png'),
height: 130),
]),
decoration: BoxDecoration(
color: Color(0xffD28928),
),
),
ListTile(
title: Text('Paramètres'),
onTap: () {
Navigator.pop(context);
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return SettingsScreen();
}),
);
},
),
ListTile(
title: Text('A propos'),
onTap: () {
// Update the state of the app.
// ...
},
),
])),
Container(
child: Align(
alignment: FractionalOffset.bottomCenter,
child: Text('Ğecko v${this.version}+${this.buildNumber}'))),
SizedBox(height: 20)
],
),
),
appBar: AppBar(
leading: Builder(
builder: (context) => IconButton(
icon: new Icon(Icons.menu, color: Colors.grey[850]),
onPressed: () => Scaffold.of(context).openDrawer(),
)),
title: Text('Ğecko', style: TextStyle(color: Colors.grey[850])),
actions: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 16),
child: Icon(Icons.search, color: Colors.grey[850]),
),
],
backgroundColor: Color(0xffFFD58D),
),
backgroundColor: Color(0xffF9F9F1), backgroundColor: Color(0xffF9F9F1),
body: SafeArea( body: SafeArea(
child: IndexedStack( child: IndexedStack(
@ -43,8 +109,8 @@ class HomeScreenState extends State<HomeScreen> {
), ),
), ),
bottomNavigationBar: BottomNavigationBar( bottomNavigationBar: BottomNavigationBar(
backgroundColor: Color(0xffFFD68E), backgroundColor: Color(0xffFFD58D),
fixedColor: Color(0xff855F2D), fixedColor: Colors.grey[850],
unselectedItemColor: Color(0xffBD935C), unselectedItemColor: Color(0xffBD935C),
type: BottomNavigationBarType.fixed, type: BottomNavigationBarType.fixed,
onTap: onTabTapped, onTap: onTabTapped,
@ -63,4 +129,14 @@ class HomeScreenState extends State<HomeScreen> {
), ),
); );
} }
Future getAppVersion() async {
PackageInfo packageInfo = await PackageInfo.fromPlatform();
this.appName = packageInfo.appName;
this.version = packageInfo.version;
this.buildNumber = packageInfo.buildNumber;
print(this.appName);
setState(() {});
}
} }

View File

@ -36,7 +36,7 @@ class ChangePinScreenState extends State<ChangePinScreen> {
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
title: SizedBox( title: SizedBox(
height: 25, height: 22,
child: Text(widget.walletName), child: Text(widget.walletName),
)), )),
body: Center( body: Center(
@ -44,7 +44,7 @@ class ChangePinScreenState extends State<ChangePinScreen> {
child: Column(children: <Widget>[ child: Column(children: <Widget>[
SizedBox(height: 80), SizedBox(height: 80),
Text( Text(
'Veuillez tapper votre code secret pour en générer un nouveau :', 'Choisissez un code secret autogénéré :',
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 17.0, fontSize: 17.0,

View File

@ -53,7 +53,7 @@ class ConfirmStoreWalletState extends State<ConfirmStoreWallet> {
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
title: SizedBox( title: SizedBox(
height: 25, height: 22,
child: Text('Confirmez ce portefeuille'), child: Text('Confirmez ce portefeuille'),
)), )),
body: Center( body: Center(

View File

@ -39,7 +39,7 @@ class GenerateWalletsState extends State<GenerateWalletsScreen> {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: SizedBox( title: SizedBox(
height: 25, height: 22,
child: Text('Générer un portefeuille'), child: Text('Générer un portefeuille'),
)), )),
floatingActionButton: Container( floatingActionButton: Container(
@ -54,7 +54,10 @@ class GenerateWalletsState extends State<GenerateWalletsScreen> {
// onTabTapped(0); // onTabTapped(0);
// } // }
child: Container( child: Container(
height: 40.0, width: 40.0, child: Icon(Icons.replay)), height: 40.0,
width: 40.0,
child: Icon(Icons.replay, color: Colors.grey[850]),
),
backgroundColor: Color( backgroundColor: Color(
0xffEFEFBF), //Color(0xffFFD68E), //Color.fromARGB(500, 204, 255, 255), 0xffEFEFBF), //Color(0xffFFD68E), //Color.fromARGB(500, 204, 255, 255),
))), ))),

View File

@ -22,6 +22,7 @@ class WalletOptionsState extends State<WalletOptions> {
Directory appPath; Directory appPath;
TextEditingController _pubkey = new TextEditingController(); TextEditingController _pubkey = new TextEditingController();
TextEditingController _enterPin = new TextEditingController(); TextEditingController _enterPin = new TextEditingController();
TextEditingController _newWalletName = new TextEditingController();
final formKey = GlobalKey<FormState>(); final formKey = GlobalKey<FormState>();
bool hasError = false; bool hasError = false;
String validPin = 'NO PIN'; String validPin = 'NO PIN';
@ -44,7 +45,7 @@ class WalletOptionsState extends State<WalletOptions> {
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
title: SizedBox( title: SizedBox(
height: 25, height: 22,
child: Text(widget.walletName), child: Text(widget.walletName),
)), )),
body: Center( body: Center(
@ -83,18 +84,11 @@ class WalletOptionsState extends State<WalletOptions> {
0xffFFD68E), //Color(0xffFFD68E), // background 0xffFFD68E), //Color(0xffFFD68E), // background
onPrimary: Colors.black, // foreground onPrimary: Colors.black, // foreground
), ),
onPressed: () { onPressed: () =>
// changePin(widget.walletName, this.walletPin); _renameWalletAlerte().then((_) {
Navigator.push( setState(() {});
context,
MaterialPageRoute(builder: (context) {
return ChangePinScreen(
walletName: widget.walletName,
oldPin: this.walletPin);
}), }),
); child: Text('Renommer ce portefeuille',
},
child: Text('Changer mon code secret',
style: TextStyle(fontSize: 20)))))), style: TextStyle(fontSize: 20)))))),
SizedBox(height: 30), SizedBox(height: 30),
SizedBox( SizedBox(
@ -102,13 +96,37 @@ class WalletOptionsState extends State<WalletOptions> {
width: 300, width: 300,
child: ElevatedButton( child: ElevatedButton(
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
elevation: 6, elevation: 5,
primary: primary: Color(
Colors.red, //Color(0xffFFD68E), // background 0xffFFD68E), //Color(0xffFFD68E), // background
onPrimary: Colors.black, // foreground onPrimary: Colors.black, // foreground
), ),
onPressed: () { onPressed: () {
deleteWallet(widget.walletName); // changePin(widget.walletName, this.walletPin);
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return ChangePinScreen(
walletName: widget.walletName,
oldPin: this.walletPin);
}),
);
},
child: Text('Changer mon code secret',
style: TextStyle(fontSize: 20)))),
SizedBox(height: 30),
SizedBox(
height: 50,
width: 300,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
elevation: 6,
primary: Colors
.redAccent, //Color(0xffFFD68E), // background
onPrimary: Colors.black, // foreground
),
onPressed: () {
_deleteWallet(widget.walletName);
}, },
child: Text('Supprimer ce portefeuille', child: Text('Supprimer ce portefeuille',
style: TextStyle(fontSize: 20)))), style: TextStyle(fontSize: 20)))),
@ -185,7 +203,7 @@ class WalletOptionsState extends State<WalletOptions> {
onCompleted: (_pin) async { onCompleted: (_pin) async {
print("Completed"); print("Completed");
final resultWallet = final resultWallet =
await readLocalWallet(_pin.toUpperCase()); await _readLocalWallet(_pin.toUpperCase());
if (resultWallet == 'bad') { if (resultWallet == 'bad') {
errorController.add(ErrorAnimationType errorController.add(ErrorAnimationType
.shake); // Triggering error shake animation .shake); // Triggering error shake animation
@ -216,7 +234,7 @@ class WalletOptionsState extends State<WalletOptions> {
])))); ]))));
} }
Future getPubkeyFromDewif(_dewif, _pin) async { Future _getPubkeyFromDewif(_dewif, _pin) async {
String _pubkey; String _pubkey;
RegExp regExp = new RegExp( RegExp regExp = new RegExp(
r'^[A-Z0-9]+$', r'^[A-Z0-9]+$',
@ -250,14 +268,14 @@ class WalletOptionsState extends State<WalletOptions> {
} }
} }
Future readLocalWallet(String _pin) async { Future _readLocalWallet(String _pin) async {
// print(pin); // print(pin);
try { try {
final file = await _localWallet(widget.walletName); final file = await _localWallet(widget.walletName);
String _localDewif = await file.readAsString(); String _localDewif = await file.readAsString();
String _localPubkey; String _localPubkey;
if ((_localPubkey = await getPubkeyFromDewif(_localDewif, _pin)) != if ((_localPubkey = await _getPubkeyFromDewif(_localDewif, _pin)) !=
'false') { 'false') {
setState(() { setState(() {
this._pubkey.text = _localPubkey; this._pubkey.text = _localPubkey;
@ -276,7 +294,54 @@ class WalletOptionsState extends State<WalletOptions> {
} }
} }
Future<int> deleteWallet(_name) async { Future _renameWallet(_newName) async {
final appPath = await _localPath;
final _walletFile = Directory('$appPath/wallets/${widget.walletName}');
try {
_walletFile.rename('$appPath/wallets/$_newName');
} catch (e) {
print('ERREUR lors du renommage du wallet: $e');
}
}
Future<bool> _renameWalletAlerte() async {
return showDialog<bool>(
context: context,
barrierDismissible: true, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: Text('Choisissez un nouveau nom pour ce portefeuille'),
content: SingleChildScrollView(
child: ListBody(
children: <Widget>[
TextField(
controller: this._newWalletName,
maxLines: 1,
textAlign: TextAlign.center,
decoration: InputDecoration(),
style: TextStyle(
fontSize: 14.0,
color: Colors.black,
fontWeight: FontWeight.bold)),
],
),
),
actions: <Widget>[
TextButton(
child: Text("Valider"),
onPressed: () {
_renameWallet(this._newWalletName.text);
Navigator.pop(context, true);
},
),
],
);
},
);
}
Future<int> _deleteWallet(_name) async {
try { try {
final appPath = await _localPath; final appPath = await _localPath;
final _walletFile = Directory('$appPath/wallets/$_name'); final _walletFile = Directory('$appPath/wallets/$_name');

View File

@ -63,7 +63,8 @@ class WalletsHomeState extends State<WalletsHome> {
child: Container( child: Container(
height: 40.0, height: 40.0,
width: 40.0, width: 40.0,
child: Icon(Icons.person_add_alt_1_rounded)), child: Icon(Icons.person_add_alt_1_rounded,
color: Colors.grey[850])),
backgroundColor: Color(0xffEFEFBF))))), backgroundColor: Color(0xffEFEFBF))))),
body: SafeArea( body: SafeArea(
child: Column(children: <Widget>[ child: Column(children: <Widget>[

116
lib/ui/settingsScreen.dart Normal file
View File

@ -0,0 +1,116 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:dubp/dubp.dart';
import 'dart:io';
import 'dart:async';
import 'package:path_provider/path_provider.dart';
class SettingsScreen extends StatefulWidget {
const SettingsScreen({Key keyGenWallet}) : super(key: keyGenWallet);
@override
_SettingsScreenState createState() => _SettingsScreenState();
}
class _SettingsScreenState extends State<SettingsScreen> {
void initState() {
super.initState();
}
String generatedMnemonic;
bool walletIsGenerated = false;
NewWallet actualWallet;
String newWalletName;
bool hasError = false;
String validPin = 'NO PIN';
String currentText = "";
var pinColor = Colors.grey[300];
Directory appPath;
@override
Widget build(BuildContext context) {
// getAppDirectory();
return Scaffold(
appBar: AppBar(
title: SizedBox(
height: 22,
child: Text('Paramètres'),
)),
body: Column(children: <Widget>[
SizedBox(height: 20),
Expanded(
child: Align(
alignment: Alignment.bottomCenter,
child: SizedBox(
height: 100,
width: 1000,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
elevation: 5,
primary: Colors
.redAccent, //Color(0xffFFD68E), // background
onPrimary: Colors.black, // foreground
),
onPressed: () => {
print('Suppression de tous les wallets'),
_deleteWallet()
},
child: Text(
"EFFACER TOUS MES PORTEFEUILLES, LE TEMPS DE L'ALPHA",
style: TextStyle(fontSize: 20)))))),
SizedBox(height: 50),
]));
}
Future<int> _deleteWallet() async {
try {
final appPath = await _localPath;
final _walletsFolder = Directory('$appPath/wallets');
print('DELETE THAT ?: $_walletsFolder');
final bool _answer = await _confirmDeletingWallets();
if (_answer) {
_walletsFolder.deleteSync(recursive: true);
_walletsFolder.createSync();
Navigator.pop(context);
}
return 0;
} catch (e) {
return 1;
}
}
Future<bool> _confirmDeletingWallets() async {
return showDialog<bool>(
context: context,
barrierDismissible: true, // user must tap button!
builder: (BuildContext context) {
return AlertDialog(
title: Text(
'Êtes-vous sûr de vouloir supprimer tous vos portefeuilles ?'),
content: SingleChildScrollView(child: Text('')),
actions: <Widget>[
TextButton(
child: Text("Non"),
onPressed: () {
Navigator.pop(context, false);
},
),
TextButton(
child: Text("Oui"),
onPressed: () {
Navigator.pop(context, true);
},
),
],
);
},
);
}
Future<String> get _localPath async {
final directory = await getApplicationDocumentsDirectory();
return directory.path;
}
}

View File

@ -318,7 +318,7 @@ packages:
source: hosted source: hosted
version: "0.4.5" version: "0.4.5"
package_info: package_info:
dependency: transitive dependency: "direct main"
description: description:
name: package_info name: package_info
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"

View File

@ -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.0+11 version: 0.0.0+13
environment: environment:
sdk: ">=2.7.0 <3.0.0" sdk: ">=2.7.0 <3.0.0"
@ -28,12 +28,13 @@ dependencies:
pin_code_fields: ^6.0.2 pin_code_fields: ^6.0.2
http: ^0.12.2 http: ^0.12.2
super_tooltip: ^0.9.6 super_tooltip: ^0.9.6
package_info: ^0.4.3+2
flutter_icons: flutter_icons:
android: "ic_launcher" android: "ic_launcher"
ios: true ios: true
image_path: "assets/icon/gecko5bduniter2.png" image_path: "assets/icon/gecko_final.png"
cupertino_icons: ^1.0.0 cupertino_icons: ^1.0.0
dev_dependencies: dev_dependencies:
@ -47,3 +48,5 @@ flutter:
assets: assets:
- images/ - images/
- config/ - config/
- assets/icon/gecko_final.png
- assets/

5
scripts/generateIcon.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
flutter pub run flutter_launcher_icons:main
exit 0