@applicaster/zapp-react-native-ui-components 12.0.22-alpha.1628418248 → 12.0.22-alpha.1975406433
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/VideoModal/PlayerWrapper.tsx +98 -35
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +14 -19
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +1 -1
- package/Components/VideoModal/utils.ts +7 -83
- package/package.json +5 -5
- package/Components/VideoModal/types.ts +0 -11
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Dimensions,
|
|
4
|
+
Platform,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
View,
|
|
7
|
+
ViewStyle,
|
|
8
|
+
} from "react-native";
|
|
3
9
|
import { Edge, SafeAreaView } from "react-native-safe-area-context";
|
|
4
10
|
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
5
11
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
6
12
|
import { PlayerDetails } from "./PlayerDetails";
|
|
7
|
-
import {
|
|
8
|
-
directionStyles,
|
|
9
|
-
getEdges,
|
|
10
|
-
getScreenAspectRatio,
|
|
11
|
-
getTabletSidebarWidth,
|
|
12
|
-
getTabletWidth,
|
|
13
|
-
playerDimensionsHack,
|
|
14
|
-
} from "./utils";
|
|
13
|
+
import { playerDimensionsHack } from "./utils";
|
|
15
14
|
import { useDelayedPlayerDetails } from "./hooks";
|
|
16
15
|
|
|
17
16
|
import {
|
|
@@ -20,7 +19,20 @@ import {
|
|
|
20
19
|
AnimationComponent,
|
|
21
20
|
ComponentAnimationType,
|
|
22
21
|
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
23
|
-
|
|
22
|
+
|
|
23
|
+
const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get("screen");
|
|
24
|
+
|
|
25
|
+
type DimensionsT = {
|
|
26
|
+
width: number | string;
|
|
27
|
+
height: number | string | undefined;
|
|
28
|
+
aspectRatio?: number;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type Configuration = {
|
|
32
|
+
[key: string]: any;
|
|
33
|
+
tablet_landscape_sidebar_width?: string;
|
|
34
|
+
tablet_landscape_player_container_background_color?: string;
|
|
35
|
+
};
|
|
24
36
|
|
|
25
37
|
type Props = {
|
|
26
38
|
entry: ZappEntry;
|
|
@@ -42,6 +54,74 @@ const defaultStyles = StyleSheet.create({
|
|
|
42
54
|
flex: { flex: 1 },
|
|
43
55
|
});
|
|
44
56
|
|
|
57
|
+
const orientationStyles = StyleSheet.create({
|
|
58
|
+
landscape: { flexDirection: "row" },
|
|
59
|
+
portrait: { flexDirection: "column" },
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const directionStyles = (isTabletLandscape: boolean): ViewStyle => {
|
|
63
|
+
if (isTabletLandscape) {
|
|
64
|
+
return orientationStyles.landscape;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return orientationStyles.portrait;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const getScreenAspectRatio = () => {
|
|
71
|
+
const longEdge = Math.max(SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
72
|
+
const shortEdge = Math.min(SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
73
|
+
|
|
74
|
+
return longEdge / shortEdge;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const safeAreaStyles = (
|
|
78
|
+
configuration: Configuration,
|
|
79
|
+
isTablet: boolean
|
|
80
|
+
): ViewStyle => {
|
|
81
|
+
const tablet_landscape_player_container_background_color =
|
|
82
|
+
configuration?.tablet_landscape_player_container_background_color;
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
backgroundColor: isTablet
|
|
86
|
+
? tablet_landscape_player_container_background_color
|
|
87
|
+
: "transparent",
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const getEdges = (isTablet: boolean, isInlineModal: boolean) => {
|
|
92
|
+
if (isTablet) {
|
|
93
|
+
return ["top"];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (!isInlineModal && Platform.OS === "android") {
|
|
97
|
+
return [];
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return ["top"];
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const getTabletWidth = (
|
|
104
|
+
configuration: Configuration,
|
|
105
|
+
dimensions: DimensionsT
|
|
106
|
+
) => {
|
|
107
|
+
const tablet_landscape_sidebar_width =
|
|
108
|
+
configuration?.tablet_landscape_sidebar_width;
|
|
109
|
+
|
|
110
|
+
const { width } = dimensions;
|
|
111
|
+
|
|
112
|
+
const sidebarWidth = Number(tablet_landscape_sidebar_width?.replace("%", ""));
|
|
113
|
+
|
|
114
|
+
if (tablet_landscape_sidebar_width?.includes("%")) {
|
|
115
|
+
return Number(width) * (1 - sidebarWidth / 100);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (Number.isNaN(sidebarWidth)) {
|
|
119
|
+
return Number(width) * 0.65;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return Number(width) - sidebarWidth;
|
|
123
|
+
};
|
|
124
|
+
|
|
45
125
|
const PlayerWrapperComponent = (props: Props) => {
|
|
46
126
|
const {
|
|
47
127
|
entry,
|
|
@@ -53,7 +133,6 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
53
133
|
children,
|
|
54
134
|
isTabletPortrait,
|
|
55
135
|
configuration,
|
|
56
|
-
fullscreen,
|
|
57
136
|
pip,
|
|
58
137
|
} = props;
|
|
59
138
|
|
|
@@ -71,16 +150,9 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
71
150
|
isPip: pip,
|
|
72
151
|
});
|
|
73
152
|
|
|
74
|
-
const isTabletLandscape = isTablet && !isTabletPortrait;
|
|
75
|
-
|
|
76
|
-
const tabletSidebarWidthValue = configuration?.tablet_landscape_sidebar_width;
|
|
153
|
+
const isTabletLandscape = !isTV() && isTablet && !isTabletPortrait;
|
|
77
154
|
|
|
78
|
-
const tabletWidth = getTabletWidth(
|
|
79
|
-
|
|
80
|
-
const tabletSidebarWidth = getTabletSidebarWidth(
|
|
81
|
-
tabletSidebarWidthValue,
|
|
82
|
-
style
|
|
83
|
-
);
|
|
155
|
+
const tabletWidth = getTabletWidth(configuration, style);
|
|
84
156
|
|
|
85
157
|
const baseDimensions: DimensionsT = React.useMemo(
|
|
86
158
|
() => ({
|
|
@@ -116,17 +188,14 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
116
188
|
[containerDimensions, playerDimensionsHack]
|
|
117
189
|
);
|
|
118
190
|
|
|
119
|
-
const wrapperViewStyle: ViewStyle = {
|
|
120
|
-
backgroundColor:
|
|
121
|
-
isTablet && !fullscreen
|
|
122
|
-
? configuration?.tablet_landscape_player_container_background_color
|
|
123
|
-
: "transparent",
|
|
124
|
-
};
|
|
125
|
-
|
|
126
191
|
return (
|
|
127
192
|
<WrapperView
|
|
128
193
|
edges={getEdges(isTablet, isInlineModal) as readonly Edge[]}
|
|
129
|
-
style={[
|
|
194
|
+
style={[
|
|
195
|
+
safeAreaStyles(configuration, isTablet),
|
|
196
|
+
style,
|
|
197
|
+
playerDimensionsHack,
|
|
198
|
+
]}
|
|
130
199
|
>
|
|
131
200
|
<AnimationComponent
|
|
132
201
|
animationType={ComponentAnimationType.moveUpComponent}
|
|
@@ -161,13 +230,7 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
161
230
|
{isShowPlayerDetails && (
|
|
162
231
|
<AnimationComponent
|
|
163
232
|
animationType={ComponentAnimationType.componentFade}
|
|
164
|
-
style={
|
|
165
|
-
isTabletLandscape
|
|
166
|
-
? {
|
|
167
|
-
width: tabletSidebarWidth,
|
|
168
|
-
}
|
|
169
|
-
: defaultStyles.flex
|
|
170
|
-
}
|
|
233
|
+
style={defaultStyles.flex}
|
|
171
234
|
>
|
|
172
235
|
<PlayerDetails
|
|
173
236
|
configuration={configuration}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { View } from "react-native";
|
|
4
|
+
|
|
4
5
|
import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
5
6
|
|
|
6
7
|
const props = {
|
|
@@ -16,20 +17,13 @@ const props = {
|
|
|
16
17
|
},
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
Platform.OS = "android";
|
|
20
|
-
|
|
21
|
-
jest.mock("react-native/Libraries/Utilities/Platform", () => ({
|
|
22
|
-
OS: "android",
|
|
23
|
-
select: () => null,
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
20
|
const useIsTablet = jest.fn();
|
|
27
21
|
|
|
22
|
+
jest.mock("react-native");
|
|
23
|
+
|
|
28
24
|
jest.mock("react-native-gesture-handler");
|
|
29
25
|
|
|
30
|
-
jest.mock("../PlayerDetails", () => ({
|
|
31
|
-
PlayerDetails: jest.requireActual("react-native").View,
|
|
32
|
-
}));
|
|
26
|
+
jest.mock("../PlayerDetails", () => ({ PlayerDetails: View }));
|
|
33
27
|
|
|
34
28
|
jest.mock(
|
|
35
29
|
"@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext",
|
|
@@ -42,11 +36,14 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/device", () => ({
|
|
|
42
36
|
useIsTablet,
|
|
43
37
|
}));
|
|
44
38
|
|
|
39
|
+
jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
|
|
40
|
+
useTheme: jest.fn(() => ({})),
|
|
41
|
+
}));
|
|
42
|
+
|
|
45
43
|
jest.mock("@applicaster/zapp-react-native-utils/reactUtils", () => ({
|
|
46
|
-
...jest.requireActual<any>("@applicaster/zapp-react-native-utils/reactUtils"),
|
|
47
44
|
isTV: jest.fn(() => false),
|
|
48
45
|
isApplePlatform: jest.fn(() => true),
|
|
49
|
-
platformSelect: jest.fn((props) => props.android
|
|
46
|
+
platformSelect: jest.fn((props) => props.android),
|
|
50
47
|
}));
|
|
51
48
|
|
|
52
49
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
@@ -62,16 +59,14 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
|
62
59
|
})),
|
|
63
60
|
}));
|
|
64
61
|
|
|
62
|
+
jest.mock("../utils", () => ({ playerDimensionsHack: {} }));
|
|
63
|
+
|
|
64
|
+
const { PlayerWrapper } = require("../PlayerWrapper");
|
|
65
|
+
|
|
65
66
|
jest.useFakeTimers();
|
|
66
67
|
const children = jest.fn(() => {});
|
|
67
68
|
|
|
68
69
|
describe("PlayerWrapper", () => {
|
|
69
|
-
let PlayerWrapper;
|
|
70
|
-
|
|
71
|
-
beforeAll(() => {
|
|
72
|
-
PlayerWrapper = require("../PlayerWrapper").PlayerWrapper;
|
|
73
|
-
});
|
|
74
|
-
|
|
75
70
|
it("renders properly", () => {
|
|
76
71
|
useIsTablet.mockReturnValue(false);
|
|
77
72
|
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
isAndroidPlatform,
|
|
5
|
-
platformSelect,
|
|
6
|
-
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
3
|
+
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
7
4
|
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
8
|
-
import {
|
|
9
|
-
|
|
5
|
+
import {
|
|
6
|
+
useNavigation,
|
|
7
|
+
useIsTablet,
|
|
8
|
+
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
10
9
|
import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
|
|
11
|
-
import { StyleSheet, Dimensions, ViewStyle } from "react-native";
|
|
12
|
-
import { DimensionsT } from "./types";
|
|
13
10
|
|
|
14
11
|
export const useConfiguration = () => {
|
|
15
12
|
const {
|
|
@@ -55,85 +52,12 @@ export const useConfiguration = () => {
|
|
|
55
52
|
const fullSize = {
|
|
56
53
|
width: "100%",
|
|
57
54
|
height: "100%",
|
|
58
|
-
}
|
|
55
|
+
};
|
|
59
56
|
|
|
60
|
-
export const playerDimensionsHack
|
|
57
|
+
export const playerDimensionsHack = platformSelect({
|
|
61
58
|
android_tv: fullSize,
|
|
62
59
|
amazon: fullSize,
|
|
63
60
|
lg_tv: fullSize,
|
|
64
61
|
samsung_tv: fullSize,
|
|
65
62
|
default: {},
|
|
66
63
|
});
|
|
67
|
-
|
|
68
|
-
const orientationStyles = StyleSheet.create({
|
|
69
|
-
landscape: { flexDirection: "row" },
|
|
70
|
-
portrait: { flexDirection: "column" },
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
export const directionStyles = (isTabletLandscape: boolean): ViewStyle => {
|
|
74
|
-
if (isTabletLandscape) {
|
|
75
|
-
return orientationStyles.landscape;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return orientationStyles.portrait;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export const getScreenAspectRatio = () => {
|
|
82
|
-
const { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } =
|
|
83
|
-
Dimensions.get("screen");
|
|
84
|
-
|
|
85
|
-
const longEdge = Math.max(SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
86
|
-
const shortEdge = Math.min(SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
87
|
-
|
|
88
|
-
return longEdge / shortEdge;
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export const getEdges = (isTablet: boolean, isInlineModal: boolean) => {
|
|
92
|
-
if (isTablet) {
|
|
93
|
-
return ["top"];
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (!isInlineModal && isAndroidPlatform()) {
|
|
97
|
-
return [];
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return ["top"];
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export const getTabletWidth = (
|
|
104
|
-
tabletSidebarWidth: string | undefined,
|
|
105
|
-
dimensions: DimensionsT
|
|
106
|
-
) => {
|
|
107
|
-
const { width } = dimensions;
|
|
108
|
-
|
|
109
|
-
const sidebarWidthPercentage = Number(tabletSidebarWidth?.replace("%", ""));
|
|
110
|
-
|
|
111
|
-
if (tabletSidebarWidth?.includes("%")) {
|
|
112
|
-
return Number(width) * (1 - sidebarWidthPercentage / 100);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (Number.isNaN(sidebarWidthPercentage)) {
|
|
116
|
-
return Number(width) * 0.65;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return Number(width) - sidebarWidthPercentage;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export const getTabletSidebarWidth = (
|
|
123
|
-
tabletSidebarWidth: string | undefined,
|
|
124
|
-
dimensions: DimensionsT
|
|
125
|
-
) => {
|
|
126
|
-
const { width } = dimensions;
|
|
127
|
-
|
|
128
|
-
const sidebarWidthPercentage = Number(tabletSidebarWidth?.replace("%", ""));
|
|
129
|
-
|
|
130
|
-
if (tabletSidebarWidth?.includes("%")) {
|
|
131
|
-
return Number(width) * (sidebarWidthPercentage / 100);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (Number.isNaN(sidebarWidthPercentage)) {
|
|
135
|
-
return Number(width) * 0.35;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return sidebarWidthPercentage;
|
|
139
|
-
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "12.0.22-alpha.
|
|
3
|
+
"version": "12.0.22-alpha.1975406433",
|
|
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",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"redux-mock-store": "^1.5.3"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@applicaster/applicaster-types": "12.0.22-alpha.
|
|
38
|
-
"@applicaster/zapp-react-native-bridge": "12.0.22-alpha.
|
|
39
|
-
"@applicaster/zapp-react-native-redux": "12.0.22-alpha.
|
|
40
|
-
"@applicaster/zapp-react-native-utils": "12.0.22-alpha.
|
|
37
|
+
"@applicaster/applicaster-types": "12.0.22-alpha.1975406433",
|
|
38
|
+
"@applicaster/zapp-react-native-bridge": "12.0.22-alpha.1975406433",
|
|
39
|
+
"@applicaster/zapp-react-native-redux": "12.0.22-alpha.1975406433",
|
|
40
|
+
"@applicaster/zapp-react-native-utils": "12.0.22-alpha.1975406433",
|
|
41
41
|
"promise": "^8.3.0",
|
|
42
42
|
"react-router-native": "^5.1.2",
|
|
43
43
|
"url": "^0.11.0",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type DimensionsT = {
|
|
2
|
-
width: number | string;
|
|
3
|
-
height: number | string | undefined;
|
|
4
|
-
aspectRatio?: number;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export type Configuration = {
|
|
8
|
-
[key: string]: any;
|
|
9
|
-
tablet_landscape_sidebar_width?: string;
|
|
10
|
-
tablet_landscape_player_container_background_color?: string;
|
|
11
|
-
};
|