diff --git a/lib/router.dart b/lib/router.dart index a253eea22..91a5ac4e1 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -520,8 +520,10 @@ Route createRoute(RouteSettings settings) { )); case Routes.desktop_actions: - return CupertinoPageRoute( - builder: (_) => DesktopDashboardActions(getIt())); + return PageRouteBuilder( + opaque: false, + pageBuilder: (_, __, ___) => DesktopDashboardActions(getIt()), + ); case Routes.desktop_settings_page: return CupertinoPageRoute( diff --git a/lib/src/screens/dashboard/desktop_dashboard_page.dart b/lib/src/screens/dashboard/desktop_dashboard_page.dart index ac5700af4..1ab45fc7c 100644 --- a/lib/src/screens/dashboard/desktop_dashboard_page.dart +++ b/lib/src/screens/dashboard/desktop_dashboard_page.dart @@ -1,7 +1,6 @@ import 'dart:async'; import 'package:cake_wallet/di.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_wallet_selection_dropdown.dart'; -import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/src/screens/yat_emoji_id.dart'; @@ -18,6 +17,7 @@ import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_v import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:mobx/mobx.dart'; import 'package:cake_wallet/main.dart'; +import 'package:cake_wallet/router.dart' as Router; class DesktopDashboardPage extends BasePage { DesktopDashboardPage({ @@ -27,6 +27,8 @@ class DesktopDashboardPage extends BasePage { required this.desktopSidebarViewModel, }); + static final GlobalKey desktopKey = GlobalKey(); + @override Color get backgroundLightColor => currentTheme.type == ThemeType.bright ? Colors.transparent : Colors.white; @@ -73,13 +75,12 @@ class DesktopDashboardPage extends BasePage { }); if (currentPath == Routes.transactionsPage) { - desktopSidebarViewModel.resetSidebar(); - return; - } + desktopSidebarViewModel.resetSidebar(); + return; + } desktopSidebarViewModel.onPageChange(SidebarItem.transactions); desktopKey.currentState!.pushNamed(Routes.transactionsPage); - }, child: Observer( builder: (_) { @@ -105,7 +106,26 @@ class DesktopDashboardPage extends BasePage { Widget body(BuildContext context) { _setEffects(context); - return DesktopDashboardView(balancePage); + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Expanded( + flex: 3, + child: balancePage, + ), + Expanded( + flex: 5, + child: Navigator( + key: desktopKey, + initialRoute: Routes.desktop_actions, + onGenerateRoute: (settings) => Router.createRoute(settings), + onGenerateInitialRoutes: (NavigatorState navigator, String initialRouteName) { + return [navigator.widget.onGenerateRoute!(RouteSettings(name: initialRouteName))!]; + }, + ), + ), + ], + ); } void _setEffects(BuildContext context) async { diff --git a/lib/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart b/lib/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart deleted file mode 100644 index 7e2bba777..000000000 --- a/lib/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart +++ /dev/null @@ -1,35 +0,0 @@ -import 'package:cake_wallet/routes.dart'; -import 'package:flutter/material.dart'; -import 'package:cake_wallet/router.dart' as Router; - -GlobalKey desktopKey = GlobalKey(); - -class DesktopDashboardView extends StatelessWidget { - final Widget balancePage; - - const DesktopDashboardView(this.balancePage, {Key? key}) : super(key: key); - - @override - Widget build(BuildContext context) { - return Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Expanded( - flex: 3, - child: balancePage, - ), - Expanded( - flex: 5, - child: Navigator( - key: desktopKey, - initialRoute: Routes.desktop_actions, - onGenerateRoute: (settings) => Router.createRoute(settings), - onGenerateInitialRoutes: (NavigatorState navigator, String initialRouteName) { - return [navigator.widget.onGenerateRoute!(RouteSettings(name: initialRouteName))!]; - }, - ), - ), - ], - ); - } -} diff --git a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart b/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart index 19e417211..81dd8243f 100644 --- a/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart +++ b/lib/src/screens/dashboard/desktop_widgets/desktop_sidebar_wrapper.dart @@ -1,5 +1,5 @@ import 'package:cake_wallet/routes.dart'; -import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_dashboard_view.dart'; +import 'package:cake_wallet/src/screens/dashboard/desktop_dashboard_page.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu.dart'; import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_sidebar/side_menu_item.dart'; import 'package:cake_wallet/view_model/dashboard/desktop_sidebar_view_model.dart'; @@ -21,7 +21,7 @@ class DesktopSidebarWrapper extends StatelessWidget { reaction((_) => desktopSidebarViewModel.currentPage, (page) { String? currentPath; - desktopKey.currentState?.popUntil((route) { + DesktopDashboardPage.desktopKey.currentState?.popUntil((route) { currentPath = route.settings.name; return true; }); @@ -30,7 +30,7 @@ class DesktopSidebarWrapper extends StatelessWidget { } if (currentPath == Routes.transactionsPage) { - Navigator.of(desktopKey.currentContext!).pop(); + Navigator.of(DesktopDashboardPage.desktopKey.currentContext!).pop(); } pageController.jumpToPage(page.index); diff --git a/lib/src/screens/dashboard/widgets/balance_page.dart b/lib/src/screens/dashboard/widgets/balance_page.dart index 48eaa0a3e..fe750538b 100644 --- a/lib/src/screens/dashboard/widgets/balance_page.dart +++ b/lib/src/screens/dashboard/widgets/balance_page.dart @@ -16,9 +16,6 @@ class BalancePage extends StatelessWidget{ final DashboardViewModel dashboardViewModel; final SettingsStore settingsStore; - - Color get backgroundLightColor => - settingsStore.currentTheme.type == ThemeType.bright ? Colors.transparent : Colors.white; @override Widget build(BuildContext context) {