From f6769b283fe83d7abbc0545077b3dca978184eed Mon Sep 17 00:00:00 2001 From: John Fawcett Date: Wed, 12 Apr 2023 20:27:55 -0500 Subject: Mobile Web (#427) * WIP * WIP * Fix header offset on web * Remove debug * Fix web mobile feed and FAB layout * Fix modals on mobile web * Remove dead code * Remove ios config that shouldnt be committed now * Move bottom bar into its own folder * Fix web drawer navigation and state behaviors * Remove dark mode toggle from web drawer for now * Fix search on mobile web * Fix the logged out splash screen on mobile web * Fixes to detox simulator --------- Co-authored-by: Paul Frazee --- src/view/shell/Drawer.tsx | 68 ++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 36 deletions(-) (limited to 'src/view/shell/Drawer.tsx') diff --git a/src/view/shell/Drawer.tsx b/src/view/shell/Drawer.tsx index ebadb2126..de36463e1 100644 --- a/src/view/shell/Drawer.tsx +++ b/src/view/shell/Drawer.tsx @@ -8,11 +8,7 @@ import { View, ViewStyle, } from 'react-native' -import { - useNavigation, - useNavigationState, - StackActions, -} from '@react-navigation/native' +import {useNavigation, StackActions} from '@react-navigation/native' import {observer} from 'mobx-react-lite' import { FontAwesomeIcon, @@ -40,6 +36,8 @@ import {useAnalytics} from 'lib/analytics' import {pluralize} from 'lib/strings/helpers' import {getTabState, TabState} from 'lib/routes/helpers' import {NavigationProp} from 'lib/routes/types' +import {useNavigationTabState} from 'lib/hooks/useNavigationTabState' +import {isWeb} from 'platform/detection' export const DrawerContent = observer(() => { const theme = useTheme() @@ -47,16 +45,7 @@ export const DrawerContent = observer(() => { const store = useStores() const navigation = useNavigation() const {track} = useAnalytics() - const {isAtHome, isAtSearch, isAtNotifications} = useNavigationState( - state => { - return { - isAtHome: getTabState(state, 'Home') !== TabState.Outside, - isAtSearch: getTabState(state, 'Search') !== TabState.Outside, - isAtNotifications: - getTabState(state, 'Notifications') !== TabState.Outside, - } - }, - ) + const {isAtHome, isAtSearch, isAtNotifications} = useNavigationTabState() // events // = @@ -66,14 +55,19 @@ export const DrawerContent = observer(() => { track('Menu:ItemClicked', {url: tab}) const state = navigation.getState() store.shell.closeDrawer() - const tabState = getTabState(state, tab) - if (tabState === TabState.InsideAtRoot) { - store.emitScreenSoftReset() - } else if (tabState === TabState.Inside) { - navigation.dispatch(StackActions.popToTop()) - } else { + if (isWeb) { // @ts-ignore must be Home, Search, or Notifications - navigation.navigate(`${tab}Tab`) + navigation.navigate(tab) + } else { + const tabState = getTabState(state, tab) + if (tabState === TabState.InsideAtRoot) { + store.emitScreenSoftReset() + } else if (tabState === TabState.Inside) { + navigation.dispatch(StackActions.popToTop()) + } else { + // @ts-ignore must be Home, Search, or Notifications + navigation.navigate(`${tab}Tab`) + } } }, [store, track, navigation], @@ -240,20 +234,22 @@ export const DrawerContent = observer(() => { - - } - strokeWidth={2} - /> - + {!isWeb && ( + + } + strokeWidth={2} + /> + + )}