diff options
author | John Fawcett <jrf0110@gmail.com> | 2023-04-12 20:27:55 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-12 18:27:55 -0700 |
commit | f6769b283fe83d7abbc0545077b3dca978184eed (patch) | |
tree | fab3973591fd0514d290de18f37280baca5563f9 /src/view/shell/Drawer.tsx | |
parent | 2fed6c402159c6084dd481ab87c5e8b034e910ac (diff) | |
download | voidsky-f6769b283fe83d7abbc0545077b3dca978184eed.tar.zst |
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 <pfrazee@gmail.com>
Diffstat (limited to 'src/view/shell/Drawer.tsx')
-rw-r--r-- | src/view/shell/Drawer.tsx | 68 |
1 files changed, 32 insertions, 36 deletions
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<NavigationProp>() 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(() => { </View> <View style={s.flex1} /> <View style={styles.footer}> - <TouchableOpacity - onPress={onDarkmodePress} - style={[ - styles.footerBtn, - theme.colorScheme === 'light' - ? pal.btn - : styles.footerBtnDarkMode, - ]}> - <MoonIcon - size={22} - style={pal.text as StyleProp<ViewStyle>} - strokeWidth={2} - /> - </TouchableOpacity> + {!isWeb && ( + <TouchableOpacity + onPress={onDarkmodePress} + style={[ + styles.footerBtn, + theme.colorScheme === 'light' + ? pal.btn + : styles.footerBtnDarkMode, + ]}> + <MoonIcon + size={22} + style={pal.text as StyleProp<ViewStyle>} + strokeWidth={2} + /> + </TouchableOpacity> + )} <TouchableOpacity onPress={onPressFeedback} style={[ |