diff options
author | Eric Bailey <git@esb.lol> | 2023-11-07 13:37:47 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-07 11:37:47 -0800 |
commit | bfe196bac5e618bfbeab4f6fabef3e5a18194868 (patch) | |
tree | f3fd74b8472f5bcd3bbcf3b111a0f19b059de404 /src/view/shell/index.web.tsx | |
parent | 7158157f5fe07b8f97842736ea87b598baabb7da (diff) | |
download | voidsky-bfe196bac5e618bfbeab4f6fabef3e5a18194868.tar.zst |
Extract shell state into separate context (#1824)
* WIP * Add shell state * Integrate new shell state for drawer and minimal shell mode * Replace isDrawerSwipeDisabled * Split shell state into separate contexts to avoid needless re-renders * Fix typo --------- Co-authored-by: Paul Frazee <pfrazee@gmail.com>
Diffstat (limited to 'src/view/shell/index.web.tsx')
-rw-r--r-- | src/view/shell/index.web.tsx | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/view/shell/index.web.tsx b/src/view/shell/index.web.tsx index 3f2fed69b..843d0b284 100644 --- a/src/view/shell/index.web.tsx +++ b/src/view/shell/index.web.tsx @@ -17,18 +17,22 @@ import {BottomBarWeb} from './bottom-bar/BottomBarWeb' import {useNavigation} from '@react-navigation/native' import {NavigationProp} from 'lib/routes/types' import {useAuxClick} from 'lib/hooks/useAuxClick' +import {useIsDrawerOpen, useSetDrawerOpen} from '#/state/shell' const ShellInner = observer(function ShellInnerImpl() { const store = useStores() + const isDrawerOpen = useIsDrawerOpen() + const setDrawerOpen = useSetDrawerOpen() const {isDesktop, isMobile} = useWebMediaQueries() const navigator = useNavigation<NavigationProp>() useAuxClick() useEffect(() => { navigator.addListener('state', () => { + setDrawerOpen(false) store.shell.closeAnyActiveElement() }) - }, [navigator, store.shell]) + }, [navigator, store.shell, setDrawerOpen]) const showBottomBar = isMobile && !store.onboarding.isActive const showSideNavs = @@ -57,9 +61,9 @@ const ShellInner = observer(function ShellInnerImpl() { {showBottomBar && <BottomBarWeb />} <ModalsContainer /> <Lightbox /> - {!isDesktop && store.shell.isDrawerOpen && ( + {!isDesktop && isDrawerOpen && ( <TouchableOpacity - onPress={() => store.shell.closeDrawer()} + onPress={() => setDrawerOpen(false)} style={styles.drawerMask} accessibilityLabel="Close navigation footer" accessibilityHint="Closes bottom navigation bar"> |