@applicaster/quick-brick-player 15.0.0-rc.34 → 15.0.0-rc.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/quick-brick-player",
|
|
3
|
-
"version": "15.0.0-rc.
|
|
3
|
+
"version": "15.0.0-rc.35",
|
|
4
4
|
"description": "Quick Brick Player",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -37,9 +37,9 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@applicaster/quick-brick-mobile-transport-controls": "15.0.0-rc.34",
|
|
39
39
|
"@applicaster/quick-brick-tv-transport-controls": "15.0.0-rc.15",
|
|
40
|
-
"@applicaster/zapp-react-native-tvos-app": "15.0.0-rc.
|
|
41
|
-
"@applicaster/zapp-react-native-ui-components": "15.0.0-rc.
|
|
42
|
-
"@applicaster/zapp-react-native-utils": "15.0.0-rc.
|
|
40
|
+
"@applicaster/zapp-react-native-tvos-app": "15.0.0-rc.35",
|
|
41
|
+
"@applicaster/zapp-react-native-ui-components": "15.0.0-rc.35",
|
|
42
|
+
"@applicaster/zapp-react-native-utils": "15.0.0-rc.35",
|
|
43
43
|
"query-string": "7.1.3",
|
|
44
44
|
"shaka-player": "4.3.5",
|
|
45
45
|
"typeface-montserrat": "^0.0.54",
|
|
@@ -5,8 +5,8 @@ import { PanGestureHandler } from "react-native-gesture-handler";
|
|
|
5
5
|
import { useStyles } from "./styles";
|
|
6
6
|
import { useVideoModalState } from "./hooks";
|
|
7
7
|
import { MODAL_COLLAPSE_RATIO, MODAL_RADIUS } from "./consts";
|
|
8
|
-
import { useModalAnimationContext } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
9
8
|
import { getWindowHeight } from "./utils";
|
|
9
|
+
import { useSafeAreaFrame } from "react-native-safe-area-context";
|
|
10
10
|
|
|
11
11
|
type AnimatedModalProps = {
|
|
12
12
|
content?: ReactElement;
|
|
@@ -17,21 +17,17 @@ export function AnimatedModal({
|
|
|
17
17
|
content,
|
|
18
18
|
collapsedContent,
|
|
19
19
|
}: AnimatedModalProps) {
|
|
20
|
-
const
|
|
20
|
+
const { translateY, collapsed, gestureHandlerProps, expand, offset } =
|
|
21
|
+
useVideoModalState();
|
|
21
22
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
collapsed,
|
|
25
|
-
collapsedHeight,
|
|
26
|
-
gestureHandlerProps,
|
|
27
|
-
expand,
|
|
28
|
-
} = useVideoModalState(translateYRef);
|
|
29
|
-
|
|
30
|
-
const styles = useStyles({ height: collapsedHeight, type: "audio" });
|
|
23
|
+
const frame = useSafeAreaFrame();
|
|
24
|
+
const collapsedHeight = frame.height - offset.current;
|
|
31
25
|
|
|
32
26
|
const height = getWindowHeight();
|
|
33
27
|
const heightAboveMinimised = height - collapsedHeight;
|
|
34
28
|
|
|
29
|
+
const styles = useStyles({ height: collapsedHeight, type: "audio" });
|
|
30
|
+
|
|
35
31
|
const MODAL_COLLAPSE_START = height * MODAL_COLLAPSE_RATIO;
|
|
36
32
|
|
|
37
33
|
// Interpolated opacities for smooth cross-fade
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
VIDEO_TRANSITION_THRESHOLD,
|
|
13
13
|
} from "./consts";
|
|
14
14
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
15
|
-
import { useModalAnimationContext } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/useModalAnimationContext";
|
|
16
15
|
import { PROGRESS_BAR_HEIGHT } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/utils";
|
|
17
16
|
import {
|
|
18
17
|
SafeAreaView,
|
|
@@ -29,6 +28,9 @@ import {
|
|
|
29
28
|
getScaledPos,
|
|
30
29
|
getExtraContentPadding,
|
|
31
30
|
} from "./utils";
|
|
31
|
+
import { addOrientationChangeListener } from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
|
|
32
|
+
|
|
33
|
+
const AnimatedSafeAreaView = Animated.createAnimatedComponent(SafeAreaView);
|
|
32
34
|
|
|
33
35
|
type AnimatedModalProps = {
|
|
34
36
|
pip?: boolean;
|
|
@@ -65,30 +67,26 @@ export function VideoPlayerModal({
|
|
|
65
67
|
() =>
|
|
66
68
|
isTablet && !isTabletPortrait
|
|
67
69
|
? style.tabletLandscapeWidth
|
|
68
|
-
: getWindowWidth(),
|
|
70
|
+
: getWindowWidth(isTablet, !isTabletPortrait),
|
|
69
71
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
70
72
|
[]
|
|
71
73
|
);
|
|
72
74
|
|
|
73
|
-
const height = useMemo(
|
|
75
|
+
const height = useMemo(
|
|
76
|
+
() => getWindowHeight(isTablet, !isTabletPortrait),
|
|
77
|
+
[]
|
|
78
|
+
); // remember initial height, ignore rotation changes
|
|
79
|
+
|
|
74
80
|
const MODAL_COLLAPSE_START = height * MODAL_COLLAPSE_RATIO;
|
|
75
81
|
|
|
76
82
|
const { minimised_height: minimisedHeight } = useConfiguration();
|
|
77
83
|
const scrollViewRef = useRef<typeof Animated.ScrollView | null>(null);
|
|
78
84
|
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
const dummyRef = useRef(new Animated.Value(0));
|
|
82
|
-
|
|
83
|
-
const {
|
|
84
|
-
translateY,
|
|
85
|
-
collapsed,
|
|
86
|
-
collapsedHeight,
|
|
87
|
-
gestureHandlerProps,
|
|
88
|
-
expand,
|
|
89
|
-
} = useVideoModalState(modal ? translateYRef : dummyRef);
|
|
85
|
+
const { translateY, collapsed, gestureHandlerProps, expand, offset } =
|
|
86
|
+
useVideoModalState();
|
|
90
87
|
|
|
91
88
|
const frame = useSafeAreaFrame();
|
|
89
|
+
const collapsedHeight = frame.height - offset.current;
|
|
92
90
|
|
|
93
91
|
const heightAboveMinimised = height - collapsedHeight;
|
|
94
92
|
|
|
@@ -98,9 +96,27 @@ export function VideoPlayerModal({
|
|
|
98
96
|
|
|
99
97
|
const insets = useSafeAreaInsets();
|
|
100
98
|
|
|
101
|
-
const
|
|
99
|
+
const [isFullScreenMode, setFullScreenMode] = React.useState(
|
|
100
|
+
fullscreen || pip
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
React.useEffect(() => {
|
|
104
|
+
const listener = addOrientationChangeListener(({ toOrientation }) => {
|
|
105
|
+
/* ignored in collapsed mode non-PiP player */
|
|
106
|
+
if (collapsed && !pip) return;
|
|
107
|
+
setFullScreenMode(!(toOrientation === 1));
|
|
108
|
+
});
|
|
102
109
|
|
|
103
|
-
|
|
110
|
+
return () => {
|
|
111
|
+
listener.remove();
|
|
112
|
+
};
|
|
113
|
+
}, [collapsed, pip]);
|
|
114
|
+
|
|
115
|
+
const isFullScreenOrPIP = isFullScreenMode;
|
|
116
|
+
|
|
117
|
+
const vidHeight = width / aspectRatio;
|
|
118
|
+
|
|
119
|
+
// animated opacity for smooth cross-fade of collapsed content
|
|
104
120
|
const collapsedOpacity = !isFullScreenOrPIP
|
|
105
121
|
? translateY.interpolate({
|
|
106
122
|
inputRange: [MODAL_COLLAPSE_START, heightAboveMinimised],
|
|
@@ -109,6 +125,7 @@ export function VideoPlayerModal({
|
|
|
109
125
|
})
|
|
110
126
|
: new Animated.Value(0);
|
|
111
127
|
|
|
128
|
+
// animated opacity for extra content
|
|
112
129
|
const expandedOpacity = !isFullScreenOrPIP
|
|
113
130
|
? translateY.interpolate({
|
|
114
131
|
inputRange: [0, heightAboveMinimised],
|
|
@@ -117,7 +134,7 @@ export function VideoPlayerModal({
|
|
|
117
134
|
})
|
|
118
135
|
: new Animated.Value(1);
|
|
119
136
|
|
|
120
|
-
// animated position for video content
|
|
137
|
+
// animated x position for video content
|
|
121
138
|
const xPosition = !isFullScreenOrPIP
|
|
122
139
|
? translateY.interpolate({
|
|
123
140
|
inputRange: [height * VIDEO_TRANSITION_THRESHOLD, MODAL_COLLAPSE_START],
|
|
@@ -126,9 +143,7 @@ export function VideoPlayerModal({
|
|
|
126
143
|
})
|
|
127
144
|
: new Animated.Value(0);
|
|
128
145
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
// animated position for video content during modal transition
|
|
146
|
+
// animated y position for video content
|
|
132
147
|
const yPosition = !isFullScreenOrPIP
|
|
133
148
|
? translateY.interpolate({
|
|
134
149
|
inputRange: [height * VIDEO_TRANSITION_THRESHOLD, MODAL_COLLAPSE_START],
|
|
@@ -144,7 +159,7 @@ export function VideoPlayerModal({
|
|
|
144
159
|
})
|
|
145
160
|
: new Animated.Value(0);
|
|
146
161
|
|
|
147
|
-
// animated position for video content
|
|
162
|
+
// animated position for video content
|
|
148
163
|
const scalePosition = !isFullScreenOrPIP
|
|
149
164
|
? translateY.interpolate({
|
|
150
165
|
inputRange: [height * VIDEO_TRANSITION_THRESHOLD, MODAL_COLLAPSE_START],
|
|
@@ -179,9 +194,11 @@ export function VideoPlayerModal({
|
|
|
179
194
|
<PanGestureHandler
|
|
180
195
|
enabled={enabled}
|
|
181
196
|
waitFor={scrollViewRef}
|
|
197
|
+
activeOffsetY={[-25, 25]}
|
|
198
|
+
activeOffsetX={[-25, 25]}
|
|
182
199
|
{...gestureHandlerProps}
|
|
183
200
|
>
|
|
184
|
-
<
|
|
201
|
+
<AnimatedSafeAreaView pointerEvents="box-none" edges={["bottom"]}>
|
|
185
202
|
<Animated.View
|
|
186
203
|
pointerEvents={"auto"}
|
|
187
204
|
style={[
|
|
@@ -266,7 +283,7 @@ export function VideoPlayerModal({
|
|
|
266
283
|
) : null}
|
|
267
284
|
</Animated.View>
|
|
268
285
|
</Animated.View>
|
|
269
|
-
</
|
|
286
|
+
</AnimatedSafeAreaView>
|
|
270
287
|
</PanGestureHandler>
|
|
271
288
|
);
|
|
272
289
|
}
|
|
@@ -1,171 +1,132 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
2
|
-
|
|
3
|
-
useSafeAreaFrame,
|
|
4
|
-
useSafeAreaInsets,
|
|
5
|
-
} from "react-native-safe-area-context";
|
|
2
|
+
|
|
6
3
|
import { State } from "react-native-gesture-handler";
|
|
7
|
-
import { Animated } from "react-native";
|
|
8
4
|
|
|
9
5
|
import { VideoModalMode } from "@applicaster/zapp-react-native-ui-components/Components/PlayerContainer/PlayerContainer";
|
|
10
|
-
import {
|
|
11
|
-
useConfiguration,
|
|
12
|
-
useAnimationStateStore,
|
|
13
|
-
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/utils";
|
|
14
|
-
import { getTabBarHeight } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/getTabBarHeight";
|
|
6
|
+
import { useAnimationStateStore } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/utils";
|
|
15
7
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
|
|
16
|
-
import { isMenuVisible } from "@applicaster/zapp-react-native-ui-components/Components/Screen/navigationHandler";
|
|
17
8
|
import {
|
|
18
9
|
ANIMATION_DURATION,
|
|
19
10
|
DRAG_TO_COLLAPSE,
|
|
20
11
|
DRAG_TO_EXPAND,
|
|
21
12
|
} from "../consts";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import { isOldAndroidDevice } from "../utils";
|
|
25
|
-
|
|
26
|
-
const bottomTabBarHeight = getTabBarHeight();
|
|
13
|
+
import { Animated } from "react-native";
|
|
14
|
+
import { useModalAnimationContext } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
27
15
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const { minimised_height: minimisedHeight } = useConfiguration();
|
|
16
|
+
const getAnimatedValue = (animatedValue: Animated.Value): number => {
|
|
17
|
+
return (animatedValue as any).__getValue() as number;
|
|
18
|
+
};
|
|
32
19
|
|
|
20
|
+
export const useVideoModalState = () => {
|
|
33
21
|
const {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
} =
|
|
40
|
-
|
|
41
|
-
const plugins = usePlugins();
|
|
42
|
-
|
|
43
|
-
const menuVisible = isMenuVisible(currentRoute, screenData, plugins);
|
|
44
|
-
|
|
45
|
-
const collapsed =
|
|
46
|
-
videoModalState.visible &&
|
|
47
|
-
videoModalState.mode === VideoModalMode.MINIMIZED;
|
|
48
|
-
|
|
49
|
-
const frame = useSafeAreaFrame();
|
|
50
|
-
const insets = useSafeAreaInsets();
|
|
51
|
-
|
|
52
|
-
const collapsedHeight =
|
|
53
|
-
minimisedHeight +
|
|
54
|
-
(menuVisible ? bottomTabBarHeight : 0) +
|
|
55
|
-
(isOldAndroidDevice ? 0 : insets.bottom) + // insets.bottom is added to properly display docked modal
|
|
56
|
-
PROGRESS_BAR_HEIGHT;
|
|
57
|
-
|
|
58
|
-
const heightAboveMinimised = frame.height - collapsedHeight;
|
|
22
|
+
yTranslate,
|
|
23
|
+
offset,
|
|
24
|
+
heightAboveMinimised,
|
|
25
|
+
gestureTranslationRef,
|
|
26
|
+
offsetAnimatedValueRef,
|
|
27
|
+
} = useModalAnimationContext();
|
|
59
28
|
|
|
60
|
-
const
|
|
29
|
+
const modalAnimatedValue = offsetAnimatedValueRef.current;
|
|
30
|
+
const gestureTranslation = gestureTranslationRef.current;
|
|
61
31
|
|
|
62
|
-
const
|
|
63
|
-
(toValue: number) =>
|
|
64
|
-
|
|
32
|
+
const updateModalTranslation = useCallback(
|
|
33
|
+
(toValue: number, duration: number = ANIMATION_DURATION) =>
|
|
34
|
+
Animated.timing(modalAnimatedValue, {
|
|
65
35
|
toValue,
|
|
66
|
-
duration
|
|
36
|
+
duration,
|
|
67
37
|
useNativeDriver: true,
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
[translateYRef]
|
|
38
|
+
}),
|
|
39
|
+
[modalAnimatedValue]
|
|
71
40
|
);
|
|
72
41
|
|
|
73
|
-
const
|
|
74
|
-
(toValue: number) => {
|
|
75
|
-
return Animated.timing(translateYRef.current, {
|
|
76
|
-
toValue,
|
|
77
|
-
duration: ANIMATION_DURATION,
|
|
78
|
-
useNativeDriver: true,
|
|
79
|
-
});
|
|
80
|
-
},
|
|
81
|
-
[translateYRef]
|
|
82
|
-
);
|
|
42
|
+
const translateY = yTranslate.current;
|
|
83
43
|
|
|
84
|
-
const
|
|
44
|
+
const { maximiseVideoModal, minimiseVideoModal, videoModalState } =
|
|
45
|
+
useNavigation();
|
|
85
46
|
|
|
86
|
-
|
|
87
|
-
const onGestureEvent = useCallback(
|
|
88
|
-
(event: any) => {
|
|
89
|
-
if (event.nativeEvent.state === State.ACTIVE) {
|
|
90
|
-
const y = event.nativeEvent.translationY;
|
|
91
|
-
let newY = offset.current + y;
|
|
92
|
-
if (newY < 0) newY = 0;
|
|
47
|
+
const videoModalMode = videoModalState.mode;
|
|
93
48
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
49
|
+
const prevModeStateRef = useRef(videoModalMode); // keep track of last non-PIP mode
|
|
50
|
+
const gestureStateRef = useRef<any>(State.UNDETERMINED); // keep track of gesture state
|
|
97
51
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
52
|
+
// Track last non-PIP mode
|
|
53
|
+
if (videoModalMode !== prevModeStateRef.current) {
|
|
54
|
+
if (["MAXIMIZED", "MINIMIZED"].includes(videoModalMode)) {
|
|
55
|
+
prevModeStateRef.current = videoModalMode;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const collapsed =
|
|
60
|
+
videoModalState.visible &&
|
|
61
|
+
((prevModeStateRef.current === "MINIMIZED" &&
|
|
62
|
+
videoModalState.mode === "PIP") || // If STILL in PIP mode, check if last non-PIP mode was MINIMIZED
|
|
63
|
+
videoModalState.mode === VideoModalMode.MINIMIZED); // Or if currently in MINIMIZED mode
|
|
64
|
+
|
|
65
|
+
// Gesture handler for modal
|
|
66
|
+
const onGestureEvent = useMemo(
|
|
67
|
+
() =>
|
|
68
|
+
Animated.event([{ nativeEvent: { translationY: gestureTranslation } }], {
|
|
69
|
+
useNativeDriver: true,
|
|
70
|
+
}),
|
|
71
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
|
+
[]
|
|
102
73
|
);
|
|
103
74
|
|
|
104
75
|
const onHandlerStateChange = useCallback(
|
|
105
76
|
(event: any) => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
) {
|
|
77
|
+
const { state: newState, oldState, translationY } = event.nativeEvent;
|
|
78
|
+
|
|
79
|
+
if (newState === State.ACTIVE || oldState === State.ACTIVE) {
|
|
110
80
|
useAnimationStateStore.setState({
|
|
111
|
-
isAnimationInProgress:
|
|
81
|
+
isAnimationInProgress: newState === State.ACTIVE,
|
|
112
82
|
});
|
|
113
83
|
}
|
|
114
84
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
85
|
+
// Update gesture state tracking
|
|
86
|
+
gestureStateRef.current = newState;
|
|
87
|
+
|
|
88
|
+
if (translationY !== 0) {
|
|
89
|
+
if (newState === State.BEGAN) {
|
|
90
|
+
// clean up gesture translation
|
|
91
|
+
gestureTranslation.setValue(0);
|
|
92
|
+
} else if (
|
|
93
|
+
newState === State.END ||
|
|
94
|
+
newState === State.FAILED ||
|
|
95
|
+
newState === State.CANCELLED
|
|
96
|
+
) {
|
|
97
|
+
const newY = getAnimatedValue(gestureTranslation);
|
|
98
|
+
|
|
99
|
+
// clean up gesture translation
|
|
100
|
+
gestureTranslation.setValue(0);
|
|
101
|
+
|
|
102
|
+
const v = getAnimatedValue(modalAnimatedValue);
|
|
103
|
+
|
|
104
|
+
// store current offset
|
|
105
|
+
modalAnimatedValue.setValue(v + newY);
|
|
106
|
+
|
|
107
|
+
const shouldCollapse = newY > offset.current * DRAG_TO_COLLAPSE;
|
|
108
|
+
|
|
109
|
+
const shouldExpand = newY < offset.current * DRAG_TO_EXPAND;
|
|
110
|
+
|
|
111
|
+
if (!collapsed && shouldCollapse) {
|
|
112
|
+
// Collapse
|
|
113
|
+
updateModalTranslation(offset.current).start(() => {
|
|
114
|
+
minimiseVideoModal();
|
|
115
|
+
});
|
|
116
|
+
} else if (collapsed && shouldExpand) {
|
|
117
|
+
// Expand
|
|
118
|
+
updateModalTranslation(0).start(() => {
|
|
119
|
+
maximiseVideoModal();
|
|
120
|
+
});
|
|
121
|
+
} else {
|
|
122
|
+
// Snap back to current state
|
|
123
|
+
updateModalTranslation(collapsed ? offset.current : 0).start();
|
|
124
|
+
}
|
|
122
125
|
}
|
|
123
|
-
|
|
124
|
-
const shouldCollapse =
|
|
125
|
-
translationY > heightAboveMinimised * DRAG_TO_COLLAPSE;
|
|
126
|
-
|
|
127
|
-
const shouldExpand =
|
|
128
|
-
translationY < -heightAboveMinimised * DRAG_TO_EXPAND;
|
|
129
|
-
|
|
130
|
-
if (!collapsed && shouldCollapse) {
|
|
131
|
-
// Collapse
|
|
132
|
-
Animated.timing(translateY, {
|
|
133
|
-
toValue: heightAboveMinimised,
|
|
134
|
-
duration: ANIMATION_DURATION,
|
|
135
|
-
useNativeDriver: true,
|
|
136
|
-
}).start(() => {
|
|
137
|
-
minimiseVideoModal();
|
|
138
|
-
offset.current = heightAboveMinimised;
|
|
139
|
-
});
|
|
140
|
-
} else if (collapsed && shouldExpand) {
|
|
141
|
-
// Expand
|
|
142
|
-
Animated.timing(translateY, {
|
|
143
|
-
toValue: 0,
|
|
144
|
-
duration: ANIMATION_DURATION,
|
|
145
|
-
useNativeDriver: true,
|
|
146
|
-
}).start(() => {
|
|
147
|
-
maximiseVideoModal();
|
|
148
|
-
offset.current = 0;
|
|
149
|
-
translateY.setValue(0);
|
|
150
|
-
});
|
|
151
|
-
} else {
|
|
152
|
-
// Snap back to current state
|
|
153
|
-
Animated.spring(translateY, {
|
|
154
|
-
toValue: collapsed ? heightAboveMinimised : 0,
|
|
155
|
-
useNativeDriver: true,
|
|
156
|
-
}).start(() => {
|
|
157
|
-
offset.current = collapsed ? heightAboveMinimised : 0;
|
|
158
|
-
translateY.setValue(offset.current);
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
} else if (event.nativeEvent.state === State.BEGAN) {
|
|
162
|
-
// Gesture started, set offset
|
|
163
|
-
translateY.stopAnimation((value: number) => {
|
|
164
|
-
offset.current = value;
|
|
165
|
-
});
|
|
166
126
|
}
|
|
167
127
|
},
|
|
168
|
-
|
|
128
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
129
|
+
[collapsed]
|
|
169
130
|
);
|
|
170
131
|
|
|
171
132
|
const gestureHandlerProps = useMemo(() => {
|
|
@@ -175,44 +136,34 @@ export const useVideoModalState = (
|
|
|
175
136
|
};
|
|
176
137
|
}, [onGestureEvent, onHandlerStateChange]);
|
|
177
138
|
|
|
139
|
+
// Track video modal state changes & calling updateAnimatedPosition
|
|
178
140
|
useEffect(() => {
|
|
179
141
|
if (videoModalState.visible) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
142
|
+
const mode =
|
|
143
|
+
videoModalMode === "PIP" ? prevModeStateRef.current : videoModalMode;
|
|
144
|
+
|
|
145
|
+
// Prevent changes during active gesture states to avoid interference
|
|
146
|
+
if ([State.ACTIVE].includes(gestureStateRef.current)) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (mode === VideoModalMode.MAXIMIZED) {
|
|
151
|
+
updateModalTranslation(0).start();
|
|
152
|
+
} else if (mode === VideoModalMode.MINIMIZED) {
|
|
153
|
+
updateModalTranslation(heightAboveMinimised).start();
|
|
192
154
|
}
|
|
193
155
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
videoModalState.mode,
|
|
197
|
-
collapsedHeight,
|
|
198
|
-
heightAboveMinimised,
|
|
199
|
-
]);
|
|
156
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
157
|
+
}, [videoModalState.visible, videoModalState.mode, heightAboveMinimised]);
|
|
200
158
|
|
|
201
159
|
return useMemo(
|
|
202
160
|
() => ({
|
|
203
161
|
collapsed,
|
|
204
|
-
collapsedHeight,
|
|
205
162
|
offset,
|
|
206
163
|
gestureHandlerProps,
|
|
207
164
|
translateY,
|
|
208
165
|
expand: maximiseVideoModal,
|
|
209
166
|
}),
|
|
210
|
-
[
|
|
211
|
-
collapsed,
|
|
212
|
-
collapsedHeight,
|
|
213
|
-
gestureHandlerProps,
|
|
214
|
-
translateY,
|
|
215
|
-
maximiseVideoModal,
|
|
216
|
-
]
|
|
167
|
+
[collapsed, offset, gestureHandlerProps, translateY, maximiseVideoModal]
|
|
217
168
|
);
|
|
218
169
|
};
|
|
@@ -5,10 +5,7 @@ import {
|
|
|
5
5
|
isAndroidVersionAtLeast,
|
|
6
6
|
isTV,
|
|
7
7
|
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
8
|
-
import {
|
|
9
|
-
isTablet,
|
|
10
|
-
useIsTablet as getIsTablet,
|
|
11
|
-
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
8
|
+
import { useIsTablet as getIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
12
9
|
|
|
13
10
|
const SAFE_AREA_BREAKING_API_VERSION = 35;
|
|
14
11
|
|
|
@@ -16,9 +13,20 @@ export const isOldAndroidDevice =
|
|
|
16
13
|
isAndroidPlatform() &&
|
|
17
14
|
!isAndroidVersionAtLeast(SAFE_AREA_BREAKING_API_VERSION);
|
|
18
15
|
|
|
19
|
-
export const getWindowHeight = (
|
|
16
|
+
export const getWindowHeight = (
|
|
17
|
+
isTablet: boolean,
|
|
18
|
+
landscape: boolean
|
|
19
|
+
): number => {
|
|
20
20
|
const windowDimensions = Dimensions.get("window");
|
|
21
21
|
|
|
22
|
+
if (isTablet && landscape) {
|
|
23
|
+
return windowDimensions.height;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (windowDimensions.width > windowDimensions.height) {
|
|
27
|
+
return windowDimensions.width;
|
|
28
|
+
}
|
|
29
|
+
|
|
22
30
|
return windowDimensions.height;
|
|
23
31
|
};
|
|
24
32
|
|
|
@@ -28,14 +36,25 @@ export const getScreenHeight = (): number => {
|
|
|
28
36
|
return screenDimensions.height;
|
|
29
37
|
};
|
|
30
38
|
|
|
31
|
-
export const getWindowWidth = (
|
|
39
|
+
export const getWindowWidth = (
|
|
40
|
+
isTablet: boolean,
|
|
41
|
+
landscape: boolean
|
|
42
|
+
): number => {
|
|
32
43
|
const windowDimensions = Dimensions.get("window");
|
|
33
44
|
|
|
45
|
+
if (isTablet && landscape) {
|
|
46
|
+
return windowDimensions.width;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (windowDimensions.width > windowDimensions.height) {
|
|
50
|
+
return windowDimensions.height;
|
|
51
|
+
}
|
|
52
|
+
|
|
34
53
|
return windowDimensions.width;
|
|
35
54
|
};
|
|
36
55
|
|
|
37
56
|
const getIsTabletLandscape = (isTabletPortrait: boolean): boolean => {
|
|
38
|
-
return !isTV() &&
|
|
57
|
+
return !isTV() && getIsTablet() && !isTabletPortrait;
|
|
39
58
|
};
|
|
40
59
|
|
|
41
60
|
export const getInsetsOffset = (
|
|
@@ -44,7 +63,7 @@ export const getInsetsOffset = (
|
|
|
44
63
|
): number => {
|
|
45
64
|
const isTabletLandscape = getIsTabletLandscape(isTabletPortrait);
|
|
46
65
|
|
|
47
|
-
return
|
|
66
|
+
return getIsTablet() && isTabletLandscape
|
|
48
67
|
? isOldAndroidDevice
|
|
49
68
|
? insets.top / 2
|
|
50
69
|
: 0
|