@applicaster/quick-brick-player 14.0.0-alpha.8419134002 → 14.0.0-alpha.9119252693
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 +6 -9
- package/src/Player/AudioLayer/AudioPlayerWrapper.tsx +25 -81
- package/src/Player/AudioLayer/Layout/DockedControls/index.tsx +85 -101
- package/src/Player/AudioLayer/Layout/MobileLayout.tsx +4 -37
- package/src/Player/AudioLayer/Layout/PlayerImage/index.tsx +22 -72
- package/src/Player/AudioLayer/Layout/TabletLandscapeLayout.tsx +0 -16
- package/src/Player/AudioLayer/Layout/TransportInfo/index.tsx +3 -9
- package/src/Player/PlayerModal/GestureAnimatedScrollView.ts +7 -0
- package/src/Player/PlayerModal/PlayerModal.tsx +111 -0
- package/src/Player/PlayerModal/VideoPlayerModal.tsx +240 -0
- package/src/Player/PlayerModal/consts/index.ts +30 -0
- package/src/Player/PlayerModal/hooks/index.ts +161 -0
- package/src/Player/PlayerModal/index.ts +3 -0
- package/src/Player/PlayerModal/styles.ts +100 -0
- package/src/Player/index.tsx +161 -104
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { LayoutChangeEvent, View } from "react-native";
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
AnimationComponent,
|
|
6
|
-
ComponentAnimationType,
|
|
7
|
-
useModalAnimationContext,
|
|
8
|
-
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
9
4
|
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
10
5
|
import { toBooleanWithDefaultTrue } from "@applicaster/zapp-react-native-utils/booleanUtils";
|
|
11
6
|
|
|
@@ -13,100 +8,55 @@ import { AnimatedImage } from "./AnimatedImage";
|
|
|
13
8
|
import { FlexImage } from "./FlexImage";
|
|
14
9
|
|
|
15
10
|
import { styles } from "./styles";
|
|
16
|
-
import {
|
|
17
|
-
import { PlayNextData } from "../types";
|
|
11
|
+
import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
18
12
|
|
|
19
13
|
type Props = {
|
|
20
14
|
entry: ZappEntry;
|
|
21
|
-
layoutState: QuickBrickPlayer.LayoutState;
|
|
22
|
-
playerState: QuickBrickPlayer.PlayerState;
|
|
23
|
-
value: GetValue;
|
|
24
15
|
configuration: QuickBrickPlayer.AudioPlayerProps["configuration"];
|
|
25
|
-
dimensions: QuickBrickPlayer.AudioPlayerProps["dimensions"];
|
|
26
|
-
onCloseVideoModal: Callback;
|
|
27
|
-
onPlayerSeek: (targetTime: number) => void;
|
|
28
|
-
playNextData: PlayNextData;
|
|
29
|
-
title: string | number;
|
|
30
|
-
summary: string | number;
|
|
31
16
|
docked: boolean;
|
|
32
17
|
imageWidth?: Option<number>;
|
|
33
|
-
verticalOffset: number;
|
|
34
18
|
onLayoutImage?: (event: LayoutChangeEvent) => void;
|
|
35
19
|
};
|
|
36
20
|
|
|
37
21
|
export const PlayerImage = (props: Props) => {
|
|
38
22
|
const {
|
|
39
23
|
entry,
|
|
40
|
-
dimensions,
|
|
41
24
|
docked,
|
|
42
|
-
verticalOffset,
|
|
43
25
|
imageWidth,
|
|
44
26
|
configuration,
|
|
45
27
|
onLayoutImage = noop,
|
|
46
28
|
} = props;
|
|
47
29
|
|
|
48
|
-
const {
|
|
49
|
-
isActiveGesture,
|
|
50
|
-
startComponentsAnimation,
|
|
51
|
-
playerAnimationState,
|
|
52
|
-
minimisedHeight,
|
|
53
|
-
} = useModalAnimationContext();
|
|
54
|
-
|
|
55
30
|
const isShadowEnabled = toBooleanWithDefaultTrue(
|
|
56
31
|
configuration?.audio_player_artwork_shadow_enabled
|
|
57
32
|
);
|
|
58
33
|
|
|
59
34
|
const shouldShowShadow = !docked && isShadowEnabled;
|
|
60
35
|
|
|
61
|
-
const borderRadius =
|
|
62
|
-
|
|
63
|
-
startComponentsAnimation,
|
|
64
|
-
isActiveGesture,
|
|
65
|
-
playerAnimationState,
|
|
66
|
-
configuration
|
|
36
|
+
const borderRadius = toNumberWithDefaultZero(
|
|
37
|
+
configuration.audio_player_artwork_border_radius
|
|
67
38
|
);
|
|
68
39
|
|
|
69
40
|
return (
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}}
|
|
75
|
-
style={styles.flex}
|
|
76
|
-
>
|
|
77
|
-
<AnimationComponent
|
|
78
|
-
animationType={ComponentAnimationType.moveComponentHorizontal}
|
|
79
|
-
additionalData={{
|
|
80
|
-
// we move image horiontally to this value due artwork is centered
|
|
81
|
-
moveValue: (dimensions.width - minimisedHeight) / 2,
|
|
82
|
-
}}
|
|
83
|
-
style={styles.alignItemsCenter}
|
|
41
|
+
<View style={styles.alignItemsCenter}>
|
|
42
|
+
<View
|
|
43
|
+
onLayout={onLayoutImage}
|
|
44
|
+
style={[shouldShowShadow ? styles.shadow : undefined, { borderRadius }]}
|
|
84
45
|
>
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
// we have imageSize here and now we could animate resizing of this image
|
|
101
|
-
<AnimatedImage
|
|
102
|
-
entry={entry}
|
|
103
|
-
style={[styles.backgroundImageContainer, { borderRadius }]}
|
|
104
|
-
imageWidth={imageWidth}
|
|
105
|
-
docked={docked}
|
|
106
|
-
/>
|
|
107
|
-
)}
|
|
108
|
-
</View>
|
|
109
|
-
</AnimationComponent>
|
|
110
|
-
</AnimationComponent>
|
|
46
|
+
{!imageWidth ? (
|
|
47
|
+
<View style={[styles.defaultImageWrapperView, { borderRadius }]}>
|
|
48
|
+
<FlexImage entry={entry} style={styles.backgroundImageContainer} />
|
|
49
|
+
</View>
|
|
50
|
+
) : (
|
|
51
|
+
// we have imageSize here and now we could animate resizing of this image
|
|
52
|
+
<AnimatedImage
|
|
53
|
+
entry={entry}
|
|
54
|
+
style={[styles.backgroundImageContainer, { borderRadius }]}
|
|
55
|
+
imageWidth={imageWidth}
|
|
56
|
+
docked={docked}
|
|
57
|
+
/>
|
|
58
|
+
)}
|
|
59
|
+
</View>
|
|
60
|
+
</View>
|
|
111
61
|
);
|
|
112
62
|
};
|
|
@@ -11,13 +11,11 @@ import { TransportInfo } from "./TransportInfo";
|
|
|
11
11
|
import { PlayerImage } from "./PlayerImage";
|
|
12
12
|
import { Controls } from "./Controls";
|
|
13
13
|
|
|
14
|
-
import { DockedControls } from "./DockedControls";
|
|
15
14
|
import { withDebug } from "./debug";
|
|
16
15
|
|
|
17
16
|
import { Props } from "./types";
|
|
18
17
|
import { isSmallTabletHeight as getIsSmallTabletHeight } from "./utils";
|
|
19
18
|
import { NAVBAR_HEIGHT, TABLET_LANDSCAPE } from "./const";
|
|
20
|
-
import { FlexImage } from "./PlayerImage/FlexImage";
|
|
21
19
|
|
|
22
20
|
const isIOS = isApplePlatform();
|
|
23
21
|
|
|
@@ -193,20 +191,6 @@ export function TabletLandscapeLayout({
|
|
|
193
191
|
</View>
|
|
194
192
|
</View>
|
|
195
193
|
</View>
|
|
196
|
-
|
|
197
|
-
<DockedControls
|
|
198
|
-
ImageComponent={<FlexImage entry={entry} style={styles.flex} />}
|
|
199
|
-
entry={entry}
|
|
200
|
-
layoutState={layoutState}
|
|
201
|
-
playerState={playerState}
|
|
202
|
-
value={value}
|
|
203
|
-
dimensions={dimensions}
|
|
204
|
-
onCloseVideoModal={onCloseVideoModal}
|
|
205
|
-
onPlayerSeek={onPlayerSeek}
|
|
206
|
-
playNextData={playNextData}
|
|
207
|
-
title={title}
|
|
208
|
-
summary={summary}
|
|
209
|
-
/>
|
|
210
194
|
</View>
|
|
211
195
|
);
|
|
212
196
|
}
|
|
@@ -4,10 +4,7 @@ import { LayoutChangeEvent, StyleSheet, View } from "react-native";
|
|
|
4
4
|
import { TransportInfo as MobileTransportInfo } from "@applicaster/quick-brick-mobile-transport-controls";
|
|
5
5
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
6
6
|
import { useLanguageData } from "@applicaster/zapp-react-native-utils/reactHooks/player";
|
|
7
|
-
|
|
8
|
-
AnimationComponent,
|
|
9
|
-
ComponentAnimationType,
|
|
10
|
-
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
7
|
+
|
|
11
8
|
import { toPositiveNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
12
9
|
import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
13
10
|
|
|
@@ -104,10 +101,7 @@ export const TransportInfo = ({
|
|
|
104
101
|
]}
|
|
105
102
|
onLayout={handleLayout}
|
|
106
103
|
>
|
|
107
|
-
<
|
|
108
|
-
animationType={ComponentAnimationType.componentFade}
|
|
109
|
-
style={styles.animatedContainer}
|
|
110
|
-
>
|
|
104
|
+
<View style={styles.animatedContainer}>
|
|
111
105
|
<MobileTransportInfo
|
|
112
106
|
content={entry}
|
|
113
107
|
value={value}
|
|
@@ -116,7 +110,7 @@ export const TransportInfo = ({
|
|
|
116
110
|
layoutState={layoutState}
|
|
117
111
|
actionButtons={actionButtons}
|
|
118
112
|
/>
|
|
119
|
-
</
|
|
113
|
+
</View>
|
|
120
114
|
</View>
|
|
121
115
|
);
|
|
122
116
|
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React, { ReactElement } from "react";
|
|
2
|
+
|
|
3
|
+
import { Animated, Pressable } from "react-native";
|
|
4
|
+
import { PanGestureHandler } from "react-native-gesture-handler";
|
|
5
|
+
import { useStyles } from "./styles";
|
|
6
|
+
import { useVideoModalState } from "./hooks";
|
|
7
|
+
import { MODAL_COLLAPSE_START, MODAL_RADIUS, SCREEN_HEIGHT } from "./consts";
|
|
8
|
+
import { useModalAnimationContext } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
9
|
+
|
|
10
|
+
type AnimatedModalProps = {
|
|
11
|
+
content?: ReactElement;
|
|
12
|
+
collapsedContent?: ReactElement;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function AnimatedModal({
|
|
16
|
+
content,
|
|
17
|
+
collapsedContent,
|
|
18
|
+
}: AnimatedModalProps) {
|
|
19
|
+
const translateYRef = useModalAnimationContext().yTranslate;
|
|
20
|
+
|
|
21
|
+
const {
|
|
22
|
+
translateY,
|
|
23
|
+
collapsed,
|
|
24
|
+
collapsedHeight,
|
|
25
|
+
gestureHandlerProps,
|
|
26
|
+
expand,
|
|
27
|
+
} = useVideoModalState(translateYRef);
|
|
28
|
+
|
|
29
|
+
const styles = useStyles({ height: collapsedHeight, type: "audio" });
|
|
30
|
+
|
|
31
|
+
// Interpolated opacities for smooth cross-fade
|
|
32
|
+
const collapsedOpacity = translateY.interpolate({
|
|
33
|
+
inputRange: [MODAL_COLLAPSE_START, SCREEN_HEIGHT - collapsedHeight],
|
|
34
|
+
outputRange: [0, 1],
|
|
35
|
+
extrapolate: "clamp",
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const expandedOpacity = translateY.interpolate({
|
|
39
|
+
inputRange: [0, SCREEN_HEIGHT - collapsedHeight],
|
|
40
|
+
outputRange: [1, 0],
|
|
41
|
+
extrapolate: "clamp",
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const borderTopRadiusAnimated = translateY.interpolate({
|
|
45
|
+
inputRange: [0, SCREEN_HEIGHT - collapsedHeight],
|
|
46
|
+
outputRange: [MODAL_RADIUS, 0],
|
|
47
|
+
extrapolate: "clamp",
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<PanGestureHandler {...gestureHandlerProps}>
|
|
52
|
+
<Animated.View
|
|
53
|
+
pointerEvents={"auto"}
|
|
54
|
+
style={[
|
|
55
|
+
styles.modalWrapper,
|
|
56
|
+
{
|
|
57
|
+
borderTopLeftRadius: borderTopRadiusAnimated,
|
|
58
|
+
borderTopRightRadius: borderTopRadiusAnimated,
|
|
59
|
+
transform: [{ translateY }],
|
|
60
|
+
height: SCREEN_HEIGHT,
|
|
61
|
+
},
|
|
62
|
+
]}
|
|
63
|
+
>
|
|
64
|
+
<Animated.View
|
|
65
|
+
style={[
|
|
66
|
+
styles.modal,
|
|
67
|
+
{
|
|
68
|
+
borderTopLeftRadius: borderTopRadiusAnimated,
|
|
69
|
+
borderTopRightRadius: borderTopRadiusAnimated,
|
|
70
|
+
height: SCREEN_HEIGHT,
|
|
71
|
+
},
|
|
72
|
+
]}
|
|
73
|
+
>
|
|
74
|
+
{/* Expanded Content (fades in) */}
|
|
75
|
+
<Animated.View
|
|
76
|
+
pointerEvents={!collapsed ? "auto" : "none"}
|
|
77
|
+
style={styles.modalContent}
|
|
78
|
+
>
|
|
79
|
+
<Animated.View
|
|
80
|
+
pointerEvents={!collapsed ? "auto" : "none"}
|
|
81
|
+
style={[
|
|
82
|
+
styles.expandedContentContainer,
|
|
83
|
+
{ opacity: expandedOpacity },
|
|
84
|
+
]}
|
|
85
|
+
>
|
|
86
|
+
{content}
|
|
87
|
+
</Animated.View>
|
|
88
|
+
</Animated.View>
|
|
89
|
+
{/* Collapsed Bar (fades out) */}
|
|
90
|
+
<Animated.View
|
|
91
|
+
pointerEvents={collapsed ? "box-none" : "none"}
|
|
92
|
+
style={[
|
|
93
|
+
styles.collapsedBarContainer,
|
|
94
|
+
{ opacity: collapsedOpacity },
|
|
95
|
+
]}
|
|
96
|
+
>
|
|
97
|
+
<Pressable
|
|
98
|
+
testID="collapsedBarWrapper"
|
|
99
|
+
onPress={() => {
|
|
100
|
+
expand();
|
|
101
|
+
}}
|
|
102
|
+
style={styles.collapsedBarWrapper}
|
|
103
|
+
>
|
|
104
|
+
{collapsedContent}
|
|
105
|
+
</Pressable>
|
|
106
|
+
</Animated.View>
|
|
107
|
+
</Animated.View>
|
|
108
|
+
</Animated.View>
|
|
109
|
+
</PanGestureHandler>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import React, { useRef, ReactElement } from "react";
|
|
2
|
+
|
|
3
|
+
import { StyleSheet, Animated, Pressable, ViewStyle } from "react-native";
|
|
4
|
+
import { PanGestureHandler } from "react-native-gesture-handler";
|
|
5
|
+
import { useStyles } from "./styles";
|
|
6
|
+
import { useConfiguration } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/utils";
|
|
7
|
+
import { useVideoModalState } from "./hooks";
|
|
8
|
+
import {
|
|
9
|
+
DEFAULT_IMAGE_RATIO_VIDEO,
|
|
10
|
+
MODAL_COLLAPSE_START,
|
|
11
|
+
MODAL_RADIUS,
|
|
12
|
+
SCREEN_HEIGHT,
|
|
13
|
+
SCREEN_WIDTH,
|
|
14
|
+
} from "./consts";
|
|
15
|
+
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
16
|
+
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
17
|
+
import { useModalAnimationContext } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/useModalAnimationContext";
|
|
18
|
+
import { PROGRESS_BAR_HEIGHT } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/utils";
|
|
19
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
20
|
+
import { GestureAnimatedScrollView } from "./GestureAnimatedScrollView";
|
|
21
|
+
|
|
22
|
+
const orientationStyles = StyleSheet.create({
|
|
23
|
+
landscape: { flexDirection: "row" },
|
|
24
|
+
portrait: { flexDirection: "column" },
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const directionStyles = (isLandscape: boolean): ViewStyle => {
|
|
28
|
+
return isLandscape ? orientationStyles.landscape : orientationStyles.portrait;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type AnimatedModalProps = {
|
|
32
|
+
enabled?: boolean;
|
|
33
|
+
pip?: boolean;
|
|
34
|
+
content?: (
|
|
35
|
+
opacity: Animated.Value | Animated.AnimatedInterpolation
|
|
36
|
+
) => ReactElement;
|
|
37
|
+
collapsedContent?: (
|
|
38
|
+
opacity: Animated.Value | Animated.AnimatedInterpolation
|
|
39
|
+
) => ReactElement;
|
|
40
|
+
extraContent?: (
|
|
41
|
+
opacity: Animated.Value | Animated.AnimatedInterpolation
|
|
42
|
+
) => ReactElement;
|
|
43
|
+
aspectRatio?: number;
|
|
44
|
+
isTabletPortrait?: boolean;
|
|
45
|
+
style?: {
|
|
46
|
+
tabletLandscapeWidth?: number;
|
|
47
|
+
width?: number;
|
|
48
|
+
height?: number;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export function VideoPlayerModal({
|
|
53
|
+
enabled = true,
|
|
54
|
+
aspectRatio = DEFAULT_IMAGE_RATIO_VIDEO,
|
|
55
|
+
content,
|
|
56
|
+
extraContent,
|
|
57
|
+
collapsedContent,
|
|
58
|
+
isTabletPortrait,
|
|
59
|
+
style,
|
|
60
|
+
pip = false,
|
|
61
|
+
}: AnimatedModalProps) {
|
|
62
|
+
const isTablet = useIsTablet();
|
|
63
|
+
|
|
64
|
+
let width = SCREEN_WIDTH;
|
|
65
|
+
let height = SCREEN_HEIGHT;
|
|
66
|
+
|
|
67
|
+
if (isTablet && !isTabletPortrait) {
|
|
68
|
+
width = style?.tabletLandscapeWidth || width;
|
|
69
|
+
height = SCREEN_HEIGHT; // Keep height consistent for landscape
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const { minimised_height: minimisedHeight } = useConfiguration();
|
|
73
|
+
const scrollViewRef = useRef<typeof Animated.ScrollView | null>(null);
|
|
74
|
+
|
|
75
|
+
const translateYRef = useModalAnimationContext().yTranslate;
|
|
76
|
+
|
|
77
|
+
const {
|
|
78
|
+
translateY,
|
|
79
|
+
collapsed,
|
|
80
|
+
collapsedHeight,
|
|
81
|
+
gestureHandlerProps,
|
|
82
|
+
expand,
|
|
83
|
+
} = useVideoModalState(translateYRef);
|
|
84
|
+
|
|
85
|
+
const isTabletLandscape = !isTV() && isTablet && !isTabletPortrait;
|
|
86
|
+
|
|
87
|
+
const styles = useStyles({ height: collapsedHeight });
|
|
88
|
+
|
|
89
|
+
const SCALE_FACTOR = 1 / (width / aspectRatio / minimisedHeight); // Scale factor for expanded content
|
|
90
|
+
|
|
91
|
+
const VIDEO_TRANSITION_THRESHOLD = 0.5; // Threshold for video transition
|
|
92
|
+
|
|
93
|
+
const insets = useSafeAreaInsets();
|
|
94
|
+
|
|
95
|
+
// Interpolated opacities for smooth cross-fade
|
|
96
|
+
const collapsedOpacity = translateY.interpolate({
|
|
97
|
+
inputRange: [MODAL_COLLAPSE_START, height - collapsedHeight],
|
|
98
|
+
outputRange: [0, 1],
|
|
99
|
+
extrapolate: "clamp",
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const expandedOpacity = translateY.interpolate({
|
|
103
|
+
inputRange: [0, height - collapsedHeight],
|
|
104
|
+
outputRange: [1, 0],
|
|
105
|
+
extrapolate: "clamp",
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const xPosition = translateY.interpolate({
|
|
109
|
+
inputRange: [height * VIDEO_TRANSITION_THRESHOLD, height - collapsedHeight],
|
|
110
|
+
outputRange: [0, -(width - width * SCALE_FACTOR) / 2],
|
|
111
|
+
extrapolate: "clamp",
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const vidHeight = width / aspectRatio;
|
|
115
|
+
|
|
116
|
+
const yPosition = translateY.interpolate({
|
|
117
|
+
inputRange: [height * VIDEO_TRANSITION_THRESHOLD, height - collapsedHeight],
|
|
118
|
+
outputRange: [
|
|
119
|
+
0,
|
|
120
|
+
isTablet && isTabletLandscape
|
|
121
|
+
? -(
|
|
122
|
+
(-PROGRESS_BAR_HEIGHT + SCREEN_HEIGHT - vidHeight * SCALE_FACTOR) /
|
|
123
|
+
2
|
|
124
|
+
)
|
|
125
|
+
: -(
|
|
126
|
+
PROGRESS_BAR_HEIGHT +
|
|
127
|
+
insets.top / 2 +
|
|
128
|
+
(SCREEN_WIDTH / aspectRatio -
|
|
129
|
+
(SCREEN_WIDTH / aspectRatio) * SCALE_FACTOR) /
|
|
130
|
+
2
|
|
131
|
+
),
|
|
132
|
+
],
|
|
133
|
+
extrapolate: "clamp",
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
const scalePosition = translateY.interpolate({
|
|
137
|
+
inputRange: [
|
|
138
|
+
SCREEN_HEIGHT * VIDEO_TRANSITION_THRESHOLD,
|
|
139
|
+
SCREEN_HEIGHT - collapsedHeight,
|
|
140
|
+
],
|
|
141
|
+
outputRange: [1, SCALE_FACTOR],
|
|
142
|
+
extrapolate: "clamp",
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
const borderTopRadiusAnimated = translateY.interpolate({
|
|
146
|
+
inputRange: [0, SCREEN_HEIGHT - collapsedHeight],
|
|
147
|
+
outputRange: [MODAL_RADIUS, 0],
|
|
148
|
+
extrapolate: "clamp",
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
if (pip) {
|
|
152
|
+
return content(new Animated.Value(1));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<PanGestureHandler
|
|
157
|
+
enabled={enabled}
|
|
158
|
+
waitFor={scrollViewRef}
|
|
159
|
+
{...gestureHandlerProps}
|
|
160
|
+
>
|
|
161
|
+
<Animated.View
|
|
162
|
+
pointerEvents={"auto"}
|
|
163
|
+
style={[
|
|
164
|
+
styles.modalWrapper,
|
|
165
|
+
{
|
|
166
|
+
borderTopLeftRadius: borderTopRadiusAnimated,
|
|
167
|
+
borderTopRightRadius: borderTopRadiusAnimated,
|
|
168
|
+
transform: [{ translateY }],
|
|
169
|
+
height: SCREEN_HEIGHT,
|
|
170
|
+
},
|
|
171
|
+
]}
|
|
172
|
+
>
|
|
173
|
+
<Animated.View
|
|
174
|
+
pointerEvents={"auto"}
|
|
175
|
+
style={[
|
|
176
|
+
styles.modal,
|
|
177
|
+
collapsed ? styles.collapsedModalBg : null,
|
|
178
|
+
{
|
|
179
|
+
borderTopLeftRadius: borderTopRadiusAnimated,
|
|
180
|
+
borderTopRightRadius: borderTopRadiusAnimated,
|
|
181
|
+
height: SCREEN_HEIGHT,
|
|
182
|
+
},
|
|
183
|
+
]}
|
|
184
|
+
>
|
|
185
|
+
<Animated.View
|
|
186
|
+
pointerEvents={!collapsed ? "auto" : "none"}
|
|
187
|
+
style={[styles.modalContent, directionStyles(isTabletLandscape)]}
|
|
188
|
+
>
|
|
189
|
+
<Animated.View
|
|
190
|
+
style={[
|
|
191
|
+
styles.expandedContentContainer,
|
|
192
|
+
{
|
|
193
|
+
transform: [
|
|
194
|
+
{ translateX: xPosition },
|
|
195
|
+
{ translateY: yPosition },
|
|
196
|
+
{ scale: scalePosition },
|
|
197
|
+
],
|
|
198
|
+
},
|
|
199
|
+
]}
|
|
200
|
+
>
|
|
201
|
+
{content(expandedOpacity)}
|
|
202
|
+
</Animated.View>
|
|
203
|
+
{extraContent ? (
|
|
204
|
+
<GestureAnimatedScrollView
|
|
205
|
+
ref={scrollViewRef}
|
|
206
|
+
contentContainerStyle={{
|
|
207
|
+
paddingBottom: insets.bottom,
|
|
208
|
+
}}
|
|
209
|
+
style={[
|
|
210
|
+
styles.extraContentScrollView,
|
|
211
|
+
{ opacity: expandedOpacity },
|
|
212
|
+
]}
|
|
213
|
+
>
|
|
214
|
+
{extraContent ? extraContent(expandedOpacity) : null}
|
|
215
|
+
</GestureAnimatedScrollView>
|
|
216
|
+
) : null}
|
|
217
|
+
</Animated.View>
|
|
218
|
+
|
|
219
|
+
<Animated.View
|
|
220
|
+
pointerEvents={collapsed ? "box-none" : "none"}
|
|
221
|
+
style={[
|
|
222
|
+
styles.collapsedBarContainer,
|
|
223
|
+
{ opacity: collapsedOpacity },
|
|
224
|
+
]}
|
|
225
|
+
>
|
|
226
|
+
<Pressable
|
|
227
|
+
testID="collapsedBarWrapper"
|
|
228
|
+
onPress={() => {
|
|
229
|
+
expand();
|
|
230
|
+
}}
|
|
231
|
+
style={styles.collapsedBarWrapper}
|
|
232
|
+
>
|
|
233
|
+
{collapsedContent}
|
|
234
|
+
</Pressable>
|
|
235
|
+
</Animated.View>
|
|
236
|
+
</Animated.View>
|
|
237
|
+
</Animated.View>
|
|
238
|
+
</PanGestureHandler>
|
|
239
|
+
);
|
|
240
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isAndroidPlatform,
|
|
3
|
+
isAndroidVersionAtLeast,
|
|
4
|
+
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
5
|
+
import { Dimensions, StatusBar } from "react-native";
|
|
6
|
+
|
|
7
|
+
export const DOCKED_PROGRESSBAR_HEIGHT = 3; // Height of the docked progress bar plugins/mobile-transport-controls/src/ProgressBar/layouts/DockedLayout.tsx
|
|
8
|
+
|
|
9
|
+
const windowDimensions = Dimensions.get("window");
|
|
10
|
+
|
|
11
|
+
const isOldAndroidDevice = !isAndroidVersionAtLeast(35) && isAndroidPlatform();
|
|
12
|
+
|
|
13
|
+
export const SCREEN_WIDTH = windowDimensions.width;
|
|
14
|
+
|
|
15
|
+
export const SCREEN_HEIGHT =
|
|
16
|
+
windowDimensions.height + (isOldAndroidDevice ? StatusBar.currentHeight : 0);
|
|
17
|
+
|
|
18
|
+
export const MODAL_COLLAPSE_START = SCREEN_HEIGHT * 0.7; // 70% of screen height
|
|
19
|
+
|
|
20
|
+
export const DRAG_TO_COLLAPSE = 0.02; // 2% to collapse
|
|
21
|
+
|
|
22
|
+
export const DRAG_TO_EXPAND = 0.02; // 2% to expand
|
|
23
|
+
|
|
24
|
+
export const DEFAULT_IMAGE_RATIO_VIDEO = 16 / 9; // Default aspect ratio for video
|
|
25
|
+
|
|
26
|
+
export const DEFAULT_IMAGE_RATIO_AUDIO = 1; // Default aspect ratio for audio
|
|
27
|
+
|
|
28
|
+
export const ANIMATION_DURATION = 250; // Default animation duration in milliseconds
|
|
29
|
+
|
|
30
|
+
export const MODAL_RADIUS = 16; // Default border radius for modal
|