mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import React from 'react'
2import {SharedValue, useSharedValue} from 'react-native-reanimated'
3
4type StateContext = {
5 headerHeight: SharedValue<number>
6 footerHeight: SharedValue<number>
7}
8
9const stateContext = React.createContext<StateContext>({
10 headerHeight: {
11 value: 0,
12 addListener() {},
13 removeListener() {},
14 modify() {},
15 },
16 footerHeight: {
17 value: 0,
18 addListener() {},
19 removeListener() {},
20 modify() {},
21 },
22})
23
24export function Provider({children}: React.PropsWithChildren<{}>) {
25 const headerHeight = useSharedValue(0)
26 const footerHeight = useSharedValue(0)
27
28 const value = React.useMemo(
29 () => ({
30 headerHeight,
31 footerHeight,
32 }),
33 [headerHeight, footerHeight],
34 )
35
36 return <stateContext.Provider value={value}>{children}</stateContext.Provider>
37}
38
39export function useShellLayout() {
40 return React.useContext(stateContext)
41}