65 lines
2.6 KiB
TypeScript
65 lines
2.6 KiB
TypeScript
// Metro module 14123 (f14124).
|
|
import * as Module19 from "react";
|
|
import { createContext, useMemo, useEffect } from "react";
|
|
import QuestDockStore from "./QuestDockStore";
|
|
import { QuestDockMode } from "../../QuestConstants";
|
|
import { QUEST_DOCK_COLLAPSED_HEIGHT, QUEST_DOCK_EXPANDED_HEIGHT } from "./QuestDockConstants";
|
|
import { createFakeSharedValue } from "../../../reanimated/ReanimatedHelperTypes";
|
|
import { getWindowDimensions } from "../../../screen/useWindowDimensions.native";
|
|
import { useSharedValue } from "../../../reanimated/ReanimatedRexport";
|
|
import { useYouBarHorizontalMargin } from "../../../main_tabs_v2/native/you_bar/hooks/useYouBarMargins";
|
|
import { getQuestDockCollapsedWidth, isSoftDismissed } from "./QuestDockUtils";
|
|
import subscribeToWindowDimensions_native from "../../../screen/subscribeToWindowDimensions.native";
|
|
const context = createContext({
|
|
questDockWrapperSpecs: createFakeSharedValue({
|
|
width: 0,
|
|
height: 0,
|
|
x: 0,
|
|
y: 0,
|
|
prevDeltaY: 0
|
|
}),
|
|
windowDimensions: createFakeSharedValue({
|
|
width: 0,
|
|
height: 0,
|
|
maxContentHeight: 0,
|
|
landscape: false
|
|
}),
|
|
activeQuestDockMode: createFakeSharedValue(QuestDockMode.COLLAPSED),
|
|
minExpandedContentHeight: createFakeSharedValue(0)
|
|
});
|
|
const r52 = Module19.memo(function QuestDockGestureContextProviderInner(props) {
|
|
const memo = useMemo(getWindowDimensions, []);
|
|
const sharedValue = useSharedValue({
|
|
width: memo.width,
|
|
height: memo.height,
|
|
landscape: memo.width > memo.height,
|
|
maxContentHeight: memo.height
|
|
});
|
|
const youBarHorizontalMargin = useYouBarHorizontalMargin();
|
|
const sharedValue2 = useSharedValue({
|
|
width: getQuestDockCollapsedWidth(memo.width, youBarHorizontalMargin, youBarHorizontalMargin),
|
|
height: QUEST_DOCK_COLLAPSED_HEIGHT,
|
|
x: 0,
|
|
y: -8,
|
|
prevDeltaY: 0
|
|
});
|
|
const sharedValue3 = useSharedValue(isSoftDismissed(QuestDockStore.questDockSoftDismissedAt) ? QuestDockMode.SOFT_DISMISSED : QuestDockMode.COLLAPSED);
|
|
const sharedValue4 = useSharedValue(QUEST_DOCK_EXPANDED_HEIGHT);
|
|
useEffect(() => subscribeToWindowDimensions_native(({ width, height }) => {
|
|
sharedValue.set({
|
|
width,
|
|
height,
|
|
landscape: width > height,
|
|
maxContentHeight: height
|
|
});
|
|
}), [sharedValue]);
|
|
return <context.Provider value={useMemo(() => ({
|
|
windowDimensions: sharedValue,
|
|
questDockWrapperSpecs: sharedValue2,
|
|
activeQuestDockMode: sharedValue3,
|
|
minExpandedContentHeight: sharedValue4
|
|
}), [sharedValue, sharedValue2, sharedValue3, sharedValue4])}>{props.children}</context.Provider>;
|
|
});
|
|
export { context as QuestDockGestureContext };
|
|
export { r52 as QuestDockGestureContextProvider };
|