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

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,6 +86,7 @@ export function CellWithFocusable(props: Props) {
86
86
  shouldUsePreferredFocus
87
87
  onFocus={onGroupFocus}
88
88
  onBlur={onGroupBlur}
89
+ skipFocusManagerRegistration={skipFocusManagerRegistration}
89
90
  >
90
91
  <CellRenderer
91
92
  testID={"cell-with-focusable-cell-renderer"}
@@ -584,7 +584,7 @@ const PlayerContainerComponent = (props: Props) => {
584
584
  );
585
585
  }
586
586
 
587
- if (screen_background_color) {
587
+ if (screen_background_color && mode !== VideoModalMode.FULLSCREEN) {
588
588
  updatedStyles.playerScreen.backgroundColor = screen_background_color;
589
589
  }
590
590
 
@@ -602,6 +602,7 @@ const PlayerContainerComponent = (props: Props) => {
602
602
  tv_component_container_height,
603
603
  screen_background_color,
604
604
  isInlineTV,
605
+ mode,
605
606
  ]);
606
607
 
607
608
  const applePlayerProps = {
@@ -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 { playerDimensionsHack } from "./utils";
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,74 +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 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
-
125
45
  const PlayerWrapperComponent = (props: Props) => {
126
46
  const {
127
47
  entry,
@@ -133,6 +53,7 @@ const PlayerWrapperComponent = (props: Props) => {
133
53
  children,
134
54
  isTabletPortrait,
135
55
  configuration,
56
+ fullscreen,
136
57
  pip,
137
58
  } = props;
138
59
 
@@ -150,9 +71,16 @@ const PlayerWrapperComponent = (props: Props) => {
150
71
  isPip: pip,
151
72
  });
152
73
 
153
- const isTabletLandscape = !isTV() && isTablet && !isTabletPortrait;
74
+ const isTabletLandscape = isTablet && !isTabletPortrait;
75
+
76
+ const tabletSidebarWidthValue = configuration?.tablet_landscape_sidebar_width;
154
77
 
155
- const tabletWidth = getTabletWidth(configuration, style);
78
+ const tabletWidth = getTabletWidth(tabletSidebarWidthValue, style);
79
+
80
+ const tabletSidebarWidth = getTabletSidebarWidth(
81
+ tabletSidebarWidthValue,
82
+ style
83
+ );
156
84
 
157
85
  const baseDimensions: DimensionsT = React.useMemo(
158
86
  () => ({
@@ -188,14 +116,17 @@ const PlayerWrapperComponent = (props: Props) => {
188
116
  [containerDimensions, playerDimensionsHack]
189
117
  );
190
118
 
119
+ const wrapperViewStyle: ViewStyle = {
120
+ backgroundColor:
121
+ isTablet && !fullscreen
122
+ ? configuration?.tablet_landscape_player_container_background_color
123
+ : "transparent",
124
+ };
125
+
191
126
  return (
192
127
  <WrapperView
193
128
  edges={getEdges(isTablet, isInlineModal) as readonly Edge[]}
194
- style={[
195
- safeAreaStyles(configuration, isTablet),
196
- style,
197
- playerDimensionsHack,
198
- ]}
129
+ style={[wrapperViewStyle, style, playerDimensionsHack]}
199
130
  >
200
131
  <AnimationComponent
201
132
  animationType={ComponentAnimationType.moveUpComponent}
@@ -230,7 +161,13 @@ const PlayerWrapperComponent = (props: Props) => {
230
161
  {isShowPlayerDetails && (
231
162
  <AnimationComponent
232
163
  animationType={ComponentAnimationType.componentFade}
233
- style={defaultStyles.flex}
164
+ style={
165
+ isTabletLandscape
166
+ ? {
167
+ width: tabletSidebarWidth,
168
+ }
169
+ : defaultStyles.flex
170
+ }
234
171
  >
235
172
  <PlayerDetails
236
173
  configuration={configuration}
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
 
3
- import { View } from "react-native";
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
- const useIsTablet = jest.fn();
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", () => ({ PlayerDetails: View }));
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
 
@@ -262,7 +262,7 @@ exports[`PlayerWrapper renders properly 1`] = `
262
262
  "bottom": "off",
263
263
  "left": "off",
264
264
  "right": "off",
265
- "top": "additive",
265
+ "top": "off",
266
266
  }
267
267
  }
268
268
  style={
@@ -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
- useNavigation,
7
- useIsTablet,
8
- } from "@applicaster/zapp-react-native-utils/reactHooks";
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.21",
3
+ "version": "12.0.22-alpha.1628418248",
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.21",
38
- "@applicaster/zapp-react-native-bridge": "12.0.21",
39
- "@applicaster/zapp-react-native-redux": "12.0.21",
40
- "@applicaster/zapp-react-native-utils": "12.0.21",
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",
41
41
  "promise": "^8.3.0",
42
42
  "react-router-native": "^5.1.2",
43
43
  "url": "^0.11.0",