@applicaster/zapp-react-native-ui-components 15.0.0-alpha.4069571733 → 15.0.0-alpha.4254682703
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/Components/Cell/TvOSCellComponent.tsx +12 -3
- package/Components/PlayerImageBackground/index.tsx +2 -11
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +120 -27
- package/Components/VideoModal/ModalAnimation/index.ts +1 -3
- package/Components/VideoModal/ModalAnimation/utils.ts +1 -12
- package/Components/VideoModal/PlayerWrapper.tsx +14 -52
- package/Components/VideoModal/VideoModal.tsx +1 -5
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
- package/Components/VideoModal/hooks/useModalSize.ts +5 -1
- package/Components/VideoModal/playerWrapperStyle.ts +70 -0
- package/Components/VideoModal/playerWrapperUtils.ts +16 -12
- package/Components/VideoModal/utils.ts +7 -0
- package/package.json +5 -5
- package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +0 -17
|
@@ -17,6 +17,7 @@ import { CellWithFocusable } from "./CellWithFocusable";
|
|
|
17
17
|
import { FocusableWrapper } from "./FocusableWrapper";
|
|
18
18
|
|
|
19
19
|
import { focusableButtonsRegistration$ } from "@applicaster/zapp-react-native-utils/appUtils/focusManagerAux/utils/utils.ios";
|
|
20
|
+
import { toNumberWithDefaultZero } from "@applicaster/zapp-react-native-utils/numberUtils";
|
|
20
21
|
|
|
21
22
|
type Props = {
|
|
22
23
|
item: ZappEntry;
|
|
@@ -37,6 +38,9 @@ type Props = {
|
|
|
37
38
|
component: {
|
|
38
39
|
id: number | string;
|
|
39
40
|
component_type: string;
|
|
41
|
+
styles?: {
|
|
42
|
+
component_margin_top?: number;
|
|
43
|
+
};
|
|
40
44
|
};
|
|
41
45
|
selected: boolean;
|
|
42
46
|
CellRenderer: React.FunctionComponent<any> & {
|
|
@@ -204,11 +208,16 @@ class TvOSCell extends React.Component<Props, State> {
|
|
|
204
208
|
const extraAnchorPointYOffset =
|
|
205
209
|
screenLayout?.extraAnchorPointYOffset || 0;
|
|
206
210
|
|
|
211
|
+
const componentMarginTop = toNumberWithDefaultZero(
|
|
212
|
+
component?.styles?.component_margin_top
|
|
213
|
+
);
|
|
214
|
+
|
|
207
215
|
const totalOffset =
|
|
208
216
|
headerOffset +
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
217
|
+
(componentAnchorPointY || 0) +
|
|
218
|
+
extraAnchorPointYOffset -
|
|
219
|
+
(componentsMapOffset || 0) +
|
|
220
|
+
componentMarginTop;
|
|
212
221
|
|
|
213
222
|
mainOffsetUpdater?.(
|
|
214
223
|
{ tag: this.target },
|
|
@@ -2,10 +2,6 @@ import React, { PropsWithChildren } from "react";
|
|
|
2
2
|
import { ImageBackground, View } from "react-native";
|
|
3
3
|
|
|
4
4
|
import { imageSrcFromMediaItem } from "@applicaster/zapp-react-native-utils/configurationUtils";
|
|
5
|
-
import {
|
|
6
|
-
AnimationComponent,
|
|
7
|
-
ComponentAnimationType,
|
|
8
|
-
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
9
5
|
|
|
10
6
|
type Props = PropsWithChildren<{
|
|
11
7
|
entry: ZappEntry;
|
|
@@ -23,7 +19,6 @@ const PlayerImageBackgroundComponent = ({
|
|
|
23
19
|
style,
|
|
24
20
|
imageStyle,
|
|
25
21
|
imageKey,
|
|
26
|
-
defaultImageDimensions,
|
|
27
22
|
}: Props) => {
|
|
28
23
|
const source = React.useMemo(
|
|
29
24
|
() => ({ uri: imageSrcFromMediaItem(entry, [imageKey]) }),
|
|
@@ -34,11 +29,7 @@ const PlayerImageBackgroundComponent = ({
|
|
|
34
29
|
|
|
35
30
|
return (
|
|
36
31
|
<View style={style}>
|
|
37
|
-
<
|
|
38
|
-
style={style}
|
|
39
|
-
animationType={ComponentAnimationType.player}
|
|
40
|
-
additionalData={defaultImageDimensions}
|
|
41
|
-
>
|
|
32
|
+
<View style={style}>
|
|
42
33
|
<ImageBackground
|
|
43
34
|
resizeMode="cover"
|
|
44
35
|
style={imageSize}
|
|
@@ -47,7 +38,7 @@ const PlayerImageBackgroundComponent = ({
|
|
|
47
38
|
>
|
|
48
39
|
{children}
|
|
49
40
|
</ImageBackground>
|
|
50
|
-
</
|
|
41
|
+
</View>
|
|
51
42
|
</View>
|
|
52
43
|
);
|
|
53
44
|
};
|
|
@@ -1,62 +1,155 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
2
|
import { Animated, Dimensions } from "react-native";
|
|
3
3
|
|
|
4
4
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
|
|
5
5
|
|
|
6
6
|
import { useConfiguration } from "../utils";
|
|
7
|
-
import {
|
|
7
|
+
import { usePlugins } from "@applicaster/zapp-react-native-redux/hooks";
|
|
8
|
+
import { isMenuVisible } from "../../Screen/navigationHandler";
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
useSafeAreaFrame,
|
|
12
|
+
useSafeAreaInsets,
|
|
13
|
+
} from "react-native-safe-area-context";
|
|
14
|
+
import {
|
|
15
|
+
isAndroidPlatform,
|
|
16
|
+
isAndroidVersionAtLeast,
|
|
17
|
+
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
18
|
+
import { getTabBarHeight } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/getTabBarHeight";
|
|
19
|
+
import { PROGRESS_BAR_HEIGHT } from "./utils";
|
|
20
|
+
import { useIsTablet as getIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
21
|
+
import { useAppSelector } from "@applicaster/zapp-react-native-redux";
|
|
8
22
|
|
|
9
23
|
export type ModalAnimationContextT = {
|
|
10
|
-
yTranslate: React.MutableRefObject<Animated.
|
|
24
|
+
yTranslate: React.MutableRefObject<Animated.AnimatedInterpolation<number>>;
|
|
25
|
+
offsetAnimatedValueRef: React.MutableRefObject<Animated.Value>;
|
|
26
|
+
offset: React.MutableRefObject<number>;
|
|
27
|
+
heightAboveMinimised: number;
|
|
28
|
+
gestureTranslationRef: React.MutableRefObject<Animated.Value>;
|
|
11
29
|
minimisedHeight: number;
|
|
12
30
|
};
|
|
13
31
|
|
|
14
32
|
export const ReactContext = React.createContext<ModalAnimationContextT>({
|
|
15
33
|
yTranslate: React.createRef<Animated.Value | null>(),
|
|
34
|
+
offsetAnimatedValueRef: React.createRef<Animated.Value>(),
|
|
35
|
+
offset: React.createRef<number>(),
|
|
36
|
+
heightAboveMinimised: 0,
|
|
37
|
+
gestureTranslationRef: React.createRef<Animated.Value>(),
|
|
16
38
|
minimisedHeight: 60,
|
|
17
39
|
});
|
|
18
40
|
|
|
41
|
+
const SAFE_AREA_BREAKING_API_VERSION = 35;
|
|
42
|
+
|
|
43
|
+
export const isOldAndroidDevice =
|
|
44
|
+
isAndroidPlatform() &&
|
|
45
|
+
!isAndroidVersionAtLeast(SAFE_AREA_BREAKING_API_VERSION);
|
|
46
|
+
|
|
47
|
+
const bottomTabBarHeight = getTabBarHeight();
|
|
48
|
+
|
|
19
49
|
const Provider = ({ children }: { children: React.ReactNode }) => {
|
|
50
|
+
const { height } = Dimensions.get("window");
|
|
51
|
+
|
|
20
52
|
const yTranslate = React.useRef(
|
|
21
|
-
new Animated.Value(
|
|
53
|
+
new Animated.Value(height).interpolate<number>({
|
|
54
|
+
inputRange: [0, height],
|
|
55
|
+
outputRange: [0, height],
|
|
56
|
+
})
|
|
22
57
|
);
|
|
23
58
|
|
|
59
|
+
const { minimised_height: minimisedHeight } = useConfiguration();
|
|
60
|
+
|
|
24
61
|
const {
|
|
25
|
-
videoModalState: { visible },
|
|
62
|
+
videoModalState: { visible, mode },
|
|
63
|
+
currentRoute,
|
|
64
|
+
screenData,
|
|
26
65
|
} = useNavigation();
|
|
27
66
|
|
|
28
|
-
const
|
|
67
|
+
const isTabletPortrait = useAppSelector(
|
|
68
|
+
(state) => state.appData.isTabletPortrait
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const plugins = usePlugins();
|
|
72
|
+
|
|
73
|
+
const menuVisible = isMenuVisible(currentRoute, screenData, plugins);
|
|
74
|
+
|
|
75
|
+
const frame = useSafeAreaFrame();
|
|
76
|
+
const insets = useSafeAreaInsets();
|
|
77
|
+
|
|
78
|
+
const [heightAboveMinimised, setHeightAboveMinimised] = React.useState(0);
|
|
79
|
+
|
|
80
|
+
// memoizing heightAboveMinimised value
|
|
81
|
+
const offset = React.useRef(heightAboveMinimised);
|
|
82
|
+
|
|
83
|
+
// Used for memoizing modal y position after start/end of transition
|
|
84
|
+
const offsetAnimatedValueRef = React.useRef(
|
|
85
|
+
new Animated.Value(-offset.current)
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
// Used for gesture handling
|
|
89
|
+
const gestureTranslationRef = React.useRef(new Animated.Value(0));
|
|
90
|
+
|
|
91
|
+
const videoModalStateRef = React.useRef({ visible, mode });
|
|
92
|
+
|
|
93
|
+
React.useEffect(() => {
|
|
94
|
+
videoModalStateRef.current = { visible, mode };
|
|
95
|
+
}, [visible, mode]);
|
|
96
|
+
|
|
97
|
+
const translateY = useMemo(() => {
|
|
98
|
+
const maxRange = heightAboveMinimised;
|
|
99
|
+
|
|
100
|
+
const combined: Animated.AnimatedAddition<number> = Animated.add(
|
|
101
|
+
offsetAnimatedValueRef.current,
|
|
102
|
+
gestureTranslationRef.current
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
return combined.interpolate({
|
|
106
|
+
inputRange: [0, maxRange],
|
|
107
|
+
outputRange: [0, maxRange],
|
|
108
|
+
extrapolate: "clamp",
|
|
109
|
+
});
|
|
110
|
+
}, [visible, heightAboveMinimised]);
|
|
111
|
+
|
|
112
|
+
offset.current = heightAboveMinimised;
|
|
113
|
+
yTranslate.current = translateY;
|
|
114
|
+
|
|
115
|
+
React.useEffect(() => {
|
|
116
|
+
const collapsedHeight =
|
|
117
|
+
minimisedHeight +
|
|
118
|
+
(menuVisible ? bottomTabBarHeight : 0) +
|
|
119
|
+
(isOldAndroidDevice ? 0 : insets.bottom) + // insets.bottom is added to properly display docked modal
|
|
120
|
+
PROGRESS_BAR_HEIGHT;
|
|
121
|
+
|
|
122
|
+
const heightAboveMinimised = frame.height - collapsedHeight;
|
|
123
|
+
|
|
124
|
+
const isLandscape = frame.width > frame.height;
|
|
125
|
+
|
|
126
|
+
const isTablet = getIsTablet();
|
|
127
|
+
|
|
128
|
+
const shouldIgnoreLandscape = isTablet ? isTabletPortrait : true;
|
|
29
129
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (windowDimensions.height > windowDimensions.width) {
|
|
39
|
-
yTranslate.current?.setValue(windowDimensions.height);
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
yTranslate.current?.setValue(windowDimensions.height);
|
|
43
|
-
}
|
|
130
|
+
if (
|
|
131
|
+
heightAboveMinimised !== offset.current &&
|
|
132
|
+
videoModalStateRef.current.mode !== "PIP" &&
|
|
133
|
+
videoModalStateRef.current.mode !== "FULLSCREEN"
|
|
134
|
+
) {
|
|
135
|
+
if (isLandscape && shouldIgnoreLandscape) return;
|
|
136
|
+
setHeightAboveMinimised(heightAboveMinimised);
|
|
137
|
+
offset.current = heightAboveMinimised;
|
|
44
138
|
}
|
|
45
|
-
}, [
|
|
46
|
-
visible,
|
|
47
|
-
windowDimensions.height,
|
|
48
|
-
isTabletLandscape,
|
|
49
|
-
windowDimensions.width,
|
|
50
|
-
]);
|
|
139
|
+
}, [frame.height, insets.bottom, menuVisible, minimisedHeight]);
|
|
51
140
|
|
|
52
141
|
return (
|
|
53
142
|
<ReactContext.Provider
|
|
54
143
|
value={useMemo(
|
|
55
144
|
() => ({
|
|
56
145
|
yTranslate,
|
|
146
|
+
offsetAnimatedValueRef,
|
|
147
|
+
offset,
|
|
148
|
+
heightAboveMinimised,
|
|
57
149
|
minimisedHeight,
|
|
150
|
+
gestureTranslationRef,
|
|
58
151
|
}),
|
|
59
|
-
[minimisedHeight]
|
|
152
|
+
[minimisedHeight, heightAboveMinimised]
|
|
60
153
|
)}
|
|
61
154
|
>
|
|
62
155
|
{children}
|
|
@@ -2,8 +2,6 @@ export { withModalAnimationProvider } from "./ModalAnimationContext";
|
|
|
2
2
|
|
|
3
3
|
export { useModalAnimationContext } from "./useModalAnimationContext";
|
|
4
4
|
|
|
5
|
-
export {
|
|
6
|
-
|
|
7
|
-
export { ComponentAnimationType, defaultAspectRatioWidth } from "./utils";
|
|
5
|
+
export { defaultAspectRatioWidth } from "./utils";
|
|
8
6
|
|
|
9
7
|
export { DURATION_TO_MINIMIZE, DURATION_TO_MAXIMIZE } from "./const";
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
/* eslint-disable padding-line-between-statements */
|
|
2
|
-
|
|
3
|
-
export enum ComponentAnimationType {
|
|
4
|
-
bottomBar = "bottomBar",
|
|
5
|
-
player = "player",
|
|
6
|
-
componentFade = "componentFade",
|
|
7
|
-
componentAppears = "componentAppears",
|
|
8
|
-
moveUpComponent = "moveUpComponent",
|
|
9
|
-
moveComponentHorizontal = "moveComponentHorizontal",
|
|
10
|
-
audioPlayerPaddingHorizontal = "audioPlayerPaddingHorizontal",
|
|
11
|
-
}
|
|
12
|
-
|
|
13
1
|
export const AUDIO_PLAYER_HORIZONTAL_PADDING = 15;
|
|
2
|
+
|
|
14
3
|
export const PROGRESS_BAR_HEIGHT = 3;
|
|
15
4
|
|
|
16
5
|
export const defaultAspectRatioWidth = (height: number): number =>
|
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { View, ViewStyle } from "react-native";
|
|
3
3
|
import { Edge, SafeAreaView } from "react-native-safe-area-context";
|
|
4
4
|
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
5
5
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
6
6
|
import { playerDimensionsHack } from "./utils";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
DimensionsT,
|
|
10
|
-
Configuration,
|
|
11
|
-
getEdges,
|
|
12
|
-
getBaseDimensions,
|
|
13
|
-
calculateAspectRatio,
|
|
14
|
-
getPlayerDimensions,
|
|
15
|
-
getContainerDimensions,
|
|
16
|
-
} from "./playerWrapperUtils";
|
|
7
|
+
import { DimensionsT, Configuration, getEdges } from "./playerWrapperUtils";
|
|
8
|
+
import { defaultStyles, useStyle } from "./playerWrapperStyle";
|
|
17
9
|
|
|
18
10
|
type Props = {
|
|
19
11
|
entry: ZappEntry;
|
|
@@ -30,10 +22,6 @@ type Props = {
|
|
|
30
22
|
playerContent: (styles: ViewStyle) => React.ReactNode;
|
|
31
23
|
};
|
|
32
24
|
|
|
33
|
-
const defaultStyles = StyleSheet.create({
|
|
34
|
-
playerContainer: { position: "relative", alignSelf: "center", zIndex: 200 },
|
|
35
|
-
});
|
|
36
|
-
|
|
37
25
|
const PlayerWrapperComponent = (props: Props) => {
|
|
38
26
|
const {
|
|
39
27
|
entry,
|
|
@@ -47,47 +35,21 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
47
35
|
playerContent,
|
|
48
36
|
} = props;
|
|
49
37
|
|
|
38
|
+
const styles = useStyle({
|
|
39
|
+
style,
|
|
40
|
+
inline,
|
|
41
|
+
isModal,
|
|
42
|
+
isTabletPortrait,
|
|
43
|
+
configuration,
|
|
44
|
+
pip,
|
|
45
|
+
});
|
|
46
|
+
|
|
50
47
|
const isTablet = useIsTablet();
|
|
51
48
|
|
|
52
49
|
const isInlineModal = inline && isModal;
|
|
53
50
|
|
|
54
|
-
const isTabletLandscape = !isTV() && isTablet && !isTabletPortrait;
|
|
55
|
-
|
|
56
|
-
const tabletWidth = getTabletWidth(
|
|
57
|
-
configuration.tablet_landscape_sidebar_width,
|
|
58
|
-
style
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
const baseDimensions: DimensionsT = React.useMemo(
|
|
62
|
-
() => getBaseDimensions(isInlineModal, isTabletLandscape, tabletWidth),
|
|
63
|
-
[isInlineModal, isTabletLandscape, tabletWidth]
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
const aspectRatio = React.useMemo(
|
|
67
|
-
() => calculateAspectRatio(isInlineModal, pip),
|
|
68
|
-
[isInlineModal, pip]
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
const playerDimensions = React.useMemo(
|
|
72
|
-
() => getPlayerDimensions(baseDimensions, aspectRatio),
|
|
73
|
-
[baseDimensions, aspectRatio]
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
const containerDimensions: DimensionsT = React.useMemo(
|
|
77
|
-
() => getContainerDimensions(baseDimensions, playerDimensions.aspectRatio),
|
|
78
|
-
[baseDimensions, playerDimensions.aspectRatio]
|
|
79
|
-
);
|
|
80
|
-
|
|
81
51
|
const WrapperView = React.useMemo(() => (isTV() ? View : SafeAreaView), []);
|
|
82
52
|
|
|
83
|
-
const childrenStyles = React.useMemo(
|
|
84
|
-
() => ({
|
|
85
|
-
...playerDimensions,
|
|
86
|
-
...playerDimensionsHack,
|
|
87
|
-
}),
|
|
88
|
-
[playerDimensions]
|
|
89
|
-
);
|
|
90
|
-
|
|
91
53
|
return (
|
|
92
54
|
<WrapperView
|
|
93
55
|
edges={getEdges(isTablet, isInlineModal) as readonly Edge[]}
|
|
@@ -98,11 +60,11 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
98
60
|
style={[
|
|
99
61
|
defaultStyles.playerContainer,
|
|
100
62
|
playerDimensionsHack,
|
|
101
|
-
containerDimensions,
|
|
63
|
+
styles.containerDimensions,
|
|
102
64
|
containerStyle,
|
|
103
65
|
]}
|
|
104
66
|
>
|
|
105
|
-
{playerContent(childrenStyles)}
|
|
67
|
+
{playerContent(styles.childrenStyles)}
|
|
106
68
|
</View>
|
|
107
69
|
</WrapperView>
|
|
108
70
|
);
|
|
@@ -139,11 +139,7 @@ const VideoModalComponent = () => {
|
|
|
139
139
|
|
|
140
140
|
{itemIdHooksFinished === item?.id ? (
|
|
141
141
|
<View pointerEvents="box-none" style={styles.container}>
|
|
142
|
-
<HandlePlayable
|
|
143
|
-
item={item}
|
|
144
|
-
isModal={mode !== "PIP"}
|
|
145
|
-
mode={mode}
|
|
146
|
-
/>
|
|
142
|
+
<HandlePlayable item={item} isModal mode={mode} />
|
|
147
143
|
</View>
|
|
148
144
|
) : (
|
|
149
145
|
<View style={styles.loaderContainer}>
|
|
@@ -46,6 +46,7 @@ jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
|
|
|
46
46
|
|
|
47
47
|
jest.mock("@applicaster/zapp-react-native-utils/reactUtils", () => ({
|
|
48
48
|
isTV: jest.fn(() => false),
|
|
49
|
+
isAndroidPlatform: jest.fn(() => false),
|
|
49
50
|
isApplePlatform: jest.fn(() => true),
|
|
50
51
|
platformSelect: jest.fn((props) => props.android),
|
|
51
52
|
}));
|
|
@@ -33,8 +33,12 @@ const MODAL_SIZE_FOR_LANDSCAPE: Size = {
|
|
|
33
33
|
height: "100%",
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
+
const SAFE_AREA_BREAKING_API_VERSION = 35;
|
|
37
|
+
|
|
36
38
|
const isOldAndroidDevice =
|
|
37
|
-
isAndroidPlatform() &&
|
|
39
|
+
isAndroidPlatform() &&
|
|
40
|
+
!isAndroidVersionAtLeast(SAFE_AREA_BREAKING_API_VERSION) &&
|
|
41
|
+
!isAndroidTablet();
|
|
38
42
|
|
|
39
43
|
export const useModalSize = (): Size => {
|
|
40
44
|
const frame = useSafeAreaFrame();
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { StyleSheet, ViewStyle } from "react-native";
|
|
3
|
+
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
4
|
+
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
5
|
+
import { playerDimensionsHack } from "./utils";
|
|
6
|
+
import { getTabletWidth } from "@applicaster/zapp-react-native-utils/playerUtils";
|
|
7
|
+
import {
|
|
8
|
+
getBaseDimensions,
|
|
9
|
+
calculateAspectRatio,
|
|
10
|
+
getPlayerDimensions,
|
|
11
|
+
getContainerDimensions,
|
|
12
|
+
} from "./playerWrapperUtils";
|
|
13
|
+
|
|
14
|
+
export const defaultStyles = StyleSheet.create({
|
|
15
|
+
playerContainer: { position: "relative", alignSelf: "center", zIndex: 200 },
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const useStyle = ({
|
|
19
|
+
style,
|
|
20
|
+
inline,
|
|
21
|
+
isModal,
|
|
22
|
+
isTabletPortrait,
|
|
23
|
+
configuration,
|
|
24
|
+
pip,
|
|
25
|
+
}) => {
|
|
26
|
+
const isTablet = useIsTablet();
|
|
27
|
+
|
|
28
|
+
const isInlineModal = inline && isModal;
|
|
29
|
+
|
|
30
|
+
const isTabletLandscape = !isTV() && isTablet && !isTabletPortrait;
|
|
31
|
+
|
|
32
|
+
const tabletWidth = getTabletWidth(
|
|
33
|
+
configuration.tablet_landscape_sidebar_width,
|
|
34
|
+
style
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const baseDimensions: ViewStyle = React.useMemo(
|
|
38
|
+
() => getBaseDimensions(isInlineModal, isTabletLandscape, tabletWidth),
|
|
39
|
+
[isInlineModal, isTabletLandscape, tabletWidth]
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const aspectRatio = React.useMemo(
|
|
43
|
+
() => calculateAspectRatio(isInlineModal, pip),
|
|
44
|
+
// ignoring insets - only initial needed
|
|
45
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
|
+
[isInlineModal, pip]
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return React.useMemo(() => {
|
|
50
|
+
const playerDimensions: ViewStyle = getPlayerDimensions(
|
|
51
|
+
baseDimensions,
|
|
52
|
+
aspectRatio
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const containerDimensions: ViewStyle = getContainerDimensions(
|
|
56
|
+
baseDimensions,
|
|
57
|
+
aspectRatio
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const childrenStyles = {
|
|
61
|
+
...playerDimensions,
|
|
62
|
+
...playerDimensionsHack,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return StyleSheet.create({
|
|
66
|
+
containerDimensions,
|
|
67
|
+
childrenStyles,
|
|
68
|
+
});
|
|
69
|
+
}, [baseDimensions, aspectRatio]);
|
|
70
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Dimensions, Platform } from "react-native";
|
|
1
|
+
import { Dimensions, DimensionValue, Platform, ViewStyle } from "react-native";
|
|
2
2
|
import { Edge } from "react-native-safe-area-context";
|
|
3
3
|
|
|
4
4
|
export type DimensionsT = {
|
|
@@ -13,6 +13,10 @@ export type Configuration = {
|
|
|
13
13
|
tablet_landscape_player_container_background_color?: string;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
+
// This is safe, remembering screen dimensions once as they do not change during runtime
|
|
17
|
+
// TODO: consider sharing screen orientation as a shared function for the app
|
|
18
|
+
const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get("screen");
|
|
19
|
+
|
|
16
20
|
export const getWindowDimensions = () => {
|
|
17
21
|
const { width, height } = Dimensions.get("window");
|
|
18
22
|
|
|
@@ -32,8 +36,8 @@ export const getMinWindowDimension = () => {
|
|
|
32
36
|
};
|
|
33
37
|
|
|
34
38
|
export const getScreenAspectRatio = () => {
|
|
35
|
-
const longEdge =
|
|
36
|
-
const shortEdge =
|
|
39
|
+
const longEdge = Math.max(SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
40
|
+
const shortEdge = Math.min(SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
37
41
|
|
|
38
42
|
return longEdge / shortEdge;
|
|
39
43
|
};
|
|
@@ -56,8 +60,8 @@ export const getEdges = (
|
|
|
56
60
|
export const getBaseDimensions = (
|
|
57
61
|
isInlineModal: boolean,
|
|
58
62
|
isTabletLandscape: boolean,
|
|
59
|
-
tabletWidth:
|
|
60
|
-
):
|
|
63
|
+
tabletWidth: DimensionValue
|
|
64
|
+
): ViewStyle => ({
|
|
61
65
|
width: isInlineModal && isTabletLandscape ? tabletWidth : "100%",
|
|
62
66
|
height: undefined,
|
|
63
67
|
});
|
|
@@ -70,18 +74,18 @@ export const calculateAspectRatio = (
|
|
|
70
74
|
};
|
|
71
75
|
|
|
72
76
|
export const getPlayerDimensions = (
|
|
73
|
-
baseDimensions:
|
|
77
|
+
baseDimensions: ViewStyle,
|
|
74
78
|
aspectRatio: number
|
|
75
|
-
):
|
|
76
|
-
...baseDimensions,
|
|
79
|
+
): ViewStyle => ({
|
|
80
|
+
...(baseDimensions as any),
|
|
77
81
|
width: baseDimensions.width,
|
|
78
82
|
aspectRatio,
|
|
79
83
|
});
|
|
80
84
|
|
|
81
85
|
export const getContainerDimensions = (
|
|
82
|
-
baseDimensions:
|
|
83
|
-
|
|
84
|
-
):
|
|
86
|
+
baseDimensions: ViewStyle,
|
|
87
|
+
aspectRatio?: string | number
|
|
88
|
+
): ViewStyle => ({
|
|
85
89
|
...baseDimensions,
|
|
86
|
-
aspectRatio
|
|
90
|
+
aspectRatio,
|
|
87
91
|
});
|
|
@@ -4,6 +4,7 @@ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
|
4
4
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
|
|
5
5
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks/device/useIsTablet";
|
|
6
6
|
import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
|
|
7
|
+
import { create } from "zustand";
|
|
7
8
|
|
|
8
9
|
export const useConfiguration = () => {
|
|
9
10
|
const {
|
|
@@ -52,6 +53,12 @@ export const useConfiguration = () => {
|
|
|
52
53
|
};
|
|
53
54
|
};
|
|
54
55
|
|
|
56
|
+
export const useAnimationStateStore = create<{
|
|
57
|
+
isAnimationInProgress: boolean;
|
|
58
|
+
}>(() => ({
|
|
59
|
+
isAnimationInProgress: false,
|
|
60
|
+
}));
|
|
61
|
+
|
|
55
62
|
const fullSize = {
|
|
56
63
|
width: "100%",
|
|
57
64
|
height: "100%",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "15.0.0-alpha.
|
|
3
|
+
"version": "15.0.0-alpha.4254682703",
|
|
4
4
|
"description": "Applicaster Zapp React Native ui components for the Quick Brick App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "15.0.0-alpha.
|
|
32
|
-
"@applicaster/zapp-react-native-bridge": "15.0.0-alpha.
|
|
33
|
-
"@applicaster/zapp-react-native-redux": "15.0.0-alpha.
|
|
34
|
-
"@applicaster/zapp-react-native-utils": "15.0.0-alpha.
|
|
31
|
+
"@applicaster/applicaster-types": "15.0.0-alpha.4254682703",
|
|
32
|
+
"@applicaster/zapp-react-native-bridge": "15.0.0-alpha.4254682703",
|
|
33
|
+
"@applicaster/zapp-react-native-redux": "15.0.0-alpha.4254682703",
|
|
34
|
+
"@applicaster/zapp-react-native-utils": "15.0.0-alpha.4254682703",
|
|
35
35
|
"promise": "^8.3.0",
|
|
36
36
|
"url": "^0.11.0",
|
|
37
37
|
"uuid": "^3.3.2"
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { View } from "react-native";
|
|
3
|
-
|
|
4
|
-
type Props = {
|
|
5
|
-
animationType: string;
|
|
6
|
-
children: React.ReactNode;
|
|
7
|
-
style?: Record<string, any>;
|
|
8
|
-
additionalData?: { [key: string]: any };
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const AnimationComponent = (props: Props) => {
|
|
12
|
-
const { style } = props;
|
|
13
|
-
|
|
14
|
-
const Component = style ? View : React.Fragment;
|
|
15
|
-
|
|
16
|
-
return <Component {...props}>{props.children}</Component>;
|
|
17
|
-
};
|