fluffychat/lib/pangea/navigation/navigation_util.dart
ggurdin 2e0d38e801
4860 dms all chats (#5015)
* feat: initial work for dms => all chats

* more navigation updates

* change all chats tooltip
2025-12-31 14:05:16 -05:00

31 lines
866 B
Dart

import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
class NavigationUtil {
static void goToSpaceRoute(
String route,
BuildContext context, {
Object? extra,
}) {
final currentRoute = GoRouterState.of(context);
final currentRouteSegments = currentRoute.uri.pathSegments;
if (currentRouteSegments.length > 1 &&
currentRouteSegments[0] == 'rooms' &&
currentRouteSegments[1] == 'spaces') {
final spaceId = currentRoute.pathParameters['spaceid'];
final subroute = route.split('/rooms/');
String goalRoute = "/rooms/spaces/$spaceId/";
if (subroute.length > 1) {
goalRoute += subroute[1];
}
if (goalRoute != currentRoute.uri.path) {
context.go(goalRoute, extra: extra);
return;
}
}
context.go(route, extra: extra);
}
}