Peer-programming with Hugo: Copy pubkeys on tap and display notif for it. Improve pubkeys fonts

This commit is contained in:
poka 2021-02-06 08:31:14 +01:00
parent 3bf3f85b9c
commit d80b1190ae
10 changed files with 247 additions and 213 deletions

View File

@ -28,6 +28,8 @@ Future<void> main() async {
await _homeProvider.createDefaultAvatar(); await _homeProvider.createDefaultAvatar();
appVersion = await _homeProvider.getAppVersion(); appVersion = await _homeProvider.getAppVersion();
prefs = await SharedPreferences.getInstance(); prefs = await SharedPreferences.getInstance();
final HiveStore _store =
await HiveStore.open(path: '${appPath.path}/gqlCache');
String _randomEndpoint; String _randomEndpoint;
int i = 0; int i = 0;
@ -52,21 +54,20 @@ Future<void> main() async {
options.dsn = options.dsn =
'https://c09587b46eaa42e8b9fda28d838ed180@o496840.ingest.sentry.io/5572110'; 'https://c09587b46eaa42e8b9fda28d838ed180@o496840.ingest.sentry.io/5572110';
}, },
appRunner: () => runApp(Gecko(_randomEndpoint)), appRunner: () => runApp(Gecko(_randomEndpoint, _store)),
); );
} else { } else {
print('Debug mode enabled: No sentry alerte'); print('Debug mode enabled: No sentry alerte');
runApp(Gecko( runApp(Gecko(_randomEndpoint, _store));
_randomEndpoint,
));
} }
} }
// ignore: must_be_immutable // ignore: must_be_immutable
class Gecko extends StatelessWidget { class Gecko extends StatelessWidget {
Gecko(this.randomEndpoint); Gecko(this.randomEndpoint, this._store);
final String randomEndpoint; final String randomEndpoint;
final HiveStore _store;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -76,7 +77,7 @@ class Gecko extends StatelessWidget {
final _client = ValueNotifier( final _client = ValueNotifier(
GraphQLClient( GraphQLClient(
cache: GraphQLCache(store: null), cache: GraphQLCache(store: _store),
link: _httpLink, link: _httpLink,
), ),
); );

View File

@ -9,7 +9,6 @@ import 'dart:math';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
class HistoryProvider with ChangeNotifier { class HistoryProvider with ChangeNotifier {
// String pubkey = 'D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU'; // For debug
String pubkey = ''; String pubkey = '';
HistoryProvider(this.pubkey); HistoryProvider(this.pubkey);
final TextEditingController outputPubkey = new TextEditingController(); final TextEditingController outputPubkey = new TextEditingController();
@ -63,8 +62,10 @@ class HistoryProvider with ChangeNotifier {
return ''; return '';
} }
// Pi: D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU // For debug
// Boris: JE6mkuzSpT3ePciCPRTpuMT9fqPUVVLJz2618d33p7tn // Boris: JE6mkuzSpT3ePciCPRTpuMT9fqPUVVLJz2618d33p7tn
// Matograine portefeuille: 9p5nHsES6xujFR7pw2yGy4PLKKHgWsMvsDHaHF64Uj25 // Matograine portefeuille: 9p5nHsES6xujFR7pw2yGy4PLKKHgWsMvsDHaHF64Uj25.
// Lion simone: 78jhpprYkMNF6i5kQPXfkAVBpd2aqcpieNsXTSW4c21f
List parseHistory(txs, _pubkey) { List parseHistory(txs, _pubkey) {
// print(txs); // print(txs);
@ -162,7 +163,7 @@ class HistoryProvider with ChangeNotifier {
return opts; return opts;
} }
snackNode(context) { void snackNode(context) {
if (isFirstBuild) { if (isFirstBuild) {
String _message; String _message;
if (endPointGVA == 'HS') { if (endPointGVA == 'HS') {

View File

@ -26,11 +26,9 @@ class MyWalletsProvider with ChangeNotifier {
Future importWallet() async {} Future importWallet() async {}
Map getAllWalletsNames() { Map getAllWalletsNames() {
print(listWallets);
if (listWallets.isNotEmpty) { if (listWallets.isNotEmpty) {
listWallets.clear(); listWallets.clear();
} }
print(walletsDirectory.path);
// int i = 0; // int i = 0;
walletsDirectory walletsDirectory
@ -39,7 +37,6 @@ class MyWalletsProvider with ChangeNotifier {
String _name = wallet.path.split('/').last; String _name = wallet.path.split('/').last;
List _pubkeyList = File(wallet.path + '/pubkey').readAsLinesSync(); List _pubkeyList = File(wallet.path + '/pubkey').readAsLinesSync();
String _pubkey = _pubkeyList[0]; String _pubkey = _pubkeyList[0];
print("$_name: $_pubkey");
listWallets[_name] = _pubkey; listWallets[_name] = _pubkey;
// i++; // i++;

View File

@ -52,7 +52,6 @@ class WalletOptionsProvider with ChangeNotifier {
Future readLocalWallet(String _name, String _pin) async { Future readLocalWallet(String _name, String _pin) async {
isWalletUnlock = false; isWalletUnlock = false;
print('NOM: ' + _name);
try { try {
File _walletFile = File('${walletsDirectory.path}/$_name/wallet.dewif'); File _walletFile = File('${walletsDirectory.path}/$_name/wallet.dewif');
String _localDewif = await _walletFile.readAsString(); String _localDewif = await _walletFile.readAsString();
@ -204,9 +203,15 @@ class WalletOptionsProvider with ChangeNotifier {
final walletFile = File('${walletNameDirectory.path}/wallet.dewif'); final walletFile = File('${walletNameDirectory.path}/wallet.dewif');
walletFile.writeAsString('${_newWalletFile.dewif}'); walletFile.writeAsString('${_newWalletFile.dewif}');
Navigator.pop(context); Navigator.pop(context);
return _name; return _name;
} }
snackCopyKey(context) {
final snackBar = SnackBar(
content:
Text("Cette clé publique a été copié dans votre presse-papier."),
duration: Duration(seconds: 2));
Scaffold.of(context).showSnackBar(snackBar);
}
} }

View File

@ -34,6 +34,7 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
_historyProvider.snackNode(context); _historyProvider.snackNode(context);
}); });
return Scaffold( return Scaffold(
floatingActionButton: Container( floatingActionButton: Container(
height: 80.0, height: 80.0,
@ -78,16 +79,17 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
disabledBorder: InputBorder.none, disabledBorder: InputBorder.none,
), ),
style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.bold)), style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.bold)),
if (_historyProvider.pubkey != '') historyQuery(context), if (_historyProvider.pubkey != '')
historyQuery(context, _historyProvider),
])); ]));
} }
historyQuery(context) { Widget historyQuery(context, _historyProvider) {
print("I'M HERE 1");
_pubkeyFocus.unfocus(); _pubkeyFocus.unfocus();
HistoryProvider _historyProvider = Provider.of<HistoryProvider>(context); // HistoryProvider _historyProvider = Provider.of<HistoryProvider>(context);
CesiumPlusProvider _cesiumPlusProvider = CesiumPlusProvider _cesiumPlusProvider =
Provider.of<CesiumPlusProvider>(context); Provider.of<CesiumPlusProvider>(context);
print("I'M HERE 1");
return Expanded( return Expanded(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
@ -104,8 +106,10 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
), ),
builder: (QueryResult result, {fetchMore, refetch}) { builder: (QueryResult result, {fetchMore, refetch}) {
print("I'M HERE 2 !"); print("I'M HERE 2 !");
print(result.source.isEager);
if (result.isLoading && result.data == null) { if (result.isLoading && result.data == null) {
print("I'M HERE 3 !");
return const Center( return const Center(
child: CircularProgressIndicator(), child: CircularProgressIndicator(),
); );

View File

@ -59,7 +59,8 @@ class GenerateWalletsScreen extends StatelessWidget {
style: TextStyle( style: TextStyle(
fontSize: 14.0, fontSize: 14.0,
color: Colors.black, color: Colors.black,
fontWeight: FontWeight.bold)), fontWeight: FontWeight.bold,
fontFamily: 'Monospace')),
SizedBox(height: 8), SizedBox(height: 8),
toolTips(_toolTipSentence, 'Phrase de restauration:', toolTips(_toolTipSentence, 'Phrase de restauration:',
"Notez et gardez cette phrase précieusement sur un papier, elle vous servira à restaurer votre portefeuille sur un autre appareil"), "Notez et gardez cette phrase précieusement sur un papier, elle vous servira à restaurer votre portefeuille sur un autre appareil"),

View File

@ -7,6 +7,7 @@ import 'package:gecko/screens/myWallets/changePin.dart';
import 'dart:async'; import 'dart:async';
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:flutter/services.dart';
// ignore: must_be_immutable // ignore: must_be_immutable
class WalletOptions extends StatelessWidget with ChangeNotifier { class WalletOptions extends StatelessWidget with ChangeNotifier {
@ -15,7 +16,7 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
String walletName; String walletName;
StreamController<ErrorAnimationType> errorController; StreamController<ErrorAnimationType> errorController;
TextEditingController _enterPin = new TextEditingController(); TextEditingController _enterPin = TextEditingController();
final formKey = GlobalKey<FormState>(); final formKey = GlobalKey<FormState>();
bool hasError = false; bool hasError = false;
var pinColor = Color(0xffF9F9F1); var pinColor = Color(0xffF9F9F1);
@ -32,6 +33,7 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
Provider.of<MyWalletsProvider>(context); Provider.of<MyWalletsProvider>(context);
errorController = StreamController<ErrorAnimationType>(); errorController = StreamController<ErrorAnimationType>();
// _walletOptions.isWalletUnlock = false; // _walletOptions.isWalletUnlock = false;
return WillPopScope( return WillPopScope(
onWillPop: () { onWillPop: () {
_walletOptions.isWalletUnlock = false; _walletOptions.isWalletUnlock = false;
@ -50,8 +52,8 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
height: 22, height: 22,
child: Text(walletName), child: Text(walletName),
)), )),
body: Center( body: Builder(
child: SafeArea( builder: (ctx) => SafeArea(
child: Column(children: <Widget>[ child: Column(children: <Widget>[
Visibility( Visibility(
visible: _walletOptions.isWalletUnlock, visible: _walletOptions.isWalletUnlock,
@ -66,13 +68,20 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
fontWeight: FontWeight.w400), fontWeight: FontWeight.w400),
), ),
SizedBox(height: 15), SizedBox(height: 15),
Text( GestureDetector(
onTap: () {
Clipboard.setData(ClipboardData(
text: _walletOptions.pubkey.text));
_walletOptions.snackCopyKey(ctx);
},
child: Text(
_walletOptions.pubkey.text, _walletOptions.pubkey.text,
style: TextStyle( style: TextStyle(
fontSize: 14.0, fontSize: 14.0,
color: Colors.black, color: Colors.black,
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold,
), fontFamily: 'Monospace'),
)),
Expanded( Expanded(
child: Align( child: Align(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
@ -84,7 +93,8 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
elevation: 5, elevation: 5,
primary: Color( primary: Color(
0xffFFD68E), //Color(0xffFFD68E), // background 0xffFFD68E), //Color(0xffFFD68E), // background
onPrimary: Colors.black, // foreground onPrimary:
Colors.black, // foreground
), ),
onPressed: () => _walletOptions onPressed: () => _walletOptions
.renameWalletAlerte( .renameWalletAlerte(
@ -92,16 +102,21 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
.then((_result) { .then((_result) {
if (_result == true) { if (_result == true) {
WidgetsBinding.instance WidgetsBinding.instance
.addPostFrameCallback((_) { .addPostFrameCallback(
_myWalletProvider.listWallets = (_) {
_myWalletProvider
.listWallets =
_myWalletProvider _myWalletProvider
.getAllWalletsNames(); .getAllWalletsNames();
_myWalletProvider.rebuildWidget(); _myWalletProvider
.rebuildWidget();
}); });
} }
}), }),
child: Text('Renommer ce portefeuille', child: Text(
style: TextStyle(fontSize: 20)))))), 'Renommer ce portefeuille',
style: TextStyle(
fontSize: 20)))))),
SizedBox(height: 30), SizedBox(height: 30),
SizedBox( SizedBox(
height: 50, height: 50,
@ -140,9 +155,11 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
onPressed: () async { onPressed: () async {
await _walletOptions.deleteWallet( await _walletOptions.deleteWallet(
context, walletName); context, walletName);
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance
.addPostFrameCallback((_) {
_myWalletProvider.listWallets = _myWalletProvider.listWallets =
_myWalletProvider.getAllWalletsNames(); _myWalletProvider
.getAllWalletsNames();
_myWalletProvider.rebuildWidget(); _myWalletProvider.rebuildWidget();
}); });
}, },
@ -200,12 +217,15 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
borderRadius: BorderRadius.circular(5), borderRadius: BorderRadius.circular(5),
fieldHeight: 60, fieldHeight: 60,
fieldWidth: 50, fieldWidth: 50,
activeFillColor: activeFillColor: hasError
hasError ? Colors.orange : Colors.white, ? Colors.orange
: Colors.white,
), ),
cursorColor: Colors.black, cursorColor: Colors.black,
animationDuration: Duration(milliseconds: 300), animationDuration:
textStyle: TextStyle(fontSize: 20, height: 1.6), Duration(milliseconds: 300),
textStyle:
TextStyle(fontSize: 20, height: 1.6),
backgroundColor: pinColor, backgroundColor: pinColor,
enableActiveFill: false, enableActiveFill: false,
errorAnimationController: errorController, errorAnimationController: errorController,
@ -222,7 +242,8 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
print("Completed"); print("Completed");
final resultWallet = final resultWallet =
await _walletOptions.readLocalWallet( await _walletOptions.readLocalWallet(
this.walletName, _pin.toUpperCase()); this.walletName,
_pin.toUpperCase());
if (resultWallet == 'bad') { if (resultWallet == 'bad') {
errorController.add(ErrorAnimationType errorController.add(ErrorAnimationType
.shake); // Triggering error shake animation .shake); // Triggering error shake animation

View File

@ -13,7 +13,6 @@ class WalletsHome extends StatelessWidget {
Provider.of<MyWalletsProvider>(context); Provider.of<MyWalletsProvider>(context);
WalletOptionsProvider _walletOptions = WalletOptionsProvider _walletOptions =
Provider.of<WalletOptionsProvider>(context); Provider.of<WalletOptionsProvider>(context);
print('BUILD: WalletsHome');
_walletOptions.isWalletUnlock = false; _walletOptions.isWalletUnlock = false;
myWalletProvider.listWallets = myWalletProvider.getAllWalletsNames(); myWalletProvider.listWallets = myWalletProvider.getAllWalletsNames();
final bool isWalletsExists = myWalletProvider.checkIfWalletExist(); final bool isWalletsExists = myWalletProvider.checkIfWalletExist();
@ -97,8 +96,6 @@ class WalletsHome extends StatelessWidget {
List _listWallets = []; List _listWallets = [];
myWalletProvider.listWallets.forEach((_name, _pubkey) { myWalletProvider.listWallets.forEach((_name, _pubkey) {
_listWallets.add(_name); _listWallets.add(_name);
// _balance[_name] = _historyProvider.getBalance(_pubkey).toString();
print(_name + _pubkey);
}); });
return Column(children: <Widget>[ return Column(children: <Widget>[

View File

@ -232,14 +232,14 @@ packages:
name: graphql name: graphql
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.0-beta.6" version: "4.0.0"
graphql_flutter: graphql_flutter:
dependency: "direct main" dependency: "direct main"
description: description:
name: graphql_flutter name: graphql_flutter
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.0-beta.6" version: "4.0.0"
hive: hive:
dependency: transitive dependency: transitive
description: description:
@ -595,6 +595,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.0" version: "0.2.0"
system_info:
dependency: transitive
description:
name: system_info
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:

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.1+2 version: 0.0.1+3
environment: environment:
sdk: ">=2.7.0 <3.0.0" sdk: ">=2.7.0 <3.0.0"