From 7bef4a9cd3197da8959c5e50764aea4d804387c2 Mon Sep 17 00:00:00 2001 From: poka Date: Mon, 30 May 2022 14:48:12 +0200 Subject: [PATCH] bugs fix --- lib/globals.dart | 3 + lib/providers/home.dart | 182 ++++++++++------------- lib/providers/substrate_sdk.dart | 8 +- lib/providers/wallet_options.dart | 2 +- lib/providers/wallets_profiles.dart | 4 +- lib/screens/home.dart | 1 + lib/screens/settings.dart | 4 +- lib/screens/transaction_in_progress.dart | 11 +- lib/screens/wallet_view.dart | 21 ++- pubspec.yaml | 2 +- 10 files changed, 120 insertions(+), 118 deletions(-) diff --git a/lib/globals.dart b/lib/globals.dart index 4f3d9c2..7057e15 100644 --- a/lib/globals.dart +++ b/lib/globals.dart @@ -34,6 +34,9 @@ String cesiumPod = "https://g1.data.presles.fr"; late bool isTall; late double ratio; +// Contexts +late BuildContext homeContext; + // Logger var log = Logger(); diff --git a/lib/providers/home.dart b/lib/providers/home.dart index 2bbff48..a228db0 100644 --- a/lib/providers/home.dart +++ b/lib/providers/home.dart @@ -96,49 +96,6 @@ class HomeProvider with ChangeNotifier { } log.i('ENDPOINT: ' + _listEndpoints.toString()); - - // int i = 0; - // String? _endpoint; - // int _statusCode = 0; - - // final _client = HttpClient(); - // _client.connectionTimeout = const Duration(milliseconds: 1000); - - // do { - // i++; - // log.d(i.toString() + ' ème essai de recherche de endpoint GVA.'); - // log.d('Try GVA endpoint: ${_listEndpoints[i - 1]}'); - // int listLenght = _listEndpoints.length - 1; - // if (i > listLenght) { - // log.e('NO VALID GVA ENDPOINT FOUND'); - // _endpoint = 'HS'; - // break; - // } - // if (i != 0) { - // await Future.delayed(const Duration(milliseconds: 300)); - // } - - // try { - // final request = await _client.postUrl(Uri.parse(_listEndpoints[i])); - // final response = await request.close(); - - // _endpoint = _listEndpoints[i]; - // _statusCode = response.statusCode; - // } on TimeoutException catch (_) { - // log.e('This endpoint is timeout, next'); - // _statusCode = 50; - // continue; - // } on SocketException catch (_) { - // log.e('This endpoint is a bad endpoint, next'); - // _statusCode = 70; - // continue; - // } on Exception { - // log.e('Unknown error'); - // _statusCode = 60; - // continue; - // } - // } while (_statusCode != 400); - return _listEndpoints; } @@ -164,70 +121,74 @@ class HomeProvider with ChangeNotifier { WalletsProfilesProvider _historyProvider = Provider.of(context, listen: false); + final size = MediaQuery.of(context).size; + const bool _showBottomBar = true; return Visibility( visible: _showBottomBar, child: Container( color: yellowC, - width: double.infinity, + width: size.width, height: 80, - child: Row( - // mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - const Spacer(flex: 1), - IconButton( - iconSize: 40, - icon: const Image(image: AssetImage('assets/loupe-noire.png')), - onPressed: () { - // Navigator.popUntil( - // context, - // ModalRoute.withName('/'), - // ); - Navigator.push( - context, - MaterialPageRoute(builder: (context) { - return const SearchScreen(); - }), - ); - }, - ), - // SizedBox(width: 0), - const Spacer(flex: 2), - IconButton( - iconSize: 60, - icon: const Image(image: AssetImage('assets/qrcode-scan.png')), - onPressed: () async { - // Navigator.popUntil( - // context, - // ModalRoute.withName('/'), - // ); - await _historyProvider.scan(context); - }, - ), - const Spacer(flex: 2), - IconButton( - iconSize: 60, - icon: const Image(image: AssetImage('assets/wallet.png')), - onPressed: () { - WalletData? defaultWallet = - _myWalletProvider.getDefaultWallet(); - Navigator.push( - context, - MaterialPageRoute( - builder: (context) { - return UnlockingWallet( - wallet: defaultWallet, - action: "mywallets", - ); - }, - ), - ); - }, - ), - const Spacer(flex: 1), - ], - ), + child: + // Stack( + // children: [ + // // CustomPaint( + // // size: Size(size.width, 110), + // // painter: CustomRoundedButton(), + // // ), + Row(mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ + IconButton( + iconSize: 40, + icon: const Image(image: AssetImage('assets/loupe-noire.png')), + onPressed: () { + Navigator.popUntil( + context, + ModalRoute.withName('/'), + ); + Navigator.push( + context, + MaterialPageRoute(builder: (homeContext) { + return const SearchScreen(); + }), + ); + }, + ), + IconButton( + iconSize: 70, + icon: const Image(image: AssetImage('assets/qrcode-scan.png')), + onPressed: () async { + Navigator.popUntil( + context, + ModalRoute.withName('/'), + ); + _historyProvider.scan(homeContext); + }, + ), + IconButton( + iconSize: 60, + icon: const Image(image: AssetImage('assets/wallet.png')), + onPressed: () { + Navigator.popUntil( + context, + ModalRoute.withName('/'), + ); + WalletData? defaultWallet = _myWalletProvider.getDefaultWallet(); + Navigator.push( + context, + MaterialPageRoute( + builder: (homeContext) { + return UnlockingWallet( + wallet: defaultWallet, + action: "mywallets", + ); + }, + ), + ); + }, + ), + ]), ), ); } @@ -250,3 +211,24 @@ class HomeProvider with ChangeNotifier { notifyListeners(); } } + +class CustomRoundedButton extends CustomPainter { + @override + void paint(Canvas canvas, Size size) { + Paint paint = Paint() + ..color = yellowC + ..style = PaintingStyle.fill; + Path path = Path(); + path.lineTo(size.width * 0.4, 0); + path.quadraticBezierTo(size.width * 0.5, -40, size.width * 0.6, 0); + path.lineTo(size.width, 0); + path.lineTo(size.width, size.height); + path.lineTo(0, size.height); + canvas.drawPath(path, paint); + } + + @override + bool shouldRepaint(covariant CustomPainter oldDelegate) { + return false; + } +} diff --git a/lib/providers/substrate_sdk.dart b/lib/providers/substrate_sdk.dart index 8d3425d..7b130fb 100644 --- a/lib/providers/substrate_sdk.dart +++ b/lib/providers/substrate_sdk.dart @@ -106,7 +106,7 @@ class SubstrateSdk with ChangeNotifier { nodeConnected = false; debugConnection = res.toString(); notifyListeners(); - _homeProvider.changeMessage('Vous êtes pas connecté', 3); + _homeProvider.changeMessage("Vous n'êtes pas connecté:", 3); // snackNode(ctx, false); } @@ -335,10 +335,8 @@ class SubstrateSdk with ChangeNotifier { password, onStatusChange: (status) { log.d('Transaction status: ' + status); - if (status == 'Ready') { - transactionStatus = 'sent'; - notifyListeners(); - } + transactionStatus = status; + notifyListeners(); }, ).timeout( const Duration(seconds: 12), diff --git a/lib/providers/wallet_options.dart b/lib/providers/wallet_options.dart index 0f5d531..111fe0f 100644 --- a/lib/providers/wallet_options.dart +++ b/lib/providers/wallet_options.dart @@ -62,7 +62,7 @@ class WalletOptionsProvider with ChangeNotifier { final bool? _answer = await (confirmPopup(context, 'Êtes-vous sûr de vouloir oublier le portefeuille "${wallet.name}" ?')); - if (_answer!) { + if (_answer ?? false) { await walletBox.delete(wallet.key); await _sub.deleteAccounts([wallet.address!]); diff --git a/lib/providers/wallets_profiles.dart b/lib/providers/wallets_profiles.dart index 53b6c4b..dc958d7 100644 --- a/lib/providers/wallets_profiles.dart +++ b/lib/providers/wallets_profiles.dart @@ -27,7 +27,7 @@ class WalletsProfilesProvider with ChangeNotifier { int nRepositories = 20; int nPage = 1; - Future scan(context) async { + Future scan(context) async { if (Platform.isAndroid || Platform.isIOS) { await Permission.camera.request(); } @@ -42,7 +42,7 @@ class WalletsProfilesProvider with ChangeNotifier { Navigator.push( context, MaterialPageRoute(builder: (context) { - return WalletViewScreen(pubkey: pubkey); + return WalletViewScreen(pubkey: barcode!); }), ); } else { diff --git a/lib/screens/home.dart b/lib/screens/home.dart index afaa3b2..defe4d9 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -24,6 +24,7 @@ class HomeScreen extends StatelessWidget { @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]); + homeContext = context; MyWalletsProvider _myWalletProvider = Provider.of(context); Provider.of(context); diff --git a/lib/screens/settings.dart b/lib/screens/settings.dart index e5c780f..e426d67 100644 --- a/lib/screens/settings.dart +++ b/lib/screens/settings.dart @@ -53,7 +53,9 @@ class SettingsScreen extends StatelessWidget { child: Row(children: [ Text(' Noeud $currencyName :'), const Spacer(), - Icon(_sub.nodeConnected ? Icons.check : Icons.close), + Icon(_sub.nodeConnected && !_sub.isLoadingEndpoint + ? Icons.check + : Icons.close), const Spacer(), SizedBox( width: 200, diff --git a/lib/screens/transaction_in_progress.dart b/lib/screens/transaction_in_progress.dart index 07ac2e3..70a5f10 100644 --- a/lib/screens/transaction_in_progress.dart +++ b/lib/screens/transaction_in_progress.dart @@ -58,7 +58,12 @@ class TransactionInProgress extends StatelessWidget { _resultText = 'Envoi en cours ...'; } break; - case 'sent': + case 'Ready': + { + _resultText = 'En cours de propagation...'; + } + break; + case 'Broadcast': { _resultText = 'En cours de validation ...'; } @@ -81,7 +86,7 @@ class TransactionInProgress extends StatelessWidget { _sub.transactionStatus = ''; Navigator.pop(context); Navigator.pop(context); - if (_actionName == 'pay') { + if (transType == 'pay') { Navigator.pop(context); } return Future.value(true); @@ -186,7 +191,7 @@ class TransactionInProgress extends StatelessWidget { onPressed: () { Navigator.pop(context); Navigator.pop(context); - if (_actionName == 'pay') { + if (transType == 'pay') { Navigator.pop(context); } }, diff --git a/lib/screens/wallet_view.dart b/lib/screens/wallet_view.dart index ebbf720..3038be8 100644 --- a/lib/screens/wallet_view.dart +++ b/lib/screens/wallet_view.dart @@ -304,11 +304,22 @@ class WalletViewScreen extends StatelessWidget { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - const Text( - 'Effectuer un virement', - style: TextStyle( - fontSize: 26, fontWeight: FontWeight.w700), - ), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + const Text( + 'Effectuer un virement', + style: TextStyle( + fontSize: 26, fontWeight: FontWeight.w700), + ), + IconButton( + iconSize: 40, + icon: const Icon(Icons.cancel_outlined), + onPressed: () { + Navigator.pop(context); + }, + ), + ]), const SizedBox(height: 20), Text( 'Depuis:', diff --git a/pubspec.yaml b/pubspec.yaml index c831e23..96d1d45 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,7 +5,7 @@ description: Pay with G1. # 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.7+4 +version: 0.0.7+5 environment: sdk: '>=2.12.0 <3.0.0'