From 0e0110aa135b0dd0d9e3ccecabc91758b948d55d Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Wed, 28 May 2025 12:17:25 +0300 Subject: [PATCH] improve navigation types --- src/Navigation.tsx | 24 +++++++++++------------- src/lib/routes/types.ts | 2 +- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/Navigation.tsx b/src/Navigation.tsx index da4480c49d..fd36315b9e 100644 --- a/src/Navigation.tsx +++ b/src/Navigation.tsx @@ -127,7 +127,7 @@ const Tab = createBottomTabNavigator() /** * These "common screens" are reused across stacks. */ -function commonScreens(Stack: typeof HomeTab, unreadCountLabel?: string) { +function commonScreens(Stack: typeof Flat, unreadCountLabel?: string) { const title = (page: MessageDescriptor) => bskyTitle(i18n._(page), unreadCountLabel) @@ -530,7 +530,7 @@ function HomeTabNavigator() { }}> HomeScreen} /> HomeScreen} /> - {commonScreens(HomeTab)} + {commonScreens(HomeTab as typeof Flat)} ) } @@ -548,7 +548,7 @@ function SearchTabNavigator() { contentStyle: t.atoms.bg, }}> SearchScreen} /> - {commonScreens(SearchTab as typeof HomeTab)} + {commonScreens(SearchTab as typeof Flat)} ) } @@ -570,7 +570,7 @@ function NotificationsTabNavigator() { getComponent={() => NotificationsScreen} options={{requireAuth: true}} /> - {commonScreens(NotificationsTab as typeof HomeTab)} + {commonScreens(NotificationsTab as typeof Flat)} ) } @@ -588,15 +588,13 @@ function MyProfileTabNavigator() { contentStyle: t.atoms.bg, }}> ProfileScreen} - initialParams={{ - name: 'me', - hideBackButton: true, - }} + initialParams={{name: 'me', hideBackButton: true}} /> - {commonScreens(MyProfileTab as typeof HomeTab)} + {commonScreens(MyProfileTab as unknown as typeof Flat)} ) } @@ -621,7 +619,7 @@ function MessagesTabNavigator() { animationTypeForReplace: route.params?.animation ?? 'push', })} /> - {commonScreens(MessagesTab as typeof HomeTab)} + {commonScreens(MessagesTab as typeof Flat)} ) } @@ -672,7 +670,7 @@ const FlatNavigator = () => { getComponent={() => HomeScreen} options={{title: title(msg`Home`)}} /> - {commonScreens(Flat as typeof HomeTab, numUnread)} + {commonScreens(Flat, numUnread)} ) } diff --git a/src/lib/routes/types.ts b/src/lib/routes/types.ts index 0bc85b630c..6f102d438a 100644 --- a/src/lib/routes/types.ts +++ b/src/lib/routes/types.ts @@ -92,7 +92,7 @@ export type NotificationsTabNavigatorParams = CommonNavigatorParams & { } export type MyProfileTabNavigatorParams = CommonNavigatorParams & { - MyProfile: undefined + MyProfile: {name: 'me'; hideBackButton: true} } export type MessagesTabNavigatorParams = CommonNavigatorParams & {