140 lines
5.0 KiB
TypeScript
140 lines
5.0 KiB
TypeScript
// Metro module 10520 (f10521).
|
|
import { memo, useState, useRef } from "react";
|
|
import { View, StyleSheet } from "react-native";
|
|
import { toggleFocus } from "../ChannelCallStore";
|
|
import { PictureInPicturePositions } from "../../../../Constants";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import { generateBoxShadowStyle, EIGHT_DP_ELEVATION_SHADOW_PARAMS } from "../../../../design/void/native";
|
|
import { useShouldForcePipOrientation } from "./useShouldForcePipOrientation";
|
|
import useWindowDimensions_native from "../../../screen/useWindowDimensions.native";
|
|
import useSafeAreaInsetsKeyboardAware_native from "../../../safe_area/useSafeAreaInsetsKeyboardAware.native";
|
|
import usePipDimensions from "./usePipDimensions";
|
|
import ReanimatedRexport, { useAnimatedStyle } from "../../../reanimated/ReanimatedRexport";
|
|
import * as _spring from "../../../../design/animation/reanimated/spring/spring";
|
|
import { useIsViewingActivity } from "../../../activities/native/useIsViewingActivity";
|
|
import { useDraggablePip } from "../useDraggablePip";
|
|
import { GestureDetector } from "../../../../_bundle/Module5273";
|
|
import { isIOS } from "../../../../utils/PlatformUtils";
|
|
let getSpringAnimationConfig, __initData;
|
|
const useStyles = createStyles({
|
|
pipOuterContainer: {
|
|
...StyleSheet.absoluteFillObject,
|
|
alignItems: "baseline"
|
|
},
|
|
pipInnerContainer: {
|
|
...StyleSheet.absoluteFillObject,
|
|
alignItems: "baseline"
|
|
},
|
|
elevationShadow: generateBoxShadowStyle(EIGHT_DP_ELEVATION_SHADOW_PARAMS)
|
|
});
|
|
const getSpringAnimationConfig2 = function getSpringAnimationConfig(a0) {
|
|
return {
|
|
mass: 0.2,
|
|
damping: 7.5,
|
|
stiffness: 100,
|
|
restDisplacementThreshold: 0.1,
|
|
restSpeedThreshold: 0.1,
|
|
overshootClamping: true,
|
|
velocity: a0
|
|
};
|
|
};
|
|
getSpringAnimationConfig2.__closure = {};
|
|
getSpringAnimationConfig2.__workletHash = 6627401186753;
|
|
getSpringAnimationConfig2.__initData = {
|
|
code: "function getSpringAnimationConfig_PictureInPictureTsx1(velocity){return{mass:0.2,damping:7.5,stiffness:100,restDisplacementThreshold:0.1,restSpeedThreshold:0.1,overshootClamping:true,velocity:velocity};}"
|
|
};
|
|
getSpringAnimationConfig = getSpringAnimationConfig2;
|
|
const TOP_LEFT = PictureInPicturePositions.TOP_LEFT;
|
|
__initData = {
|
|
code: "function PictureInPictureTsx2(){const{insets,withSpring,getSpringAnimationConfig}=this.__closure;return{marginTop:insets.top,marginBottom:withSpring(insets.bottom,getSpringAnimationConfig())};}"
|
|
};
|
|
const r60 = memo(function(a0) {
|
|
const { children, style } = a0;
|
|
if (a0.preferredPosition === void 0) {
|
|
PictureInPicturePositions.TOP_LEFT;
|
|
}
|
|
let ref;
|
|
const channel = a0.channel;
|
|
ref = void 0;
|
|
const styles = useStyles();
|
|
const shouldForcePipOrientation = useShouldForcePipOrientation({
|
|
channel
|
|
});
|
|
const windowDimensions_native = useWindowDimensions_native();
|
|
const { width, height } = windowDimensions_native;
|
|
const insets = useSafeAreaInsetsKeyboardAware_native({
|
|
includeKeyboardHeight: true
|
|
}).insets;
|
|
const pipDimensions = usePipDimensions({
|
|
channelId: channel.id,
|
|
forcedOrientation: shouldForcePipOrientation
|
|
});
|
|
const [state, setState] = useState({
|
|
x: 0,
|
|
y: 0,
|
|
width,
|
|
height,
|
|
pageX: 0,
|
|
pageY: 0
|
|
});
|
|
const w = function w() {
|
|
return {
|
|
marginTop: insets.top,
|
|
marginBottom: _spring.withSpring(insets.bottom, {
|
|
mass: 0.2,
|
|
damping: 7.5,
|
|
stiffness: 100,
|
|
restDisplacementThreshold: 0.1,
|
|
restSpeedThreshold: 0.1,
|
|
overshootClamping: true,
|
|
velocity: void 0
|
|
})
|
|
};
|
|
};
|
|
w.__closure = {
|
|
insets,
|
|
withSpring: _spring.withSpring,
|
|
getSpringAnimationConfig
|
|
};
|
|
w.__workletHash = 16677290574613;
|
|
w.__initData = __initData;
|
|
const animatedStyle = useAnimatedStyle(w);
|
|
const isViewingActivity = useIsViewingActivity({
|
|
channelId: channel.id
|
|
});
|
|
const draggablePip = useDraggablePip({
|
|
width: pipDimensions.width,
|
|
height: pipDimensions.height,
|
|
containerWidth: state.width,
|
|
containerHeight: state.height,
|
|
snapToCorners: !isViewingActivity,
|
|
onPress: isViewingActivity ? toggleFocus : void 0
|
|
});
|
|
const { gesture, draggableGridItemStyles } = draggablePip;
|
|
ref = useRef(null);
|
|
return <ReanimatedRexport.View style={[styles.pipOuterContainer, animatedStyle, style]} pointerEvents="box-none">
|
|
<View ref={ref} style={styles.pipInnerContainer} pointerEvents="box-none" onLayout={() => {
|
|
if (ref.current != null) {
|
|
ref.current.measure((a0, a1, a2, a3, a4, a5) => {
|
|
setState({
|
|
x: a0,
|
|
y: a1,
|
|
width: a2,
|
|
height: a3,
|
|
pageX: a4,
|
|
pageY: a5
|
|
});
|
|
});
|
|
}
|
|
}}>
|
|
<GestureDetector gesture={gesture}>
|
|
<ReanimatedRexport.View style={[draggableGridItemStyles, isIOS() ? styles.elevationShadow : void 0]}>
|
|
<View>{children}</View>
|
|
</ReanimatedRexport.View>
|
|
</GestureDetector>
|
|
</View>
|
|
</ReanimatedRexport.View>;
|
|
});
|
|
export default r60;
|
|
export { TOP_LEFT as DEFAULT_PIP_POSITION };
|