Skip to content

Commit

Permalink
fix: add default size for panel if wallet list is not measured
Browse files Browse the repository at this point in the history
  • Loading branch information
gabaldon committed Nov 15, 2024
1 parent cd8d500 commit 9189326
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
13 changes: 13 additions & 0 deletions lib/util/get_sized_height.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:flutter/material.dart';

double getWalletListSize(BuildContext context, int walletsLenght) {
double walletHeight = 98;
double actionHeight = 40;
return walletsLenght * walletHeight + actionHeight;
}

double getBottomNavigationPadding(BuildContext context) {
return (MediaQuery.of(context).viewInsets.bottom +
kBottomNavigationBarHeight +
MediaQuery.of(context).viewPadding.bottom);
}
16 changes: 12 additions & 4 deletions lib/widgets/layouts/dashboard_layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import 'package:my_wit_wallet/util/current_route.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:my_wit_wallet/screens/login/bloc/login_bloc.dart';
import 'package:my_wit_wallet/shared/api_database.dart';
import 'package:my_wit_wallet/util/get_sized_height.dart';
import 'package:my_wit_wallet/util/panel.dart';
import 'package:my_wit_wallet/util/storage/database/wallet.dart';
import 'package:my_wit_wallet/util/storage/database/wallet_storage.dart';
import 'package:my_wit_wallet/widgets/bottom_navigation.dart';
import 'package:my_wit_wallet/widgets/send_receive.dart';
import 'package:my_wit_wallet/widgets/stake_unstake.dart';
Expand Down Expand Up @@ -45,13 +47,13 @@ class DashboardLayout extends StatefulWidget {

class DashboardLayoutState extends State<DashboardLayout>
with TickerProviderStateMixin {
Wallet? walletStorage;
late Timer explorerTimer;
bool isAddressCopied = false;
bool isCopyAddressFocus = false;
FocusNode _copyToClipboardFocusNode = FocusNode();
Wallet get currentWallet =>
Locator.instance.get<ApiDatabase>().walletStorage.currentWallet;
WalletStorage get walletStorage =>
Locator.instance.get<ApiDatabase>().walletStorage;
Wallet get currentWallet => walletStorage.currentWallet;
PanelUtils get panel => Locator.instance.get<PanelUtils>();
Widget get panelContent => panel.getContent();

Expand Down Expand Up @@ -134,11 +136,17 @@ class DashboardLayoutState extends State<DashboardLayout>
children: <Widget>[],
);
}

double walletListSize =
getWalletListSize(context, walletStorage.wallets.length);
double maxSize = MediaQuery.of(context).size.height * 0.8;
return Layout(
scrollController: widget.scrollController,
topNavigation: TopNavigation(
onShowWalletList: () async => {
// Sets panel height that shows the wallet list
panel.setHeight(walletListSize > maxSize
? maxSize
: walletListSize),
setState(() => panel.setContent(WalletList())),
await panel.toggle(),
},
Expand Down
3 changes: 2 additions & 1 deletion lib/widgets/layouts/layout.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:my_wit_wallet/auto_updater_overlay.dart';
import 'package:my_wit_wallet/bloc/explorer/explorer_bloc.dart';
import 'package:my_wit_wallet/bloc/transactions/value_transfer/vtt_create/vtt_create_bloc.dart';
import 'package:my_wit_wallet/constants.dart';
import 'package:my_wit_wallet/util/get_sized_height.dart';
import 'package:my_wit_wallet/util/panel.dart';
import 'package:my_wit_wallet/util/showTxConnectionError.dart';
import 'package:my_wit_wallet/widgets/layouts/listen_fourth_button.dart';
Expand Down Expand Up @@ -203,7 +204,7 @@ class LayoutState extends State<Layout> with TickerProviderStateMixin {
backdropEnabled: true,
color: extendedTheme.panelBgColor!,
minHeight: 0,
maxHeight: panel.getHeight(),
maxHeight: panel.getHeight() + getBottomNavigationPadding(context),
borderRadius: BorderRadius.only(
topLeft: extendedTheme.borderRadius!,
topRight: extendedTheme.borderRadius!),
Expand Down
7 changes: 0 additions & 7 deletions lib/widgets/wallet_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'package:my_wit_wallet/screens/create_wallet/bloc/create_wallet_bloc.dart
import 'package:my_wit_wallet/screens/create_wallet/create_wallet_screen.dart';
import 'package:my_wit_wallet/screens/dashboard/bloc/dashboard_bloc.dart';
import 'package:my_wit_wallet/shared/locator.dart';
import 'package:my_wit_wallet/util/panel.dart';
import 'package:my_wit_wallet/util/sort_wallets_by_name.dart';
import 'package:my_wit_wallet/util/storage/database/account.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
Expand Down Expand Up @@ -189,12 +188,6 @@ class WalletListState extends State<WalletList> {

@override
Widget build(BuildContext context) {
double walletListSize = (sortedWalletsByName.length * 100) + 16;
double maxSize = MediaQuery.of(context).size.height * 0.8;
// Sets panel height that shows the wallet list
Locator.instance
.get<PanelUtils>()
.setHeight(walletListSize > maxSize ? maxSize : walletListSize);
return SafeArea(
top: false,
child: ListView(padding: EdgeInsets.all(8), children: [
Expand Down

0 comments on commit 9189326

Please sign in to comment.