mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
fix: Desktop resize bug (#1461)
* fix: Desktop resize bug * Change default spl tokens * Minor enhancements [skip ci] * minor enhancements [skip ci] --------- Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
This commit is contained in:
co-authored by
OmarHatem
parent
dfba5be2cd
commit
461fe1c859
@@ -36,7 +36,7 @@ import 'package:cake_wallet/src/screens/release_notes/release_notes_screen.dart'
|
||||
import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart';
|
||||
import 'package:cake_wallet/themes/extensions/balance_page_theme.dart';
|
||||
|
||||
class DashboardPage extends StatelessWidget {
|
||||
class DashboardPage extends StatefulWidget {
|
||||
DashboardPage({
|
||||
required this.bottomSheetService,
|
||||
required this.balancePage,
|
||||
@@ -50,43 +50,71 @@ class DashboardPage extends StatelessWidget {
|
||||
final WalletAddressListViewModel addressListViewModel;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screenHeight = MediaQuery.of(context).size.height;
|
||||
return Scaffold(
|
||||
body: Builder(
|
||||
builder: (_) {
|
||||
final dashboardPageView = RefreshIndicator(
|
||||
displacement: screenHeight * 0.1,
|
||||
onRefresh: () async => await dashboardViewModel.refreshDashboard(),
|
||||
child: SingleChildScrollView(
|
||||
physics: AlwaysScrollableScrollPhysics(),
|
||||
child: Container(
|
||||
height: screenHeight,
|
||||
child: _DashboardPageView(
|
||||
balancePage: balancePage,
|
||||
bottomSheetService: bottomSheetService,
|
||||
dashboardViewModel: dashboardViewModel,
|
||||
addressListViewModel: addressListViewModel,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
State<DashboardPage> createState() => _DashboardPageState();
|
||||
}
|
||||
|
||||
if (DeviceInfo.instance.isDesktop) {
|
||||
if (responsiveLayoutUtil.screenWidth >
|
||||
ResponsiveLayoutUtilBase.kDesktopMaxDashBoardWidthConstraint) {
|
||||
return getIt.get<DesktopSidebarWrapper>();
|
||||
} else {
|
||||
return dashboardPageView;
|
||||
}
|
||||
} else if (responsiveLayoutUtil.shouldRenderMobileUI) {
|
||||
return dashboardPageView;
|
||||
} else {
|
||||
return getIt.get<DesktopSidebarWrapper>();
|
||||
}
|
||||
},
|
||||
class _DashboardPageState extends State<DashboardPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
bool isMobileLayout =
|
||||
responsiveLayoutUtil.screenWidth < ResponsiveLayoutUtilBase.kMobileThreshold;
|
||||
|
||||
reaction((_) => responsiveLayoutUtil.screenWidth, (screenWidth) {
|
||||
// Check if it was previously in mobile layout, and now changing to desktop
|
||||
if (isMobileLayout &&
|
||||
screenWidth > ResponsiveLayoutUtilBase.kDesktopMaxDashBoardWidthConstraint) {
|
||||
setState(() {
|
||||
isMobileLayout = false;
|
||||
});
|
||||
}
|
||||
|
||||
// Check if it was previously in desktop layout, and now changing to mobile
|
||||
if (!isMobileLayout &&
|
||||
screenWidth <= ResponsiveLayoutUtilBase.kDesktopMaxDashBoardWidthConstraint) {
|
||||
setState(() {
|
||||
isMobileLayout = true;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget dashboardChild;
|
||||
|
||||
final dashboardPageView = RefreshIndicator(
|
||||
displacement: responsiveLayoutUtil.screenHeight * 0.1,
|
||||
onRefresh: () async => await widget.dashboardViewModel.refreshDashboard(),
|
||||
child: SingleChildScrollView(
|
||||
physics: AlwaysScrollableScrollPhysics(),
|
||||
child: Container(
|
||||
height: responsiveLayoutUtil.screenHeight,
|
||||
child: _DashboardPageView(
|
||||
balancePage: widget.balancePage,
|
||||
bottomSheetService: widget.bottomSheetService,
|
||||
dashboardViewModel: widget.dashboardViewModel,
|
||||
addressListViewModel: widget.addressListViewModel,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (DeviceInfo.instance.isDesktop) {
|
||||
if (responsiveLayoutUtil.screenWidth >
|
||||
ResponsiveLayoutUtilBase.kDesktopMaxDashBoardWidthConstraint) {
|
||||
dashboardChild = getIt.get<DesktopSidebarWrapper>();
|
||||
} else {
|
||||
dashboardChild = dashboardPageView;
|
||||
}
|
||||
} else if (responsiveLayoutUtil.shouldRenderMobileUI) {
|
||||
dashboardChild = dashboardPageView;
|
||||
} else {
|
||||
dashboardChild = getIt.get<DesktopSidebarWrapper>();
|
||||
}
|
||||
|
||||
return Scaffold(body: dashboardChild);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ part 'responsive_layout_util.g.dart';
|
||||
class _ResponsiveLayoutUtil = ResponsiveLayoutUtilBase with _$_ResponsiveLayoutUtil;
|
||||
|
||||
abstract class ResponsiveLayoutUtilBase with Store, WidgetsBindingObserver {
|
||||
static const double _kMobileThreshold = 550;
|
||||
static const double kMobileThreshold = 550;
|
||||
static const double kDesktopMaxWidthConstraint = 400;
|
||||
static const double kDesktopMaxDashBoardWidthConstraint = 900;
|
||||
static const double kPopupWidth = 400;
|
||||
@@ -42,13 +42,13 @@ abstract class ResponsiveLayoutUtilBase with Store, WidgetsBindingObserver {
|
||||
|
||||
@computed
|
||||
bool get shouldRenderMobileUI {
|
||||
return (screenWidth <= _kMobileThreshold) ||
|
||||
return (screenWidth <= kMobileThreshold) ||
|
||||
(orientation == Orientation.portrait && screenWidth < screenHeight) ||
|
||||
(orientation == Orientation.landscape && screenWidth < screenHeight);
|
||||
}
|
||||
|
||||
bool get shouldRenderTabletUI {
|
||||
return screenWidth > _kMobileThreshold && screenWidth < kDesktopMaxDashBoardWidthConstraint;
|
||||
return screenWidth > kMobileThreshold && screenWidth < kDesktopMaxDashBoardWidthConstraint;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user