Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat adjust panel height #616

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ const int PAGINATION_LIMIT = 10;
const double DASHBOARD_HEADER_HEIGHT = 70;
const double DEFAULT_BOTTOM_PADDING = 24;
const double HEADER_HEIGHT = 140;
const double PANEL_ACTION_HEIGHT = 69;
const double PANEL_BALANCE_HEIGHT = 208;
const String VERSION_NUMBER = '1.1.4';
const int ENCRYPTED_XPRV_LENGTH = 293;
const int XPRV_LENGTH = 117;
Expand Down
3 changes: 2 additions & 1 deletion lib/screens/dashboard/view/dashboard_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,11 @@ class DashboardScreenState extends State<DashboardScreen>
WalletInfo(
currentWallet: currentWallet!,
onShowBalanceDetails: () async => {
panel.setHeight(PANEL_BALANCE_HEIGHT),
setState(() => panel.setContent(BalanceDetails(
balance: currentWallet!.balanceNanoWit(),
stakedBalance: currentWallet!.stakedNanoWit()))),
await panel.toggle(),
await panel.toggle()
}),
SizedBox(height: 8)
];
Expand Down
18 changes: 4 additions & 14 deletions lib/screens/preferences/delete_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:my_wit_wallet/screens/preferences/logout.dart';
import 'package:my_wit_wallet/shared/api_database.dart';
import 'package:my_wit_wallet/shared/locator.dart';
import 'package:my_wit_wallet/theme/extended_theme.dart';
import 'package:my_wit_wallet/theme/wallet_theme.dart';
import 'package:my_wit_wallet/util/get_localization.dart';
import 'package:my_wit_wallet/screens/dashboard/bloc/dashboard_bloc.dart';
import 'package:my_wit_wallet/util/storage/database/wallet.dart';
Expand Down Expand Up @@ -115,14 +114,10 @@ class DeleteSingleWalletState extends State<DeleteSingleWallet> {
],
icon: FontAwesomeIcons.circleExclamation,
title: localization.deleteWalletWarning,
content: Column(mainAxisSize: MainAxisSize.min, children: [
SizedBox(height: 16),
svgThemeImage(theme, name: 'general-warning', height: 100),
]));
content: Container());
}

void showStorageDeletedMessage() {
final theme = Theme.of(context);
return buildAlertDialog(
context: context,
actions: [
Expand All @@ -131,11 +126,9 @@ class DeleteSingleWalletState extends State<DeleteSingleWallet> {
text: localization.continueLabel,
onPressed: () => logout(context))
],
icon: FontAwesomeIcons.check,
title: localization.deleteWalletSuccess,
content: Column(mainAxisSize: MainAxisSize.min, children: [
SizedBox(height: 16),
svgThemeImage(theme, name: 'transaction-success', height: 100),
]));
content: Container());
}

void toggleCheckBox(bool? value) {
Expand All @@ -149,9 +142,6 @@ class DeleteSingleWalletState extends State<DeleteSingleWallet> {
final theme = Theme.of(context);

TextStyle bodyLarge = theme.textTheme.bodyLarge!;
TextStyle bodyLargeBold = bodyLarge.copyWith(
fontWeight: FontWeight.bold,
);

return BlocBuilder<DashboardBloc, DashboardState>(
builder: (previous, current) {
Expand All @@ -163,7 +153,7 @@ class DeleteSingleWalletState extends State<DeleteSingleWallet> {
SizedBox(height: 10),
Text(localization.reestablishInstructions, style: bodyLarge),
SizedBox(height: 10),
Text(localization.whatToDo, style: bodyLargeBold),
Text(localization.whatToDo, style: theme.textTheme.titleMedium),
SizedBox(height: 10),
buildOrderedListItem(
'1. ', localization.reestablishSteps01, context),
Expand Down
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);
}
9 changes: 9 additions & 0 deletions lib/util/panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:sliding_up_panel/sliding_up_panel.dart';

class PanelUtils {
Widget panelContent = Text('');
double contentHeight = 0;
final PanelController panelController = PanelController();

void setContent(Widget content) {
Expand All @@ -14,6 +15,14 @@ class PanelUtils {
return panelContent;
}

void setHeight(double height) {
contentHeight = height;
}

double getHeight() {
return contentHeight;
}

Future<void> toggle() async {
if (panelController.isPanelClosed) {
await open();
Expand Down
61 changes: 20 additions & 41 deletions lib/widgets/balance_details.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:my_wit_wallet/constants.dart';
import 'package:my_wit_wallet/theme/extended_theme.dart';
import 'package:my_wit_wallet/util/extensions/num_extensions.dart';
import 'package:my_wit_wallet/util/get_localization.dart';
import 'package:my_wit_wallet/util/storage/database/balance_info.dart';
import 'package:flutter/material.dart';
import 'package:my_wit_wallet/widgets/info_element.dart';

typedef void VoidCallback();

Expand All @@ -14,10 +14,6 @@ class BalanceDetails extends StatelessWidget {

Widget build(BuildContext context) {
final theme = Theme.of(context);
final extendedTheme = theme.extension<ExtendedTheme>()!;
final textStyle = extendedTheme.regularPanelText;
final labelTextStyle = extendedTheme.mediumPanelText;
;
return Padding(
padding: EdgeInsets.only(top: 32, bottom: 32, left: 24, right: 24),
child: Column(
Expand All @@ -26,44 +22,27 @@ class BalanceDetails extends StatelessWidget {
children: [
Text(
localization.balanceDetails,
style: labelTextStyle,
style: theme.textTheme.titleLarge,
),
SizedBox(height: 24),
Row(children: [
Text(
localization.available,
style: labelTextStyle,
),
Spacer(),
Text(
'${balance.availableNanoWit.standardizeWitUnits().toString()} ${WIT_UNIT[WitUnit.Wit]}',
style: textStyle,
),
]),
SizedBox(height: 16),
Row(children: [
Text(
localization.locked,
style: labelTextStyle,
),
Spacer(),
Text(
'${balance.lockedNanoWit.standardizeWitUnits().toString()} ${WIT_UNIT[WitUnit.Wit]}',
style: textStyle,
),
]),
SizedBox(height: 16),
Row(children: [
Text(
localization.staked,
style: labelTextStyle,
),
Spacer(),
Text(
'${stakedBalance.stakedNanoWit.standardizeWitUnits().toString()} ${WIT_UNIT[WitUnit.Wit]}',
style: textStyle,
),
])
InfoElement(
isContentImportant: true,
label: localization.available,
text:
'${balance.availableNanoWit.standardizeWitUnits().toString()} ${WIT_UNIT[WitUnit.Wit]}',
),
InfoElement(
isContentImportant: true,
label: localization.locked,
text:
'${balance.lockedNanoWit.standardizeWitUnits().toString()} ${WIT_UNIT[WitUnit.Wit]}',
),
InfoElement(
isContentImportant: true,
label: localization.staked,
text:
'${stakedBalance.stakedNanoWit.standardizeWitUnits().toString()} ${WIT_UNIT[WitUnit.Wit]}',
),
]));
}
}
20 changes: 16 additions & 4 deletions lib/widgets/layouts/dashboard_layout.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:my_wit_wallet/constants.dart';
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 @@ -44,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 All @@ -73,13 +76,16 @@ class DashboardLayoutState extends State<DashboardLayout>
}

Widget _buildBottomNavigation() {
double actionsHeight = PANEL_ACTION_HEIGHT * 2;
return BottomNavigation(
currentScreen: currentRoute(context),
onSendReceiveAction: () async => {
panel.setHeight(actionsHeight),
setState(() => panel.setContent(SendReceiveButtons())),
await panel.toggle(),
},
onStakeUnstakeAction: () async => {
panel.setHeight(actionsHeight),
setState(() => panel.setContent(StakeUnstakeButtons())),
await panel.toggle(),
});
Expand Down Expand Up @@ -130,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: MediaQuery.of(context).size.height * 0.4,
maxHeight: panel.getHeight() + getBottomNavigationPadding(context),
borderRadius: BorderRadius.only(
topLeft: extendedTheme.borderRadius!,
topRight: extendedTheme.borderRadius!),
Expand Down
16 changes: 8 additions & 8 deletions lib/widgets/wallet_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ class WalletListState extends State<WalletList> {
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [_buildInitialButtons()]),
SizedBox(height: 8),
ListView.builder(
padding: EdgeInsets.zero,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: sortedWalletsByName.length,
itemBuilder: (context, index) {
return _buildWalletItem(sortedWalletsByName[index]);
},
),
padding: EdgeInsets.zero,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount: sortedWalletsByName.length,
itemBuilder: (context, index) {
return _buildWalletItem(sortedWalletsByName[index]);
})
]));
}
}
Loading