From 71d321700b29e73b3ede26dba3ee877b07b71aab Mon Sep 17 00:00:00 2001
From: poka <poka@p2p.legal>
Date: Fri, 10 Jun 2022 01:24:50 +0200
Subject: [PATCH] restore chest: can use space to go next case

---
 lib/providers/generate_wallets.dart      |  1 +
 lib/providers/my_wallets.dart            |  3 ++-
 lib/screens/myWallets/restore_chest.dart | 13 +++++++++++++
 pubspec.yaml                             |  2 +-
 4 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/lib/providers/generate_wallets.dart b/lib/providers/generate_wallets.dart
index 0f80bfbf..d4ca755c 100644
--- a/lib/providers/generate_wallets.dart
+++ b/lib/providers/generate_wallets.dart
@@ -390,6 +390,7 @@ class GenerateWalletsProvider with ChangeNotifier {
             const Duration(seconds: 1),
             onTimeout: () => 0,
           );
+      // const balance = 0;
 
       log.d(balance);
       if (balance != 0) {
diff --git a/lib/providers/my_wallets.dart b/lib/providers/my_wallets.dart
index a03832dc..361f2101 100644
--- a/lib/providers/my_wallets.dart
+++ b/lib/providers/my_wallets.dart
@@ -77,7 +77,8 @@ class MyWalletsProvider with ChangeNotifier {
     } else {
       chest ??= getCurrentChest();
       int? defaultWalletNumber = chestBox.get(chest)!.defaultWallet;
-      return getWalletDataById([chest, defaultWalletNumber])!;
+      return getWalletDataById([chest, defaultWalletNumber]) ??
+          WalletData(chest: chest, number: 0);
     }
   }
 
diff --git a/lib/screens/myWallets/restore_chest.dart b/lib/screens/myWallets/restore_chest.dart
index 2dc935db..08d0c93d 100644
--- a/lib/screens/myWallets/restore_chest.dart
+++ b/lib/screens/myWallets/restore_chest.dart
@@ -184,11 +184,23 @@ class RestoreChest extends StatelessWidget {
     return Container(
       width: 102,
       height: 40 * ratio,
+      // child: RawKeyboardListener(
+      //   focusNode: FocusNode(), // or FocusNode()
+      //   onKey: (event) {
+      //     if (event.logicalKey == LogicalKeyboardKey.space) {
+      //       FocusScope.of(context).nextFocus();
+      //     }
+      //   },
+
       child: TextField(
         autofocus: true,
         controller: cellCtl,
         textInputAction: TextInputAction.next,
         onChanged: (v) {
+          if (v.contains(' ')) {
+            cellCtl.text = cellCtl.text.replaceAll(' ', '');
+            FocusScope.of(context).nextFocus();
+          }
           bool isValid = generateWalletProvider.isBipWord(v);
           if (isValid) cellCtl.text = cellCtl.text.toLowerCase();
           if (isValid && generateWalletProvider.cellController11.text.isEmpty) {
@@ -198,6 +210,7 @@ class RestoreChest extends StatelessWidget {
         textAlign: TextAlign.center,
         style: const TextStyle(fontSize: 20),
       ),
+      // ),
       decoration: BoxDecoration(
         border: Border.all(color: Colors.grey),
         color: Colors.white,
diff --git a/pubspec.yaml b/pubspec.yaml
index cf8ff7e4..3becc8a5 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.8+5
+version: 0.0.8+6
 
 environment:
   sdk: '>=2.12.0 <3.0.0'
-- 
GitLab