@applicaster/zapp-react-native-ui-components 15.0.0-alpha.4368022015 → 15.0.0-alpha.4374322811
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/BaseFocusable/index.ios.ts +12 -2
- package/Components/Cell/Cell.tsx +8 -3
- package/Components/Cell/FocusableWrapper.tsx +3 -0
- package/Components/Cell/TvOSCellComponent.tsx +26 -5
- package/Components/Focusable/Focusable.tsx +4 -2
- package/Components/Focusable/FocusableTvOS.tsx +18 -1
- package/Components/Focusable/__tests__/__snapshots__/FocusableTvOS.test.tsx.snap +1 -0
- package/Components/FocusableGroup/FocusableTvOS.tsx +32 -1
- package/Components/GeneralContentScreen/utils/useCurationAPI.ts +14 -3
- package/Components/HandlePlayable/HandlePlayable.tsx +10 -7
- package/Components/Layout/TV/LayoutBackground.tsx +5 -2
- package/Components/Layout/TV/ScreenContainer.tsx +2 -6
- package/Components/Layout/TV/index.tsx +3 -4
- package/Components/Layout/TV/index.web.tsx +3 -4
- package/Components/LinkHandler/LinkHandler.tsx +2 -2
- package/Components/MasterCell/DefaultComponents/BorderContainerView/__tests__/index.test.tsx +16 -1
- package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +30 -2
- package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +5 -1
- package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +11 -3
- package/Components/MasterCell/DefaultComponents/Image/Image.web.tsx +9 -1
- package/Components/MasterCell/DefaultComponents/Image/hooks/useImage.ts +15 -14
- package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +10 -6
- package/Components/MasterCell/DefaultComponents/Text/index.tsx +8 -8
- package/Components/MasterCell/index.tsx +2 -0
- package/Components/MasterCell/utils/__tests__/resolveColor.test.js +82 -3
- package/Components/MasterCell/utils/index.ts +61 -31
- package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +102 -87
- package/Components/MeasurmentsPortal/__tests__/MeasurementsPortal.test.tsx +355 -0
- package/Components/OfflineHandler/NotificationView/NotificationView.tsx +2 -2
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +17 -18
- package/Components/OfflineHandler/__tests__/index.test.tsx +27 -18
- package/Components/PlayerContainer/PlayerContainer.tsx +51 -40
- package/Components/PlayerContainer/useRestrictMobilePlayback.tsx +101 -0
- package/Components/River/TV/River.tsx +31 -14
- package/Components/River/TV/index.tsx +8 -4
- package/Components/River/TV/utils/__tests__/toStringOrEmpty.test.ts +30 -0
- package/Components/River/TV/utils/index.ts +4 -0
- package/Components/River/TV/withFocusableGroupForContent.tsx +71 -0
- package/Components/Screen/TV/index.web.tsx +4 -2
- package/Components/Screen/__tests__/Screen.test.tsx +65 -42
- package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +68 -44
- package/Components/Screen/hooks.ts +2 -3
- package/Components/Screen/index.tsx +2 -3
- package/Components/Screen/navigationHandler.ts +49 -24
- package/Components/Screen/orientationHandler.ts +3 -3
- package/Components/ScreenResolver/index.tsx +13 -7
- package/Components/ScreenRevealManager/ScreenRevealManager.ts +40 -8
- package/Components/ScreenRevealManager/__tests__/ScreenRevealManager.test.ts +86 -69
- package/Components/Tabs/TV/Tabs.tsx +20 -3
- package/Components/Transitioner/Scene.tsx +15 -2
- package/Components/Transitioner/index.js +3 -3
- package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +124 -27
- package/Components/VideoModal/PlayerWrapper.tsx +15 -61
- package/Components/VideoModal/VideoModal.tsx +1 -5
- package/Components/VideoModal/hooks/useModalSize.ts +5 -1
- package/Components/VideoModal/playerWrapperStyle.ts +70 -0
- package/Components/VideoModal/playerWrapperUtils.ts +20 -33
- package/Components/VideoModal/utils.ts +19 -9
- package/Decorators/Analytics/index.tsx +6 -5
- package/Decorators/ConfigurationWrapper/__tests__/__snapshots__/withConfigurationProvider.test.tsx.snap +1 -0
- package/Decorators/ConfigurationWrapper/const.ts +1 -0
- package/Decorators/ZappPipesDataConnector/__tests__/zappPipesDataConnector.test.js +1 -1
- package/Decorators/ZappPipesDataConnector/index.tsx +2 -2
- package/Decorators/ZappPipesDataConnector/resolvers/StaticFeedResolver.tsx +1 -1
- package/Helpers/DataSourceHelper/__tests__/itemLimitForData.test.ts +80 -0
- package/Helpers/DataSourceHelper/index.ts +19 -0
- package/index.d.ts +7 -0
- package/package.json +6 -5
- package/Components/River/TV/withTVEventHandler.tsx +0 -27
- package/Helpers/DataSourceHelper/index.js +0 -19
|
@@ -1,62 +1,159 @@
|
|
|
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 {
|
|
8
|
+
useAppData,
|
|
9
|
+
usePlugins,
|
|
10
|
+
} from "@applicaster/zapp-react-native-redux/hooks";
|
|
11
|
+
import { isBottomTabVisible } from "../../Screen/navigationHandler";
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
useSafeAreaFrame,
|
|
15
|
+
useSafeAreaInsets,
|
|
16
|
+
} from "react-native-safe-area-context";
|
|
17
|
+
import {
|
|
18
|
+
isAndroidPlatform,
|
|
19
|
+
isAndroidVersionAtLeast,
|
|
20
|
+
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
21
|
+
import { getTabBarHeight } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/getTabBarHeight";
|
|
22
|
+
import { PROGRESS_BAR_HEIGHT } from "./utils";
|
|
23
|
+
import { useIsTablet as getIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
8
24
|
|
|
9
25
|
export type ModalAnimationContextT = {
|
|
10
|
-
yTranslate: React.MutableRefObject<Animated.
|
|
26
|
+
yTranslate: React.MutableRefObject<Animated.AnimatedInterpolation<number>>;
|
|
27
|
+
offsetAnimatedValueRef: React.MutableRefObject<Animated.Value>;
|
|
28
|
+
offset: React.MutableRefObject<number>;
|
|
29
|
+
heightAboveMinimised: number;
|
|
30
|
+
gestureTranslationRef: React.MutableRefObject<Animated.Value>;
|
|
11
31
|
minimisedHeight: number;
|
|
12
32
|
};
|
|
13
33
|
|
|
14
34
|
export const ReactContext = React.createContext<ModalAnimationContextT>({
|
|
15
35
|
yTranslate: React.createRef<Animated.Value | null>(),
|
|
36
|
+
offsetAnimatedValueRef: React.createRef<Animated.Value>(),
|
|
37
|
+
offset: React.createRef<number>(),
|
|
38
|
+
heightAboveMinimised: 0,
|
|
39
|
+
gestureTranslationRef: React.createRef<Animated.Value>(),
|
|
16
40
|
minimisedHeight: 60,
|
|
17
41
|
});
|
|
18
42
|
|
|
43
|
+
const SAFE_AREA_BREAKING_API_VERSION = 35;
|
|
44
|
+
|
|
45
|
+
export const isOldAndroidDevice =
|
|
46
|
+
isAndroidPlatform() &&
|
|
47
|
+
!isAndroidVersionAtLeast(SAFE_AREA_BREAKING_API_VERSION);
|
|
48
|
+
|
|
49
|
+
const bottomTabBarHeight = getTabBarHeight();
|
|
50
|
+
|
|
19
51
|
const Provider = ({ children }: { children: React.ReactNode }) => {
|
|
52
|
+
const { height } = Dimensions.get("window");
|
|
53
|
+
|
|
20
54
|
const yTranslate = React.useRef(
|
|
21
|
-
new Animated.Value(
|
|
55
|
+
new Animated.Value(height).interpolate<number>({
|
|
56
|
+
inputRange: [0, height],
|
|
57
|
+
outputRange: [0, height],
|
|
58
|
+
})
|
|
22
59
|
);
|
|
23
60
|
|
|
61
|
+
const { minimised_height: minimisedHeight } = useConfiguration();
|
|
62
|
+
|
|
24
63
|
const {
|
|
25
|
-
videoModalState: { visible },
|
|
64
|
+
videoModalState: { visible, mode },
|
|
65
|
+
currentRoute,
|
|
66
|
+
screenData,
|
|
26
67
|
} = useNavigation();
|
|
27
68
|
|
|
28
|
-
const {
|
|
69
|
+
const { isTabletPortrait } = useAppData();
|
|
70
|
+
|
|
71
|
+
const plugins = usePlugins();
|
|
72
|
+
|
|
73
|
+
const bottomTabsVisible = isBottomTabVisible(
|
|
74
|
+
currentRoute,
|
|
75
|
+
screenData,
|
|
76
|
+
plugins
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const frame = useSafeAreaFrame();
|
|
80
|
+
const insets = useSafeAreaInsets();
|
|
81
|
+
|
|
82
|
+
const [heightAboveMinimised, setHeightAboveMinimised] = React.useState(0);
|
|
83
|
+
|
|
84
|
+
// memoizing heightAboveMinimised value
|
|
85
|
+
const offset = React.useRef(heightAboveMinimised);
|
|
86
|
+
|
|
87
|
+
// Used for memoizing modal y position after start/end of transition
|
|
88
|
+
const offsetAnimatedValueRef = React.useRef(
|
|
89
|
+
new Animated.Value(-offset.current)
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
// Used for gesture handling
|
|
93
|
+
const gestureTranslationRef = React.useRef(new Animated.Value(0));
|
|
94
|
+
|
|
95
|
+
const videoModalStateRef = React.useRef({ visible, mode });
|
|
96
|
+
|
|
97
|
+
React.useEffect(() => {
|
|
98
|
+
videoModalStateRef.current = { visible, mode };
|
|
99
|
+
}, [visible, mode]);
|
|
100
|
+
|
|
101
|
+
const translateY = useMemo(() => {
|
|
102
|
+
const maxRange = heightAboveMinimised;
|
|
103
|
+
|
|
104
|
+
const combined: Animated.AnimatedAddition<number> = Animated.add(
|
|
105
|
+
offsetAnimatedValueRef.current,
|
|
106
|
+
gestureTranslationRef.current
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
return combined.interpolate({
|
|
110
|
+
inputRange: [0, maxRange],
|
|
111
|
+
outputRange: [0, maxRange],
|
|
112
|
+
extrapolate: "clamp",
|
|
113
|
+
});
|
|
114
|
+
}, [visible, heightAboveMinimised]);
|
|
115
|
+
|
|
116
|
+
offset.current = heightAboveMinimised;
|
|
117
|
+
yTranslate.current = translateY;
|
|
118
|
+
|
|
119
|
+
React.useEffect(() => {
|
|
120
|
+
const collapsedHeight =
|
|
121
|
+
minimisedHeight +
|
|
122
|
+
(bottomTabsVisible ? bottomTabBarHeight : 0) +
|
|
123
|
+
(isOldAndroidDevice ? 0 : insets.bottom) + // insets.bottom is added to properly display docked modal
|
|
124
|
+
PROGRESS_BAR_HEIGHT;
|
|
125
|
+
|
|
126
|
+
const heightAboveMinimised = frame.height - collapsedHeight;
|
|
127
|
+
|
|
128
|
+
const isLandscape = frame.width > frame.height;
|
|
129
|
+
|
|
130
|
+
const isTablet = getIsTablet();
|
|
131
|
+
|
|
132
|
+
const shouldIgnoreLandscape = isTablet ? isTabletPortrait : true;
|
|
29
133
|
|
|
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
|
-
}
|
|
134
|
+
if (
|
|
135
|
+
heightAboveMinimised !== offset.current &&
|
|
136
|
+
videoModalStateRef.current.mode !== "PIP" &&
|
|
137
|
+
videoModalStateRef.current.mode !== "FULLSCREEN"
|
|
138
|
+
) {
|
|
139
|
+
if (isLandscape && shouldIgnoreLandscape) return;
|
|
140
|
+
setHeightAboveMinimised(heightAboveMinimised);
|
|
141
|
+
offset.current = heightAboveMinimised;
|
|
44
142
|
}
|
|
45
|
-
}, [
|
|
46
|
-
visible,
|
|
47
|
-
windowDimensions.height,
|
|
48
|
-
isTabletLandscape,
|
|
49
|
-
windowDimensions.width,
|
|
50
|
-
]);
|
|
143
|
+
}, [frame.height, insets.bottom, bottomTabsVisible, minimisedHeight]);
|
|
51
144
|
|
|
52
145
|
return (
|
|
53
146
|
<ReactContext.Provider
|
|
54
147
|
value={useMemo(
|
|
55
148
|
() => ({
|
|
56
149
|
yTranslate,
|
|
150
|
+
offsetAnimatedValueRef,
|
|
151
|
+
offset,
|
|
152
|
+
heightAboveMinimised,
|
|
57
153
|
minimisedHeight,
|
|
154
|
+
gestureTranslationRef,
|
|
58
155
|
}),
|
|
59
|
-
[minimisedHeight]
|
|
156
|
+
[minimisedHeight, heightAboveMinimised]
|
|
60
157
|
)}
|
|
61
158
|
>
|
|
62
159
|
{children}
|
|
@@ -1,23 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
Edge,
|
|
5
|
-
SafeAreaView,
|
|
6
|
-
useSafeAreaInsets,
|
|
7
|
-
} from "react-native-safe-area-context";
|
|
2
|
+
import { View, ViewStyle } from "react-native";
|
|
3
|
+
import { Edge, SafeAreaView } from "react-native-safe-area-context";
|
|
8
4
|
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
9
5
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
10
6
|
import { playerDimensionsHack } from "./utils";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
DimensionsT,
|
|
14
|
-
Configuration,
|
|
15
|
-
getEdges,
|
|
16
|
-
getBaseDimensions,
|
|
17
|
-
calculateAspectRatio,
|
|
18
|
-
getPlayerDimensions,
|
|
19
|
-
getContainerDimensions,
|
|
20
|
-
} from "./playerWrapperUtils";
|
|
7
|
+
import { DimensionsT, Configuration, getEdges } from "./playerWrapperUtils";
|
|
8
|
+
import { defaultStyles, useStyle } from "./playerWrapperStyle";
|
|
21
9
|
|
|
22
10
|
type Props = {
|
|
23
11
|
entry: ZappEntry;
|
|
@@ -34,10 +22,6 @@ type Props = {
|
|
|
34
22
|
playerContent: (styles: ViewStyle) => React.ReactNode;
|
|
35
23
|
};
|
|
36
24
|
|
|
37
|
-
const defaultStyles = StyleSheet.create({
|
|
38
|
-
playerContainer: { position: "relative", alignSelf: "center", zIndex: 200 },
|
|
39
|
-
});
|
|
40
|
-
|
|
41
25
|
const PlayerWrapperComponent = (props: Props) => {
|
|
42
26
|
const {
|
|
43
27
|
entry,
|
|
@@ -51,51 +35,21 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
51
35
|
playerContent,
|
|
52
36
|
} = props;
|
|
53
37
|
|
|
38
|
+
const styles = useStyle({
|
|
39
|
+
style,
|
|
40
|
+
inline,
|
|
41
|
+
isModal,
|
|
42
|
+
isTabletPortrait,
|
|
43
|
+
configuration,
|
|
44
|
+
pip,
|
|
45
|
+
});
|
|
46
|
+
|
|
54
47
|
const isTablet = useIsTablet();
|
|
55
48
|
|
|
56
49
|
const isInlineModal = inline && isModal;
|
|
57
50
|
|
|
58
|
-
const isTabletLandscape = !isTV() && isTablet && !isTabletPortrait;
|
|
59
|
-
|
|
60
|
-
const tabletWidth = getTabletWidth(
|
|
61
|
-
configuration.tablet_landscape_sidebar_width,
|
|
62
|
-
style
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const baseDimensions: DimensionsT = React.useMemo(
|
|
66
|
-
() => getBaseDimensions(isInlineModal, isTabletLandscape, tabletWidth),
|
|
67
|
-
[isInlineModal, isTabletLandscape, tabletWidth]
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
const insets = useSafeAreaInsets();
|
|
71
|
-
|
|
72
|
-
const aspectRatio = React.useMemo(
|
|
73
|
-
() => calculateAspectRatio(isInlineModal, pip, insets),
|
|
74
|
-
// ignoring insets - only initial needed
|
|
75
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
76
|
-
[isInlineModal, pip]
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
const playerDimensions = React.useMemo(
|
|
80
|
-
() => getPlayerDimensions(baseDimensions, aspectRatio),
|
|
81
|
-
[baseDimensions, aspectRatio]
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
const containerDimensions: DimensionsT = React.useMemo(
|
|
85
|
-
() => getContainerDimensions(baseDimensions, playerDimensions.aspectRatio),
|
|
86
|
-
[baseDimensions, playerDimensions.aspectRatio]
|
|
87
|
-
);
|
|
88
|
-
|
|
89
51
|
const WrapperView = React.useMemo(() => (isTV() ? View : SafeAreaView), []);
|
|
90
52
|
|
|
91
|
-
const childrenStyles = React.useMemo(
|
|
92
|
-
() => ({
|
|
93
|
-
...playerDimensions,
|
|
94
|
-
...playerDimensionsHack,
|
|
95
|
-
}),
|
|
96
|
-
[playerDimensions]
|
|
97
|
-
);
|
|
98
|
-
|
|
99
53
|
return (
|
|
100
54
|
<WrapperView
|
|
101
55
|
edges={getEdges(isTablet, isInlineModal) as readonly Edge[]}
|
|
@@ -106,11 +60,11 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
106
60
|
style={[
|
|
107
61
|
defaultStyles.playerContainer,
|
|
108
62
|
playerDimensionsHack,
|
|
109
|
-
containerDimensions,
|
|
63
|
+
styles.containerDimensions,
|
|
110
64
|
containerStyle,
|
|
111
65
|
]}
|
|
112
66
|
>
|
|
113
|
-
{playerContent(childrenStyles)}
|
|
67
|
+
{playerContent(styles.childrenStyles)}
|
|
114
68
|
</View>
|
|
115
69
|
</WrapperView>
|
|
116
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}>
|
|
@@ -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,16 +1,6 @@
|
|
|
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
|
-
import {
|
|
5
|
-
isAndroidPlatform,
|
|
6
|
-
isAndroidVersionAtLeast,
|
|
7
|
-
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
8
|
-
|
|
9
|
-
const MIN_SUPPORTED_ANDROID_API = 34;
|
|
10
|
-
|
|
11
|
-
export const isOldAndroidDevice =
|
|
12
|
-
isAndroidPlatform() && !isAndroidVersionAtLeast(MIN_SUPPORTED_ANDROID_API);
|
|
13
|
-
|
|
14
4
|
export type DimensionsT = {
|
|
15
5
|
width: number | string;
|
|
16
6
|
height: number | string | undefined;
|
|
@@ -23,6 +13,10 @@ export type Configuration = {
|
|
|
23
13
|
tablet_landscape_player_container_background_color?: string;
|
|
24
14
|
};
|
|
25
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
|
+
|
|
26
20
|
export const getWindowDimensions = () => {
|
|
27
21
|
const { width, height } = Dimensions.get("window");
|
|
28
22
|
|
|
@@ -41,15 +35,11 @@ export const getMinWindowDimension = () => {
|
|
|
41
35
|
return Math.min(width, height);
|
|
42
36
|
};
|
|
43
37
|
|
|
44
|
-
export const getScreenAspectRatio = (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}) => {
|
|
48
|
-
const longEdge = getMaxWindowDimension();
|
|
49
|
-
const shortEdge = getMinWindowDimension();
|
|
38
|
+
export const getScreenAspectRatio = () => {
|
|
39
|
+
const longEdge = Math.max(SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
40
|
+
const shortEdge = Math.min(SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
50
41
|
|
|
51
|
-
|
|
52
|
-
return longEdge / (shortEdge - ((insets?.top ?? 0) + (insets?.bottom ?? 0)));
|
|
42
|
+
return longEdge / shortEdge;
|
|
53
43
|
};
|
|
54
44
|
|
|
55
45
|
export const getEdges = (
|
|
@@ -70,35 +60,32 @@ export const getEdges = (
|
|
|
70
60
|
export const getBaseDimensions = (
|
|
71
61
|
isInlineModal: boolean,
|
|
72
62
|
isTabletLandscape: boolean,
|
|
73
|
-
tabletWidth:
|
|
74
|
-
):
|
|
63
|
+
tabletWidth: DimensionValue
|
|
64
|
+
): ViewStyle => ({
|
|
75
65
|
width: isInlineModal && isTabletLandscape ? tabletWidth : "100%",
|
|
76
66
|
height: undefined,
|
|
77
67
|
});
|
|
78
68
|
|
|
79
69
|
export const calculateAspectRatio = (
|
|
80
70
|
isInlineModal: boolean,
|
|
81
|
-
pip?: boolean
|
|
82
|
-
insets?: { top: number; bottom: number }
|
|
71
|
+
pip?: boolean
|
|
83
72
|
): number => {
|
|
84
|
-
return !isInlineModal && !pip
|
|
85
|
-
? getScreenAspectRatio(isOldAndroidDevice ? insets : undefined)
|
|
86
|
-
: 16 / 9;
|
|
73
|
+
return !isInlineModal && !pip ? getScreenAspectRatio() : 16 / 9;
|
|
87
74
|
};
|
|
88
75
|
|
|
89
76
|
export const getPlayerDimensions = (
|
|
90
|
-
baseDimensions:
|
|
77
|
+
baseDimensions: ViewStyle,
|
|
91
78
|
aspectRatio: number
|
|
92
|
-
):
|
|
93
|
-
...baseDimensions,
|
|
79
|
+
): ViewStyle => ({
|
|
80
|
+
...(baseDimensions as any),
|
|
94
81
|
width: baseDimensions.width,
|
|
95
82
|
aspectRatio,
|
|
96
83
|
});
|
|
97
84
|
|
|
98
85
|
export const getContainerDimensions = (
|
|
99
|
-
baseDimensions:
|
|
100
|
-
|
|
101
|
-
):
|
|
86
|
+
baseDimensions: ViewStyle,
|
|
87
|
+
aspectRatio?: string | number
|
|
88
|
+
): ViewStyle => ({
|
|
102
89
|
...baseDimensions,
|
|
103
|
-
aspectRatio
|
|
90
|
+
aspectRatio,
|
|
104
91
|
});
|
|
@@ -1,31 +1,35 @@
|
|
|
1
1
|
import { mergeRight } from "ramda";
|
|
2
2
|
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
useAppSelector,
|
|
5
|
+
useContentTypes,
|
|
6
|
+
} from "@applicaster/zapp-react-native-redux/hooks";
|
|
4
7
|
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
|
|
5
8
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks/device/useIsTablet";
|
|
6
9
|
import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
|
|
10
|
+
import { create } from "zustand";
|
|
11
|
+
import { useRivers } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
12
|
+
import { selectPluginConfigurationsByPluginId } from "@applicaster/zapp-react-native-redux";
|
|
7
13
|
|
|
8
14
|
export const useConfiguration = () => {
|
|
9
15
|
const {
|
|
10
16
|
videoModalState: { item },
|
|
11
17
|
} = useNavigation();
|
|
12
18
|
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
"contentTypes",
|
|
16
|
-
"pluginConfigurations",
|
|
17
|
-
]);
|
|
19
|
+
const rivers = useRivers();
|
|
20
|
+
const contentTypes = useContentTypes();
|
|
18
21
|
|
|
19
22
|
const targetScreenId = contentTypes?.[item?.type?.value]?.screen_id;
|
|
20
23
|
const targetScreenConfiguration = rivers?.[targetScreenId];
|
|
21
24
|
|
|
22
|
-
const
|
|
23
|
-
|
|
25
|
+
const { configuration_json } = useAppSelector((state) =>
|
|
26
|
+
selectPluginConfigurationsByPluginId(state, targetScreenConfiguration?.type)
|
|
27
|
+
);
|
|
24
28
|
|
|
25
29
|
const playerPluginConfig = playerManager.getPluginConfiguration();
|
|
26
30
|
|
|
27
31
|
const config = mergeRight(playerPluginConfig, {
|
|
28
|
-
...
|
|
32
|
+
...configuration_json,
|
|
29
33
|
...targetScreenConfiguration?.general,
|
|
30
34
|
...targetScreenConfiguration?.styles,
|
|
31
35
|
});
|
|
@@ -52,6 +56,12 @@ export const useConfiguration = () => {
|
|
|
52
56
|
};
|
|
53
57
|
};
|
|
54
58
|
|
|
59
|
+
export const useAnimationStateStore = create<{
|
|
60
|
+
isAnimationInProgress: boolean;
|
|
61
|
+
}>(() => ({
|
|
62
|
+
isAnimationInProgress: false,
|
|
63
|
+
}));
|
|
64
|
+
|
|
55
65
|
const fullSize = {
|
|
56
66
|
width: "100%",
|
|
57
67
|
height: "100%",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
3
|
import { getAnalyticsFunctions } from "@applicaster/zapp-react-native-utils/analyticsUtils";
|
|
4
|
-
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
5
4
|
|
|
6
5
|
type ComponentProps = {
|
|
7
6
|
component: {
|
|
@@ -21,11 +20,13 @@ type ComponentProps = {
|
|
|
21
20
|
|
|
22
21
|
function withAnalytics(Component) {
|
|
23
22
|
return function WithAnalytics(props: ComponentProps) {
|
|
24
|
-
const { appData } = usePickFromState(["appData"]);
|
|
25
|
-
|
|
26
23
|
const analyticsFunctions = React.useMemo(
|
|
27
|
-
() =>
|
|
28
|
-
|
|
24
|
+
() =>
|
|
25
|
+
getAnalyticsFunctions({
|
|
26
|
+
component: props.component,
|
|
27
|
+
zappPipesData: props.zappPipesData,
|
|
28
|
+
} as any),
|
|
29
|
+
[props.component, props.zappPipesData]
|
|
29
30
|
);
|
|
30
31
|
|
|
31
32
|
return (
|
|
@@ -88,6 +88,7 @@ exports[`withConfigurationProvider correctly passes all the configuration keys c
|
|
|
88
88
|
tab_cell_padding_right={10}
|
|
89
89
|
tab_cell_padding_top={14}
|
|
90
90
|
tablet_theme={false}
|
|
91
|
+
tabs_screen_background_color="transparent"
|
|
91
92
|
target={false}
|
|
92
93
|
target_screen_switch={false}
|
|
93
94
|
text_label_active_font_color="rgba(239, 239, 239, 0.5)"
|
|
@@ -208,4 +208,5 @@ export const keysMap: Record<string, Function> = {
|
|
|
208
208
|
tab_bar_item_margin_right: castOrDefaultValue(Number, 0),
|
|
209
209
|
tab_bar_item_margin_bottom: castOrDefaultValue(Number, 0),
|
|
210
210
|
tab_bar_item_margin_left: castOrDefaultValue(Number, 0),
|
|
211
|
+
tabs_screen_background_color: castOrDefaultValue(R.identity, "transparent"),
|
|
211
212
|
};
|
|
@@ -3,7 +3,7 @@ import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUt
|
|
|
3
3
|
|
|
4
4
|
import * as zappPipesRedux from "@applicaster/zapp-react-native-redux/ZappPipes";
|
|
5
5
|
import configureStore from "redux-mock-store";
|
|
6
|
-
import thunk from "redux-thunk";
|
|
6
|
+
import { thunk } from "redux-thunk";
|
|
7
7
|
|
|
8
8
|
import { zappPipesDataConnector } from "../index";
|
|
9
9
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// <reference types="@applicaster/zapp-react-native-ui-components" />
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
5
|
-
import {
|
|
5
|
+
import { usePlugins } from "@applicaster/zapp-react-native-redux/hooks";
|
|
6
6
|
import { ZappPipesSearchContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
|
|
7
7
|
import { useScreenContext } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
|
|
8
8
|
import { ResolverSelector } from "./ResolverSelector";
|
|
@@ -23,7 +23,7 @@ export function zappPipesDataConnector(
|
|
|
23
23
|
) {
|
|
24
24
|
return function WrappedWithZappPipesData(props: Props) {
|
|
25
25
|
const { screenData } = useRoute();
|
|
26
|
-
const
|
|
26
|
+
const plugins = usePlugins();
|
|
27
27
|
const screenContextData = useScreenContext();
|
|
28
28
|
|
|
29
29
|
const {
|
|
@@ -76,7 +76,7 @@ export function StaticFeedResolver({
|
|
|
76
76
|
|
|
77
77
|
const zappPipesDataProps = useMemo(
|
|
78
78
|
() => ({
|
|
79
|
-
zappPipesData: { url, loading, data, error },
|
|
79
|
+
zappPipesData: { url, loading, data, error }, // todo: add applyItemLimit
|
|
80
80
|
reloadData,
|
|
81
81
|
loadNextData: undefined, // Static resolver doesn't support pagination
|
|
82
82
|
}),
|