Sync top/bottom bar disappearance to the scroll (#1855)
* Disable existing code that toggles shell * Make shell mode a float * Translate based on the gesture * Track header and footer heights * Add web support * Fix types and cleanup * Add back isScrolled logic * Add comments
This commit is contained in:
parent
1dcf882619
commit
7a55ca6133
10 changed files with 183 additions and 107 deletions
41
src/state/shell/shell-layout.tsx
Normal file
41
src/state/shell/shell-layout.tsx
Normal file
|
@ -0,0 +1,41 @@
|
|||
import React from 'react'
|
||||
import {SharedValue, useSharedValue} from 'react-native-reanimated'
|
||||
|
||||
type StateContext = {
|
||||
headerHeight: SharedValue<number>
|
||||
footerHeight: SharedValue<number>
|
||||
}
|
||||
|
||||
const stateContext = React.createContext<StateContext>({
|
||||
headerHeight: {
|
||||
value: 0,
|
||||
addListener() {},
|
||||
removeListener() {},
|
||||
modify() {},
|
||||
},
|
||||
footerHeight: {
|
||||
value: 0,
|
||||
addListener() {},
|
||||
removeListener() {},
|
||||
modify() {},
|
||||
},
|
||||
})
|
||||
|
||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
const headerHeight = useSharedValue(0)
|
||||
const footerHeight = useSharedValue(0)
|
||||
|
||||
const value = React.useMemo(
|
||||
() => ({
|
||||
headerHeight,
|
||||
footerHeight,
|
||||
}),
|
||||
[headerHeight, footerHeight],
|
||||
)
|
||||
|
||||
return <stateContext.Provider value={value}>{children}</stateContext.Provider>
|
||||
}
|
||||
|
||||
export function useShellLayout() {
|
||||
return React.useContext(stateContext)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue