Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
1.5 kB · 58 lines
TypeScript
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859/** * Navigator structure mapping - defines which routes belong to which parent navigators */const NAVIGATOR_STRUCTURE: Record<string, string[]> = { Home: ["HomeMain", "Stream"], Settings: [ "MainSettings", "AboutCategory", "AccountCategory", "StreamingCategory", "WebhooksSettings", "PrivacyCategory", "DanmuCategory", "AdvancedCategory", "LanguagesCategory", "DeveloperSettings", "KeyManagement", ],};
/** * Finds the parent navigator for a given route name */function findParentNavigator(routeName: string): string | null { for (const [parent, children] of Object.entries(NAVIGATOR_STRUCTURE)) { if (children.includes(routeName)) { return parent; } } return null;}
/** * Navigates to a route, automatically handling nested navigators */export function navigateToRoute( navigation: any, route: { name: string; params?: any },) { const parent = findParentNavigator(route.name);
if (parent) { // nested route - navigate to parent with screen param console.log( `navigateToRoute: ${route.name} is nested in ${parent}, navigating with screen param`, ); (navigation.navigate as any)(parent, { screen: route.name, params: route.params, }); } else { // top-level route - navigate directly console.log( `navigateToRoute: ${route.name} is top-level, navigating directly`, ); (navigation.navigate as any)(route.name, route.params); }}