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

View File

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

View File

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

View File

@ -52,7 +52,6 @@ class WalletOptionsProvider with ChangeNotifier {
Future readLocalWallet(String _name, String _pin) async {
isWalletUnlock = false;
print('NOM: ' + _name);
try {
File _walletFile = File('${walletsDirectory.path}/$_name/wallet.dewif');
String _localDewif = await _walletFile.readAsString();
@ -204,9 +203,15 @@ class WalletOptionsProvider with ChangeNotifier {
final walletFile = File('${walletNameDirectory.path}/wallet.dewif');
walletFile.writeAsString('${_newWalletFile.dewif}');
Navigator.pop(context);
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((_) {
_historyProvider.snackNode(context);
});
return Scaffold(
floatingActionButton: Container(
height: 80.0,
@ -78,16 +79,17 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
disabledBorder: InputBorder.none,
),
style: TextStyle(fontSize: 14.0, fontWeight: FontWeight.bold)),
if (_historyProvider.pubkey != '') historyQuery(context),
if (_historyProvider.pubkey != '')
historyQuery(context, _historyProvider),
]));
}
historyQuery(context) {
print("I'M HERE 1");
Widget historyQuery(context, _historyProvider) {
_pubkeyFocus.unfocus();
HistoryProvider _historyProvider = Provider.of<HistoryProvider>(context);
// HistoryProvider _historyProvider = Provider.of<HistoryProvider>(context);
CesiumPlusProvider _cesiumPlusProvider =
Provider.of<CesiumPlusProvider>(context);
print("I'M HERE 1");
return Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
@ -104,8 +106,10 @@ class HistoryScreen extends StatelessWidget with ChangeNotifier {
),
builder: (QueryResult result, {fetchMore, refetch}) {
print("I'M HERE 2 !");
print(result.source.isEager);
if (result.isLoading && result.data == null) {
print("I'M HERE 3 !");
return const Center(
child: CircularProgressIndicator(),
);

View File

@ -59,7 +59,8 @@ class GenerateWalletsScreen extends StatelessWidget {
style: TextStyle(
fontSize: 14.0,
color: Colors.black,
fontWeight: FontWeight.bold)),
fontWeight: FontWeight.bold,
fontFamily: 'Monospace')),
SizedBox(height: 8),
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"),

View File

@ -7,6 +7,7 @@ import 'package:gecko/screens/myWallets/changePin.dart';
import 'dart:async';
import 'package:pin_code_fields/pin_code_fields.dart';
import 'package:provider/provider.dart';
import 'package:flutter/services.dart';
// ignore: must_be_immutable
class WalletOptions extends StatelessWidget with ChangeNotifier {
@ -15,7 +16,7 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
String walletName;
StreamController<ErrorAnimationType> errorController;
TextEditingController _enterPin = new TextEditingController();
TextEditingController _enterPin = TextEditingController();
final formKey = GlobalKey<FormState>();
bool hasError = false;
var pinColor = Color(0xffF9F9F1);
@ -32,6 +33,7 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
Provider.of<MyWalletsProvider>(context);
errorController = StreamController<ErrorAnimationType>();
// _walletOptions.isWalletUnlock = false;
return WillPopScope(
onWillPop: () {
_walletOptions.isWalletUnlock = false;
@ -50,33 +52,73 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
height: 22,
child: Text(walletName),
)),
body: Center(
child: SafeArea(
child: Column(children: <Widget>[
Visibility(
visible: _walletOptions.isWalletUnlock,
child: Expanded(
child: Column(children: <Widget>[
SizedBox(height: 15),
Text(
'Clé publique:',
style: TextStyle(
fontSize: 15.0,
color: Colors.grey[600],
fontWeight: FontWeight.w400),
),
SizedBox(height: 15),
Text(
_walletOptions.pubkey.text,
style: TextStyle(
fontSize: 14.0,
color: Colors.black,
fontWeight: FontWeight.bold),
),
Expanded(
child: Align(
alignment: Alignment.bottomCenter,
child: SizedBox(
body: Builder(
builder: (ctx) => SafeArea(
child: Column(children: <Widget>[
Visibility(
visible: _walletOptions.isWalletUnlock,
child: Expanded(
child: Column(children: <Widget>[
SizedBox(height: 15),
Text(
'Clé publique:',
style: TextStyle(
fontSize: 15.0,
color: Colors.grey[600],
fontWeight: FontWeight.w400),
),
SizedBox(height: 15),
GestureDetector(
onTap: () {
Clipboard.setData(ClipboardData(
text: _walletOptions.pubkey.text));
_walletOptions.snackCopyKey(ctx);
},
child: Text(
_walletOptions.pubkey.text,
style: TextStyle(
fontSize: 14.0,
color: Colors.black,
fontWeight: FontWeight.bold,
fontFamily: 'Monospace'),
)),
Expanded(
child: Align(
alignment: Alignment.bottomCenter,
child: SizedBox(
height: 50,
width: 300,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
elevation: 5,
primary: Color(
0xffFFD68E), //Color(0xffFFD68E), // background
onPrimary:
Colors.black, // foreground
),
onPressed: () => _walletOptions
.renameWalletAlerte(
context, walletName)
.then((_result) {
if (_result == true) {
WidgetsBinding.instance
.addPostFrameCallback(
(_) {
_myWalletProvider
.listWallets =
_myWalletProvider
.getAllWalletsNames();
_myWalletProvider
.rebuildWidget();
});
}
}),
child: Text(
'Renommer ce portefeuille',
style: TextStyle(
fontSize: 20)))))),
SizedBox(height: 30),
SizedBox(
height: 50,
width: 300,
child: ElevatedButton(
@ -86,167 +128,146 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
0xffFFD68E), //Color(0xffFFD68E), // background
onPrimary: Colors.black, // foreground
),
onPressed: () => _walletOptions
.renameWalletAlerte(
context, walletName)
.then((_result) {
if (_result == true) {
WidgetsBinding.instance
.addPostFrameCallback((_) {
_myWalletProvider.listWallets =
_myWalletProvider
.getAllWalletsNames();
_myWalletProvider.rebuildWidget();
});
}
onPressed: () {
// changePin(widget.walletName, this.walletPin);
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return ChangePinScreen(
walletName: walletName,
oldPin: this.walletPin);
}),
child: Text('Renommer ce portefeuille',
style: TextStyle(fontSize: 20)))))),
SizedBox(height: 30),
SizedBox(
height: 50,
width: 300,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
elevation: 5,
primary: Color(
0xffFFD68E), //Color(0xffFFD68E), // background
onPrimary: Colors.black, // foreground
);
},
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: () async {
await _walletOptions.deleteWallet(
context, walletName);
WidgetsBinding.instance
.addPostFrameCallback((_) {
_myWalletProvider.listWallets =
_myWalletProvider
.getAllWalletsNames();
_myWalletProvider.rebuildWidget();
});
},
child: Text('Supprimer ce portefeuille',
style: TextStyle(fontSize: 20)))),
SizedBox(height: 50),
Text(
'Portefeuille déverrouillé',
style: TextStyle(
color: Colors.green,
fontWeight: FontWeight.w700,
fontSize: 15),
),
onPressed: () {
// changePin(widget.walletName, this.walletPin);
Navigator.push(
context,
MaterialPageRoute(builder: (context) {
return ChangePinScreen(
walletName: 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
SizedBox(height: 10)
]))),
Visibility(
visible: !_walletOptions.isWalletUnlock,
child: Expanded(
child: Column(children: <Widget>[
SizedBox(height: 80),
Text(
'Veuillez tapper votre code secret pour dévérouiller votre portefeuille.',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 15.0,
color: Colors.black,
fontWeight: FontWeight.w400),
),
onPressed: () async {
await _walletOptions.deleteWallet(
context, walletName);
WidgetsBinding.instance.addPostFrameCallback((_) {
_myWalletProvider.listWallets =
_myWalletProvider.getAllWalletsNames();
_myWalletProvider.rebuildWidget();
});
},
child: Text('Supprimer ce portefeuille',
style: TextStyle(fontSize: 20)))),
SizedBox(height: 50),
Text(
'Portefeuille déverrouillé',
style: TextStyle(
color: Colors.green,
fontWeight: FontWeight.w700,
fontSize: 15),
),
SizedBox(height: 10)
]))),
Visibility(
visible: !_walletOptions.isWalletUnlock,
child: Expanded(
child: Column(children: <Widget>[
SizedBox(height: 80),
Text(
'Veuillez tapper votre code secret pour dévérouiller votre portefeuille.',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 15.0,
color: Colors.black,
fontWeight: FontWeight.w400),
),
SizedBox(height: 50),
Form(
key: formKey,
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 8.0, horizontal: 30),
child: PinCodeTextField(
autoFocus: true,
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: (_pin) async {
print("Completed");
final resultWallet =
await _walletOptions.readLocalWallet(
this.walletName, _pin.toUpperCase());
if (resultWallet == 'bad') {
errorController.add(ErrorAnimationType
.shake); // Triggering error shake animation
hasError = true;
pinColor = Colors.red[200];
notifyListeners();
} else {
pinColor = Colors.green[200];
// setState(() {});
// await Future.delayed(Duration(milliseconds: 50));
this.walletPin = _pin.toUpperCase();
// isWalletUnlock = true;
notifyListeners();
}
},
onChanged: (value) {
if (pinColor != Color(0xffF9F9F1)) {
pinColor = Color(0xffF9F9F1);
}
print(value);
},
)),
)
]))),
])))));
SizedBox(height: 50),
Form(
key: formKey,
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 8.0, horizontal: 30),
child: PinCodeTextField(
autoFocus: true,
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: (_pin) async {
print("Completed");
final resultWallet =
await _walletOptions.readLocalWallet(
this.walletName,
_pin.toUpperCase());
if (resultWallet == 'bad') {
errorController.add(ErrorAnimationType
.shake); // Triggering error shake animation
hasError = true;
pinColor = Colors.red[200];
notifyListeners();
} else {
pinColor = Colors.green[200];
// setState(() {});
// await Future.delayed(Duration(milliseconds: 50));
this.walletPin = _pin.toUpperCase();
// isWalletUnlock = true;
notifyListeners();
}
},
onChanged: (value) {
if (pinColor != Color(0xffF9F9F1)) {
pinColor = Color(0xffF9F9F1);
}
print(value);
},
)),
)
]))),
])))));
}
}

View File

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

View File

@ -232,14 +232,14 @@ packages:
name: graphql
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0-beta.6"
version: "4.0.0"
graphql_flutter:
dependency: "direct main"
description:
name: graphql_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0-beta.6"
version: "4.0.0"
hive:
dependency: transitive
description:
@ -595,6 +595,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
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:
dependency: transitive
description:

View File

@ -5,7 +5,7 @@ description: A new Flutter project.
# 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
version: 0.0.1+2
version: 0.0.1+3
environment:
sdk: ">=2.7.0 <3.0.0"