@applicaster/zapp-react-native-ui-components 16.0.0-rc.5 → 16.0.0-rc.50
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.
- package/Components/BackgroundImage/BackgroundImage.android.tv.tsx +28 -0
- package/Components/BackgroundImage/BackgroundImage.ios.tv.tsx +24 -0
- package/Components/BackgroundImage/BackgroundImage.tsx +42 -0
- package/Components/BackgroundImage/index.ts +1 -0
- package/Components/CellRendererResolver/index.ts +2 -2
- package/Components/ComponentResolver/__tests__/componentResolver.test.js +1 -1
- package/Components/FocusableGroup/FocusableTvOS.tsx +11 -7
- package/Components/GeneralContentScreen/GeneralContentScreenHookAdapter.tsx +39 -0
- package/Components/GeneralContentScreen/__tests__/GeneralContentScreenHookAdapter.test.tsx +64 -0
- package/Components/GeneralContentScreen/__tests__/HookContentFocusGroup.web.test.tsx +91 -0
- package/Components/GeneralContentScreen/hookAdapter/__tests__/networkService.test.ts +74 -0
- package/Components/GeneralContentScreen/hookAdapter/__tests__/runInBackground.test.ts +139 -0
- package/Components/GeneralContentScreen/hookAdapter/__tests__/validationHelper.test.ts +124 -0
- package/Components/GeneralContentScreen/hookAdapter/logger.ts +6 -0
- package/Components/GeneralContentScreen/hookAdapter/networkService.ts +53 -0
- package/Components/GeneralContentScreen/hookAdapter/runInBackground.ts +48 -0
- package/Components/GeneralContentScreen/hookAdapter/validationHelper.ts +72 -0
- package/Components/GeneralContentScreen/hookFocus/index.tsx +13 -0
- package/Components/GeneralContentScreen/hookFocus/index.web.tsx +69 -0
- package/Components/GeneralContentScreen/index.ts +2 -0
- package/Components/Layout/FullWidthRow.tsx +38 -0
- package/Components/Layout/TV/ScreenContainer.tsx +5 -0
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +0 -1
- package/Components/Layout/TV/index.tsx +3 -4
- package/Components/Layout/TV/index.web.tsx +2 -3
- package/Components/MasterCell/DefaultComponents/ActionButton.tsx +16 -5
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/__tests__/placement.test.ts +47 -21
- package/Components/MasterCell/DefaultComponents/ActionButtonsCore/placement.ts +34 -6
- package/Components/MasterCell/DefaultComponents/ButtonContainerView/index.tsx +1 -1
- package/Components/MasterCell/DefaultComponents/Image/hoc/utils/__tests__/withDimensions.test.ts +420 -125
- package/Components/MasterCell/DefaultComponents/Image/hoc/utils/index.ts +114 -19
- package/Components/MasterCell/DefaultComponents/Image/hoc/withDimensions.tsx +19 -8
- package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -3
- package/Components/MasterCell/DefaultComponents/PressableView.tsx +29 -9
- package/Components/MasterCell/DefaultComponents/Text/hooks/useText.ts +4 -0
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/ActionButton.tsx +154 -100
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/AssetComponent.tsx +15 -4
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Button.ts +56 -22
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/Spacer.ts +6 -4
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/TextLabelsContainer.ts +3 -1
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/PressableView.test.tsx +32 -21
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/__tests__/index.test.ts +15 -4
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/index.ts +23 -16
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/__tests__/insertButtons.test.ts +8 -3
- package/Components/MasterCell/DefaultComponents/mobile/MobileActionButtons/utils/index.ts +2 -2
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/__tests__/insertButtonsBetweenLabels.test.ts +45 -13
- package/Components/MasterCell/DefaultComponents/tv/TvActionButtons/utils/index.ts +2 -2
- package/Components/MasterCell/contexts/PressedStateContext.ts +3 -0
- package/Components/MasterCell/dataAdapter.ts +15 -5
- package/Components/MasterCell/hooks/index.ts +2 -0
- package/Components/MasterCell/hooks/usePressedState.ts +4 -0
- package/Components/MasterCell/index.tsx +30 -5
- package/Components/MasterCell/utils/__tests__/resolveColor.test.js +169 -132
- package/Components/MasterCell/utils/__tests__/resolveColorForProp.test.js +92 -0
- package/Components/MasterCell/utils/index.ts +85 -46
- package/Components/ModalComponent/AudioPlayer/Components/Action.tsx +332 -0
- package/Components/ModalComponent/AudioPlayer/Components/Button.tsx +402 -0
- package/Components/ModalComponent/AudioPlayer/Components/Header.tsx +811 -0
- package/Components/ModalComponent/AudioPlayer/Components/Input.tsx +671 -0
- package/Components/ModalComponent/AudioPlayer/Components/Item.tsx +878 -0
- package/Components/ModalComponent/AudioPlayer/Components/index.ts +9 -0
- package/Components/ModalComponent/BottomSheetDragArea.tsx +33 -0
- package/Components/ModalComponent/BottomSheetModalContent.tsx +49 -26
- package/Components/ModalComponent/__tests__/BottomSheetDragArea.test.tsx +74 -0
- package/Components/OfflineHandler/__tests__/__snapshots__/index.test.tsx.snap +4 -85
- package/Components/OfflineHandler/__tests__/index.test.tsx +78 -18
- package/Components/OfflineHandler/hooks.ts +123 -0
- package/Components/OfflineHandler/index.tsx +51 -73
- package/Components/OfflineHandler/utils/index.ts +1 -13
- package/Components/PlayerContainer/PlayerContainer.tsx +23 -13
- package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +285 -0
- package/Components/PreloaderWrapper/index.tsx +1 -1
- package/Components/River/ComponentsMap/ComponentsMap.tsx +2 -2
- package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +3 -15
- package/Components/Screen/TV/hooks/__tests__/useAfterPaint.test.ts +60 -0
- package/Components/Screen/TV/hooks/index.ts +2 -0
- package/Components/Screen/TV/hooks/useAfterPaint.ts +23 -0
- package/Components/Screen/TV/index.web.tsx +16 -7
- package/Components/Screen/index.tsx +8 -4
- package/Components/ScreenFeedLoader/ScreenFeedLoader.tsx +5 -3
- package/Components/ScreenResolverFeedProvider/ScreenResolverFeedProvider.tsx +1 -1
- package/Components/ScreenRevealManager/Overlay.tsx +34 -0
- package/Components/ScreenRevealManager/__tests__/Overlay.test.tsx +88 -0
- package/Components/ScreenRevealManager/withScreenRevealManager.tsx +8 -19
- package/Components/TopCutoffOverlay/index.tsx +2 -2
- package/Components/Transitioner/Transitioner.tsx +28 -17
- package/Components/VideoLive/LiveImageManager.ts +56 -45
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +4 -2
- package/Components/VideoModal/utils.ts +6 -1
- package/Components/ZappFrameworkComponents/BarView/BarView.tsx +12 -5
- package/Components/ZappFrameworkComponents/BarView/__tests__/BarView.test.tsx +2 -2
- package/Contexts/CachedDimensionsContext/__tests__/index.test.ts +154 -0
- package/Contexts/CachedDimensionsContext/index.ts +17 -2
- package/Helpers/ComponentCellSelectionHelper/index.js +0 -6
- package/Helpers/index.js +7 -40
- package/package.json +5 -5
- package/Components/Layout/TV/LayoutBackground.tsx +0 -31
- package/Components/OfflineHandler/NotificationView/NotificationView.lg.tsx +0 -112
- package/Components/OfflineHandler/NotificationView/NotificationView.samsung.tsx +0 -107
- package/Components/OfflineHandler/NotificationView/NotificationView.tsx +0 -153
- package/Components/OfflineHandler/NotificationView/__tests__/index.test.tsx +0 -66
- package/Components/OfflineHandler/NotificationView/utils.ts +0 -34
- package/Components/Screen/utils.ts +0 -16
- package/Helpers/Analytics/index.js +0 -95
- /package/Components/MasterCell/DefaultComponents/ButtonContainerView/{index.tv.android.tsx → index.android.tv.tsx} +0 -0
|
@@ -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
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
);
|
|
@@ -18,10 +18,13 @@ import {
|
|
|
18
18
|
useScreenData,
|
|
19
19
|
} from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
20
20
|
import { getNavigationPluginModule } from "@applicaster/zapp-react-native-app/App/Layout/layoutHelpers";
|
|
21
|
+
import {
|
|
22
|
+
isValidColor,
|
|
23
|
+
isTransparentColor,
|
|
24
|
+
} from "@applicaster/zapp-react-native-utils/colorUtils";
|
|
21
25
|
|
|
22
26
|
import { RouteManager } from "../RouteManager";
|
|
23
27
|
import { useScreenConfiguration } from "../River/useScreenConfiguration";
|
|
24
|
-
import { isValidColor } from "./utils";
|
|
25
28
|
import { useWaitForValidOrientation } from "./hooks";
|
|
26
29
|
|
|
27
30
|
const screenStyles = {
|
|
@@ -82,9 +85,10 @@ export function Screen(_props: Props) {
|
|
|
82
85
|
const style = React.useMemo(
|
|
83
86
|
() => ({
|
|
84
87
|
...screenStyles,
|
|
85
|
-
backgroundColor:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
backgroundColor:
|
|
89
|
+
isValidColor(backgroundColor) && !isTransparentColor(backgroundColor)
|
|
90
|
+
? backgroundColor
|
|
91
|
+
: theme.app_background_color,
|
|
88
92
|
}),
|
|
89
93
|
[theme.app_background_color, backgroundColor]
|
|
90
94
|
);
|
|
@@ -8,9 +8,11 @@ import { componentsLogger } from "../../Helpers/logger";
|
|
|
8
8
|
const logger = componentsLogger.addSubsystem("ScreenFeedLoader");
|
|
9
9
|
|
|
10
10
|
/** Loads and provides `feedData` and store to */
|
|
11
|
-
export const ScreenFeedLoader: React.FC<
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
export const ScreenFeedLoader: React.FC<{
|
|
12
|
+
id: string;
|
|
13
|
+
feedData: any;
|
|
14
|
+
children: React.ReactElement | null;
|
|
15
|
+
}> = ({ id, feedData, children }) => {
|
|
14
16
|
const { source: feedUrl, mapping } = feedData;
|
|
15
17
|
|
|
16
18
|
const { data, loading, error } = useFeedLoader({
|
|
@@ -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
|
|
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
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
</>
|
|
@@ -7,7 +7,7 @@ import { useMarginTop } from "./hooks";
|
|
|
7
7
|
|
|
8
8
|
interface IProps {
|
|
9
9
|
targetScreenId?: string;
|
|
10
|
-
children
|
|
10
|
+
children: React.ReactElement | null;
|
|
11
11
|
applyTopCutoff?: boolean;
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -21,7 +21,7 @@ export const TopCutoffOverlay: React.FC<IProps> = ({
|
|
|
21
21
|
targetScreenId,
|
|
22
22
|
children,
|
|
23
23
|
applyTopCutoff = true,
|
|
24
|
-
}
|
|
24
|
+
}) => {
|
|
25
25
|
const cutoffHeight = useMarginTop(targetScreenId);
|
|
26
26
|
|
|
27
27
|
const { backgroundColor: screenBackgroundColor } =
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
import { append, compose, identity,
|
|
3
|
+
import { append, compose, identity, tail, take, update } from "ramda";
|
|
4
4
|
|
|
5
5
|
import { AnimationManager } from "./AnimationManager";
|
|
6
6
|
import { Scene } from "./Scene";
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
shouldSkipAnimationForPreviousWebViewScene,
|
|
11
11
|
} from "./utils";
|
|
12
12
|
import { v4 as uuid_v4 } from "uuid";
|
|
13
|
+
import { isScreenActiveForRoute } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useIsScreenActive";
|
|
13
14
|
|
|
14
15
|
export const NAV_ACTION_PUSH = "PUSH";
|
|
15
16
|
|
|
@@ -50,16 +51,16 @@ function scenesForBackTransition(props: SceneProps, { scenes }) {
|
|
|
50
51
|
: [prepareScene(props.children), scenes[0]];
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
const isModalClosed = (navigator) => {
|
|
54
|
-
return !!isNil(navigator?.modalData);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
54
|
type Props = {
|
|
58
55
|
transitionConfig: any;
|
|
59
56
|
children: React.ReactNode;
|
|
60
57
|
navigator: {
|
|
61
58
|
previousAction: string;
|
|
62
59
|
currentRoute: string;
|
|
60
|
+
videoModalState?: {
|
|
61
|
+
visible?: boolean;
|
|
62
|
+
mode?: string;
|
|
63
|
+
};
|
|
63
64
|
screenData: {
|
|
64
65
|
[key: string]: any;
|
|
65
66
|
};
|
|
@@ -283,8 +284,10 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
|
|
|
283
284
|
// so only a single scene should be rendered,
|
|
284
285
|
// instead of dangerous nulls or duplicates.
|
|
285
286
|
renderSingleScene({ scenes, to }) {
|
|
286
|
-
const { contentStyle } = this.props;
|
|
287
|
-
|
|
287
|
+
const { contentStyle, navigator, children } = this.props;
|
|
288
|
+
|
|
289
|
+
const { currentRoute, videoModalState } = navigator;
|
|
290
|
+
const screenData = children.props.screenData;
|
|
288
291
|
const pathname = scenes[to.index].key;
|
|
289
292
|
|
|
290
293
|
return (
|
|
@@ -293,7 +296,11 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
|
|
|
293
296
|
<Scene
|
|
294
297
|
{...{ style: to?.style || {} }}
|
|
295
298
|
pathname={pathname}
|
|
296
|
-
isActive={
|
|
299
|
+
isActive={isScreenActiveForRoute(
|
|
300
|
+
pathname,
|
|
301
|
+
currentRoute,
|
|
302
|
+
videoModalState
|
|
303
|
+
)}
|
|
297
304
|
contentStyle={contentStyle}
|
|
298
305
|
key={scenes[to.index].key}
|
|
299
306
|
screenUniqueId={scenes[to.index].screenUniqueId}
|
|
@@ -311,16 +318,19 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
|
|
|
311
318
|
// Looks redundant, but when written like this
|
|
312
319
|
// we do not need to pass or generate keys.
|
|
313
320
|
renderScenes({ scenes, from, to }) {
|
|
314
|
-
const { contentStyle } = this.props;
|
|
321
|
+
const { contentStyle, navigator } = this.props;
|
|
322
|
+
|
|
323
|
+
const { currentRoute, videoModalState } = navigator;
|
|
315
324
|
|
|
316
325
|
const fromScene = scenes[from.index] && (
|
|
317
326
|
<Scene
|
|
318
327
|
key={scenes[from.index].key}
|
|
319
328
|
pathname={scenes[from.index].key}
|
|
320
|
-
isActive={
|
|
321
|
-
scenes[from.index].key
|
|
322
|
-
|
|
323
|
-
|
|
329
|
+
isActive={isScreenActiveForRoute(
|
|
330
|
+
scenes[from.index].key,
|
|
331
|
+
currentRoute,
|
|
332
|
+
videoModalState
|
|
333
|
+
)}
|
|
324
334
|
style={from.style}
|
|
325
335
|
pointerEvents="none"
|
|
326
336
|
overlayStyle={from.overlayStyle}
|
|
@@ -336,10 +346,11 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
|
|
|
336
346
|
const toScene = scenes[to.index] && (
|
|
337
347
|
<Scene
|
|
338
348
|
pathname={scenes[to.index].key}
|
|
339
|
-
isActive={
|
|
340
|
-
scenes[to.index].key
|
|
341
|
-
|
|
342
|
-
|
|
349
|
+
isActive={isScreenActiveForRoute(
|
|
350
|
+
scenes[to.index].key,
|
|
351
|
+
currentRoute,
|
|
352
|
+
videoModalState
|
|
353
|
+
)}
|
|
343
354
|
key={scenes[to.index].key}
|
|
344
355
|
style={to.style}
|
|
345
356
|
overlayStyle={to.overlayStyle}
|
|
@@ -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.
|
|
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.
|
|
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 = (
|
|
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,
|
|
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;
|
|
@@ -10,6 +10,7 @@ import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
|
|
|
10
10
|
import { create } from "zustand";
|
|
11
11
|
import { useRivers } from "@applicaster/zapp-react-native-utils/reactHooks";
|
|
12
12
|
import { selectPluginConfigurationsByPluginId } from "@applicaster/zapp-react-native-redux";
|
|
13
|
+
import { usePlayer } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayer";
|
|
13
14
|
|
|
14
15
|
export const useConfiguration = () => {
|
|
15
16
|
const {
|
|
@@ -18,6 +19,7 @@ export const useConfiguration = () => {
|
|
|
18
19
|
|
|
19
20
|
const rivers = useRivers();
|
|
20
21
|
const contentTypes = useContentTypes();
|
|
22
|
+
const player = usePlayer();
|
|
21
23
|
|
|
22
24
|
const targetScreenId = contentTypes?.[item?.type?.value]?.screen_id;
|
|
23
25
|
const targetScreenConfiguration = rivers?.[targetScreenId];
|
|
@@ -26,7 +28,10 @@ export const useConfiguration = () => {
|
|
|
26
28
|
selectPluginConfigurationsByPluginId(state, targetScreenConfiguration?.type)
|
|
27
29
|
);
|
|
28
30
|
|
|
29
|
-
const playerPluginConfig =
|
|
31
|
+
const playerPluginConfig =
|
|
32
|
+
player?.getPluginConfiguration() ??
|
|
33
|
+
playerManager.getInstanceController()?.getPluginConfiguration() ??
|
|
34
|
+
{};
|
|
30
35
|
|
|
31
36
|
const config = mergeRight(playerPluginConfig, {
|
|
32
37
|
...configuration_json,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { StyleSheet,
|
|
3
|
-
|
|
2
|
+
import { StyleSheet, SafeAreaView as RNSafeAreaView } from "react-native";
|
|
3
|
+
import { SafeAreaView } from "react-native-safe-area-context";
|
|
4
4
|
import { useIsRTL } from "@applicaster/zapp-react-native-utils/localizationUtils";
|
|
5
5
|
import CloseButton from "./Buttons/CloseButton";
|
|
6
6
|
import BackButton from "./Buttons/BackButton";
|
|
7
7
|
import BarTitle from "./BarTitle";
|
|
8
|
+
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
8
9
|
|
|
9
10
|
type Props = {
|
|
10
11
|
screenStyles: {
|
|
@@ -23,6 +24,11 @@ const defaultState: NavBarState = {
|
|
|
23
24
|
title: "",
|
|
24
25
|
};
|
|
25
26
|
|
|
27
|
+
const SafeAreaViewPlatform = platformSelect({
|
|
28
|
+
ios: RNSafeAreaView,
|
|
29
|
+
android: SafeAreaView,
|
|
30
|
+
});
|
|
31
|
+
|
|
26
32
|
const BarView = ({ screenStyles, barState = defaultState }: Props) => {
|
|
27
33
|
const isRTL = useIsRTL();
|
|
28
34
|
|
|
@@ -44,14 +50,15 @@ const BarView = ({ screenStyles, barState = defaultState }: Props) => {
|
|
|
44
50
|
);
|
|
45
51
|
|
|
46
52
|
return (
|
|
47
|
-
<
|
|
53
|
+
<SafeAreaViewPlatform
|
|
54
|
+
edges={["top", "left", "right"]}
|
|
48
55
|
style={[style.view, isRTL ? style.rtlStyle : {}]}
|
|
49
|
-
testID="BarView-
|
|
56
|
+
testID="BarView-safeAreaView"
|
|
50
57
|
>
|
|
51
58
|
{backButton}
|
|
52
59
|
<BarTitle title={barState.title} screenStyles={screenStyles} />
|
|
53
60
|
{closeButton}
|
|
54
|
-
</
|
|
61
|
+
</SafeAreaViewPlatform>
|
|
55
62
|
);
|
|
56
63
|
};
|
|
57
64
|
|
|
@@ -46,7 +46,7 @@ describe("BarView", () => {
|
|
|
46
46
|
<BarView screenStyles={screenStyles} barState={barState} />
|
|
47
47
|
);
|
|
48
48
|
|
|
49
|
-
expect(getByTestId("BarView-
|
|
49
|
+
expect(getByTestId("BarView-safeAreaView").props.style).toContainEqual({
|
|
50
50
|
transform: [{ scaleX: -1 }],
|
|
51
51
|
});
|
|
52
52
|
});
|
|
@@ -58,7 +58,7 @@ describe("BarView", () => {
|
|
|
58
58
|
<BarView screenStyles={screenStyles} barState={barState} />
|
|
59
59
|
);
|
|
60
60
|
|
|
61
|
-
expect(getByTestId("BarView-
|
|
61
|
+
expect(getByTestId("BarView-safeAreaView").props.style).not.toContainEqual({
|
|
62
62
|
transform: [{ scaleX: -1 }],
|
|
63
63
|
});
|
|
64
64
|
});
|