diff options
author | Ansh <anshnanda10@gmail.com> | 2023-04-18 09:19:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-18 11:19:37 -0500 |
commit | 10621e86e4379ff05b2262a659b8512d80203a4b (patch) | |
tree | fdc91b7db00526f945d9463b732785da6cceb5c7 /src/lib | |
parent | 2509290fdd2b20c76c302d4962216f5d2d2b5a73 (diff) | |
download | voidsky-10621e86e4379ff05b2262a659b8512d80203a4b.tar.zst |
APP-70 give profile its own tab mobile (#469)
* add prebuild command to package.json * add ProfileTab navigator and screen * add prop to remove back button from profile * fix MyProfileTabNavigatorParams type * fix dep array for rendering ProfileHeader * just added ts-ignore * enable opening drawer in profile tab * clean up useNavigationTabState * clean up code * fix hideBackButton code flow
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/hooks/useNavigationTabState.ts | 15 | ||||
-rw-r--r-- | src/lib/hooks/useNavigationTabState.web.ts | 1 | ||||
-rw-r--r-- | src/lib/routes/helpers.ts | 3 | ||||
-rw-r--r-- | src/lib/routes/types.ts | 14 |
4 files changed, 30 insertions, 3 deletions
diff --git a/src/lib/hooks/useNavigationTabState.ts b/src/lib/hooks/useNavigationTabState.ts index 8afc799eb..fb3662152 100644 --- a/src/lib/hooks/useNavigationTabState.ts +++ b/src/lib/hooks/useNavigationTabState.ts @@ -3,11 +3,24 @@ import {getTabState, TabState} from 'lib/routes/helpers' export function useNavigationTabState() { return useNavigationState(state => { - return { + const res = { isAtHome: getTabState(state, 'Home') !== TabState.Outside, isAtSearch: getTabState(state, 'Search') !== TabState.Outside, isAtNotifications: getTabState(state, 'Notifications') !== TabState.Outside, + isAtMyProfile: getTabState(state, 'MyProfile') !== TabState.Outside, } + if ( + !res.isAtHome && + !res.isAtNotifications && + !res.isAtSearch && + !res.isAtMyProfile + ) { + // HACK for some reason useNavigationState will give us pre-hydration results + // and not update after, so we force isAtHome if all came back false + // -prf + res.isAtHome = true + } + return res }) } diff --git a/src/lib/hooks/useNavigationTabState.web.ts b/src/lib/hooks/useNavigationTabState.web.ts index d0173aa0f..704424781 100644 --- a/src/lib/hooks/useNavigationTabState.web.ts +++ b/src/lib/hooks/useNavigationTabState.web.ts @@ -8,6 +8,7 @@ export function useNavigationTabState() { isAtHome: currentRoute === 'Home', isAtSearch: currentRoute === 'Search', isAtNotifications: currentRoute === 'Notifications', + isAtMyProfile: currentRoute === 'MyProfile', } }) } diff --git a/src/lib/routes/helpers.ts b/src/lib/routes/helpers.ts index be76b9669..cfa6ae53b 100644 --- a/src/lib/routes/helpers.ts +++ b/src/lib/routes/helpers.ts @@ -20,7 +20,8 @@ export function isStateAtTabRoot(state: State | undefined) { return ( isTab(currentRoute.name, 'Home') || isTab(currentRoute.name, 'Search') || - isTab(currentRoute.name, 'Notifications') + isTab(currentRoute.name, 'Notifications') || + isTab(currentRoute.name, 'MyProfile') ) } diff --git a/src/lib/routes/types.ts b/src/lib/routes/types.ts index 48edcc956..f8698f1cc 100644 --- a/src/lib/routes/types.ts +++ b/src/lib/routes/types.ts @@ -6,7 +6,7 @@ export type {NativeStackScreenProps} from '@react-navigation/native-stack' export type CommonNavigatorParams = { NotFound: undefined Settings: undefined - Profile: {name: string} + Profile: {name: string; hideBackButton?: boolean} ProfileFollowers: {name: string} ProfileFollows: {name: string} PostThread: {name: string; rkey: string} @@ -21,6 +21,13 @@ export type CommonNavigatorParams = { CopyrightPolicy: undefined } +export type BottomTabNavigatorParams = CommonNavigatorParams & { + HomeTab: undefined + SearchTab: undefined + NotificationsTab: undefined + MyProfileTab: undefined +} + export type HomeTabNavigatorParams = CommonNavigatorParams & { Home: undefined } @@ -33,6 +40,10 @@ export type NotificationsTabNavigatorParams = CommonNavigatorParams & { Notifications: undefined } +export type MyProfileTabNavigatorParams = CommonNavigatorParams & { + MyProfile: undefined +} + export type FlatNavigatorParams = CommonNavigatorParams & { Home: undefined Search: {q?: string} @@ -46,6 +57,7 @@ export type AllNavigatorParams = CommonNavigatorParams & { Search: {q?: string} NotificationsTab: undefined Notifications: undefined + MyProfileTab: undefined } // NOTE |