From 10f04c1a5ac4eafdcd702c7c959a8c5c7572a8ad Mon Sep 17 00:00:00 2001
From: poka <poka@p2p.legal>
Date: Sat, 28 May 2022 21:48:04 +0200
Subject: [PATCH] balanceBuilder on choose_wallets; bugs fix

---
 lib/providers/home.dart                   |  2 +-
 lib/screens/myWallets/chest_options.dart  |  2 +-
 lib/screens/myWallets/choose_wallet.dart  | 23 +++++++++++++++++++++++
 lib/screens/myWallets/wallet_options.dart |  2 +-
 lib/screens/myWallets/wallets_home.dart   |  2 +-
 lib/screens/search_result.dart            |  4 ++++
 lib/screens/wallet_view.dart              |  2 +-
 7 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/lib/providers/home.dart b/lib/providers/home.dart
index 5a542568..0b52d947 100644
--- a/lib/providers/home.dart
+++ b/lib/providers/home.dart
@@ -148,7 +148,7 @@ class HomeProvider with ChangeNotifier {
   //       volume: volume, mode: PlayerMode.LOW_LATENCY, stayAwake: false);
   // }
 
-  Widget bottomAppBar(BuildContext context, int index) {
+  Widget bottomAppBar(BuildContext context) {
     MyWalletsProvider _myWalletProvider =
         Provider.of<MyWalletsProvider>(context, listen: false);
     WalletsProfilesProvider _historyProvider =
diff --git a/lib/screens/myWallets/chest_options.dart b/lib/screens/myWallets/chest_options.dart
index 2fa95d7e..ac0e2090 100644
--- a/lib/screens/myWallets/chest_options.dart
+++ b/lib/screens/myWallets/chest_options.dart
@@ -41,7 +41,7 @@ class ChestOptions extends StatelessWidget {
             height: 22,
             child: Text(currentChest.name!),
           )),
-      bottomNavigationBar: _homeProvider.bottomAppBar(context, 2),
+      bottomNavigationBar: _homeProvider.bottomAppBar(context),
       body: Builder(
         builder: (ctx) => SafeArea(
           child: Column(children: <Widget>[
diff --git a/lib/screens/myWallets/choose_wallet.dart b/lib/screens/myWallets/choose_wallet.dart
index d6c5a800..98a93476 100644
--- a/lib/screens/myWallets/choose_wallet.dart
+++ b/lib/screens/myWallets/choose_wallet.dart
@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
 import 'package:gecko/models/wallet_data.dart';
 import 'package:gecko/providers/my_wallets.dart';
 import 'package:gecko/providers/substrate_sdk.dart';
+import 'package:gecko/providers/wallet_options.dart';
 import 'package:gecko/screens/myWallets/wallets_home.dart';
 import 'package:provider/provider.dart';
 // import 'package:gecko/models/home.dart';
@@ -166,6 +167,8 @@ class ChooseWalletScreen extends StatelessWidget {
                                     ),
                                   ),
                           )),
+                          balanceBuilder(context, _repository.address!,
+                              selectedWallet!.address == _repository.address!),
                           ListTile(
                             shape: const RoundedRectangleBorder(
                               borderRadius: BorderRadius.vertical(
@@ -205,4 +208,24 @@ class ChooseWalletScreen extends StatelessWidget {
           ]),
     ]);
   }
+
+  Widget balanceBuilder(context, String _address, bool isDefault) {
+    return Container(
+      width: double.infinity,
+      color: isDefault ? orangeC : yellowC,
+      child: SizedBox(
+        height: 25,
+        child: Column(children: [
+          const Spacer(),
+          // Text(
+          //   '0.0 gd',
+          //   textAlign: TextAlign.center,
+          //   style: TextStyle(color: isDefault ? Colors.white : Colors.black),
+          // ),
+          balance(
+              context, _address, 15, isDefault ? Colors.white : Colors.black)
+        ]),
+      ),
+    );
+  }
 }
diff --git a/lib/screens/myWallets/wallet_options.dart b/lib/screens/myWallets/wallet_options.dart
index 4ef5b1b2..704a98e4 100644
--- a/lib/screens/myWallets/wallet_options.dart
+++ b/lib/screens/myWallets/wallet_options.dart
@@ -67,7 +67,7 @@ class WalletOptions extends StatelessWidget {
             }),
           ),
         ),
-        bottomNavigationBar: _homeProvider.bottomAppBar(context, 2),
+        bottomNavigationBar: _homeProvider.bottomAppBar(context),
         body: Builder(
           builder: (ctx) => SafeArea(
             child: Column(children: <Widget>[
diff --git a/lib/screens/myWallets/wallets_home.dart b/lib/screens/myWallets/wallets_home.dart
index c67954ed..faeb14af 100644
--- a/lib/screens/myWallets/wallets_home.dart
+++ b/lib/screens/myWallets/wallets_home.dart
@@ -57,7 +57,7 @@ class WalletsHome extends StatelessWidget {
               style: TextStyle(color: Colors.grey[850])),
           backgroundColor: const Color(0xffFFD58D),
         ),
-        bottomNavigationBar: _homeProvider.bottomAppBar(context, 3),
+        bottomNavigationBar: _homeProvider.bottomAppBar(context),
         body: SafeArea(
           child: myWalletsTiles(context, _currentChestNumber!),
         ),
diff --git a/lib/screens/search_result.dart b/lib/screens/search_result.dart
index 97d7d776..e837167c 100644
--- a/lib/screens/search_result.dart
+++ b/lib/screens/search_result.dart
@@ -3,6 +3,7 @@ import 'package:gecko/globals.dart';
 import 'package:flutter/material.dart';
 import 'package:gecko/providers/cesium_plus.dart';
 import 'package:gecko/models/g1_wallets_list.dart';
+import 'package:gecko/providers/home.dart';
 import 'package:gecko/providers/substrate_sdk.dart';
 import 'package:gecko/providers/wallet_options.dart';
 import 'package:gecko/providers/wallets_profiles.dart';
@@ -22,6 +23,8 @@ class SearchResultScreen extends StatelessWidget {
         Provider.of<CesiumPlusProvider>(context, listen: false);
     WalletsProfilesProvider _walletsProfilesClass =
         Provider.of<WalletsProfilesProvider>(context, listen: false);
+    HomeProvider _homeProvider =
+        Provider.of<HomeProvider>(context, listen: false);
 
     int keyID = 0;
     double _avatarSize = 55;
@@ -35,6 +38,7 @@ class SearchResultScreen extends StatelessWidget {
           child: Text('Résultats de votre recherche'),
         ),
       ),
+      bottomNavigationBar: _homeProvider.bottomAppBar(context),
       body: SafeArea(
         child: Padding(
           padding: const EdgeInsets.symmetric(horizontal: 20),
diff --git a/lib/screens/wallet_view.dart b/lib/screens/wallet_view.dart
index ceeb978b..6c8f805a 100644
--- a/lib/screens/wallet_view.dart
+++ b/lib/screens/wallet_view.dart
@@ -49,7 +49,7 @@ class WalletViewScreen extends StatelessWidget {
             child: Text('Voir un portefeuille'),
           ),
         ),
-        bottomNavigationBar: _homeProvider.bottomAppBar(context, 1),
+        bottomNavigationBar: _homeProvider.bottomAppBar(context),
         // floatingActionButton: _homeProvider.floatingAction(context, 1),
         // floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
         body: SafeArea(
-- 
GitLab