@applicaster/zapp-react-native-ui-components 15.1.0-rc.12 → 15.1.0-rc.13
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.tv.android.tsx +28 -0
- package/Components/BackgroundImage/BackgroundImage.tv.ios.tsx +24 -0
- package/Components/BackgroundImage/BackgroundImage.tv.web.tsx +42 -0
- package/Components/BackgroundImage/index.ts +8 -0
- package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +0 -1
- package/Components/Layout/TV/index.tsx +2 -3
- package/Components/Layout/TV/index.web.tsx +2 -3
- package/Components/PlayerContainer/PlayerContainer.tsx +2 -0
- package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +286 -0
- package/Components/ScreenRevealManager/Overlay.tsx +34 -0
- package/Components/ScreenRevealManager/__tests__/Overlay.test.tsx +88 -0
- package/Components/ScreenRevealManager/withScreenRevealManager.tsx +8 -19
- package/Helpers/index.js +7 -1
- package/package.json +5 -5
- package/Components/Layout/TV/LayoutBackground.tsx +0 -28
|
@@ -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,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,8 @@
|
|
|
1
|
+
import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
2
|
+
|
|
3
|
+
export const BackgroundImage = platformSelect({
|
|
4
|
+
tvos: require("./BackgroundImage.tv.ios").BackgroundImage,
|
|
5
|
+
android_tv: require("./BackgroundImage.tv.android").BackgroundImage,
|
|
6
|
+
amazon: require("./BackgroundImage.tv.android").BackgroundImage,
|
|
7
|
+
web: require("./BackgroundImage.tv.web").BackgroundImage,
|
|
8
|
+
});
|
|
@@ -9,7 +9,6 @@ import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
|
|
|
9
9
|
import { PathnameContext } from "../../../Contexts/PathnameContext";
|
|
10
10
|
import { ScreenDataContext } from "../../../Contexts/ScreenDataContext";
|
|
11
11
|
import { ScreenContextProvider } from "../../../Contexts/ScreenContext";
|
|
12
|
-
import { LayoutBackground } from "./LayoutBackground";
|
|
13
12
|
|
|
14
13
|
type Components = {
|
|
15
14
|
NavBar: React.ComponentType<any>;
|
|
@@ -40,7 +39,7 @@ const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
|
|
|
40
39
|
return (
|
|
41
40
|
<LayoutContainer>
|
|
42
41
|
<ScreenLayoutContextProvider>
|
|
43
|
-
<
|
|
42
|
+
<Components.Background>
|
|
44
43
|
<ScreenDataContext.Provider value={navigator.data}>
|
|
45
44
|
<PathnameContext.Provider value={navigator.currentRoute}>
|
|
46
45
|
<ScreenContextProvider pathname={navigator.currentRoute}>
|
|
@@ -53,7 +52,7 @@ const Layout = ({ Components, ComponentsExtraProps, children }: Props) => {
|
|
|
53
52
|
</ScreenContextProvider>
|
|
54
53
|
</PathnameContext.Provider>
|
|
55
54
|
</ScreenDataContext.Provider>
|
|
56
|
-
</
|
|
55
|
+
</Components.Background>
|
|
57
56
|
</ScreenLayoutContextProvider>
|
|
58
57
|
</LayoutContainer>
|
|
59
58
|
);
|
|
@@ -5,7 +5,6 @@ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
|
5
5
|
|
|
6
6
|
import { ScreenLayoutContextProvider } from "./ScreenLayoutContextProvider";
|
|
7
7
|
import { StackNavigator } from "../../Navigator";
|
|
8
|
-
import { LayoutBackground } from "./LayoutBackground";
|
|
9
8
|
|
|
10
9
|
type Components = {
|
|
11
10
|
NavBar: React.ComponentType<any>;
|
|
@@ -26,9 +25,9 @@ const Layout = ({ Components }: Props) => {
|
|
|
26
25
|
|
|
27
26
|
return (
|
|
28
27
|
<ScreenLayoutContextProvider>
|
|
29
|
-
<
|
|
28
|
+
<Components.Background>
|
|
30
29
|
<StackNavigator Components={Components} />
|
|
31
|
-
</
|
|
30
|
+
</Components.Background>
|
|
32
31
|
</ScreenLayoutContextProvider>
|
|
33
32
|
);
|
|
34
33
|
};
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { render } from "@testing-library/react-native";
|
|
3
|
+
|
|
4
|
+
jest.mock(
|
|
5
|
+
"@applicaster/zapp-react-native-utils/appUtils/playerManager",
|
|
6
|
+
() => ({
|
|
7
|
+
playerManager: {
|
|
8
|
+
invokeHandler: jest.fn(),
|
|
9
|
+
getPluginConfiguration: jest.fn(() => ({})),
|
|
10
|
+
isRegistered: jest.fn(() => true),
|
|
11
|
+
on: jest.fn().mockReturnThis(),
|
|
12
|
+
removeHandler: jest.fn().mockReturnThis(),
|
|
13
|
+
getActivePlayer: jest.fn(() => null),
|
|
14
|
+
closeNativePlayer: jest.fn(),
|
|
15
|
+
},
|
|
16
|
+
})
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
jest.mock("@applicaster/zapp-react-native-utils/reactUtils", () => ({
|
|
20
|
+
isTV: jest.fn(() => false),
|
|
21
|
+
isAndroidTVPlatform: jest.fn(() => false),
|
|
22
|
+
isTvOSPlatform: jest.fn(() => false),
|
|
23
|
+
platformSelect: jest.fn(({ native }) => native),
|
|
24
|
+
}));
|
|
25
|
+
|
|
26
|
+
jest.mock("@applicaster/zapp-react-native-utils/playerUtils", () => ({
|
|
27
|
+
isAudioItem: jest.fn(() => false),
|
|
28
|
+
isInlineTV: jest.fn(() => false),
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
jest.mock(
|
|
32
|
+
"@applicaster/zapp-react-native-tvos-ui-components/Components/TVEventHandlerComponent",
|
|
33
|
+
() => ({
|
|
34
|
+
TVEventHandlerComponent: ({ children }) => children,
|
|
35
|
+
})
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/utils", () => ({
|
|
39
|
+
usePrevious: jest.fn(),
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
jest.mock("@applicaster/zapp-react-native-utils/reactHooks", () => {
|
|
43
|
+
const navigator = {
|
|
44
|
+
closeVideoModal: jest.fn(),
|
|
45
|
+
minimiseVideoModal: jest.fn(),
|
|
46
|
+
maximiseVideoModal: jest.fn(),
|
|
47
|
+
fullscreenVideoModal: jest.fn(),
|
|
48
|
+
isVideoModalDocked: jest.fn(() => false),
|
|
49
|
+
goBack: jest.fn(),
|
|
50
|
+
replaceTop: jest.fn(),
|
|
51
|
+
push: jest.fn(),
|
|
52
|
+
setPlayNextOverlay: jest.fn(),
|
|
53
|
+
currentRoute: "/playable/entry-1",
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const backHandlerRef: { current: (() => boolean) | null } = {
|
|
57
|
+
current: null,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
useBackHandler: jest.fn((cb) => {
|
|
62
|
+
backHandlerRef.current = cb;
|
|
63
|
+
}),
|
|
64
|
+
useNavigation: jest.fn(() => navigator),
|
|
65
|
+
__navigator: navigator,
|
|
66
|
+
__backHandlerRef: backHandlerRef,
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
jest.mock("@applicaster/zapp-react-native-bridge/QuickBrick", () => ({
|
|
71
|
+
QUICK_BRICK_EVENTS: {
|
|
72
|
+
IDLE_TIMER_DISABLED: "IDLE_TIMER_DISABLED",
|
|
73
|
+
MOVE_APP_TO_BACKGROUND: "MOVE_APP_TO_BACKGROUND",
|
|
74
|
+
},
|
|
75
|
+
sendQuickBrickEvent: jest.fn(),
|
|
76
|
+
}));
|
|
77
|
+
|
|
78
|
+
jest.mock("../ProgramInfo", () => ({
|
|
79
|
+
ProgramInfo: () => null,
|
|
80
|
+
}));
|
|
81
|
+
|
|
82
|
+
jest.mock("../../AudioPlayer", () => ({
|
|
83
|
+
AudioPlayer: () => null,
|
|
84
|
+
}));
|
|
85
|
+
|
|
86
|
+
jest.mock("../logger", () => ({
|
|
87
|
+
log_debug: jest.fn(),
|
|
88
|
+
log_info: jest.fn(),
|
|
89
|
+
log_warning: jest.fn(),
|
|
90
|
+
playerContainerLogger: { error: jest.fn() },
|
|
91
|
+
}));
|
|
92
|
+
|
|
93
|
+
jest.mock(
|
|
94
|
+
"@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayer",
|
|
95
|
+
() => {
|
|
96
|
+
const player = {
|
|
97
|
+
addListener: jest.fn(),
|
|
98
|
+
removeListener: jest.fn(),
|
|
99
|
+
isPaused: jest.fn(() => false),
|
|
100
|
+
isAd: jest.fn(() => false),
|
|
101
|
+
seekTo: jest.fn(),
|
|
102
|
+
getPluginConfiguration: jest.fn(() => ({})),
|
|
103
|
+
getOverlayObservable: jest.fn(() => ({ getPlayNextEntry: () => null })),
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
usePlayer: jest.fn(() => player),
|
|
108
|
+
__player: player,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
jest.mock(
|
|
114
|
+
"@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayNextOverlay",
|
|
115
|
+
() => ({
|
|
116
|
+
usePlayNextOverlay: jest.fn(() => null),
|
|
117
|
+
})
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
jest.mock(
|
|
121
|
+
"@applicaster/zapp-react-native-utils/appUtils/playerManager/playerNativeCommand",
|
|
122
|
+
() => ({
|
|
123
|
+
PlayerNativeCommandTypes: { clearPlayerData: "clearPlayerData" },
|
|
124
|
+
PlayerNativeSendCommand: jest.fn(),
|
|
125
|
+
})
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
jest.mock(
|
|
129
|
+
"@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext",
|
|
130
|
+
() => ({
|
|
131
|
+
useSetNavbarState: jest.fn(() => ({ setVisible: jest.fn() })),
|
|
132
|
+
})
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
jest.mock(
|
|
136
|
+
"@applicaster/zapp-react-native-utils/reactHooks/screen/useTargetScreenData",
|
|
137
|
+
() => ({
|
|
138
|
+
useTargetScreenData: jest.fn(() => ({ id: "screen-id", styles: {} })),
|
|
139
|
+
})
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
jest.mock("../PlayerContainerContext", () => {
|
|
143
|
+
const ReactActual = require("react");
|
|
144
|
+
|
|
145
|
+
return {
|
|
146
|
+
PlayerContainerContext: ReactActual.createContext({
|
|
147
|
+
isLanguageOverlayVisible: false,
|
|
148
|
+
bottomFocusableId: "bottom",
|
|
149
|
+
showComponentsContainer: false,
|
|
150
|
+
refs: null,
|
|
151
|
+
}),
|
|
152
|
+
PlayerContainerContextProvider: ({ children }) => children,
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
jest.mock(
|
|
157
|
+
"@applicaster/zapp-react-native-ui-components/Components/FocusableGroup",
|
|
158
|
+
() => ({
|
|
159
|
+
FocusableGroup: ({ children }) => children,
|
|
160
|
+
})
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
jest.mock("../WappersView/PlayerFocusableWrapperView", () => ({
|
|
164
|
+
PlayerFocusableWrapperView: ({ children }) => children,
|
|
165
|
+
}));
|
|
166
|
+
|
|
167
|
+
jest.mock("../WappersView/ComponentFocusableWrapperView", () => ({
|
|
168
|
+
ComponentFocusableWrapperView: () => null,
|
|
169
|
+
}));
|
|
170
|
+
|
|
171
|
+
jest.mock("../index", () => ({
|
|
172
|
+
FocusableGroupMainContainerId: "player-container-general",
|
|
173
|
+
}));
|
|
174
|
+
|
|
175
|
+
jest.mock(
|
|
176
|
+
"@applicaster/zapp-react-native-utils/navigationUtils/itemTypeMatchers",
|
|
177
|
+
() => ({
|
|
178
|
+
isPlayable: jest.fn(() => true),
|
|
179
|
+
})
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
jest.mock("../../GeneralContentScreen", () => ({
|
|
183
|
+
GeneralContentScreen: () => null,
|
|
184
|
+
}));
|
|
185
|
+
|
|
186
|
+
jest.mock("@applicaster/zapp-react-native-redux/hooks", () => ({
|
|
187
|
+
usePickFromState: jest.fn(() => ({
|
|
188
|
+
appData: { isTabletPortrait: false },
|
|
189
|
+
})),
|
|
190
|
+
}));
|
|
191
|
+
|
|
192
|
+
import { PlayerContainer, VideoModalMode } from "../PlayerContainer";
|
|
193
|
+
|
|
194
|
+
const { __navigator: mockNavigator, __backHandlerRef: mockBackHandlerRef } =
|
|
195
|
+
jest.requireMock("@applicaster/zapp-react-native-utils/reactHooks");
|
|
196
|
+
|
|
197
|
+
const { playerManager: mockPlayerManager } = jest.requireMock(
|
|
198
|
+
"@applicaster/zapp-react-native-utils/appUtils/playerManager"
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
const { __player: mockPlayer } = jest.requireMock(
|
|
202
|
+
"@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayer"
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
const Player = React.forwardRef(() => null);
|
|
206
|
+
|
|
207
|
+
const item = {
|
|
208
|
+
id: "entry-1",
|
|
209
|
+
title: "Test entry",
|
|
210
|
+
summary: "",
|
|
211
|
+
content: { src: "https://example.com/video.m3u8" },
|
|
212
|
+
extensions: {},
|
|
213
|
+
} as any;
|
|
214
|
+
|
|
215
|
+
const renderPlayerContainer = (props = {}) =>
|
|
216
|
+
render(
|
|
217
|
+
<PlayerContainer
|
|
218
|
+
Player={Player}
|
|
219
|
+
item={item}
|
|
220
|
+
style={{}}
|
|
221
|
+
loadPipesData={jest.fn()}
|
|
222
|
+
isModal={true}
|
|
223
|
+
mode={VideoModalMode.MAXIMIZED}
|
|
224
|
+
{...props}
|
|
225
|
+
/>
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
const pressHardwareBack = () => {
|
|
229
|
+
if (!mockBackHandlerRef.current) {
|
|
230
|
+
throw new Error("back handler was not registered via useBackHandler");
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return mockBackHandlerRef.current();
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
describe("PlayerContainer hardware back handling", () => {
|
|
237
|
+
beforeEach(() => {
|
|
238
|
+
jest.clearAllMocks();
|
|
239
|
+
mockBackHandlerRef.current = null;
|
|
240
|
+
mockPlayer.getPluginConfiguration.mockReturnValue({});
|
|
241
|
+
mockPlayer.isPaused.mockReturnValue(false);
|
|
242
|
+
mockPlayer.isAd.mockReturnValue(false);
|
|
243
|
+
|
|
244
|
+
mockPlayer.getOverlayObservable.mockReturnValue({
|
|
245
|
+
getPlayNextEntry: () => null,
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
mockPlayerManager.getPluginConfiguration.mockReturnValue({});
|
|
249
|
+
mockPlayerManager.on.mockReturnThis();
|
|
250
|
+
mockPlayerManager.removeHandler.mockReturnThis();
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
it("minimises the video modal on back press when mini player is enabled", () => {
|
|
254
|
+
renderPlayerContainer();
|
|
255
|
+
|
|
256
|
+
const handled = pressHardwareBack();
|
|
257
|
+
|
|
258
|
+
expect(mockNavigator.minimiseVideoModal).toHaveBeenCalled();
|
|
259
|
+
expect(mockNavigator.closeVideoModal).not.toHaveBeenCalled();
|
|
260
|
+
expect(handled).toBe(true);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
it("closes the video modal on back press when mini player is disabled", () => {
|
|
264
|
+
mockPlayer.getPluginConfiguration.mockReturnValue({
|
|
265
|
+
disable_mini_player_when_inline: true,
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
renderPlayerContainer();
|
|
269
|
+
|
|
270
|
+
const handled = pressHardwareBack();
|
|
271
|
+
|
|
272
|
+
expect(mockNavigator.closeVideoModal).toHaveBeenCalled();
|
|
273
|
+
expect(mockNavigator.minimiseVideoModal).not.toHaveBeenCalled();
|
|
274
|
+
expect(handled).toBe(true);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it("does not handle back press when the player is already minimised", () => {
|
|
278
|
+
renderPlayerContainer({ mode: VideoModalMode.MINIMIZED });
|
|
279
|
+
|
|
280
|
+
const handled = pressHardwareBack();
|
|
281
|
+
|
|
282
|
+
expect(handled).toBe(false);
|
|
283
|
+
expect(mockNavigator.minimiseVideoModal).not.toHaveBeenCalled();
|
|
284
|
+
expect(mockNavigator.closeVideoModal).not.toHaveBeenCalled();
|
|
285
|
+
});
|
|
286
|
+
});
|
|
@@ -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
|
</>
|
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:
|
|
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": "15.1.0-rc.
|
|
3
|
+
"version": "15.1.0-rc.13",
|
|
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": "15.1.0-rc.
|
|
32
|
-
"@applicaster/zapp-react-native-bridge": "15.1.0-rc.
|
|
33
|
-
"@applicaster/zapp-react-native-redux": "15.1.0-rc.
|
|
34
|
-
"@applicaster/zapp-react-native-utils": "15.1.0-rc.
|
|
31
|
+
"@applicaster/applicaster-types": "15.1.0-rc.13",
|
|
32
|
+
"@applicaster/zapp-react-native-bridge": "15.1.0-rc.13",
|
|
33
|
+
"@applicaster/zapp-react-native-redux": "15.1.0-rc.13",
|
|
34
|
+
"@applicaster/zapp-react-native-utils": "15.1.0-rc.13",
|
|
35
35
|
"fast-json-stable-stringify": "^2.1.0",
|
|
36
36
|
"promise": "^8.3.0",
|
|
37
37
|
"url": "^0.11.0",
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
|
|
3
|
-
import { getBackgroundImageUrl } from "../utils";
|
|
4
|
-
import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
|
|
5
|
-
|
|
6
|
-
export const LayoutBackground = ({
|
|
7
|
-
Background,
|
|
8
|
-
children,
|
|
9
|
-
}: {
|
|
10
|
-
Background: React.ComponentType<any>;
|
|
11
|
-
children: React.ReactNode;
|
|
12
|
-
}) => {
|
|
13
|
-
const theme = useTheme();
|
|
14
|
-
|
|
15
|
-
const { remoteConfigurations } = usePickFromState(["remoteConfigurations"]);
|
|
16
|
-
|
|
17
|
-
const backgroundColor = theme.app_background_color;
|
|
18
|
-
const backgroundImageUrl = getBackgroundImageUrl(remoteConfigurations);
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<Background
|
|
22
|
-
backgroundColor={backgroundColor}
|
|
23
|
-
backgroundImageUrl={backgroundImageUrl}
|
|
24
|
-
>
|
|
25
|
-
{children}
|
|
26
|
-
</Background>
|
|
27
|
-
);
|
|
28
|
-
};
|