feat: expose header height in context

This commit is contained in:
Satyajit Sahoo
2020-01-05 14:07:16 +01:00
parent a9e584c3b7
commit 133b59cd17
9 changed files with 99 additions and 44 deletions

View File

@@ -0,0 +1,3 @@
import * as React from 'react';
export default React.createContext<number>(0);

View 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;
}

View 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;
}

View 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;
}