@applicaster/zapp-react-native-ui-components 15.1.20-alpha.3704390340 → 15.1.21-alpha.2368211243

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.
@@ -248,14 +248,11 @@ const LiveImageComponent = (props: LiveImageProps) => {
248
248
 
249
249
  const isCurrentlyFocused = useTrackCurrentAutoScrollingElement(componentId);
250
250
 
251
- const rivers = appStore.get("rivers");
252
- const plugins = appStore.get("plugins");
253
-
254
251
  // New object identities here restart PlayerLiveImage's register effect,
255
252
  // which throws away the in-flight player and runs preload hooks again.
256
253
  const playerConfig = React.useMemo(
257
254
  () => getPlayerConfig(player_screen_id, actionIdentifier),
258
- [player_screen_id, actionIdentifier, rivers, plugins]
255
+ [player_screen_id, actionIdentifier]
259
256
  );
260
257
 
261
258
  const { playerPluginId, screenConfig, preloadHooks } = playerConfig ?? {};
@@ -265,6 +262,7 @@ const LiveImageComponent = (props: LiveImageProps) => {
265
262
  [playerPluginId, item?.id]
266
263
  );
267
264
 
265
+ const plugins = appStore.get("plugins");
268
266
  const playerPlugin = findPluginByIdentifier(playerPluginId, plugins);
269
267
 
270
268
  const isShouldRender =
@@ -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
@@ -37,6 +37,7 @@ jest.mock(
37
37
 
38
38
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/device", () => ({
39
39
  useIsTablet: mockUseIsDeviceTablet,
40
+ useOrientation: () => "portrait",
40
41
  }));
41
42
 
42
43
  jest.mock("@applicaster/zapp-react-native-utils/theme", () => ({
@@ -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 { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks";
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
- () => calculateAspectRatio(isInlineModal, pip),
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": "15.1.20-alpha.3704390340",
3
+ "version": "15.1.21-alpha.2368211243",
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.1.20-alpha.3704390340",
32
- "@applicaster/zapp-react-native-bridge": "15.1.20-alpha.3704390340",
33
- "@applicaster/zapp-react-native-redux": "15.1.20-alpha.3704390340",
34
- "@applicaster/zapp-react-native-utils": "15.1.20-alpha.3704390340",
31
+ "@applicaster/applicaster-types": "15.1.21-alpha.2368211243",
32
+ "@applicaster/zapp-react-native-bridge": "15.1.21-alpha.2368211243",
33
+ "@applicaster/zapp-react-native-redux": "15.1.21-alpha.2368211243",
34
+ "@applicaster/zapp-react-native-utils": "15.1.21-alpha.2368211243",
35
35
  "fast-json-stable-stringify": "^2.1.0",
36
36
  "promise": "^8.3.0",
37
37
  "react-native-sortables": "1.7.1",