@applicaster/zapp-react-native-ui-components 12.0.0-rc.34 → 12.0.0-rc.36

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.
@@ -145,34 +145,36 @@ const renderApplePlayer = ({
145
145
  }) => {
146
146
  const { title, summary } = item || {};
147
147
 
148
- if (!isApplePlatform()) {
148
+ if (!isApplePlatform() || !player) {
149
+ return null;
150
+ }
151
+
152
+ // TODO: Check if it is not breaking default player logic on tvos
153
+ // Also if needs to add on tvos brightcove player for QB player
154
+ if (player.supportsNativeControls()) {
155
+ return null;
156
+ }
157
+
158
+ if (isAudioContent) {
159
+ return (
160
+ <AudioPlayer
161
+ audio_item={item}
162
+ plugin_configuration={pluginConfiguration}
163
+ />
164
+ );
165
+ }
166
+
167
+ if (!playNextData && player.isPaused() && player.isAd() === false) {
149
168
  return null;
150
169
  }
151
170
 
152
171
  return (
153
- <>
154
- {!playNextData && (
155
- <>
156
- {!isAudioContent &&
157
- !!player?.isPaused() &&
158
- !!player?.isAd() === false && (
159
- <ProgramInfo
160
- title={title}
161
- subtitle={summary}
162
- plugin_configuration={pluginConfiguration}
163
- videoStyle={videoStyle}
164
- />
165
- )}
166
- </>
167
- )}
168
-
169
- {isAudioContent && (
170
- <AudioPlayer
171
- audio_item={item}
172
- plugin_configuration={pluginConfiguration}
173
- />
174
- )}
175
- </>
172
+ <ProgramInfo
173
+ title={title}
174
+ subtitle={summary}
175
+ plugin_configuration={pluginConfiguration}
176
+ videoStyle={videoStyle}
177
+ />
176
178
  );
177
179
  };
178
180
 
@@ -339,6 +341,18 @@ const PlayerContainerComponent = (props: Props) => {
339
341
  }
340
342
  }, [item?.id, item?.extensions?.resumeTime, player]);
341
343
 
344
+ const onVideoFullscreenPlayerWillPresent = React.useCallback(() => {
345
+ playerManager.invokeHandler("toggleFullscreen", {
346
+ fullscreen: true,
347
+ });
348
+ }, []);
349
+
350
+ const onVideoFullscreenPlayerWillDismiss = React.useCallback(() => {
351
+ playerManager.invokeHandler("toggleFullscreen", {
352
+ fullscreen: false,
353
+ });
354
+ }, []);
355
+
342
356
  // Util methods
343
357
  const toggleFullscreen = (event) => {
344
358
  const { fullscreen = false } = event || {};
@@ -381,17 +395,27 @@ const PlayerContainerComponent = (props: Props) => {
381
395
  id: playerContainerId,
382
396
  listener: {
383
397
  onVideoEnd,
384
- onError: onError,
385
- onLoad: onLoad,
398
+ onError,
399
+ onLoad,
386
400
  onPlayerClose: close,
387
401
  onPlayerDetached: close,
402
+ onVideoFullscreenPlayerWillDismiss,
403
+ onVideoFullscreenPlayerWillPresent,
388
404
  },
389
405
  });
390
406
 
391
407
  return () => {
392
408
  player.removeListener(playerContainerId);
393
409
  };
394
- }, [player, onVideoEnd]);
410
+ }, [
411
+ player,
412
+ onVideoEnd,
413
+ onError,
414
+ onLoad,
415
+ close,
416
+ onVideoFullscreenPlayerWillDismiss,
417
+ onVideoFullscreenPlayerWillPresent,
418
+ ]);
395
419
 
396
420
  useEffect(() => {
397
421
  // TODO: We should not use playerManager here to connect buttons to player container
@@ -621,7 +645,7 @@ const PlayerContainerComponent = (props: Props) => {
621
645
  }}
622
646
  focused={isInlineTV ? true : undefined}
623
647
  autoplay={true}
624
- controls={isAppleTV() && !isInlineTV}
648
+ controls={false}
625
649
  disableCastAction={disableCastAction}
626
650
  docked={navigator.isVideoModalDocked()}
627
651
  entry={item}
@@ -83,6 +83,7 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
83
83
  useNavigation: jest.fn(() => ({ currentRoute: "/river/A1234" })),
84
84
  useRoute: jest.fn(() => ({ pathname: "/river/A1234", screenData })),
85
85
  useProfilerLogging: jest.fn(),
86
+ useIsScreenActive: jest.fn().mockReturnValue(true),
86
87
  }));
87
88
 
88
89
  jest.mock("@applicaster/zapp-react-native-utils/reactHooks/screen", () => ({
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { View } from "react-native";
3
- import { create, act } from "react-test-renderer";
3
+ import { act, create } from "react-test-renderer";
4
4
 
5
5
  const Mocked_RouteManager = jest.fn((props) => (
6
6
  <View testID="routeManager" {...props} />
@@ -69,12 +69,16 @@ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
69
69
  isNavBarVisible: mockIsNavBarVisible,
70
70
  useRoute: jest.fn(() => ({
71
71
  pathname: "/river/testId",
72
+ screenData: { id: "testId" },
72
73
  })),
73
74
  useNavigation: jest.fn(() => ({
74
75
  canGoBack: () => false,
75
76
  currentRoute: "/river/testId",
77
+ activeRiver: { id: "testId" },
78
+ screenData: { id: "testId" },
76
79
  data: { screen: { id: "testId" } },
77
80
  })),
81
+ useIsScreenActive: jest.fn().mockReturnValue(true),
78
82
  }));
79
83
 
80
84
  jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
@@ -19,7 +19,11 @@ exports[`<Screen Component /> when the navbar should be hidden renders correctly
19
19
  <View>
20
20
  <View
21
21
  pathname="/river/testId"
22
- screenData={Object {}}
22
+ screenData={
23
+ Object {
24
+ "id": "testId",
25
+ }
26
+ }
23
27
  testID="routeManager"
24
28
  />
25
29
  </View>
@@ -45,7 +49,11 @@ exports[`<Screen Component /> when the navbar should show renders correctly 1`]
45
49
  <View>
46
50
  <View
47
51
  pathname="/river/testId"
48
- screenData={Object {}}
52
+ screenData={
53
+ Object {
54
+ "id": "testId",
55
+ }
56
+ }
49
57
  testID="routeManager"
50
58
  />
51
59
  </View>
@@ -23,6 +23,17 @@ import { RouteManager } from "../RouteManager";
23
23
  import { useScreenConfiguration } from "../River/useScreenConfiguration";
24
24
  import { useScreenOrientationHandler } from "./orientationHandler";
25
25
 
26
+ const getScreenId = (
27
+ screenData: LegacyNavigationScreenData,
28
+ fallbackRiver: ZappRiver
29
+ ) => {
30
+ return screenData?.targetScreen
31
+ ? screenData?.targetScreen?.id ?? fallbackRiver.id
32
+ : "screen_id" in screenData
33
+ ? screenData.screen_id
34
+ : fallbackRiver.id;
35
+ };
36
+
26
37
  function colorIsNotTransparent(color) {
27
38
  const layers = R.compose(
28
39
  R.map(R.trim),
@@ -41,17 +52,11 @@ function isValidColor(string) {
41
52
  }
42
53
 
43
54
  type Props = {
44
- pathname: string;
45
- screenData: Record<string, any>;
46
55
  setToggleMenu: () => void;
47
56
  setCloseMenu: () => void;
48
57
  };
49
58
 
50
- export function Screen({
51
- setToggleMenu,
52
- setCloseMenu,
53
- screenData: _screenData,
54
- }: Props) {
59
+ export function Screen({ setToggleMenu, setCloseMenu }: Props) {
55
60
  const theme = useTheme<BaseThemePropertiesMobile>();
56
61
  const navigation = useNavigation();
57
62
  const { plugins } = usePickFromState(["plugins"]);
@@ -68,10 +73,7 @@ export function Screen({
68
73
  const routeData = useRoute();
69
74
 
70
75
  const currentRiver = useScreenData(
71
- (routeData.screenData as ZappRiver)?.targetScreen
72
- ? (routeData.screenData as ZappRiver)?.targetScreen?.id ??
73
- navigation.activeRiver.id
74
- : (routeData.screenData as ZappRiver)?.screen_id
76
+ getScreenId(routeData.screenData, navigation.activeRiver)
75
77
  );
76
78
 
77
79
  const { title } = useNavbarState();
@@ -137,7 +139,7 @@ export function Screen({
137
139
 
138
140
  <OfflineFallbackScreen screenData={screenData}>
139
141
  {/* @TODO RouteManager doesn't use props, can they be removed ? */}
140
- <RouteManager pathname={pathname} screenData={_screenData} />
142
+ <RouteManager pathname={pathname} screenData={screenData} />
141
143
  </OfflineFallbackScreen>
142
144
  </View>
143
145
  </ScreenContextProvider>
@@ -4,6 +4,7 @@ import { render } from "@testing-library/react-native";
4
4
  import * as PlayerFactory from "@applicaster/zapp-react-native-utils/appUtils/playerManager/playerFactory";
5
5
  import { Player } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/player";
6
6
  import { ThemeContext } from "@applicaster/zapp-react-native-utils/theme";
7
+ import * as navigationHooks from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
7
8
 
8
9
  import { PlayerLiveImage } from "../PlayerLiveImageComponent";
9
10
 
@@ -18,6 +19,8 @@ jest.mock(
18
19
  })
19
20
  );
20
21
 
22
+ jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation");
23
+
21
24
  const Wrapper = ({ children }: { children: React.ReactChildren }) => (
22
25
  <ThemeContext.Provider
23
26
  value={{ themes: { myTheme: {} }, selectedThemeId: "myTheme" }}
@@ -46,6 +49,8 @@ describe("PlayerLiveImageComponent", () => {
46
49
  controller: new Player({}),
47
50
  Component: () => null,
48
51
  }));
52
+
53
+ jest.spyOn(navigationHooks, "useIsScreenActive").mockReturnValue(true);
49
54
  });
50
55
 
51
56
  it("should render correctly with default props", () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "12.0.0-rc.34",
3
+ "version": "12.0.0-rc.36",
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.0-rc.34",
38
- "@applicaster/zapp-react-native-bridge": "12.0.0-rc.34",
39
- "@applicaster/zapp-react-native-redux": "12.0.0-rc.34",
40
- "@applicaster/zapp-react-native-utils": "12.0.0-rc.34",
37
+ "@applicaster/applicaster-types": "12.0.0-rc.36",
38
+ "@applicaster/zapp-react-native-bridge": "12.0.0-rc.36",
39
+ "@applicaster/zapp-react-native-redux": "12.0.0-rc.36",
40
+ "@applicaster/zapp-react-native-utils": "12.0.0-rc.36",
41
41
  "promise": "^8.3.0",
42
42
  "react-router-native": "^5.1.2",
43
43
  "url": "^0.11.0",