mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-02-11 09:20:54 +08:00
feat: expose header height in context
This commit is contained in:
3
packages/stack/src/utils/FloatingHeaderHeightContext.tsx
Normal file
3
packages/stack/src/utils/FloatingHeaderHeightContext.tsx
Normal file
@@ -0,0 +1,3 @@
|
||||
import * as React from 'react';
|
||||
|
||||
export default React.createContext<number>(0);
|
||||
14
packages/stack/src/utils/useCardAnimation.tsx
Normal file
14
packages/stack/src/utils/useCardAnimation.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import * as React from 'react';
|
||||
import CardAnimationContext from './CardAnimationContext';
|
||||
|
||||
export default function useCardAnimation() {
|
||||
const animation = React.useContext(CardAnimationContext);
|
||||
|
||||
if (animation === undefined) {
|
||||
throw new Error(
|
||||
"Couldn't find values for card animation. Are you inside a screen in Stack?"
|
||||
);
|
||||
}
|
||||
|
||||
return animation;
|
||||
}
|
||||
14
packages/stack/src/utils/useFloatingHeaderHeight.tsx
Normal file
14
packages/stack/src/utils/useFloatingHeaderHeight.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import * as React from 'react';
|
||||
import FloatingHeaderHeightContext from './FloatingHeaderHeightContext';
|
||||
|
||||
export default function useFloatingHeaderHeight() {
|
||||
const height = React.useContext(FloatingHeaderHeightContext);
|
||||
|
||||
if (height === undefined) {
|
||||
throw new Error(
|
||||
"Couldn't find the floating header height. Are you inside a screen in Stack?"
|
||||
);
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
14
packages/stack/src/utils/useGestureHandlerRef.tsx
Normal file
14
packages/stack/src/utils/useGestureHandlerRef.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import * as React from 'react';
|
||||
import StackGestureRefContext from './GestureHandlerRefContext';
|
||||
|
||||
export default function useGestureHandlerRef() {
|
||||
const ref = React.useContext(StackGestureRefContext);
|
||||
|
||||
if (ref === undefined) {
|
||||
throw new Error(
|
||||
"Couldn't find a ref for gesture handler. Are you inside a screen in Stack?"
|
||||
);
|
||||
}
|
||||
|
||||
return ref;
|
||||
}
|
||||
Reference in New Issue
Block a user