diff --git a/src/Navigation.tsx b/src/Navigation.tsx index bbb0b1c25..b1b23f892 100644 --- a/src/Navigation.tsx +++ b/src/Navigation.tsx @@ -677,6 +677,10 @@ function TabsNavigator({ name="MyProfileTab" getComponent={() => MyProfileTabNavigator} /> + AtmosphereTabNavigator} + /> FeedsTabNavigator} /> ListsTabNavigator} /> +} + function FeedsTabNavigator() { return } @@ -1018,6 +1026,7 @@ const LINKING = { return buildStateObject('MessagesTab', 'Messages', params) } if ( + name === 'Atmosphere' || name === 'Feeds' || name === 'Lists' || name === 'Bookmarks' || diff --git a/src/lib/hooks/useNavigationTabState.ts b/src/lib/hooks/useNavigationTabState.ts index b2c2caea8..5e53c9926 100644 --- a/src/lib/hooks/useNavigationTabState.ts +++ b/src/lib/hooks/useNavigationTabState.ts @@ -1,14 +1,13 @@ import {useNavigationState} from '@react-navigation/native' -import {getCurrentRoute, getTabState, TabState} from '#/lib/routes/helpers' +import {getTabState, TabState} from '#/lib/routes/helpers' export function useNavigationTabState() { return useNavigationState(state => { - const isAtAtmosphere = getCurrentRoute(state).name === 'Atmosphere' const res = { isAtHome: getTabState(state, 'Home') !== TabState.Outside, isAtSearch: getTabState(state, 'Search') !== TabState.Outside, - isAtAtmosphere, + isAtAtmosphere: getTabState(state, 'Atmosphere') !== TabState.Outside, isAtFeeds: getTabState(state, 'Feeds') !== TabState.Outside, isAtLists: getTabState(state, 'Lists') !== TabState.Outside, isAtBookmarks: getTabState(state, 'Bookmarks') !== TabState.Outside, diff --git a/src/lib/routes/helpers.test.ts b/src/lib/routes/helpers.test.ts index fa785d237..bb3935257 100644 --- a/src/lib/routes/helpers.test.ts +++ b/src/lib/routes/helpers.test.ts @@ -18,6 +18,7 @@ describe('native tab navigation state', () => { ['MessagesTab', 'Messages'], ['NotificationsTab', 'Notifications'], ['MyProfileTab', 'MyProfile'], + ['AtmosphereTab', 'Atmosphere'], ['FeedsTab', 'Feeds'], ['ListsTab', 'Lists'], ['BookmarksTab', 'Bookmarks'], @@ -61,6 +62,7 @@ describe('native tab navigation state', () => { ['MessagesTab', 'Messages'], ['NotificationsTab', 'Notifications'], ['MyProfileTab', 'MyProfile'], + ['AtmosphereTab', 'Atmosphere'], ['FeedsTab', 'Feeds'], ['ListsTab', 'Lists'], ['BookmarksTab', 'Bookmarks'], @@ -78,7 +80,13 @@ describe('native tab navigation state', () => { ) it('builds deep links directly into the matching sidebar tab', () => { - for (const screen of ['Feeds', 'Lists', 'Bookmarks', 'Settings']) { + for (const screen of [ + 'Atmosphere', + 'Feeds', + 'Lists', + 'Bookmarks', + 'Settings', + ]) { const state = asState(buildStateObject(`${screen}Tab`, screen, {})) expect(getTabState(state, screen)).toBe(TabState.InsideAtRoot) } @@ -94,7 +102,7 @@ describe('native tab navigation state', () => { expect(getTabState(state, 'MyProfile')).toBe(TabState.Outside) }) - it.each(['Feeds', 'Lists', 'Bookmarks', 'Settings'])( + it.each(['Atmosphere', 'Feeds', 'Lists', 'Bookmarks', 'Settings'])( 'does not treat the legacy %s common screen inside HomeTab as a tab root', screen => { const state = asState(buildStateObject('HomeTab', screen, {})) diff --git a/src/lib/routes/helpers.ts b/src/lib/routes/helpers.ts index ca8fff414..62ae05e9c 100644 --- a/src/lib/routes/helpers.ts +++ b/src/lib/routes/helpers.ts @@ -42,6 +42,7 @@ export function isStateAtTabRoot(state: State | undefined) { const currentRoute = getCurrentRoute(state) const activeTab = state.routes[state.index || 0].name const isSecondaryTabRoot = + (activeTab === 'AtmosphereTab' && currentRoute.name === 'Atmosphere') || (activeTab === 'FeedsTab' && currentRoute.name === 'Feeds') || (activeTab === 'ListsTab' && currentRoute.name === 'Lists') || (activeTab === 'BookmarksTab' && currentRoute.name === 'Bookmarks') || @@ -94,6 +95,7 @@ export enum TabState { } const SECONDARY_TAB_ROUTES: Record = { + Atmosphere: 'AtmosphereTab', Feeds: 'FeedsTab', Lists: 'ListsTab', Bookmarks: 'BookmarksTab', diff --git a/src/lib/routes/tab-to-nav-item.ts b/src/lib/routes/tab-to-nav-item.ts index 877766f46..3947eccbf 100644 --- a/src/lib/routes/tab-to-nav-item.ts +++ b/src/lib/routes/tab-to-nav-item.ts @@ -4,7 +4,7 @@ export type SharedNavTab = 'Home' | 'Search' | 'Messages' | 'Notifications' | 'MyProfile' export type SidebarTab = - SharedNavTab | 'Feeds' | 'Lists' | 'Bookmarks' | 'Settings' + SharedNavTab | 'Atmosphere' | 'Feeds' | 'Lists' | 'Bookmarks' | 'Settings' export const TAB_TO_NAV_ITEM: Record< SharedNavTab, diff --git a/src/lib/routes/types.ts b/src/lib/routes/types.ts index 88d6fbe21..d7ddb2193 100644 --- a/src/lib/routes/types.ts +++ b/src/lib/routes/types.ts @@ -23,6 +23,7 @@ export type ModerationInboxTab = 'reports' | 'account' export type CommonNavigatorParams = { NotFound: undefined + Atmosphere: undefined Lists: undefined Moderation: undefined ModerationInbox: {tab?: ModerationInboxTab} @@ -113,6 +114,7 @@ export type BottomTabNavigatorParams = CommonNavigatorParams & { NotificationsTab: undefined MyProfileTab: undefined MessagesTab: undefined + AtmosphereTab: undefined FeedsTab: undefined ListsTab: undefined BookmarksTab: undefined @@ -144,7 +146,6 @@ export type MessagesTabNavigatorParams = CommonNavigatorParams & { } export type FlatNavigatorParams = CommonNavigatorParams & { - Atmosphere: undefined Home: undefined Search: SearchParams Feeds: undefined @@ -157,7 +158,6 @@ export type FlatNavigatorParams = CommonNavigatorParams & { } export type AllNavigatorParams = CommonNavigatorParams & { - Atmosphere: undefined HomeTab: undefined Home: undefined SearchTab: undefined @@ -167,6 +167,7 @@ export type AllNavigatorParams = CommonNavigatorParams & { Notifications: undefined MyProfileTab: undefined MessagesTab: undefined + AtmosphereTab: undefined FeedsTab: undefined ListsTab: undefined BookmarksTab: undefined diff --git a/src/view/shell/Drawer.tsx b/src/view/shell/Drawer.tsx index 66f8a21ce..8853f3d57 100644 --- a/src/view/shell/Drawer.tsx +++ b/src/view/shell/Drawer.tsx @@ -74,11 +74,13 @@ import {InviteFriendsDialog} from '#/features/inviteFriends' import {useActorStatus} from '#/features/liveNow' const iconWidth = 26 -type SecondarySidebarTab = 'Feeds' | 'Lists' | 'Bookmarks' | 'Settings' +type SecondarySidebarTab = + 'Atmosphere' | 'Feeds' | 'Lists' | 'Bookmarks' | 'Settings' const SECONDARY_TAB_ROUTES: Record< SecondarySidebarTab, - 'FeedsTab' | 'ListsTab' | 'BookmarksTab' | 'SettingsTab' + 'AtmosphereTab' | 'FeedsTab' | 'ListsTab' | 'BookmarksTab' | 'SettingsTab' > = { + Atmosphere: 'AtmosphereTab', Feeds: 'FeedsTab', Lists: 'ListsTab', Bookmarks: 'BookmarksTab', @@ -319,9 +321,10 @@ let DrawerContent = ({}: React.PropsWithoutRef<{}>): React.ReactNode => { const onPressAtmosphere = useCallback(() => { ax.metric('nav:click', {item: 'atmosphere', surface: 'drawer'}) - navigation.navigate('Atmosphere') - setDrawerOpen(false) - }, [navigation, setDrawerOpen, ax]) + if (IS_WEB) navigation.navigate('Atmosphere') + else navigateToSecondaryTab('Atmosphere') + if (IS_WEB) setDrawerOpen(false) + }, [navigation, navigateToSecondaryTab, setDrawerOpen, ax]) const onPressLists = useCallback(() => { ax.metric('nav:click', {item: 'lists', surface: 'drawer'}) diff --git a/src/view/shell/desktop/LeftNav.tsx b/src/view/shell/desktop/LeftNav.tsx index 71b08b2a6..dd347f754 100644 --- a/src/view/shell/desktop/LeftNav.tsx +++ b/src/view/shell/desktop/LeftNav.tsx @@ -121,6 +121,7 @@ const NAV_ITEM_TO_TAB: Partial< chat: 'Messages', notifications: 'Notifications', profile: 'MyProfile', + atmosphere: 'Atmosphere', feeds: 'Feeds', lists: 'Lists', saved: 'Bookmarks', @@ -741,6 +742,7 @@ export function DesktopLeftNav({ label={l`Atmosphere`} href="/atmosphere" navItem="atmosphere" + onNavigateTab={onNavigateTab} minimal={leftNavMinimal} beta icons={{