From 7c7f604585033f3939330e9eb922fd76446822f7 Mon Sep 17 00:00:00 2001
From: poka <poka@p2p.legal>
Date: Tue, 21 Dec 2021 11:06:11 +0100
Subject: [PATCH] Fix: reload home page after cesium wallet creation

---
 lib/models/change_pin.dart                    |   1 +
 .../myWallets/import_cesium_wallet.dart       |   5 +-
 lib/screens/myWallets/unlocking_wallet.dart   | 144 ++++++++++--------
 pubspec.yaml                                  |   2 +-
 4 files changed, 87 insertions(+), 65 deletions(-)

diff --git a/lib/models/change_pin.dart b/lib/models/change_pin.dart
index 11989fe3..20141e70 100644
--- a/lib/models/change_pin.dart
+++ b/lib/models/change_pin.dart
@@ -13,6 +13,7 @@ class ChangePinProvider with ChangeNotifier {
     try {
       final _dewif = chestBox.get(configBox.get('currentChest')).dewif;
 
+      // TODO: Durt: Detect if CesiumWallet
       NewWallet newWalletFile = Dewif().changePassword(
           dewif: _dewif,
           oldPassword: _oldPin.toUpperCase(),
diff --git a/lib/screens/myWallets/import_cesium_wallet.dart b/lib/screens/myWallets/import_cesium_wallet.dart
index b925a179..1341ba25 100644
--- a/lib/screens/myWallets/import_cesium_wallet.dart
+++ b/lib/screens/myWallets/import_cesium_wallet.dart
@@ -4,6 +4,7 @@ import 'package:flutter/services.dart';
 import 'package:gecko/globals.dart';
 import 'package:gecko/models/generate_wallets.dart';
 import 'package:flutter/material.dart';
+import 'package:gecko/models/my_wallets.dart';
 import 'package:gecko/models/wallet_data.dart';
 import 'package:gecko/models/wallet_options.dart';
 import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
@@ -21,6 +22,8 @@ class ImportWalletScreen extends StatelessWidget {
         Provider.of<GenerateWalletsProvider>(context, listen: false);
     WalletOptionsProvider _walletOptions =
         Provider.of<WalletOptionsProvider>(context, listen: false);
+    MyWalletsProvider _myWalletProvider =
+        Provider.of<MyWalletsProvider>(context);
 
     _generateWalletProvider.pin.text = randomSecretCode(5);
     return WillPopScope(
@@ -177,7 +180,7 @@ class ImportWalletScreen extends StatelessWidget {
                       ? () async {
                           final chestKey =
                               await walletProvider.importCesiumWallet();
-                          walletProvider.reloadBuild();
+                          _myWalletProvider.rebuildWidget();
 
                           await Navigator.pushAndRemoveUntil(
                             context,
diff --git a/lib/screens/myWallets/unlocking_wallet.dart b/lib/screens/myWallets/unlocking_wallet.dart
index 7a5c5932..9370d25b 100644
--- a/lib/screens/myWallets/unlocking_wallet.dart
+++ b/lib/screens/myWallets/unlocking_wallet.dart
@@ -32,6 +32,7 @@ class UnlockingWallet extends StatelessWidget {
     SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
     WalletOptionsProvider _walletOptions =
         Provider.of<WalletOptionsProvider>(context);
+    final double statusBarHeight = MediaQuery.of(context).padding.top;
 
     int _pinLenght;
     ChestData currentChest = chestBox.get(configBox.get('currentChest'));
@@ -47,71 +48,88 @@ class UnlockingWallet extends StatelessWidget {
     return Scaffold(
         // backgroundColor: Colors.brown[600],
         body: SafeArea(
-      child: Column(children: <Widget>[
-        Expanded(
-          child: Column(children: <Widget>[
-            SizedBox(height: isTall ? 100 : 20),
-            Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
-              currentChest.imageFile == null
-                  ? Image.asset(
-                      'assets/chests/${currentChest.imageName}',
-                      width: isTall ? 130 : 100,
-                    )
-                  : Image.file(
-                      currentChest.imageFile,
-                      width: isTall ? 130 : 100,
-                    ),
-              const SizedBox(width: 5),
-              SizedBox(
-                  width: 250,
-                  child: Text(
-                    currentChest.name,
-                    textAlign: TextAlign.center,
-                    style: const TextStyle(
-                        fontSize: 25,
-                        color: Colors.black,
-                        fontWeight: FontWeight.w700),
-                  )),
-            ]),
-            SizedBox(height: 30 * ratio),
-            const SizedBox(
-                width: 400,
-                child: Text(
-                  'Pour déverrouiller votre coffre, composez votre code secret à l’abri des lézards indiscrets :',
-                  style: TextStyle(
-                      fontSize: 19,
-                      color: Colors.black,
-                      fontWeight: FontWeight.w400),
-                )),
-            SizedBox(height: 40 * ratio),
-            pinForm(context, _pinLenght, currentChest),
-            SizedBox(height: 3 * ratio),
-            InkWell(
-                key: const Key('chooseChest'),
-                onTap: () {
-                  Navigator.push(
-                    context,
-                    MaterialPageRoute(builder: (context) {
-                      return ChooseChest(action: action);
-                    }),
-                  );
-                },
-                child: SizedBox(
-                  width: 400,
-                  height: 70,
-                  child: Center(
+      child: Column(
+          crossAxisAlignment: CrossAxisAlignment.start,
+          children: <Widget>[
+            Stack(children: <Widget>[
+            Positioned(
+              top: statusBarHeight + 10,
+              left: 15,
+              child: Builder(
+                builder: (context) => IconButton(
+                  key: const Key('popButton'),
+                  icon: const Icon(
+                    Icons.arrow_back,
+                    color: Colors.black,
+                    size: 25,
+                  ),
+                  onPressed: () => Navigator.pop(context),
+                ),
+              ),
+            ),Column(children: <Widget>[
+                SizedBox(height: isTall ? 100 : 20),
+                Row(
+                    mainAxisAlignment: MainAxisAlignment.center,
+                    children: <Widget>[
+                      currentChest.imageFile == null
+                          ? Image.asset(
+                              'assets/chests/${currentChest.imageName}',
+                              width: isTall ? 130 : 100,
+                            )
+                          : Image.file(
+                              currentChest.imageFile,
+                              width: isTall ? 130 : 100,
+                            ),
+                      const SizedBox(width: 5),
+                      SizedBox(
+                          width: 250,
+                          child: Text(
+                            currentChest.name,
+                            textAlign: TextAlign.center,
+                            style: const TextStyle(
+                                fontSize: 25,
+                                color: Colors.black,
+                                fontWeight: FontWeight.w700),
+                          )),
+                    ]),
+                SizedBox(height: 30 * ratio),
+                const SizedBox(
+                    width: 400,
                     child: Text(
-                      'Changer de coffre',
+                      'Pour déverrouiller votre coffre, composez votre code secret à l’abri des lézards indiscrets :',
                       style: TextStyle(
-                          fontSize: 22,
-                          color: orangeC,
-                          fontWeight: FontWeight.w600),
-                    ),
-                  ),
-                )),
-          ]),
-        ),
-      ]),
+                          fontSize: 19,
+                          color: Colors.black,
+                          fontWeight: FontWeight.w400),
+                    )),
+                SizedBox(height: 40 * ratio),
+                pinForm(context, _pinLenght, currentChest),
+                SizedBox(height: 3 * ratio),
+                InkWell(
+                    key: const Key('chooseChest'),
+                    onTap: () {
+                      Navigator.push(
+                        context,
+                        MaterialPageRoute(builder: (context) {
+                          return ChooseChest(action: action);
+                        }),
+                      );
+                    },
+                    child: SizedBox(
+                      width: 400,
+                      height: 70,
+                      child: Center(
+                        child: Text(
+                          'Changer de coffre',
+                          style: TextStyle(
+                              fontSize: 22,
+                              color: orangeC,
+                              fontWeight: FontWeight.w600),
+                        ),
+                      ),
+                    )),
+              ]),
+          ]),]),
     ));
   }
 
diff --git a/pubspec.yaml b/pubspec.yaml
index db0a916b..872d21cd 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.4+1
+version: 0.0.4+2
 
 environment:
   sdk: ">=2.7.0 <3.0.0"
-- 
GitLab