From 3ff89f828f85d046317883a77bb6dea28f126e98 Mon Sep 17 00:00:00 2001 From: Restioson Date: Wed, 15 May 2024 14:51:25 +0200 Subject: [PATCH] fix: don't refresh TradingView when switching from wallet to trading tab --- mobile/lib/common/routes.dart | 91 ++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 44 deletions(-) diff --git a/mobile/lib/common/routes.dart b/mobile/lib/common/routes.dart index 955e6508c..036153d6b 100644 --- a/mobile/lib/common/routes.dart +++ b/mobile/lib/common/routes.dart @@ -174,55 +174,58 @@ GoRouter createRoutes() { }, ) ]), - ShellRoute( - navigatorKey: shellNavigatorKey, + StatefulShellRoute.indexedStack( builder: (BuildContext context, GoRouterState state, Widget child) { return ScaffoldWithNavBar( child: child, ); }, - routes: [ - GoRoute( - path: WalletScreen.route, - builder: (BuildContext context, GoRouterState state) { - return const WalletScreen(); - }, - routes: [ - GoRoute( - path: SendOnChainScreen.subRouteName, - // Use root navigator so the screen overlays the application shell - parentNavigatorKey: rootNavigatorKey, - builder: (BuildContext context, GoRouterState state) { - return SendOnChainScreen(destination: state.extra as OnChainAddress); - }, - ), - GoRoute( - path: ReceiveScreen.subRouteName, - // Use root navigator so the screen overlays the application shell - parentNavigatorKey: rootNavigatorKey, - builder: (BuildContext context, GoRouterState state) { - if (state.extra != null) { - return ReceiveScreen(walletType: state.extra as WalletType); - } - return const ReceiveScreen(); - }, - ), - GoRoute( - path: ScannerScreen.subRouteName, - parentNavigatorKey: rootNavigatorKey, - builder: (BuildContext context, GoRouterState state) { - return const ScannerScreen(); - }, - ), - ], - ), - GoRoute( - path: TradeScreen.route, - builder: (BuildContext context, GoRouterState state) { - return const TradeScreen(); - }, - routes: const [], - ), + branches: [ + StatefulShellBranch(routes: [ + GoRoute( + path: WalletScreen.route, + builder: (BuildContext context, GoRouterState state) { + return const WalletScreen(); + }, + routes: [ + GoRoute( + path: SendOnChainScreen.subRouteName, + // Use root navigator so the screen overlays the application shell + parentNavigatorKey: rootNavigatorKey, + builder: (BuildContext context, GoRouterState state) { + return SendOnChainScreen(destination: state.extra as OnChainAddress); + }, + ), + GoRoute( + path: ReceiveScreen.subRouteName, + // Use root navigator so the screen overlays the application shell + parentNavigatorKey: rootNavigatorKey, + builder: (BuildContext context, GoRouterState state) { + if (state.extra != null) { + return ReceiveScreen(walletType: state.extra as WalletType); + } + return const ReceiveScreen(); + }, + ), + GoRoute( + path: ScannerScreen.subRouteName, + parentNavigatorKey: rootNavigatorKey, + builder: (BuildContext context, GoRouterState state) { + return const ScannerScreen(); + }, + ), + ], + ), + ]), + StatefulShellBranch(routes: [ + GoRoute( + path: TradeScreen.route, + builder: (BuildContext context, GoRouterState state) { + return const TradeScreen(); + }, + routes: const [], + ), + ]) ], ), ]),