diff --git a/src/view/shell/BottomBar.tsx b/src/view/shell/BottomBar.tsx index 273eb01879..5d9d1c4932 100644 --- a/src/view/shell/BottomBar.tsx +++ b/src/view/shell/BottomBar.tsx @@ -69,7 +69,7 @@ export const BottomBar = observer(({navigation}: BottomTabBarProps) => { track(`MobileShell:${tab}ButtonPressed`) const state = navigation.getState() const curr = currentRoute(state).name - if (curr === tab || curr === `${tab}Stack`) { + if (curr === tab || curr === `${tab}Stack` || curr === `${tab}Inner`) { store.emitScreenSoftReset() } else if (state.routes[state.index].name === `${tab}Stack`) { navigation.dispatch(StackActions.popToTop()) @@ -94,10 +94,14 @@ export const BottomBar = observer(({navigation}: BottomTabBarProps) => { }, [navigation, track, store.me.handle]) const curr = currentRoute(navigation.getState()).name - const isAtHome = curr === 'HomeStack' || curr === 'Home' - const isAtSearch = curr === 'SearchStack' || curr === 'Search' + const isAtHome = + curr === 'HomeStack' || curr === 'Home' || curr === 'HomeInner' + const isAtSearch = + curr === 'SearchStack' || curr === 'Search' || curr === 'SearchInner' const isAtNotifications = - curr === 'NotificationsStack' || curr === 'Notifications' + curr === 'NotificationsStack' || + curr === 'Notifications' || + curr === 'NotificationsInner' return ( { - const theme = useTheme() - const pal = usePalette('default') - const store = useStores() - const {track} = useAnalytics() - const isDrawerOpen = useDrawerStatus() === 'open' +export const Drawer = observer(({navigation}: DrawerContentComponentProps) => { + const theme = useTheme() + const pal = usePalette('default') + const store = useStores() + const {track} = useAnalytics() + const isDrawerOpen = useDrawerStatus() === 'open' - // events - // = + // events + // = - React.useEffect(() => { - console.log( - 'Drawer', - isDrawerOpen ? 'minimizing' : 'unminimizing', - 'shell', - ) - store.shell.setMinimalShellMode(isDrawerOpen) - }, [isDrawerOpen, store]) + React.useEffect(() => { + console.log('Drawer', isDrawerOpen ? 'minimizing' : 'unminimizing', 'shell') + store.shell.setMinimalShellMode(isDrawerOpen) + }, [isDrawerOpen, store]) - const onPressTab = React.useCallback( - (tab: string) => { - track('Menu:ItemClicked', {url: tab}) - const state = navigation.getState() - const curr = currentRoute(state).name - if (curr === tab || curr === `${tab}Stack`) { - store.emitScreenSoftReset() - } else if (state.routes[state.index].name === `${tab}Stack`) { - navigation.dispatch(StackActions.popToTop()) - } else { + const onPressTab = React.useCallback( + (tab: string) => { + track('Menu:ItemClicked', {url: tab}) + const state = navigation.getState() + navigation.closeDrawer() + const curr = currentRoute(state).name + if (curr === tab || curr === `${tab}Stack`) { + store.emitScreenSoftReset() + } else if (state.routes[state.index].name === `${tab}Stack`) { + navigation.dispatch(StackActions.popToTop()) + } else { + // wait for drawer anim to finish + setTimeout(() => { navigation.navigate(`${tab}Stack`) - } - }, - [store, track, navigation], - ) + }, 250) + } + }, + [store, track, navigation], + ) - const onPressHome = React.useCallback( - () => onPressTab('Home'), - [onPressTab], - ) + const onPressHome = React.useCallback(() => onPressTab('Home'), [onPressTab]) - const onPressSearch = React.useCallback( - () => onPressTab('Search'), - [onPressTab], - ) + const onPressSearch = React.useCallback( + () => onPressTab('Search'), + [onPressTab], + ) - const onPressNotifications = React.useCallback( - () => onPressTab('Notifications'), - [onPressTab], - ) + const onPressNotifications = React.useCallback( + () => onPressTab('Notifications'), + [onPressTab], + ) - const onPressProfile = React.useCallback(() => { - track('Menu:ItemClicked', {url: 'Profile'}) - navigation.navigate('Profile', {name: store.me.handle}) - }, [navigation, track, store.me.handle]) + const onPressProfile = React.useCallback(() => { + track('Menu:ItemClicked', {url: 'Profile'}) + navigation.navigate('Profile', {name: store.me.handle}) + navigation.closeDrawer() + }, [navigation, track, store.me.handle]) - const onPressSettings = React.useCallback(() => { - track('Menu:ItemClicked', {url: 'Settings'}) - navigation.navigate('Settings') - }, [navigation, track]) + const onPressSettings = React.useCallback(() => { + track('Menu:ItemClicked', {url: 'Settings'}) + navigation.navigate('Settings') + navigation.closeDrawer() + }, [navigation, track]) - const onPressFeedback = () => { - track('Menu:FeedbackClicked') - Linking.openURL(FEEDBACK_FORM_URL) - } + const onPressFeedback = () => { + track('Menu:FeedbackClicked') + Linking.openURL(FEEDBACK_FORM_URL) + } - // rendering - // = + // rendering + // = - const MenuItem = ({ - icon, - label, - count, - bold, - onPress, - }: { - icon: JSX.Element - label: string - count?: number - bold?: boolean - onPress: () => void - }) => ( - - - {icon} - {count ? ( - - {count} - - ) : undefined} + const MenuItem = ({ + icon, + label, + count, + bold, + onPress, + }: { + icon: JSX.Element + label: string + count?: number + bold?: boolean + onPress: () => void + }) => ( + + + {icon} + {count ? ( + + {count} + + ) : undefined} + + + {label} + + + ) + + const onDarkmodePress = () => { + track('Menu:ItemClicked', {url: '/darkmode'}) + store.shell.setDarkMode(!store.shell.darkMode) + } + + const curr = currentRoute(navigation.getState()).name + const isAtHome = + curr === 'HomeStack' || curr === 'Home' || curr === 'HomeInner' + const isAtSearch = + curr === 'SearchStack' || curr === 'Search' || curr === 'SearchInner' + const isAtNotifications = + curr === 'NotificationsStack' || + curr === 'Notifications' || + curr === 'NotificationsInner' + + return ( + + + + + + {store.me.displayName || store.me.handle} + + + @{store.me.handle} + + + + {store.me.followersCount || 0} + {' '} + {pluralize(store.me.followersCount || 0, 'follower')} ·{' '} + + {store.me.followsCount || 0} + {' '} + following + + + + + } + size={24} + strokeWidth={1.7} + /> + ) : ( + } + size={24} + strokeWidth={1.7} + /> + ) + } + label="Search" + bold={isAtSearch} + onPress={onPressSearch} + /> + } + size="24" + strokeWidth={3.25} + fillOpacity={1} + /> + ) : ( + } + size="24" + strokeWidth={3.25} + /> + ) + } + label="Home" + bold={isAtHome} + onPress={onPressHome} + /> + } + size="24" + strokeWidth={1.7} + fillOpacity={1} + /> + ) : ( + } + size="24" + strokeWidth={1.7} + /> + ) + } + label="Notifications" + count={store.me.notifications.unreadCount} + bold={isAtNotifications} + onPress={onPressNotifications} + /> + } + size="26" + strokeWidth={1.5} + /> + } + label="Profile" + onPress={onPressProfile} + /> + } + size="26" + strokeWidth={1.75} + /> + } + label="Settings" + onPress={onPressSettings} + /> - - {label} - - - ) - - const onDarkmodePress = () => { - track('Menu:ItemClicked', {url: '/darkmode'}) - store.shell.setDarkMode(!store.shell.darkMode) - } - - const curr = currentRoute(navigation.getState()).name - const isAtHome = curr === 'HomeStack' || curr === 'Home' - const isAtSearch = curr === 'SearchStack' || curr === 'Search' - const isAtNotifications = - curr === 'NotificationsStack' || curr === 'Notifications' - - return ( - - + + onNavigate(`/profile/${store.me.handle}`)}> - + } + strokeWidth={2} /> - - {store.me.displayName || store.me.handle} - - - @{store.me.handle} - - - - {store.me.followersCount || 0} - {' '} - {pluralize(store.me.followersCount || 0, 'follower')} ·{' '} - - {store.me.followsCount || 0} - {' '} - following + + + + + Feedback - - - } - size={24} - strokeWidth={1.7} - /> - ) : ( - } - size={24} - strokeWidth={1.7} - /> - ) - } - label="Search" - bold={isAtSearch} - onPress={onPressSearch} - /> - } - size="24" - strokeWidth={3.25} - fillOpacity={1} - /> - ) : ( - } - size="24" - strokeWidth={3.25} - /> - ) - } - label="Home" - bold={isAtHome} - onPress={onPressHome} - /> - } - size="24" - strokeWidth={1.7} - fillOpacity={1} - /> - ) : ( - } - size="24" - strokeWidth={1.7} - /> - ) - } - label="Notifications" - count={store.me.notifications.unreadCount} - bold={isAtNotifications} - onPress={onPressNotifications} - /> - } - size="26" - strokeWidth={1.5} - /> - } - label="Profile" - onPress={onPressProfile} - /> - } - size="26" - strokeWidth={1.75} - /> - } - label="Settings" - onPress={onPressSettings} - /> - - - - - } - strokeWidth={2} - /> - - - - - Feedback - - - - - - ) - }, -) + + + + ) +}) const styles = StyleSheet.create({ view: {