@applicaster/zapp-react-native-ui-components 16.0.0-rc.2 → 16.0.0-rc.20
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.tsx +42 -0
- package/Components/BackgroundImage/BackgroundImage.tv.android.tsx +28 -0
- package/Components/BackgroundImage/BackgroundImage.tv.ios.tsx +24 -0
- package/Components/BackgroundImage/index.ts +1 -0
- package/Components/CellRendererResolver/index.ts +1 -1
- 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/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/ButtonContainerView/index.tsx +1 -1
- package/Components/PlayerContainer/PlayerContainer.tsx +7 -7
- package/Components/PlayerContainer/__tests__/PlayerContainer.test.tsx +284 -0
- 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/ScreenRevealManager/Overlay.tsx +34 -0
- package/Components/ScreenRevealManager/__tests__/Overlay.test.tsx +88 -0
- package/Components/ScreenRevealManager/withScreenRevealManager.tsx +8 -19
- package/Components/VideoLive/LiveImageManager.ts +56 -45
- package/Components/VideoLive/PlayerLiveImageComponent.tsx +4 -2
- package/Components/VideoModal/utils.ts +6 -1
- 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/Helpers/Analytics/index.js +0 -95
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseKeyEntries,
|
|
3
|
+
getKeyToSkipHook,
|
|
4
|
+
shouldSkipHook,
|
|
5
|
+
} from "../validationHelper";
|
|
6
|
+
|
|
7
|
+
const mockSessionGetItem = jest.fn();
|
|
8
|
+
const mockLocalGetItem = jest.fn();
|
|
9
|
+
|
|
10
|
+
jest.mock(
|
|
11
|
+
"@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage",
|
|
12
|
+
() => ({
|
|
13
|
+
sessionStorage: { getItem: (...args) => mockSessionGetItem(...args) },
|
|
14
|
+
})
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
jest.mock(
|
|
18
|
+
"@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage",
|
|
19
|
+
() => ({
|
|
20
|
+
localStorage: { getItem: (...args) => mockLocalGetItem(...args) },
|
|
21
|
+
})
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
jest.mock("../logger", () => ({
|
|
25
|
+
log_debug: jest.fn(),
|
|
26
|
+
log_error: jest.fn(),
|
|
27
|
+
log_info: jest.fn(),
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
describe("parseKeyEntries", () => {
|
|
31
|
+
it("parses a namespaced key as namespace.key", () => {
|
|
32
|
+
expect(parseKeyEntries("myNamespace.myKey")).toEqual([
|
|
33
|
+
{ namespace: "myNamespace", key: "myKey" },
|
|
34
|
+
]);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("treats everything before the last dot as the namespace", () => {
|
|
38
|
+
expect(parseKeyEntries("com.applicaster.feature.someKey")).toEqual([
|
|
39
|
+
{ namespace: "com.applicaster.feature", key: "someKey" },
|
|
40
|
+
]);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("falls back to the default namespace when there is no dot", () => {
|
|
44
|
+
expect(parseKeyEntries("plainKey")).toEqual([
|
|
45
|
+
{ namespace: "applicaster.v2", key: "plainKey" },
|
|
46
|
+
]);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("splits comma-separated entries, trimming whitespace and empty items", () => {
|
|
50
|
+
expect(parseKeyEntries(" ns1.key1 , , ns2.key2 ,")).toEqual([
|
|
51
|
+
{ namespace: "ns1", key: "key1" },
|
|
52
|
+
{ namespace: "ns2", key: "key2" },
|
|
53
|
+
]);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe("getKeyToSkipHook", () => {
|
|
58
|
+
beforeEach(() => {
|
|
59
|
+
jest.clearAllMocks();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("returns the session storage value when present, without hitting local storage", async () => {
|
|
63
|
+
mockSessionGetItem.mockResolvedValue("session-value");
|
|
64
|
+
|
|
65
|
+
const value = await getKeyToSkipHook("myKey", "myNamespace");
|
|
66
|
+
|
|
67
|
+
expect(value).toBe("session-value");
|
|
68
|
+
expect(mockSessionGetItem).toHaveBeenCalledWith("myKey", "myNamespace");
|
|
69
|
+
expect(mockLocalGetItem).not.toHaveBeenCalled();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("falls back to local storage when session storage is empty", async () => {
|
|
73
|
+
mockSessionGetItem.mockResolvedValue(null);
|
|
74
|
+
mockLocalGetItem.mockResolvedValue("local-value");
|
|
75
|
+
|
|
76
|
+
const value = await getKeyToSkipHook("myKey", "myNamespace");
|
|
77
|
+
|
|
78
|
+
expect(value).toBe("local-value");
|
|
79
|
+
expect(mockLocalGetItem).toHaveBeenCalledWith("myKey", "myNamespace");
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe("shouldSkipHook", () => {
|
|
84
|
+
beforeEach(() => {
|
|
85
|
+
jest.clearAllMocks();
|
|
86
|
+
mockSessionGetItem.mockResolvedValue(null);
|
|
87
|
+
mockLocalGetItem.mockResolvedValue(null);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("returns false when no condition is provided", async () => {
|
|
91
|
+
await expect(shouldSkipHook(undefined)).resolves.toBe(false);
|
|
92
|
+
await expect(shouldSkipHook("")).resolves.toBe(false);
|
|
93
|
+
await expect(shouldSkipHook(" ")).resolves.toBe(false);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("returns true when a key is found in storage, querying with parsed namespace and key", async () => {
|
|
97
|
+
mockSessionGetItem.mockResolvedValue("value");
|
|
98
|
+
|
|
99
|
+
await expect(shouldSkipHook("myNamespace.myKey")).resolves.toBe(true);
|
|
100
|
+
expect(mockSessionGetItem).toHaveBeenCalledWith("myKey", "myNamespace");
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("returns true when any of the comma-separated keys is found", async () => {
|
|
104
|
+
mockLocalGetItem.mockImplementation((key) =>
|
|
105
|
+
Promise.resolve(key === "key2" ? "value" : null)
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
await expect(shouldSkipHook("ns1.key1, ns2.key2")).resolves.toBe(true);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("returns false when none of the keys are found", async () => {
|
|
112
|
+
await expect(shouldSkipHook("ns1.key1, ns2.key2")).resolves.toBe(false);
|
|
113
|
+
expect(mockSessionGetItem).toHaveBeenCalledTimes(2);
|
|
114
|
+
expect(mockLocalGetItem).toHaveBeenCalledTimes(2);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it("continues to the next key when a storage read throws", async () => {
|
|
118
|
+
mockSessionGetItem
|
|
119
|
+
.mockRejectedValueOnce(new Error("storage error"))
|
|
120
|
+
.mockResolvedValueOnce("value");
|
|
121
|
+
|
|
122
|
+
await expect(shouldSkipHook("ns1.key1, ns2.key2")).resolves.toBe(true);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PipesClientResponseHelper,
|
|
3
|
+
RequestBuilder,
|
|
4
|
+
} from "@applicaster/zapp-pipes-v2-client";
|
|
5
|
+
import { log_debug, log_error } from "./logger";
|
|
6
|
+
|
|
7
|
+
export const requestToSkipHook = async (
|
|
8
|
+
dataSource: ZappDataSource,
|
|
9
|
+
payload: ZappEntry
|
|
10
|
+
): Promise<boolean> => {
|
|
11
|
+
try {
|
|
12
|
+
const requestBuilder = new RequestBuilder()
|
|
13
|
+
.setEntryContext(payload)
|
|
14
|
+
// @ts-ignore: empty screen context is acceptable for this request
|
|
15
|
+
.setScreenContext({})
|
|
16
|
+
.setUrl(dataSource.source, dataSource.mapping);
|
|
17
|
+
|
|
18
|
+
const request = await requestBuilder.buildAxiosRequest();
|
|
19
|
+
|
|
20
|
+
log_debug(
|
|
21
|
+
`requestToSkipHook: Request built for source: ${
|
|
22
|
+
request?.url || dataSource.source
|
|
23
|
+
}`,
|
|
24
|
+
{ ...request, source: dataSource.source }
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const responseObject = await requestBuilder.call<boolean>();
|
|
28
|
+
const responseHelper = new PipesClientResponseHelper(responseObject);
|
|
29
|
+
|
|
30
|
+
const error = responseHelper.error;
|
|
31
|
+
const logData = responseHelper.getLogsData();
|
|
32
|
+
|
|
33
|
+
if (error) {
|
|
34
|
+
log_error(`requestToSkipHook: Error: ${error.message}`, {
|
|
35
|
+
response: logData,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
log_debug(
|
|
42
|
+
`requestToSkipHook: Request received successfully. Status: ${responseHelper.statusCode}`,
|
|
43
|
+
{ response: logData }
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// Non-empty body = skip the hook (same contract as hook-screen-wrapper)
|
|
47
|
+
return Boolean(responseHelper.responseData);
|
|
48
|
+
} catch (error) {
|
|
49
|
+
log_error(`requestToSkipHook: Error: ${error.message}`, { error });
|
|
50
|
+
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { shouldSkipHook } from "./validationHelper";
|
|
2
|
+
import { requestToSkipHook } from "./networkService";
|
|
3
|
+
import { log_debug, log_error } from "./logger";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Headless pre-hook for the General Content Screen. `configuration` is the
|
|
7
|
+
* Hook object with the screen merged in; skip-hook fields live under `rules`.
|
|
8
|
+
*/
|
|
9
|
+
export const runInBackground = async (
|
|
10
|
+
item,
|
|
11
|
+
callback,
|
|
12
|
+
configuration,
|
|
13
|
+
presentUI
|
|
14
|
+
) => {
|
|
15
|
+
try {
|
|
16
|
+
const skipHookIfKeysExist = configuration?.rules?.skip_hook_storage_key;
|
|
17
|
+
|
|
18
|
+
if (skipHookIfKeysExist) {
|
|
19
|
+
const shouldSkip = await shouldSkipHook(skipHookIfKeysExist);
|
|
20
|
+
|
|
21
|
+
if (shouldSkip) {
|
|
22
|
+
log_debug(
|
|
23
|
+
`runInBackground: Storage key found: ${skipHookIfKeysExist}. Skipping hook.`
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return callback({ success: true, error: null, payload: item });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const skipHookEndpoint = configuration?.rules?.skip_hook_endpoint;
|
|
31
|
+
|
|
32
|
+
if (skipHookEndpoint?.source) {
|
|
33
|
+
const success = await requestToSkipHook(skipHookEndpoint, item);
|
|
34
|
+
|
|
35
|
+
if (success) {
|
|
36
|
+
log_debug(
|
|
37
|
+
"runInBackground: Network call forced to finish hook. Skipping hook."
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
return callback({ success: true, error: null, payload: item });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
} catch (error) {
|
|
44
|
+
log_error(`runInBackground: Error: ${error.message}`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return presentUI();
|
|
48
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { getNamespaceAndKey } from "@applicaster/zapp-react-native-utils/appUtils/contextKeysManager/utils";
|
|
2
|
+
import { localStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/LocalStorage";
|
|
3
|
+
import { sessionStorage } from "@applicaster/zapp-react-native-bridge/ZappStorage/SessionStorage";
|
|
4
|
+
import { log_error, log_info } from "./logger";
|
|
5
|
+
|
|
6
|
+
type ParseKey = { key: string; namespace?: string };
|
|
7
|
+
|
|
8
|
+
export function parseKeyEntries(input: string): ParseKey[] {
|
|
9
|
+
return input.split(",").flatMap((item) => {
|
|
10
|
+
const trimmed = item.trim();
|
|
11
|
+
|
|
12
|
+
return trimmed ? getNamespaceAndKey(trimmed) : [];
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const getKeyToSkipHook = async (key: string, namespace?: string) => {
|
|
17
|
+
const value = await sessionStorage.getItem(key, namespace);
|
|
18
|
+
|
|
19
|
+
if (value) {
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return await localStorage.getItem(key, namespace);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const shouldSkipHook = async (
|
|
27
|
+
skipHookIfKeysExist?: string
|
|
28
|
+
): Promise<boolean> => {
|
|
29
|
+
if (!skipHookIfKeysExist?.trim()) {
|
|
30
|
+
log_info("shouldSkipHook: No skipping condition provided");
|
|
31
|
+
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const keyEntries = parseKeyEntries(skipHookIfKeysExist);
|
|
36
|
+
|
|
37
|
+
if (keyEntries.length === 0) {
|
|
38
|
+
log_info("shouldSkipHook: No valid keys provided");
|
|
39
|
+
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
for (const entry of keyEntries) {
|
|
44
|
+
try {
|
|
45
|
+
const value = await getKeyToSkipHook(entry.key, entry.namespace);
|
|
46
|
+
|
|
47
|
+
if (value) {
|
|
48
|
+
log_info(
|
|
49
|
+
`shouldSkipHook: Hook will be skipped due to: ${
|
|
50
|
+
entry.namespace ?? ""
|
|
51
|
+
} ${entry.key}. Finishing hook flow`
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
} catch (error) {
|
|
57
|
+
log_error(
|
|
58
|
+
`shouldSkipHook: Error: ${error.message} checking key: ${
|
|
59
|
+
entry.namespace ?? ""
|
|
60
|
+
} ${entry.key}`,
|
|
61
|
+
{ error }
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
log_info(
|
|
67
|
+
// eslint-disable-next-line max-len
|
|
68
|
+
"shouldSkipHook: No skipping condition met, none of the provided keys found in storage, proceeding with hook"
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
return false;
|
|
72
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
type Props = {
|
|
4
|
+
children: React.ReactElement;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* On native platforms the river `ComponentsMap` registers its own initial focus,
|
|
9
|
+
* so a hook-presented general content screen needs no extra focus wrapper here.
|
|
10
|
+
* The web counterpart (`index.web.tsx`) recreates the content focus group that
|
|
11
|
+
* the `River` wrapper would normally provide.
|
|
12
|
+
*/
|
|
13
|
+
export const HookContentFocusGroup = ({ children }: Props) => <>{children}</>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { StyleSheet } from "react-native";
|
|
3
|
+
import { shallow } from "zustand/shallow";
|
|
4
|
+
|
|
5
|
+
import { FocusableGroup } from "../../FocusableGroup";
|
|
6
|
+
import {
|
|
7
|
+
useContentId,
|
|
8
|
+
useNavbarId,
|
|
9
|
+
usePathname,
|
|
10
|
+
} from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
|
|
11
|
+
import { useZappHookModalStore } from "../../../Contexts/ZappHookModalContext";
|
|
12
|
+
|
|
13
|
+
import { useInitialFocus } from "../../Screen/TV/hooks";
|
|
14
|
+
|
|
15
|
+
const styles = StyleSheet.create({
|
|
16
|
+
container: { flex: 1 },
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
type Props = {
|
|
20
|
+
children: React.ReactElement;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A general content screen presented as a full-screen hook is rendered straight
|
|
25
|
+
* through `ComponentsMap`, bypassing the web `River` wrapper. That wrapper is what
|
|
26
|
+
* normally creates the `quick-brick-content` FocusableGroup (with `preferredFocus`)
|
|
27
|
+
* the focus manager relies on and what lets initial focus land on the content.
|
|
28
|
+
*
|
|
29
|
+
* Without it the hook screen renders but nothing is focusable on web TV. This
|
|
30
|
+
* recreates that content group and triggers initial focus, mirroring `River`.
|
|
31
|
+
*/
|
|
32
|
+
const FocusedHookContent = ({ children }: Props) => {
|
|
33
|
+
const contentId = useContentId();
|
|
34
|
+
const navbarId = useNavbarId();
|
|
35
|
+
const pathname = usePathname();
|
|
36
|
+
|
|
37
|
+
useInitialFocus();
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<FocusableGroup
|
|
41
|
+
id={contentId}
|
|
42
|
+
// Nest under the hook-modal route so the focus manager treats this as the
|
|
43
|
+
// active screen's content node; `useInitialFocus` targets the same route.
|
|
44
|
+
groupId={pathname}
|
|
45
|
+
nextFocusUp={navbarId}
|
|
46
|
+
preferredFocus
|
|
47
|
+
shouldUsePreferredFocus
|
|
48
|
+
style={styles.container}
|
|
49
|
+
>
|
|
50
|
+
{React.cloneElement(children, { groupId: contentId })}
|
|
51
|
+
</FocusableGroup>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const HookContentFocusGroup = ({ children }: Props) => {
|
|
56
|
+
const isRunningInBackground = useZappHookModalStore(
|
|
57
|
+
(state) => state.isRunningInBackground,
|
|
58
|
+
shallow
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
// A hook presented full screen (either as a `/hooks/<id>` screen or a
|
|
62
|
+
// full-screen modal) needs the content focus group. Only background runs,
|
|
63
|
+
// which render invisibly, must be left alone so they don't steal focus.
|
|
64
|
+
if (isRunningInBackground) {
|
|
65
|
+
return <>{children}</>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return <FocusedHookContent>{children}</FocusedHookContent>;
|
|
69
|
+
};
|
|
@@ -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 = (
|
|
@@ -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
|
-
<
|
|
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
|
-
</
|
|
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
|
-
<
|
|
27
|
+
<Components.Background>
|
|
29
28
|
<StackNavigator Components={Components} />
|
|
30
|
-
</
|
|
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
|
-
|
|
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(
|
|
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(
|
|
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
|
/>
|
|
@@ -265,14 +265,12 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
265
265
|
navigator.goBack();
|
|
266
266
|
}, [isModal, state.playerId, showNavBar, navigator]);
|
|
267
267
|
|
|
268
|
-
const pluginConfiguration = React.useMemo(
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
);
|
|
273
|
-
}, [playerManager.isRegistered()]);
|
|
268
|
+
const pluginConfiguration = React.useMemo(
|
|
269
|
+
() => player?.getPluginConfiguration(),
|
|
270
|
+
[player]
|
|
271
|
+
);
|
|
274
272
|
|
|
275
|
-
const playEntry = (entry) => navigator.replaceTop(entry, { mode });
|
|
273
|
+
const playEntry = (entry: ZappEntry) => navigator.replaceTop(entry, { mode });
|
|
276
274
|
|
|
277
275
|
const onPlayNextPerformNextVideoPlay = React.useCallback(() => {
|
|
278
276
|
if (!playNextOverlayState.entry) {
|
|
@@ -468,6 +466,8 @@ const PlayerContainerComponent = (props: Props) => {
|
|
|
468
466
|
if (isModal && mode === VideoModalMode.MAXIMIZED) {
|
|
469
467
|
if (disableMiniPlayer) {
|
|
470
468
|
navigator.closeVideoModal();
|
|
469
|
+
} else {
|
|
470
|
+
navigator.minimiseVideoModal();
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
473
|
|