@applicaster/zapp-react-native-ui-components 12.0.22 → 12.0.23-rc.0
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 +26 -79
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +19 -14
- package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +1 -1
- package/Components/VideoModal/types.ts +11 -0
- package/Components/VideoModal/utils.ts +83 -7
- package/package.json +5 -5
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
Dimensions,
|
|
4
|
-
Platform,
|
|
5
|
-
StyleSheet,
|
|
6
|
-
View,
|
|
7
|
-
ViewStyle,
|
|
8
|
-
} from "react-native";
|
|
2
|
+
import { StyleSheet, View, ViewStyle } from "react-native";
|
|
9
3
|
import { Edge, SafeAreaView } from "react-native-safe-area-context";
|
|
10
4
|
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
11
5
|
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
12
6
|
import { PlayerDetails } from "./PlayerDetails";
|
|
13
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
directionStyles,
|
|
9
|
+
getEdges,
|
|
10
|
+
getScreenAspectRatio,
|
|
11
|
+
getTabletSidebarWidth,
|
|
12
|
+
getTabletWidth,
|
|
13
|
+
playerDimensionsHack,
|
|
14
|
+
} from "./utils";
|
|
14
15
|
import { useDelayedPlayerDetails } from "./hooks";
|
|
15
16
|
|
|
16
17
|
import {
|
|
@@ -19,20 +20,7 @@ import {
|
|
|
19
20
|
AnimationComponent,
|
|
20
21
|
ComponentAnimationType,
|
|
21
22
|
} from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
|
|
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
|
-
};
|
|
23
|
+
import type { DimensionsT, Configuration } from "./types";
|
|
36
24
|
|
|
37
25
|
type Props = {
|
|
38
26
|
entry: ZappEntry;
|
|
@@ -54,60 +42,6 @@ const defaultStyles = StyleSheet.create({
|
|
|
54
42
|
flex: { flex: 1 },
|
|
55
43
|
});
|
|
56
44
|
|
|
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 getEdges = (isTablet: boolean, isInlineModal: boolean) => {
|
|
78
|
-
if (isTablet) {
|
|
79
|
-
return ["top"];
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (!isInlineModal && Platform.OS === "android") {
|
|
83
|
-
return [];
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return ["top"];
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const getTabletWidth = (
|
|
90
|
-
configuration: Configuration,
|
|
91
|
-
dimensions: DimensionsT
|
|
92
|
-
) => {
|
|
93
|
-
const tablet_landscape_sidebar_width =
|
|
94
|
-
configuration?.tablet_landscape_sidebar_width;
|
|
95
|
-
|
|
96
|
-
const { width } = dimensions;
|
|
97
|
-
|
|
98
|
-
const sidebarWidth = Number(tablet_landscape_sidebar_width?.replace("%", ""));
|
|
99
|
-
|
|
100
|
-
if (tablet_landscape_sidebar_width?.includes("%")) {
|
|
101
|
-
return Number(width) * (1 - sidebarWidth / 100);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
if (Number.isNaN(sidebarWidth)) {
|
|
105
|
-
return Number(width) * 0.65;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return Number(width) - sidebarWidth;
|
|
109
|
-
};
|
|
110
|
-
|
|
111
45
|
const PlayerWrapperComponent = (props: Props) => {
|
|
112
46
|
const {
|
|
113
47
|
entry,
|
|
@@ -137,9 +71,16 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
137
71
|
isPip: pip,
|
|
138
72
|
});
|
|
139
73
|
|
|
140
|
-
const isTabletLandscape =
|
|
74
|
+
const isTabletLandscape = isTablet && !isTabletPortrait;
|
|
141
75
|
|
|
142
|
-
const
|
|
76
|
+
const tabletSidebarWidthValue = configuration?.tablet_landscape_sidebar_width;
|
|
77
|
+
|
|
78
|
+
const tabletWidth = getTabletWidth(tabletSidebarWidthValue, style);
|
|
79
|
+
|
|
80
|
+
const tabletSidebarWidth = getTabletSidebarWidth(
|
|
81
|
+
tabletSidebarWidthValue,
|
|
82
|
+
style
|
|
83
|
+
);
|
|
143
84
|
|
|
144
85
|
const baseDimensions: DimensionsT = React.useMemo(
|
|
145
86
|
() => ({
|
|
@@ -220,7 +161,13 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
220
161
|
{isShowPlayerDetails && (
|
|
221
162
|
<AnimationComponent
|
|
222
163
|
animationType={ComponentAnimationType.componentFade}
|
|
223
|
-
style={
|
|
164
|
+
style={
|
|
165
|
+
isTabletLandscape
|
|
166
|
+
? {
|
|
167
|
+
width: tabletSidebarWidth,
|
|
168
|
+
}
|
|
169
|
+
: defaultStyles.flex
|
|
170
|
+
}
|
|
224
171
|
>
|
|
225
172
|
<PlayerDetails
|
|
226
173
|
configuration={configuration}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import { Platform } from "react-native";
|
|
5
4
|
import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
6
5
|
|
|
7
6
|
const props = {
|
|
@@ -17,13 +16,20 @@ const props = {
|
|
|
17
16
|
},
|
|
18
17
|
};
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
Platform.OS = "android";
|
|
21
20
|
|
|
22
|
-
jest.mock("react-native")
|
|
21
|
+
jest.mock("react-native/Libraries/Utilities/Platform", () => ({
|
|
22
|
+
OS: "android",
|
|
23
|
+
select: () => null,
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
const useIsTablet = jest.fn();
|
|
23
27
|
|
|
24
28
|
jest.mock("react-native-gesture-handler");
|
|
25
29
|
|
|
26
|
-
jest.mock("../PlayerDetails", () => ({
|
|
30
|
+
jest.mock("../PlayerDetails", () => ({
|
|
31
|
+
PlayerDetails: jest.requireActual("react-native").View,
|
|
32
|
+
}));
|
|
27
33
|
|
|
28
34
|
jest.mock(
|
|
29
35
|
"@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext",
|
|
@@ -36,14 +42,11 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/device", () => ({
|
|
|
36
42
|
useIsTablet,
|
|
37
43
|
}));
|
|
38
44
|
|
|
39
|
-
jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
|
|
40
|
-
useTheme: jest.fn(() => ({})),
|
|
41
|
-
}));
|
|
42
|
-
|
|
43
45
|
jest.mock("@applicaster/zapp-react-native-utils/reactUtils", () => ({
|
|
46
|
+
...jest.requireActual<any>("@applicaster/zapp-react-native-utils/reactUtils"),
|
|
44
47
|
isTV: jest.fn(() => false),
|
|
45
48
|
isApplePlatform: jest.fn(() => true),
|
|
46
|
-
platformSelect: jest.fn((props) => props.android),
|
|
49
|
+
platformSelect: jest.fn((props) => props.android || props.default),
|
|
47
50
|
}));
|
|
48
51
|
|
|
49
52
|
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
@@ -59,14 +62,16 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
|
59
62
|
})),
|
|
60
63
|
}));
|
|
61
64
|
|
|
62
|
-
jest.mock("../utils", () => ({ playerDimensionsHack: {} }));
|
|
63
|
-
|
|
64
|
-
const { PlayerWrapper } = require("../PlayerWrapper");
|
|
65
|
-
|
|
66
65
|
jest.useFakeTimers();
|
|
67
66
|
const children = jest.fn(() => {});
|
|
68
67
|
|
|
69
68
|
describe("PlayerWrapper", () => {
|
|
69
|
+
let PlayerWrapper;
|
|
70
|
+
|
|
71
|
+
beforeAll(() => {
|
|
72
|
+
PlayerWrapper = require("../PlayerWrapper").PlayerWrapper;
|
|
73
|
+
});
|
|
74
|
+
|
|
70
75
|
it("renders properly", () => {
|
|
71
76
|
useIsTablet.mockReturnValue(false);
|
|
72
77
|
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
};
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
2
|
|
|
3
|
-
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
4
|
-
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
5
3
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from "@applicaster/zapp-react-native-utils/
|
|
4
|
+
isAndroidPlatform,
|
|
5
|
+
platformSelect,
|
|
6
|
+
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
7
|
+
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
8
|
+
import { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks/device";
|
|
9
|
+
import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
|
|
9
10
|
import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
|
|
11
|
+
import { StyleSheet, Dimensions, ViewStyle } from "react-native";
|
|
12
|
+
import { DimensionsT } from "./types";
|
|
10
13
|
|
|
11
14
|
export const useConfiguration = () => {
|
|
12
15
|
const {
|
|
@@ -52,12 +55,85 @@ export const useConfiguration = () => {
|
|
|
52
55
|
const fullSize = {
|
|
53
56
|
width: "100%",
|
|
54
57
|
height: "100%",
|
|
55
|
-
};
|
|
58
|
+
} as const;
|
|
56
59
|
|
|
57
|
-
export const playerDimensionsHack = platformSelect({
|
|
60
|
+
export const playerDimensionsHack: ViewStyle = platformSelect({
|
|
58
61
|
android_tv: fullSize,
|
|
59
62
|
amazon: fullSize,
|
|
60
63
|
lg_tv: fullSize,
|
|
61
64
|
samsung_tv: fullSize,
|
|
62
65
|
default: {},
|
|
63
66
|
});
|
|
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.
|
|
3
|
+
"version": "12.0.23-rc.0",
|
|
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.
|
|
38
|
-
"@applicaster/zapp-react-native-bridge": "12.0.
|
|
39
|
-
"@applicaster/zapp-react-native-redux": "12.0.
|
|
40
|
-
"@applicaster/zapp-react-native-utils": "12.0.
|
|
37
|
+
"@applicaster/applicaster-types": "12.0.23-rc.0",
|
|
38
|
+
"@applicaster/zapp-react-native-bridge": "12.0.23-rc.0",
|
|
39
|
+
"@applicaster/zapp-react-native-redux": "12.0.23-rc.0",
|
|
40
|
+
"@applicaster/zapp-react-native-utils": "12.0.23-rc.0",
|
|
41
41
|
"promise": "^8.3.0",
|
|
42
42
|
"react-router-native": "^5.1.2",
|
|
43
43
|
"url": "^0.11.0",
|