@applicaster/zapp-react-native-ui-components 16.0.0-rc.116 → 16.0.0-rc.118
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 +4 -1
- package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +1 -0
- package/Components/VideoModal/__tests__/playerWrapperStyle.test.ts +58 -0
- package/Components/VideoModal/__tests__/playerWrapperUtils.test.ts +16 -0
- package/Components/VideoModal/playerWrapperStyle.ts +21 -3
- package/Components/VideoModal/playerWrapperUtils.ts +7 -1
- package/package.json +5 -5
|
@@ -14,6 +14,7 @@ type Props = {
|
|
|
14
14
|
inline?: boolean;
|
|
15
15
|
docked?: boolean;
|
|
16
16
|
pip?: boolean;
|
|
17
|
+
vertical?: boolean;
|
|
17
18
|
isModal?: boolean;
|
|
18
19
|
fullscreen?: boolean;
|
|
19
20
|
isTabletPortrait?: boolean;
|
|
@@ -32,6 +33,7 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
32
33
|
isTabletPortrait,
|
|
33
34
|
configuration,
|
|
34
35
|
pip,
|
|
36
|
+
vertical,
|
|
35
37
|
playerContent,
|
|
36
38
|
} = props;
|
|
37
39
|
|
|
@@ -42,6 +44,7 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
42
44
|
isTabletPortrait,
|
|
43
45
|
configuration,
|
|
44
46
|
pip,
|
|
47
|
+
vertical,
|
|
45
48
|
});
|
|
46
49
|
|
|
47
50
|
const isTablet = useIsTablet();
|
|
@@ -52,7 +55,7 @@ const PlayerWrapperComponent = (props: Props) => {
|
|
|
52
55
|
|
|
53
56
|
return (
|
|
54
57
|
<WrapperView
|
|
55
|
-
edges={getEdges(isTablet, isInlineModal) as readonly Edge[]}
|
|
58
|
+
edges={getEdges(isTablet, isInlineModal, vertical) as readonly Edge[]}
|
|
56
59
|
style={playerDimensionsHack}
|
|
57
60
|
>
|
|
58
61
|
<View
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { renderHook } from "@testing-library/react-native";
|
|
2
|
+
|
|
3
|
+
import { useStyle } from "../playerWrapperStyle";
|
|
4
|
+
import { getScreenAspectRatio } from "../playerWrapperUtils";
|
|
5
|
+
|
|
6
|
+
let mockOrientation = "portrait";
|
|
7
|
+
|
|
8
|
+
jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => ({
|
|
9
|
+
useIsTablet: () => false,
|
|
10
|
+
useOrientation: () => mockOrientation,
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
const getAspectRatio = (props: {
|
|
14
|
+
vertical: boolean;
|
|
15
|
+
inline?: boolean;
|
|
16
|
+
isModal?: boolean;
|
|
17
|
+
}) => {
|
|
18
|
+
const { result } = renderHook(() =>
|
|
19
|
+
useStyle({
|
|
20
|
+
style: {},
|
|
21
|
+
inline: false,
|
|
22
|
+
isModal: true,
|
|
23
|
+
isTabletPortrait: false,
|
|
24
|
+
configuration: {},
|
|
25
|
+
pip: false,
|
|
26
|
+
...props,
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
return result.current.containerDimensions.aspectRatio;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
describe("useStyle aspectRatio", () => {
|
|
34
|
+
const screenRatio = getScreenAspectRatio();
|
|
35
|
+
|
|
36
|
+
it("uses the screen ratio when not vertical", () => {
|
|
37
|
+
mockOrientation = "portrait";
|
|
38
|
+
expect(getAspectRatio({ vertical: false })).toBeCloseTo(screenRatio);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("inverts the screen ratio for vertical fullscreen in portrait", () => {
|
|
42
|
+
mockOrientation = "portrait";
|
|
43
|
+
expect(getAspectRatio({ vertical: true })).toBeCloseTo(1 / screenRatio);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("keeps the screen ratio for vertical fullscreen in landscape", () => {
|
|
47
|
+
mockOrientation = "landscape";
|
|
48
|
+
expect(getAspectRatio({ vertical: true })).toBeCloseTo(screenRatio);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("inverts 16:9 for the vertical inline modal in landscape", () => {
|
|
52
|
+
mockOrientation = "landscape";
|
|
53
|
+
|
|
54
|
+
expect(getAspectRatio({ vertical: true, inline: true })).toBeCloseTo(
|
|
55
|
+
9 / 16
|
|
56
|
+
);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getEdges } from "../playerWrapperUtils";
|
|
2
|
+
|
|
3
|
+
describe("getEdges", () => {
|
|
4
|
+
it("keeps the top edge in fullscreen when not vertical", () => {
|
|
5
|
+
expect(getEdges(false, false)).toEqual(["top"]);
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it("has no edges in vertical fullscreen", () => {
|
|
9
|
+
expect(getEdges(false, false, true)).toEqual([]);
|
|
10
|
+
expect(getEdges(true, false, true)).toEqual([]);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("keeps the top edge for the vertical inline modal", () => {
|
|
14
|
+
expect(getEdges(false, true, true)).toEqual(["top"]);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { StyleSheet, ViewStyle } from "react-native";
|
|
3
3
|
import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
useIsTablet,
|
|
6
|
+
useOrientation,
|
|
7
|
+
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
5
8
|
import { playerDimensionsHack } from "./utils";
|
|
6
9
|
import { getTabletWidth } from "@applicaster/zapp-react-native-utils/playerUtils";
|
|
7
10
|
import {
|
|
@@ -22,8 +25,10 @@ export const useStyle = ({
|
|
|
22
25
|
isTabletPortrait,
|
|
23
26
|
configuration,
|
|
24
27
|
pip,
|
|
28
|
+
vertical,
|
|
25
29
|
}) => {
|
|
26
30
|
const isTablet = useIsTablet();
|
|
31
|
+
const isLandscape = useOrientation() === "landscape";
|
|
27
32
|
|
|
28
33
|
const isInlineModal = inline && isModal;
|
|
29
34
|
|
|
@@ -40,10 +45,23 @@ export const useStyle = ({
|
|
|
40
45
|
);
|
|
41
46
|
|
|
42
47
|
const aspectRatio = React.useMemo(
|
|
43
|
-
() =>
|
|
48
|
+
() => {
|
|
49
|
+
const value = calculateAspectRatio(isInlineModal, pip);
|
|
50
|
+
|
|
51
|
+
if (!vertical) {
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// vertical fullscreen in landscape: the width is the long side, keep the screen ratio so the container matches the screen
|
|
56
|
+
if (isLandscape && !isInlineModal && !pip) {
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return 1 / value;
|
|
61
|
+
},
|
|
44
62
|
// ignoring insets - only initial needed
|
|
45
63
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
|
-
[isInlineModal, pip]
|
|
64
|
+
[isInlineModal, pip, vertical, isLandscape]
|
|
47
65
|
);
|
|
48
66
|
|
|
49
67
|
return React.useMemo(() => {
|
|
@@ -44,8 +44,14 @@ export const getScreenAspectRatio = () => {
|
|
|
44
44
|
|
|
45
45
|
export const getEdges = (
|
|
46
46
|
isTablet: boolean,
|
|
47
|
-
isInlineModal: boolean
|
|
47
|
+
isInlineModal: boolean,
|
|
48
|
+
vertical: boolean = false
|
|
48
49
|
): readonly Edge[] => {
|
|
50
|
+
// vertical fullscreen: the player takes the full screen height, a top inset would push it below the screen
|
|
51
|
+
if (vertical && !isInlineModal) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
|
|
49
55
|
if (isTablet) {
|
|
50
56
|
return ["top"];
|
|
51
57
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-ui-components",
|
|
3
|
-
"version": "16.0.0-rc.
|
|
3
|
+
"version": "16.0.0-rc.118",
|
|
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": "16.0.0-rc.
|
|
32
|
-
"@applicaster/zapp-react-native-bridge": "16.0.0-rc.
|
|
33
|
-
"@applicaster/zapp-react-native-redux": "16.0.0-rc.
|
|
34
|
-
"@applicaster/zapp-react-native-utils": "16.0.0-rc.
|
|
31
|
+
"@applicaster/applicaster-types": "16.0.0-rc.118",
|
|
32
|
+
"@applicaster/zapp-react-native-bridge": "16.0.0-rc.118",
|
|
33
|
+
"@applicaster/zapp-react-native-redux": "16.0.0-rc.118",
|
|
34
|
+
"@applicaster/zapp-react-native-utils": "16.0.0-rc.118",
|
|
35
35
|
"fast-json-stable-stringify": "^2.1.0",
|
|
36
36
|
"promise": "^8.3.0",
|
|
37
37
|
"react-native-sortables": "1.7.1",
|