diff options
Diffstat (limited to 'src/state/shell/shell-layout.tsx')
-rw-r--r-- | src/state/shell/shell-layout.tsx | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/state/shell/shell-layout.tsx b/src/state/shell/shell-layout.tsx new file mode 100644 index 000000000..a58ba851c --- /dev/null +++ b/src/state/shell/shell-layout.tsx @@ -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) +} |