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>
This commit is contained in:
Eric Bailey 2023-11-07 13:37:47 -06:00 committed by GitHub
parent 7158157f5f
commit bfe196bac5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 368 additions and 238 deletions

View file

@ -15,6 +15,7 @@ import {useSafeAreaInsets} from 'react-native-safe-area-context'
import {clamp} from 'lodash'
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
import {logger} from '#/logger'
import {useMinimalShellMode, useSetMinimalShellMode} from '#/state/shell'
const SHELL_FOOTER_HEIGHT = 44
@ -22,6 +23,8 @@ type Props = NativeStackScreenProps<CommonNavigatorParams, 'PostThread'>
export const PostThreadScreen = withAuthRequired(
observer(function PostThreadScreenImpl({route}: Props) {
const store = useStores()
const minimalShellMode = useMinimalShellMode()
const setMinimalShellMode = useSetMinimalShellMode()
const safeAreaInsets = useSafeAreaInsets()
const {name, rkey} = route.params
const uri = makeRecordUri(name, 'app.bsky.feed.post', rkey)
@ -33,7 +36,7 @@ export const PostThreadScreen = withAuthRequired(
useFocusEffect(
React.useCallback(() => {
store.shell.setMinimalShellMode(false)
setMinimalShellMode(false)
const threadCleanup = view.registerListeners()
InteractionManager.runAfterInteractions(() => {
@ -47,7 +50,7 @@ export const PostThreadScreen = withAuthRequired(
return () => {
threadCleanup()
}
}, [store, view]),
}, [view, setMinimalShellMode]),
)
const onPressReply = React.useCallback(() => {
@ -80,7 +83,7 @@ export const PostThreadScreen = withAuthRequired(
treeView={!!store.preferences.thread.lab_treeViewEnabled}
/>
</View>
{isMobile && !store.shell.minimalShellMode && (
{isMobile && !minimalShellMode && (
<View
style={[
styles.prompt,