@applicaster/zapp-react-native-ui-components 16.0.0-rc.1 → 16.0.0-rc.10

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.
@@ -0,0 +1,42 @@
1
+ import React from "react";
2
+ import { View, ViewStyle } from "react-native";
3
+
4
+ import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
5
+ import {
6
+ selectRemoteConfigurations,
7
+ useAppSelector,
8
+ } from "@applicaster/zapp-react-native-redux";
9
+
10
+ import { getBackgroundImageUrl } from "../Layout/utils";
11
+
12
+ const baseBackgroundStyles = (imageUrl, backgroundColor) =>
13
+ ({
14
+ position: "absolute",
15
+ left: 0,
16
+ top: 0,
17
+ right: 0,
18
+ bottom: 0,
19
+ zIndex: -1,
20
+ backgroundSize: "cover",
21
+ background: imageUrl
22
+ ? `url(${imageUrl}) no-repeat top center ${backgroundColor}`
23
+ : backgroundColor,
24
+ }) as ViewStyle;
25
+
26
+ export const BackgroundImage = ({ children }: React.PropsWithChildren) => {
27
+ const theme = useTheme();
28
+
29
+ const remoteConfigurations = useAppSelector(selectRemoteConfigurations);
30
+
31
+ const backgroundColor = theme.app_background_color;
32
+ const backgroundImageUrl = getBackgroundImageUrl(remoteConfigurations);
33
+
34
+ return (
35
+ <View
36
+ id="background"
37
+ style={baseBackgroundStyles(backgroundImageUrl, backgroundColor)}
38
+ >
39
+ {children}
40
+ </View>
41
+ );
42
+ };
@@ -0,0 +1,28 @@
1
+ import * as React from "react";
2
+ import {
3
+ View,
4
+ StyleSheet,
5
+ ImageURISource,
6
+ ImageBackground,
7
+ } from "react-native";
8
+
9
+ import { ASSETS } from "@applicaster/zapp-react-native-ui-components/Helpers";
10
+
11
+ const imageSource: ImageURISource = {
12
+ uri: ASSETS.APP_BACKGROUND_IMAGE,
13
+ };
14
+
15
+ const styles = StyleSheet.create({
16
+ container: { flex: 1 },
17
+ backgroundImage: { width: "100%", height: "100%" },
18
+ });
19
+
20
+ export function BackgroundImage({ children }: React.PropsWithChildren) {
21
+ return (
22
+ <View style={styles.container}>
23
+ <ImageBackground style={styles.backgroundImage} source={imageSource}>
24
+ {children}
25
+ </ImageBackground>
26
+ </View>
27
+ );
28
+ }
@@ -0,0 +1,24 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet, ImageURISource } from "react-native";
3
+
4
+ import { QBImage as Image } from "@applicaster/zapp-react-native-ui-components/Components/Image";
5
+ import { ASSETS } from "@applicaster/zapp-react-native-ui-components/Helpers";
6
+
7
+ const imageSource: ImageURISource = {
8
+ uri: ASSETS.APP_BACKGROUND_IMAGE,
9
+ };
10
+
11
+ const styles = StyleSheet.create({
12
+ container: { flex: 1 },
13
+ backgroundImage: { width: "100%", height: "100%" },
14
+ });
15
+
16
+ export function BackgroundImage({ children }: React.PropsWithChildren) {
17
+ return (
18
+ <View style={styles.container}>
19
+ <Image style={styles.backgroundImage} source={imageSource}>
20
+ {children}
21
+ </Image>
22
+ </View>
23
+ );
24
+ }
@@ -0,0 +1 @@
1
+ export { BackgroundImage } from "./BackgroundImage";
@@ -129,6 +129,11 @@ export const ScreenContainer = React.memo(function ScreenContainer({
129
129
  []
130
130
  );
131
131
 
132
+ // We need to render menu first and then proceed with screen content,
133
+ // otherwise screen will stay black until everything is loaded and screen
134
+ // rendering put huge load the CPU pushing rendering even further.
135
+ // With this approach, menu will be rendered immediately and screen content
136
+ // will be rendered after paint, which makes it more responsive and prevents black screen.
132
137
  const [navBarReady, setNavBarReady] = React.useState(false);
133
138
 
134
139
  const navBarContainer = (
@@ -2,7 +2,6 @@
2
2
 
3
3
  exports[`Layout TV renders 1`] = `
4
4
  <View
5
- backgroundColor="#000000"
6
5
  testID="background-component"
7
6
  >
8
7
  <View
@@ -1,6 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { useAppSelector } from "@applicaster/zapp-react-native-redux/hooks";
3
3
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
4
+ import { selectAppReady } from "@applicaster/zapp-react-native-redux";
4
5
 
5
6
  import { LayoutContainer } from "./LayoutContainer";
6
7
  import { ScreenContainer } from "./ScreenContainer";
@@ -9,8 +10,6 @@ import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
9
10
  import { PathnameContext } from "../../../Contexts/PathnameContext";
10
11
  import { ScreenDataContext } from "../../../Contexts/ScreenDataContext";
11
12
  import { ScreenContextProvider } from "../../../Contexts/ScreenContext";
12
- import { LayoutBackground } from "./LayoutBackground";
13
- import { selectAppReady } from "@applicaster/zapp-react-native-redux";
14
13
 
15
14
  type Components = {
16
15
  NavBar: React.ComponentType<any>;
@@ -39,7 +38,7 @@ const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
39
38
  return (
40
39
  <LayoutContainer>
41
40
  <ScreenLayoutContextProvider>
42
- <LayoutBackground Background={Components.Background}>
41
+ <Components.Background>
43
42
  <ScreenDataContext.Provider value={navigator.data}>
44
43
  <PathnameContext.Provider value={navigator.currentRoute}>
45
44
  <ScreenContextProvider pathname={navigator.currentRoute}>
@@ -52,7 +51,7 @@ const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
52
51
  </ScreenContextProvider>
53
52
  </PathnameContext.Provider>
54
53
  </ScreenDataContext.Provider>
55
- </LayoutBackground>
54
+ </Components.Background>
56
55
  </ScreenLayoutContextProvider>
57
56
  </LayoutContainer>
58
57
  );
@@ -4,7 +4,6 @@ import { useAppSelector } from "@applicaster/zapp-react-native-redux/hooks";
4
4
 
5
5
  import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
6
6
  import { StackNavigator } from "../../Navigator";
7
- import { LayoutBackground } from "./LayoutBackground";
8
7
  import { selectAppReady } from "@applicaster/zapp-react-native-redux";
9
8
 
10
9
  type Components = {
@@ -25,9 +24,9 @@ const Layout = ({ Components }: Props) => {
25
24
 
26
25
  return (
27
26
  <ScreenLayoutContextProvider>
28
- <LayoutBackground Background={Components.Background}>
27
+ <Components.Background>
29
28
  <StackNavigator Components={Components} />
30
- </LayoutBackground>
29
+ </Components.Background>
31
30
  </ScreenLayoutContextProvider>
32
31
  );
33
32
  };
@@ -37,13 +37,16 @@ function getAssetValue(asset, flavour, fallbackAsset = null) {
37
37
  return null;
38
38
  }
39
39
 
40
- if (typeof asset === "string") return asset;
40
+ if (typeof asset === "string") return fallbackAsset || asset;
41
41
 
42
42
  if (Array.isArray(asset)) {
43
43
  const flavourIndex = Number(flavour.replace("flavour_", ""));
44
- if (flavour && flavourIndex > -1) return asset[flavourIndex - 1];
45
44
 
46
- return asset[0];
45
+ if (flavour && flavourIndex > -1) {
46
+ return fallbackAsset || asset[flavourIndex - 1];
47
+ }
48
+
49
+ return fallbackAsset || asset[0];
47
50
  }
48
51
 
49
52
  return asset.src || fallbackAsset;
@@ -109,13 +112,21 @@ export const ActionButton = React.memo(function ActionButtonComponent(
109
112
  <Image
110
113
  fadeDuration={0}
111
114
  style={asset?.style || props?.style}
112
- uri={getAssetValue(actionState.asset, flavour, asset?.src)}
115
+ uri={getAssetValue(
116
+ actionState.asset,
117
+ flavour,
118
+ actionState.state === 1 ? asset?.src.active : asset?.src.inactive
119
+ )}
113
120
  {...asset?.props}
114
121
  />
115
122
  ) : (
116
123
  <AssetComponent
117
124
  flavour={flavour}
118
- asset={getAssetValue(asset, flavour)}
125
+ asset={getAssetValue(
126
+ asset,
127
+ flavour,
128
+ actionState.state === 1 ? asset?.src.active : asset?.src.inactive
129
+ )}
119
130
  cellUUID={cellUUID}
120
131
  {...(props?.extraProps ?? {})}
121
132
  />
@@ -8,7 +8,7 @@ export function ButtonContainerView({
8
8
  children,
9
9
  }: ContainerProps) {
10
10
  return (
11
- <View style={style}>
11
+ <View style={style} pointerEvents="box-none">
12
12
  <View style={contentStyle}>{children}</View>
13
13
  </View>
14
14
  );
@@ -0,0 +1,60 @@
1
+ import { renderHook, act } from "@testing-library/react-native";
2
+
3
+ import { useAfterPaint } from "../useAfterPaint";
4
+
5
+ describe("useAfterPaint", () => {
6
+ let frameCallbacks: FrameRequestCallback[];
7
+ let originalRaf: typeof requestAnimationFrame;
8
+ let originalCancelRaf: typeof cancelAnimationFrame;
9
+
10
+ const flushFrame = () => {
11
+ const callbacks = frameCallbacks;
12
+ frameCallbacks = [];
13
+
14
+ act(() => {
15
+ callbacks.forEach((cb) => cb(0));
16
+ });
17
+ };
18
+
19
+ beforeEach(() => {
20
+ frameCallbacks = [];
21
+ originalRaf = global.requestAnimationFrame;
22
+ originalCancelRaf = global.cancelAnimationFrame;
23
+
24
+ global.requestAnimationFrame = jest.fn((cb: FrameRequestCallback) => {
25
+ frameCallbacks.push(cb);
26
+
27
+ return frameCallbacks.length;
28
+ }) as unknown as typeof requestAnimationFrame;
29
+
30
+ global.cancelAnimationFrame = jest.fn();
31
+ });
32
+
33
+ afterEach(() => {
34
+ global.requestAnimationFrame = originalRaf;
35
+ global.cancelAnimationFrame = originalCancelRaf;
36
+ });
37
+
38
+ it("returns false on the initial render", () => {
39
+ const { result } = renderHook(() => useAfterPaint());
40
+
41
+ expect(result.current).toBe(false);
42
+ });
43
+
44
+ it("stays false after only one animation frame (before paint completes)", () => {
45
+ const { result } = renderHook(() => useAfterPaint());
46
+
47
+ flushFrame();
48
+
49
+ expect(result.current).toBe(false);
50
+ });
51
+
52
+ it("returns true after two animation frames (a real post-paint boundary)", () => {
53
+ const { result } = renderHook(() => useAfterPaint());
54
+
55
+ flushFrame();
56
+ flushFrame();
57
+
58
+ expect(result.current).toBe(true);
59
+ });
60
+ });
@@ -1 +1,3 @@
1
1
  export { useInitialFocus } from "./useInitialFocus";
2
+
3
+ export { useAfterPaint } from "./useAfterPaint";
@@ -0,0 +1,23 @@
1
+ import * as React from "react";
2
+
3
+ export const useAfterPaint = (): boolean => {
4
+ const [painted, setPainted] = React.useState(false);
5
+
6
+ React.useEffect(() => {
7
+ let secondFrame: number | undefined;
8
+
9
+ const firstFrame = requestAnimationFrame(() => {
10
+ secondFrame = requestAnimationFrame(() => setPainted(true));
11
+ });
12
+
13
+ return () => {
14
+ cancelAnimationFrame(firstFrame);
15
+
16
+ if (secondFrame !== undefined) {
17
+ cancelAnimationFrame(secondFrame);
18
+ }
19
+ };
20
+ }, []);
21
+
22
+ return painted;
23
+ };
@@ -21,7 +21,7 @@ import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/he
21
21
 
22
22
  import { NavBarContainer } from "../../Layout/TV/NavBarContainer";
23
23
  import { ScreenResolver } from "../../ScreenResolver";
24
- import { useInitialFocus } from "./hooks";
24
+ import { useInitialFocus, useAfterPaint } from "./hooks";
25
25
  import { isPlayerPlugin } from "@applicaster/zapp-react-native-utils/pluginUtils";
26
26
  import { focusManager } from "@applicaster/zapp-react-native-utils/appUtils";
27
27
  import { FreezeWithCallback } from "../../FreezeWithCallback";
@@ -157,6 +157,13 @@ export const Screen = ({ route, Components }: Props) => {
157
157
 
158
158
  const isScreenActive = useIsScreenActive();
159
159
 
160
+ // We need to render menu first and then proceed with screen content,
161
+ // otherwise screen will stay black until everything is loaded and screen
162
+ // rendering put huge load the CPU pushing rendering even further.
163
+ // With this approach, menu will be rendered immediately and screen content
164
+ // will be rendered after paint, which makes it more responsive and prevents black screen.
165
+ const isContentReady = useAfterPaint();
166
+
160
167
  return (
161
168
  <FreezeWithCallback freeze={!isScreenActive} onRelease={onRelease}>
162
169
  <View style={[styles.container, { backgroundColor }]}>
@@ -167,12 +174,14 @@ export const Screen = ({ route, Components }: Props) => {
167
174
  navigationProps={navigationProps}
168
175
  />
169
176
  </NavBarContainer>
170
- <ScreenResolver
171
- screenType={screenType}
172
- screenId={screenId}
173
- screenData={screenData}
174
- groupId={route}
175
- />
177
+ {isContentReady ? (
178
+ <ScreenResolver
179
+ screenType={screenType}
180
+ screenId={screenId}
181
+ screenData={screenData}
182
+ groupId={route}
183
+ />
184
+ ) : null}
176
185
  </View>
177
186
  </FreezeWithCallback>
178
187
  );
@@ -0,0 +1,34 @@
1
+ import * as React from "react";
2
+ import { Animated, StyleSheet } from "react-native";
3
+
4
+ import { BackgroundImage } from "@applicaster/zapp-react-native-ui-components/Components/BackgroundImage";
5
+
6
+ const styles = StyleSheet.create({
7
+ container: {
8
+ ...StyleSheet.absoluteFillObject,
9
+ position: "absolute",
10
+ },
11
+ });
12
+
13
+ export const Overlay = ({
14
+ opacity,
15
+ backgroundColor,
16
+ }: {
17
+ opacity: Animated.Value;
18
+ backgroundColor: string;
19
+ }) => {
20
+ return (
21
+ <Animated.View
22
+ style={[
23
+ styles.container,
24
+ {
25
+ opacity,
26
+ backgroundColor,
27
+ },
28
+ ]}
29
+ testID="animated-component"
30
+ >
31
+ <BackgroundImage />
32
+ </Animated.View>
33
+ );
34
+ };
@@ -0,0 +1,88 @@
1
+ import React from "react";
2
+ import { Animated } from "react-native";
3
+ import { render } from "@testing-library/react-native";
4
+
5
+ jest.mock(
6
+ "@applicaster/zapp-react-native-ui-components/Components/BackgroundImage",
7
+ () => {
8
+ const { Text } = require("react-native");
9
+
10
+ return {
11
+ BackgroundImage: () => (
12
+ <Text testID="background-image">BackgroundImage</Text>
13
+ ),
14
+ };
15
+ }
16
+ );
17
+
18
+ import { Overlay } from "../Overlay";
19
+
20
+ const flattenStyle = (style: unknown): Record<string, unknown> => {
21
+ if (!style) {
22
+ return {};
23
+ }
24
+
25
+ if (Array.isArray(style)) {
26
+ return style.reduce<Record<string, unknown>>(
27
+ (acc, item) => ({ ...acc, ...flattenStyle(item) }),
28
+ {}
29
+ );
30
+ }
31
+
32
+ if (typeof style === "object") {
33
+ return style as Record<string, unknown>;
34
+ }
35
+
36
+ return {};
37
+ };
38
+
39
+ describe("Overlay", () => {
40
+ it("renders the animated overlay container", () => {
41
+ const opacity = new Animated.Value(1);
42
+
43
+ const { getByTestId } = render(
44
+ <Overlay opacity={opacity} backgroundColor="#000000" />
45
+ );
46
+
47
+ expect(getByTestId("animated-component")).toBeTruthy();
48
+ });
49
+
50
+ it("applies opacity and backgroundColor to the overlay", () => {
51
+ const opacity = new Animated.Value(0.5);
52
+
53
+ const { getByTestId } = render(
54
+ <Overlay opacity={opacity} backgroundColor="#ff0000" />
55
+ );
56
+
57
+ const style = flattenStyle(getByTestId("animated-component").props.style);
58
+
59
+ expect(style.backgroundColor).toBe("#ff0000");
60
+ expect(style.opacity).toBe(0.5);
61
+ });
62
+
63
+ it("positions the overlay with absolute fill layout", () => {
64
+ const opacity = new Animated.Value(1);
65
+
66
+ const { getByTestId } = render(
67
+ <Overlay opacity={opacity} backgroundColor="#000000" />
68
+ );
69
+
70
+ const style = flattenStyle(getByTestId("animated-component").props.style);
71
+
72
+ expect(style.position).toBe("absolute");
73
+ expect(style.top).toBe(0);
74
+ expect(style.left).toBe(0);
75
+ expect(style.right).toBe(0);
76
+ expect(style.bottom).toBe(0);
77
+ });
78
+
79
+ it("renders BackgroundImage inside the overlay", () => {
80
+ const opacity = new Animated.Value(1);
81
+
82
+ const { getByTestId } = render(
83
+ <Overlay opacity={opacity} backgroundColor="#000000" />
84
+ );
85
+
86
+ expect(getByTestId("background-image")).toBeTruthy();
87
+ });
88
+ });
@@ -1,8 +1,10 @@
1
1
  import * as React from "react";
2
- import { Animated, StyleSheet } from "react-native";
2
+ import { Animated } from "react-native";
3
+
3
4
  import { isFirstComponentScreenPicker } from "@applicaster/zapp-react-native-utils/componentsUtils";
4
5
  import { useRefWithInitialValue } from "@applicaster/zapp-react-native-utils/reactHooks/state/useRefWithInitialValue";
5
6
  import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
7
+ import { Overlay } from "./Overlay";
6
8
 
7
9
  import { ScreenRevealManager } from "./ScreenRevealManager";
8
10
  import {
@@ -10,13 +12,6 @@ import {
10
12
  emitScreenRevealManagerIsNotReadyToShow,
11
13
  } from "./utils";
12
14
 
13
- const styles = StyleSheet.create({
14
- container: {
15
- ...StyleSheet.absoluteFillObject,
16
- position: "absolute",
17
- },
18
- });
19
-
20
15
  export const TIMEOUT = 300; // 300 ms
21
16
 
22
17
  const HIDDEN = 0; // opacity = 0
@@ -93,17 +88,11 @@ export const withScreenRevealManager = (Component) => {
93
88
  onLoadFailedFromScreenRevealManager={managerRef.current.onLoadFailed}
94
89
  />
95
90
  {isShowOverlay ? (
96
- <Animated.View
97
- style={[
98
- styles.container,
99
- {
100
- opacity: opacityRef.current,
101
- // TODO: we should support background image as well, but for now we will use background color from theme
102
- backgroundColor:
103
- props.backgroundColor ?? theme.app_background_color,
104
- },
105
- ]}
106
- testID="animated-component"
91
+ <Overlay
92
+ opacity={opacityRef.current}
93
+ backgroundColor={
94
+ props.backgroundColor ?? theme.app_background_color
95
+ }
107
96
  />
108
97
  ) : null}
109
98
  </>
@@ -48,7 +48,6 @@ type Position = {
48
48
  type PlayerFactoryConfig = {
49
49
  player: any; // React ref for native view
50
50
  playerId: string;
51
- muted: boolean;
52
51
  playerPluginId: string;
53
52
  screenConfig: Record<string, any>;
54
53
  entry: ZappEntry; // original entry, used as fallback if no hooks
@@ -296,7 +295,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
296
295
 
297
296
  setUserCellPlayerMutedPreference(true);
298
297
 
299
- this.items.forEach((liveImage) => liveImage.player?.mute());
298
+ this.items.forEach((liveImage) => liveImage.mute());
300
299
  };
301
300
 
302
301
  public unmuteAll = () => {
@@ -304,7 +303,7 @@ export class LiveImageManager implements PlayerLifecycleListener {
304
303
 
305
304
  setUserCellPlayerMutedPreference(false);
306
305
 
307
- this.items.forEach((liveImage) => liveImage.player?.unmute());
306
+ this.items.forEach((liveImage) => liveImage.unmute());
308
307
  };
309
308
 
310
309
  public onViewPositionChanged = (item: LiveImage) => {
@@ -574,6 +573,20 @@ export class LiveImage implements QuickBrickPlayer.SharedPlayerCallBacks {
574
573
  left: 0,
575
574
  };
576
575
 
576
+ // Keeps muted state in sync: updates the initial value for deferred
577
+ // player creation and forwards to the player if it already exists.
578
+ public initiallyMuted: boolean = true;
579
+
580
+ mute = () => {
581
+ this.initiallyMuted = true;
582
+ this.player?.mute();
583
+ };
584
+
585
+ unmute = () => {
586
+ this.initiallyMuted = false;
587
+ this.player?.unmute();
588
+ };
589
+
577
590
  positionToString() {
578
591
  if (!this.position) {
579
592
  return "position not set";
@@ -611,48 +624,7 @@ export class LiveImage implements QuickBrickPlayer.SharedPlayerCallBacks {
611
624
  return this._preparePromise;
612
625
  }
613
626
 
614
- this._preparePromise = (async (): Promise<boolean> => {
615
- // 1. Run hooks if configured
616
- let entry = this.factoryConfig.entry;
617
-
618
- if (this.preloadHooks?.length) {
619
- const result = await executePreloadHooks({
620
- preloadHooks: this.preloadHooks,
621
- entry,
622
- });
623
-
624
- if (result) {
625
- this.processedEntry = result;
626
- entry = result;
627
- } else {
628
- return false;
629
- }
630
- }
631
-
632
- // 2. Create the player with the correct entry
633
- const factoryItem = playerFactory({
634
- player: this.factoryConfig.player,
635
- playerId: this.factoryConfig.playerId,
636
- autoplay: false,
637
- entry,
638
- muted: this.factoryConfig.muted,
639
- playerPluginId: this.factoryConfig.playerPluginId,
640
- screenConfig: this.factoryConfig.screenConfig,
641
- playerRole: PlayerRole.Cell,
642
- });
643
-
644
- if (!factoryItem) {
645
- throw new Error("Player factory returned null");
646
- }
647
-
648
- this.player = factoryItem.controller;
649
- this.component = factoryItem.Component;
650
-
651
- // 3. Register callbacks — player now exists
652
- this.player.addListener({ id: "live-image", listener: this });
653
-
654
- return true;
655
- })()
627
+ this._preparePromise = this.createPreparedPlayer()
656
628
  .then((result) => {
657
629
  this._preparePromise = null;
658
630
 
@@ -672,6 +644,45 @@ export class LiveImage implements QuickBrickPlayer.SharedPlayerCallBacks {
672
644
  return this._preparePromise;
673
645
  }
674
646
 
647
+ private async createPreparedPlayer(): Promise<boolean> {
648
+ let entry = this.factoryConfig.entry;
649
+
650
+ if (this.preloadHooks?.length) {
651
+ const result = await executePreloadHooks({
652
+ preloadHooks: this.preloadHooks,
653
+ entry,
654
+ });
655
+
656
+ if (!result) return false;
657
+
658
+ this.processedEntry = result;
659
+ entry = result;
660
+ }
661
+
662
+ const factoryItem = await playerFactory({
663
+ player: this.factoryConfig.player,
664
+ playerId: this.factoryConfig.playerId,
665
+ autoplay: false,
666
+ entry,
667
+ muted: this.initiallyMuted,
668
+ playerPluginId: this.factoryConfig.playerPluginId,
669
+ screenConfig: this.factoryConfig.screenConfig,
670
+ playerRole: PlayerRole.Cell,
671
+ });
672
+
673
+ if (!factoryItem) {
674
+ throw new Error(
675
+ `Player factory returned null (playerId: ${this.factoryConfig.playerId}, playerPluginId: ${this.factoryConfig.playerPluginId})`
676
+ );
677
+ }
678
+
679
+ this.player = factoryItem.controller;
680
+ this.component = factoryItem.Component;
681
+ this.player.addListener({ id: "live-image", listener: this });
682
+
683
+ return true;
684
+ }
685
+
675
686
  public getPlayer = (): Player | null => {
676
687
  return this.player;
677
688
  };
@@ -126,14 +126,16 @@ const PlayerLiveImageComponent = (props: Props) => {
126
126
  factoryConfig: {
127
127
  player: ref,
128
128
  playerId,
129
- muted,
130
129
  playerPluginId: playerPluginId,
131
130
  screenConfig: screenConfig,
132
131
  entry: item,
133
132
  },
134
133
  tag: item.title?.toString(),
135
134
  });
136
- }, [playerId, preloadHooks, muted, playerPluginId, screenConfig, item]);
135
+ }, [playerId, preloadHooks, playerPluginId, screenConfig, item]);
136
+
137
+ // Keep the muted state in sync with user preference and player state
138
+ liveImageItem.initiallyMuted = muted;
137
139
 
138
140
  React.useEffect(() => {
139
141
  liveImageItem.setMode = setModeDebounced;
package/Helpers/index.js CHANGED
@@ -1,5 +1,11 @@
1
+ import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
2
+
1
3
  export const ASSETS = {
2
- APP_BACKGROUND_IMAGE: "app_background_image",
4
+ APP_BACKGROUND_IMAGE: platformSelect({
5
+ tvos: "app_background_image",
6
+ android_tv: "tv_app_background",
7
+ amazon: "tv_app_background",
8
+ }),
3
9
  };
4
10
 
5
11
  export const ANALYTICS_CORE_EVENTS = {
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.1",
3
+ "version": "16.0.0-rc.10",
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.1",
32
- "@applicaster/zapp-react-native-bridge": "16.0.0-rc.1",
33
- "@applicaster/zapp-react-native-redux": "16.0.0-rc.1",
34
- "@applicaster/zapp-react-native-utils": "16.0.0-rc.1",
31
+ "@applicaster/applicaster-types": "16.0.0-rc.10",
32
+ "@applicaster/zapp-react-native-bridge": "16.0.0-rc.10",
33
+ "@applicaster/zapp-react-native-redux": "16.0.0-rc.10",
34
+ "@applicaster/zapp-react-native-utils": "16.0.0-rc.10",
35
35
  "fast-json-stable-stringify": "^2.1.0",
36
36
  "promise": "^8.3.0",
37
37
  "url": "^0.11.0",
@@ -1,31 +0,0 @@
1
- import React from "react";
2
- import { getBackgroundImageUrl } from "../utils";
3
- import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
4
- import {
5
- selectRemoteConfigurations,
6
- useAppSelector,
7
- } from "@applicaster/zapp-react-native-redux";
8
-
9
- export const LayoutBackground = ({
10
- Background,
11
- children,
12
- }: {
13
- Background: React.ComponentType<any>;
14
- children: React.ReactNode;
15
- }) => {
16
- const theme = useTheme();
17
-
18
- const remoteConfigurations = useAppSelector(selectRemoteConfigurations);
19
-
20
- const backgroundColor = theme.app_background_color;
21
- const backgroundImageUrl = getBackgroundImageUrl(remoteConfigurations);
22
-
23
- return (
24
- <Background
25
- backgroundColor={backgroundColor}
26
- backgroundImageUrl={backgroundImageUrl}
27
- >
28
- {children}
29
- </Background>
30
- );
31
- };