@applicaster/zapp-react-native-ui-components 12.0.22-alpha.1628418248 → 12.0.22-alpha.2253301448

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.
@@ -86,7 +86,6 @@ export function CellWithFocusable(props: Props) {
86
86
  shouldUsePreferredFocus
87
87
  onFocus={onGroupFocus}
88
88
  onBlur={onGroupBlur}
89
- skipFocusManagerRegistration={skipFocusManagerRegistration}
90
89
  >
91
90
  <CellRenderer
92
91
  testID={"cell-with-focusable-cell-renderer"}
@@ -1,17 +1,16 @@
1
1
  import * as React from "react";
2
- import { StyleSheet, View, ViewStyle } from "react-native";
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
- import type { DimensionsT, Configuration } from "./types";
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,60 @@ 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 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
+
45
111
  const PlayerWrapperComponent = (props: Props) => {
46
112
  const {
47
113
  entry,
@@ -71,16 +137,9 @@ const PlayerWrapperComponent = (props: Props) => {
71
137
  isPip: pip,
72
138
  });
73
139
 
74
- const isTabletLandscape = isTablet && !isTabletPortrait;
140
+ const isTabletLandscape = !isTV() && isTablet && !isTabletPortrait;
75
141
 
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
- );
142
+ const tabletWidth = getTabletWidth(configuration, style);
84
143
 
85
144
  const baseDimensions: DimensionsT = React.useMemo(
86
145
  () => ({
@@ -161,13 +220,7 @@ const PlayerWrapperComponent = (props: Props) => {
161
220
  {isShowPlayerDetails && (
162
221
  <AnimationComponent
163
222
  animationType={ComponentAnimationType.componentFade}
164
- style={
165
- isTabletLandscape
166
- ? {
167
- width: tabletSidebarWidth,
168
- }
169
- : defaultStyles.flex
170
- }
223
+ style={defaultStyles.flex}
171
224
  >
172
225
  <PlayerDetails
173
226
  configuration={configuration}
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
 
3
- import { Platform } from "react-native";
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 || props.default),
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
 
@@ -262,7 +262,7 @@ exports[`PlayerWrapper renders properly 1`] = `
262
262
  "bottom": "off",
263
263
  "left": "off",
264
264
  "right": "off",
265
- "top": "off",
265
+ "top": "additive",
266
266
  }
267
267
  }
268
268
  style={
@@ -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 { useIsTablet } from "@applicaster/zapp-react-native-utils/reactHooks/device";
9
- import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation";
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
- } as const;
55
+ };
59
56
 
60
- export const playerDimensionsHack: ViewStyle = platformSelect({
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.1628418248",
3
+ "version": "12.0.22-alpha.2253301448",
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.1628418248",
38
- "@applicaster/zapp-react-native-bridge": "12.0.22-alpha.1628418248",
39
- "@applicaster/zapp-react-native-redux": "12.0.22-alpha.1628418248",
40
- "@applicaster/zapp-react-native-utils": "12.0.22-alpha.1628418248",
37
+ "@applicaster/applicaster-types": "12.0.22-alpha.2253301448",
38
+ "@applicaster/zapp-react-native-bridge": "12.0.22-alpha.2253301448",
39
+ "@applicaster/zapp-react-native-redux": "12.0.22-alpha.2253301448",
40
+ "@applicaster/zapp-react-native-utils": "12.0.22-alpha.2253301448",
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
- };