chore: update routes so that going back after clicking on option on homepage goes back to homepage (#2333)

This commit is contained in:
ggurdin 2025-04-03 09:40:11 -04:00 committed by GitHub
parent c44d4441d2
commit f5ba759bd4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 85 additions and 77 deletions

View file

@ -140,17 +140,13 @@ abstract class AppRoutes {
),
GoRoute(
path: '/join_with_alias',
pageBuilder: (context, state) => defaultPageBuilder(
context,
state,
const JoinWithAlias(),
),
redirect: (context, state) {
if (Matrix.of(context).client.isLogged()) {
return '/rooms/join_with_alias?alias=${state.uri.queryParameters['alias']}';
}
return null;
},
pageBuilder: (context, state) => Matrix.of(context).client.isLogged()
? chatListShellRouteBuilder(context, state, const JoinWithAlias())
: defaultPageBuilder(
context,
state,
const JoinWithAlias(),
),
),
GoRoute(
path: '/user_age',
@ -161,6 +157,32 @@ abstract class AppRoutes {
),
redirect: loggedOutRedirect,
),
ShellRoute(
pageBuilder: chatListShellRouteBuilder,
routes: [
GoRoute(
path: '/homepage',
redirect: loggedOutRedirect,
pageBuilder: (context, state) => defaultPageBuilder(
context,
state,
const SuggestionsPage(),
),
routes: [
...newRoomRoutes,
GoRoute(
path: '/planner',
redirect: loggedOutRedirect,
pageBuilder: (context, state) => defaultPageBuilder(
context,
state,
const ActivityGenerator(),
),
),
],
),
],
),
// Pangea#
ShellRoute(
// Never use a transition on the shell route. Changing the PageBuilder
@ -206,66 +228,6 @@ abstract class AppRoutes {
),
),
routes: [
// #Pangea
// GoRoute(
// path: 'mylearning',
// pageBuilder: (context, state) => defaultPageBuilder(
// context,
// state,
// const StudentAnalyticsPage(
// selectedView: BarChartViewSelection.messages,
// ),
// ),
// redirect: loggedOutRedirect,
// ),
// GoRoute(
// path: 'analytics',
// pageBuilder: (context, state) => defaultPageBuilder(
// context,
// state,
// const AnalyticsSpaceList(),
// ),
// redirect: loggedOutRedirect,
// routes: [
// GoRoute(
// path: ':spaceid',
// pageBuilder: (context, state) => defaultPageBuilder(
// context,
// state,
// const SpaceAnalyticsPage(
// selectedView: BarChartViewSelection.messages,
// ),
// ),
// ),
// ],
// ),
GoRoute(
path: '/join_with_alias',
pageBuilder: (context, state) => defaultPageBuilder(
context,
state,
const JoinWithAlias(),
),
),
GoRoute(
path: '/homepage',
redirect: loggedOutRedirect,
pageBuilder: (context, state) => defaultPageBuilder(
context,
state,
const SuggestionsPage(),
),
),
GoRoute(
path: '/planner',
redirect: loggedOutRedirect,
pageBuilder: (context, state) => defaultPageBuilder(
context,
state,
const ActivityGenerator(),
),
),
// Pangea#
GoRoute(
path: 'archive',
pageBuilder: (context, state) => defaultPageBuilder(
@ -299,10 +261,7 @@ abstract class AppRoutes {
redirect: loggedOutRedirect,
),
GoRoute(
// #Pangea
// path: 'newgroup',
path: 'newgroup',
// Pangea#
pageBuilder: (context, state) => defaultPageBuilder(
context,
state,
@ -725,4 +684,53 @@ abstract class AppRoutes {
// child: child,
// );
// Pangea#
// #Pangea
static List<RouteBase> get newRoomRoutes => [
GoRoute(
path: 'newgroup',
pageBuilder: (context, state) => defaultPageBuilder(
context,
state,
const NewGroup(),
),
redirect: loggedOutRedirect,
),
GoRoute(
path: 'newspace',
pageBuilder: (context, state) => defaultPageBuilder(
context,
state,
const NewGroup(createGroupType: CreateGroupType.space),
),
redirect: loggedOutRedirect,
),
];
static Page chatListShellRouteBuilder(
context,
state,
child,
) =>
noTransitionPageBuilder(
context,
state,
FluffyThemes.isColumnMode(context) &&
state.fullPath?.startsWith('/rooms/settings') == false
? TwoColumnLayout(
mainView: ChatList(
activeChat: state.pathParameters['roomid'],
displayNavigationRail:
state.path?.startsWith('/rooms/settings') != true,
),
sideView: child,
)
: FluffyThemes.isColumnMode(context) ||
(state.fullPath?.split("/").reversed.elementAt(1) ==
'rooms' &&
state.pathParameters['roomid'] != null)
? child
: BottomNavLayout(mainView: child),
);
// Pangea#
}

View file

@ -154,7 +154,7 @@ class ActivitySuggestionsAreaState extends State<ActivitySuggestionsArea> {
children: [
InkWell(
customBorder: const CircleBorder(),
onTap: () => context.go('/rooms/newgroup'),
onTap: () => context.go('/homepage/newgroup'),
child: Container(
decoration: BoxDecoration(
color: theme.colorScheme.surfaceContainerHighest,
@ -193,7 +193,7 @@ class ActivitySuggestionsAreaState extends State<ActivitySuggestionsArea> {
),
InkWell(
customBorder: const CircleBorder(),
onTap: () => context.go('/rooms/planner'),
onTap: () => context.go('/homepage/planner'),
child: Container(
decoration: BoxDecoration(
color: theme.colorScheme.surfaceContainerHighest,

View file

@ -43,7 +43,7 @@ class BottomNavBarState extends State<BottomNavBar> {
void onItemTapped(int index) {
switch (index) {
case 0:
context.go('/rooms/homepage');
context.go('/homepage');
break;
case 1:
context.go('/rooms');