From 4f316c40f5839e85d16ab6352120b3962aaf12c3 Mon Sep 17 00:00:00 2001 From: poka Date: Mon, 15 Nov 2021 21:04:06 +0100 Subject: [PATCH] Fix bad certificat for Duniter node on old Android version --- lib/main.dart | 13 +++++++++++++ lib/models/my_wallets.dart | 1 - lib/screens/myWallets/unlocking_wallet.dart | 2 +- lib/screens/myWallets/wallets_home.dart | 14 ++++++++------ pubspec.yaml | 2 +- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index e1c3f5b..ea12add 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -16,6 +16,7 @@ // ignore_for_file: avoid_print import 'dart:async'; +import 'dart:io'; import 'package:flutter/services.dart'; import 'package:gecko/globals.dart'; import 'package:gecko/models/cesium_plus.dart'; @@ -103,6 +104,8 @@ Future main() async { } else { print('Debug mode enabled: No sentry alerte'); + HttpOverrides.global = MyHttpOverrides(); + runApp(Gecko(endPointGVA)); } } @@ -177,3 +180,13 @@ class Gecko extends StatelessWidget { )); } } + +// This http overriding is needed to fix fail certifcat checking for Duniter node on old Android version +class MyHttpOverrides extends HttpOverrides { + @override + HttpClient createHttpClient(SecurityContext context) { + return super.createHttpClient(context) + ..badCertificateCallback = + (X509Certificate cert, String host, int port) => true; + } +} diff --git a/lib/models/my_wallets.dart b/lib/models/my_wallets.dart index c37d994..6953108 100644 --- a/lib/models/my_wallets.dart +++ b/lib/models/my_wallets.dart @@ -133,7 +133,6 @@ class MyWalletsProvider with ChangeNotifier { await walletBox.add(newWallet); notifyListeners(); - Navigator.pop(context); } void rebuildWidget() { diff --git a/lib/screens/myWallets/unlocking_wallet.dart b/lib/screens/myWallets/unlocking_wallet.dart index 8980a49..0db74a0 100644 --- a/lib/screens/myWallets/unlocking_wallet.dart +++ b/lib/screens/myWallets/unlocking_wallet.dart @@ -58,7 +58,7 @@ class UnlockingWallet extends StatelessWidget { Row(mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( 'assets/chests/${currentChest.imageName}', - height: 120 * ratio, + height: isTall ? 130 : 100, ), const SizedBox(width: 5), SizedBox( diff --git a/lib/screens/myWallets/wallets_home.dart b/lib/screens/myWallets/wallets_home.dart index af61e18..91a0768 100644 --- a/lib/screens/myWallets/wallets_home.dart +++ b/lib/screens/myWallets/wallets_home.dart @@ -315,6 +315,11 @@ class WalletsHome extends StatelessWidget { } Widget addNewDerivation(context) { + MyWalletsProvider _myWalletProvider = + Provider.of(context); + + String _newDerivationName = + 'Portefeuille ${_myWalletProvider.listWallets.last.number + 2}'; return Padding( padding: const EdgeInsets.all(16), child: ClipRRect( @@ -323,12 +328,9 @@ class WalletsHome extends StatelessWidget { Expanded( child: InkWell( key: const Key('addDerivation'), - onTap: () { - showDialog( - context: context, - builder: (BuildContext context) { - return addNewDerivationPopup(context); - }); + onTap: () async { + await _myWalletProvider.generateNewDerivation( + context, _newDerivationName); }, child: Container( width: double.infinity, diff --git a/pubspec.yaml b/pubspec.yaml index d40ce04..02d1c66 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.2+9 +version: 0.0.2+10 environment: sdk: ">=2.7.0 <3.0.0"