@applicaster/quick-brick-core 11.0.0-rc.99 → 12.0.0-alpha.5035843303
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/App/ActionsProvider/{ActionsProvider.js → ActionsProvider.tsx} +18 -22
- package/App/AssetCache/CacheManager.ts +33 -36
- package/App/AssetCache/__tests__/__snapshots__/assetCache.test.ts.snap +32 -26
- package/App/AssetCache/__tests__/assetCache.test.ts +12 -15
- package/App/AssetCache/__tests__/cacheManager.test.ts +2 -1
- package/App/AssetCache/index.ts +71 -31
- package/App/AssetCache/logger.ts +8 -1
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/useOpenSchemeHandler.test.tsx +2 -2
- package/App/DeepLinking/URLSchemeHandler/SchemeHandlerHooks/__tests__/usePresentSchemeHandler.test.tsx +2 -2
- package/App/DeepLinking/helpers/index.ts +4 -7
- package/App/ErrorBoundary/__tests__/errorBoundary.test.js +0 -1
- package/App/ModalProvider/index.tsx +14 -11
- package/App/NavigationProvider/NavigationProvider.tsx +49 -28
- package/App/NavigationProvider/navigator/__tests__/__snapshots__/reducer.test.ts.snap +0 -33
- package/App/NavigationProvider/navigator/__tests__/reducer.test.ts +0 -175
- package/App/NavigationProvider/navigator/reducer.ts +7 -54
- package/App/StoreConnector/{index.js → index.ts} +0 -2
- package/App/ThemeManager/{index.js → index.tsx} +9 -13
- package/App/{index.js → index.tsx} +0 -2
- package/createZappApp/index.js +9 -5
- package/helpers/index.js +0 -2
- package/index.js +0 -2
- package/package.json +8 -8
- package/renderZappApp/index.js +0 -2
- package/tsconfig.json +1 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import * as R from "ramda";
|
|
3
2
|
import url from "url";
|
|
4
3
|
import atob from "atob";
|
|
@@ -9,8 +8,8 @@ import { isTV } from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
|
9
8
|
type UrlSchemeParams = Record<string, unknown>;
|
|
10
9
|
|
|
11
10
|
type UrlScheme = {
|
|
12
|
-
host?: string;
|
|
13
|
-
path?: string;
|
|
11
|
+
host?: string | null;
|
|
12
|
+
path?: string | null;
|
|
14
13
|
scheme?: string;
|
|
15
14
|
query?: UrlSchemeParams;
|
|
16
15
|
fragment?: string;
|
|
@@ -29,8 +28,6 @@ const unescape = R.compose(...R.map(R.apply(R.replace), escapedChars));
|
|
|
29
28
|
/**
|
|
30
29
|
* tries to decode a url encoded to a base64 string.
|
|
31
30
|
* returns the original string if decoding is not possible or fails
|
|
32
|
-
* @param {String} urlString
|
|
33
|
-
* @returns {String}
|
|
34
31
|
*/
|
|
35
32
|
export function decodeUrl(urlString: string): string {
|
|
36
33
|
try {
|
|
@@ -44,8 +41,8 @@ export function decodeUrl(urlString: string): string {
|
|
|
44
41
|
|
|
45
42
|
/**
|
|
46
43
|
* parses a url string into an object, providing values for the different parts of the url
|
|
47
|
-
* @param
|
|
48
|
-
* @returns
|
|
44
|
+
* @param `urlString` to parse
|
|
45
|
+
* @returns url object - see UrlScheme type above
|
|
49
46
|
*/
|
|
50
47
|
export function parseUrl(urlString: string): UrlScheme {
|
|
51
48
|
const {
|
|
@@ -6,6 +6,7 @@ import { ModalPresenter } from "./ModalPresenter";
|
|
|
6
6
|
import { ModalContent } from "./ModalContent";
|
|
7
7
|
import { ModalChildrenWrapper } from "./ModalChildrenWrapper";
|
|
8
8
|
import { PathnameContext } from "@applicaster/zapp-react-native-ui-components/Contexts/PathnameContext";
|
|
9
|
+
import { ScreenContextProvider } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenContext";
|
|
9
10
|
import { ROUTE_TYPES } from "@applicaster/zapp-react-native-utils/navigationUtils/routeTypes";
|
|
10
11
|
|
|
11
12
|
export function ModalProvider() {
|
|
@@ -32,18 +33,20 @@ export function ModalProvider() {
|
|
|
32
33
|
...modalState.props,
|
|
33
34
|
};
|
|
34
35
|
|
|
36
|
+
const pathname = `${ROUTE_TYPES.MODAL}/${modalScreenProps?.screenId}`;
|
|
37
|
+
|
|
35
38
|
return (
|
|
36
|
-
<PathnameContext.Provider
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
</
|
|
46
|
-
</
|
|
39
|
+
<PathnameContext.Provider value={pathname}>
|
|
40
|
+
<ScreenContextProvider pathname={pathname}>
|
|
41
|
+
<ModalPresenter
|
|
42
|
+
visible={modalVisible && modalState?.visible}
|
|
43
|
+
{...modalState?.options}
|
|
44
|
+
>
|
|
45
|
+
<ModalChildrenWrapper>
|
|
46
|
+
<ModalContent modalScreenProps={modalScreenProps} />
|
|
47
|
+
</ModalChildrenWrapper>
|
|
48
|
+
</ModalPresenter>
|
|
49
|
+
</ScreenContextProvider>
|
|
47
50
|
</PathnameContext.Provider>
|
|
48
51
|
);
|
|
49
52
|
}
|
|
@@ -3,13 +3,19 @@
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import * as R from "ramda";
|
|
5
5
|
import { NavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NavigationContext";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
getTargetRoute,
|
|
8
|
+
usesVideoModal,
|
|
9
|
+
} from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
7
10
|
import {
|
|
8
11
|
allowedOrientationsForScreen,
|
|
9
12
|
useGetScreenOrientation,
|
|
10
13
|
} from "@applicaster/zapp-react-native-utils/appUtils/orientationHelper";
|
|
11
14
|
import { focusManager } from "@applicaster/zapp-react-native-utils/focusManager/FocusManager";
|
|
12
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
useContentTypes,
|
|
17
|
+
usePickFromState,
|
|
18
|
+
} from "@applicaster/zapp-react-native-redux/hooks";
|
|
13
19
|
|
|
14
20
|
import reducer, {
|
|
15
21
|
ACTIONS,
|
|
@@ -19,9 +25,6 @@ import reducer, {
|
|
|
19
25
|
push,
|
|
20
26
|
replace,
|
|
21
27
|
setBackPlayerNestedContent,
|
|
22
|
-
setNavBarSummary,
|
|
23
|
-
setNavBarTitle,
|
|
24
|
-
setNavBarVisibility,
|
|
25
28
|
setNestedContent,
|
|
26
29
|
setReplaceTop,
|
|
27
30
|
setVideoModalClose,
|
|
@@ -36,21 +39,29 @@ import reducer, {
|
|
|
36
39
|
import { HooksManager } from "@applicaster/zapp-react-native-utils/appUtils/HooksManager";
|
|
37
40
|
import { HOOKS_EVENTS } from "@applicaster/zapp-react-native-utils/appUtils/HooksManager/constants";
|
|
38
41
|
|
|
39
|
-
import {
|
|
42
|
+
import {
|
|
43
|
+
activeRiverSelector,
|
|
44
|
+
homeRiverSelector,
|
|
45
|
+
lastEntrySelector,
|
|
46
|
+
} from "./navigator/selectors";
|
|
40
47
|
|
|
41
48
|
import { coreAppLogger } from "../logger";
|
|
42
|
-
import {
|
|
49
|
+
import {
|
|
50
|
+
getPlatform,
|
|
51
|
+
isTV,
|
|
52
|
+
} from "@applicaster/zapp-react-native-utils/reactUtils";
|
|
43
53
|
import { useConnectionInfo } from "@applicaster/zapp-react-native-utils/reactHooks/connection";
|
|
44
|
-
import {
|
|
54
|
+
import {
|
|
55
|
+
getNavigationTarget,
|
|
56
|
+
getTargetScreen,
|
|
57
|
+
legacyScreenData,
|
|
58
|
+
openExternalUrl,
|
|
59
|
+
} from "./utils";
|
|
45
60
|
import { debounce } from "@applicaster/zapp-react-native-utils/functionUtils";
|
|
46
61
|
|
|
47
|
-
import {
|
|
48
|
-
findParent,
|
|
49
|
-
} from "@applicaster/zapp-react-native-ui-components/Contexts/ZappPipesContext/ZappPipesEntryContext";
|
|
62
|
+
import { findParent } from "@applicaster/zapp-react-native-ui-components/Contexts/ZappPipesContext/ZappPipesEntryContext";
|
|
50
63
|
import { ZappPipesEntryContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
|
|
51
|
-
import {
|
|
52
|
-
PlayNextState,
|
|
53
|
-
} from "@applicaster/zapp-react-native-utils/appUtils/playerManager/OverlayObserver/OverlaysObserver";
|
|
64
|
+
import { PlayNextState } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/OverlayObserver/OverlaysObserver";
|
|
54
65
|
import { inflateUrl } from "@applicaster/zapp-react-native-ui-components/Components/LinkHandler/LinkHandler";
|
|
55
66
|
|
|
56
67
|
const logger = coreAppLogger.addSubsystem("Navigator");
|
|
@@ -158,10 +169,6 @@ export function NavigationProvider({ children }: Props) {
|
|
|
158
169
|
);
|
|
159
170
|
|
|
160
171
|
const getStack = () => [...stateRef?.current?.stack?.mainStack];
|
|
161
|
-
const showNavBar = () => dispatch(setNavBarVisibility(true));
|
|
162
|
-
const hideNavBar = () => dispatch(setNavBarVisibility(false));
|
|
163
|
-
const setScreenTitle = R.compose(dispatch, setNavBarTitle);
|
|
164
|
-
const setScreenSummary = R.compose(dispatch, setNavBarSummary);
|
|
165
172
|
|
|
166
173
|
const openVideoModal = (
|
|
167
174
|
item: ZappEntry,
|
|
@@ -257,13 +264,21 @@ export function NavigationProvider({ children }: Props) {
|
|
|
257
264
|
}
|
|
258
265
|
};
|
|
259
266
|
|
|
260
|
-
const canGoBack = (fromHook = false) => {
|
|
267
|
+
const canGoBack = (fromHook = false, pathname?: string) => {
|
|
261
268
|
const stack = fromHook ? stateRef.current.stack : state.stack;
|
|
262
269
|
|
|
263
270
|
const filteredStack = state.stack.mainStack.filter(
|
|
264
271
|
(stackItem) => !stackItem?.route?.includes("/hooks")
|
|
265
272
|
);
|
|
266
273
|
|
|
274
|
+
if (pathname) {
|
|
275
|
+
const pathnameStackIndex = state.stack.mainStack.findIndex(({ route }) =>
|
|
276
|
+
route.includes(pathname)
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
return pathnameStackIndex > 1;
|
|
280
|
+
}
|
|
281
|
+
|
|
267
282
|
if (!Number.isNaN(filteredStack?.length)) {
|
|
268
283
|
return Math.min(filteredStack.length, stack.mainStack.length) > 1;
|
|
269
284
|
}
|
|
@@ -305,7 +320,10 @@ export function NavigationProvider({ children }: Props) {
|
|
|
305
320
|
state: firstRoute.state,
|
|
306
321
|
};
|
|
307
322
|
|
|
308
|
-
if (
|
|
323
|
+
if (
|
|
324
|
+
stateForBack?.state?.entry &&
|
|
325
|
+
"home" in stateForBack?.state?.entry
|
|
326
|
+
) {
|
|
309
327
|
goHome();
|
|
310
328
|
} else {
|
|
311
329
|
dispatch(back(stateForBack));
|
|
@@ -522,6 +540,16 @@ export function NavigationProvider({ children }: Props) {
|
|
|
522
540
|
return;
|
|
523
541
|
}
|
|
524
542
|
|
|
543
|
+
// Skip navigation if the entry type is empty
|
|
544
|
+
if (layoutVersion === "v2" && entry && !entry.type?.value) {
|
|
545
|
+
logger.warn({
|
|
546
|
+
message: "Empty content type",
|
|
547
|
+
data: { entry },
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
|
|
525
553
|
if (entry && usesVideoModal(entry, rivers, contentTypes)) {
|
|
526
554
|
openVideoModal(entry, options);
|
|
527
555
|
|
|
@@ -668,7 +696,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
668
696
|
// It will only work for the regular stack and pathname, It won't work for modals
|
|
669
697
|
// TODO: integrate video/hook and regular modal into stack.
|
|
670
698
|
const getStackForPathname = React.useCallback((pathname: string):
|
|
671
|
-
|
|
|
699
|
+
| NavigationScreenState
|
|
672
700
|
| undefined => {
|
|
673
701
|
const stack = getStack();
|
|
674
702
|
|
|
@@ -684,13 +712,6 @@ export function NavigationProvider({ children }: Props) {
|
|
|
684
712
|
currentRoute: pathname,
|
|
685
713
|
previousAction: lastEntrySelector(state)
|
|
686
714
|
?.action as QuickBrickNavigationActionType,
|
|
687
|
-
isNavBarVisible: state.options.navBar.visible,
|
|
688
|
-
screenTitle: state.options.navBar.title,
|
|
689
|
-
screenSummary: state.options.navBar.summary,
|
|
690
|
-
showNavBar,
|
|
691
|
-
hideNavBar,
|
|
692
|
-
setScreenTitle,
|
|
693
|
-
setScreenSummary,
|
|
694
715
|
push: pushItem,
|
|
695
716
|
replace: replaceItem,
|
|
696
717
|
setNestedScreenContent,
|
|
@@ -14,9 +14,6 @@ Object {
|
|
|
14
14
|
"REPLACE": "REPLACE",
|
|
15
15
|
"REPLACE_TOP": "REPLACE_TOP",
|
|
16
16
|
"SET_LOCATION": "SET_LOCATION",
|
|
17
|
-
"SET_NAV_BAR_SUMMARY": "SET_NAV_BAR_SUMMARY",
|
|
18
|
-
"SET_NAV_BAR_TITLE": "SET_NAV_BAR_TITLE",
|
|
19
|
-
"SET_NAV_BAR_VISIBILITY": "SET_NAV_BAR_VISIBILITY",
|
|
20
17
|
"SET_NESTED_CONTENT": "SET_NESTED_CONTENT",
|
|
21
18
|
"SET_VIDEO_MODAL_ITEM": "SET_VIDEO_MODAL_ITEM",
|
|
22
19
|
}
|
|
@@ -50,11 +47,6 @@ Object {
|
|
|
50
47
|
},
|
|
51
48
|
},
|
|
52
49
|
"options": Object {
|
|
53
|
-
"navBar": Object {
|
|
54
|
-
"summary": "",
|
|
55
|
-
"title": "",
|
|
56
|
-
"visible": true,
|
|
57
|
-
},
|
|
58
50
|
"videoModal": Object {
|
|
59
51
|
"item": null,
|
|
60
52
|
"mode": "MAXIMIZED",
|
|
@@ -125,11 +117,6 @@ Object {
|
|
|
125
117
|
},
|
|
126
118
|
},
|
|
127
119
|
"options": Object {
|
|
128
|
-
"navBar": Object {
|
|
129
|
-
"summary": "",
|
|
130
|
-
"title": "",
|
|
131
|
-
"visible": true,
|
|
132
|
-
},
|
|
133
120
|
"videoModal": Object {
|
|
134
121
|
"item": null,
|
|
135
122
|
"mode": "MAXIMIZED",
|
|
@@ -231,11 +218,6 @@ Object {
|
|
|
231
218
|
},
|
|
232
219
|
},
|
|
233
220
|
"options": Object {
|
|
234
|
-
"navBar": Object {
|
|
235
|
-
"summary": "",
|
|
236
|
-
"title": "",
|
|
237
|
-
"visible": true,
|
|
238
|
-
},
|
|
239
221
|
"videoModal": Object {
|
|
240
222
|
"item": null,
|
|
241
223
|
"mode": "MAXIMIZED",
|
|
@@ -369,11 +351,6 @@ Object {
|
|
|
369
351
|
},
|
|
370
352
|
},
|
|
371
353
|
"options": Object {
|
|
372
|
-
"navBar": Object {
|
|
373
|
-
"summary": "",
|
|
374
|
-
"title": "",
|
|
375
|
-
"visible": true,
|
|
376
|
-
},
|
|
377
354
|
"videoModal": Object {
|
|
378
355
|
"item": null,
|
|
379
356
|
"mode": "MAXIMIZED",
|
|
@@ -475,11 +452,6 @@ Object {
|
|
|
475
452
|
},
|
|
476
453
|
},
|
|
477
454
|
"options": Object {
|
|
478
|
-
"navBar": Object {
|
|
479
|
-
"summary": "",
|
|
480
|
-
"title": "",
|
|
481
|
-
"visible": true,
|
|
482
|
-
},
|
|
483
455
|
"videoModal": Object {
|
|
484
456
|
"item": null,
|
|
485
457
|
"mode": "MAXIMIZED",
|
|
@@ -613,11 +585,6 @@ Object {
|
|
|
613
585
|
},
|
|
614
586
|
},
|
|
615
587
|
"options": Object {
|
|
616
|
-
"navBar": Object {
|
|
617
|
-
"summary": "",
|
|
618
|
-
"title": "",
|
|
619
|
-
"visible": true,
|
|
620
|
-
},
|
|
621
588
|
"videoModal": Object {
|
|
622
589
|
"item": null,
|
|
623
590
|
"mode": "MAXIMIZED",
|
|
@@ -3,9 +3,6 @@ import reducer, {
|
|
|
3
3
|
push,
|
|
4
4
|
replace,
|
|
5
5
|
back,
|
|
6
|
-
setNavBarVisibility,
|
|
7
|
-
setNavBarTitle,
|
|
8
|
-
setNavBarSummary,
|
|
9
6
|
initialState,
|
|
10
7
|
} from "../reducer";
|
|
11
8
|
|
|
@@ -117,48 +114,6 @@ describe("actions", () => {
|
|
|
117
114
|
);
|
|
118
115
|
});
|
|
119
116
|
});
|
|
120
|
-
|
|
121
|
-
describe("setNavBarVisibility", () => {
|
|
122
|
-
it("returns a setNavBarVisibility action", () => {
|
|
123
|
-
const payload = true;
|
|
124
|
-
const setNavBarVisibilityAction = setNavBarVisibility(payload);
|
|
125
|
-
|
|
126
|
-
expect(setNavBarVisibilityAction).toHaveProperty(
|
|
127
|
-
"type",
|
|
128
|
-
ACTIONS.SET_NAV_BAR_VISIBILITY
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
expect(setNavBarVisibilityAction).toHaveProperty("payload", payload);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
describe("setNavBarTitle", () => {
|
|
136
|
-
it("returns a setNavBarTitle action", () => {
|
|
137
|
-
const payload = "Screen Title";
|
|
138
|
-
const setNavBarTitleAction = setNavBarTitle(payload);
|
|
139
|
-
|
|
140
|
-
expect(setNavBarTitleAction).toHaveProperty(
|
|
141
|
-
"type",
|
|
142
|
-
ACTIONS.SET_NAV_BAR_TITLE
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
expect(setNavBarTitleAction).toHaveProperty("payload", payload);
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
describe("setNavBarSummary", () => {
|
|
150
|
-
it("returns a setNavBarSummary action", () => {
|
|
151
|
-
const payload = "Screen Summary";
|
|
152
|
-
const setNavBarSummaryAction = setNavBarSummary(payload);
|
|
153
|
-
|
|
154
|
-
expect(setNavBarSummaryAction).toHaveProperty(
|
|
155
|
-
"type",
|
|
156
|
-
ACTIONS.SET_NAV_BAR_SUMMARY
|
|
157
|
-
);
|
|
158
|
-
|
|
159
|
-
expect(setNavBarSummaryAction).toHaveProperty("payload", payload);
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
117
|
});
|
|
163
118
|
|
|
164
119
|
describe("reducer", () => {
|
|
@@ -438,135 +393,5 @@ describe("reducer", () => {
|
|
|
438
393
|
expect(finalState).toEqual(newState);
|
|
439
394
|
});
|
|
440
395
|
});
|
|
441
|
-
|
|
442
|
-
// describe.skip("when there are hooks in the stack", () => {
|
|
443
|
-
// const action = replace(route, state);
|
|
444
|
-
// const newState = reducer(initialState, action);
|
|
445
|
-
// const hookPayload = { ...state, isHook: true };
|
|
446
|
-
// const hookRoute = "/hooks/hook-id";
|
|
447
|
-
// const hookAction = push(hookRoute, hookPayload);
|
|
448
|
-
// const newState2 = reducer(newState, hookAction);
|
|
449
|
-
// const hookPayload2 = { ...hookPayload, hook2: true };
|
|
450
|
-
// const hookRoute2 = "/hooks/hook-id-2";
|
|
451
|
-
// const hookAction2 = push(hookRoute2, hookPayload2);
|
|
452
|
-
// const newState3 = reducer(newState2, hookAction2);
|
|
453
|
-
// const finalState = reducer(newState3, back());
|
|
454
|
-
|
|
455
|
-
// it("goes back to the previous entry in the stack before the hooks", () => {
|
|
456
|
-
// expect(finalState).toHaveProperty("stack");
|
|
457
|
-
// expect(finalState.stack.mainStack).toBeArrayOfSize(1);
|
|
458
|
-
|
|
459
|
-
// expect(finalState.stack.mainStack[0]).toHaveProperty(
|
|
460
|
-
// "action",
|
|
461
|
-
// ACTIONS.BACK
|
|
462
|
-
// );
|
|
463
|
-
|
|
464
|
-
// expect(finalState.stack.mainStack[0]).toHaveProperty("route", route);
|
|
465
|
-
// expect(finalState.stack.mainStack[0]).toHaveProperty("state", state);
|
|
466
|
-
// });
|
|
467
|
-
|
|
468
|
-
// it("restores the location properties of the state", () => {
|
|
469
|
-
// expect(newState).toHaveProperty("location");
|
|
470
|
-
// expect(newState.location).toHaveProperty("pathname", route);
|
|
471
|
-
// expect(newState.location).toHaveProperty("state", state);
|
|
472
|
-
|
|
473
|
-
// expect(newState2).toHaveProperty("location");
|
|
474
|
-
// expect(newState2.location).toHaveProperty("pathname", hookRoute);
|
|
475
|
-
// expect(newState2.location).toHaveProperty("state", hookPayload);
|
|
476
|
-
|
|
477
|
-
// expect(newState3).toHaveProperty("location");
|
|
478
|
-
// expect(newState3.location).toHaveProperty("pathname", hookRoute2);
|
|
479
|
-
// expect(newState3.location).toHaveProperty("state", hookPayload2);
|
|
480
|
-
|
|
481
|
-
// expect(finalState).toHaveProperty("location");
|
|
482
|
-
// expect(finalState.location).toHaveProperty("pathname", route);
|
|
483
|
-
// expect(finalState.location).toHaveProperty("state", state);
|
|
484
|
-
// });
|
|
485
|
-
|
|
486
|
-
// it("leaves the navBar properties of the state unchanged", () => {
|
|
487
|
-
// expect(newState.options.navBar).toEqual(initialState.options.navBar);
|
|
488
|
-
// expect(newState2.options.navBar).toEqual(initialState.options.navBar);
|
|
489
|
-
// expect(newState3.options.navBar).toEqual(initialState.options.navBar);
|
|
490
|
-
// expect(finalState.options.navBar).toEqual(initialState.options.navBar);
|
|
491
|
-
// });
|
|
492
|
-
// });
|
|
493
|
-
});
|
|
494
|
-
|
|
495
|
-
describe("when a setNavBarVisibility action is dispatched", () => {
|
|
496
|
-
const navBarVisibility = false;
|
|
497
|
-
const action = setNavBarVisibility(navBarVisibility);
|
|
498
|
-
const newState = reducer(initialState, action);
|
|
499
|
-
|
|
500
|
-
it("updates the visibility of the navbar", () => {
|
|
501
|
-
expect(newState.options.navBar).toHaveProperty(
|
|
502
|
-
"visible",
|
|
503
|
-
navBarVisibility
|
|
504
|
-
);
|
|
505
|
-
});
|
|
506
|
-
|
|
507
|
-
it("leaves the other properties of the state unchanged", () => {
|
|
508
|
-
expect(newState.options.navBar).toHaveProperty(
|
|
509
|
-
"title",
|
|
510
|
-
initialState.options.navBar.title
|
|
511
|
-
);
|
|
512
|
-
|
|
513
|
-
expect(newState.options.navBar).toHaveProperty(
|
|
514
|
-
"summary",
|
|
515
|
-
initialState.options.navBar.summary
|
|
516
|
-
);
|
|
517
|
-
|
|
518
|
-
expect(newState.stack).toEqual(initialState.stack);
|
|
519
|
-
expect(newState.location).toEqual(initialState.location);
|
|
520
|
-
});
|
|
521
|
-
});
|
|
522
|
-
|
|
523
|
-
describe("when a setNavBarTitle action is dispatched", () => {
|
|
524
|
-
const navBarTitle = "Screen Title";
|
|
525
|
-
const action = setNavBarTitle(navBarTitle);
|
|
526
|
-
const newState = reducer(initialState, action);
|
|
527
|
-
|
|
528
|
-
it("updates the navbar title", () => {
|
|
529
|
-
expect(newState.options.navBar).toHaveProperty("title", navBarTitle);
|
|
530
|
-
});
|
|
531
|
-
|
|
532
|
-
it("leaves the other properties of the state unchanged", () => {
|
|
533
|
-
expect(newState.options.navBar).toHaveProperty(
|
|
534
|
-
"visible",
|
|
535
|
-
initialState.options.navBar.visible
|
|
536
|
-
);
|
|
537
|
-
|
|
538
|
-
expect(newState.options.navBar).toHaveProperty(
|
|
539
|
-
"summary",
|
|
540
|
-
initialState.options.navBar.summary
|
|
541
|
-
);
|
|
542
|
-
|
|
543
|
-
expect(newState.stack).toEqual(initialState.stack);
|
|
544
|
-
expect(newState.location).toEqual(initialState.location);
|
|
545
|
-
});
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
describe("when a setNavBarSummary action is dispatched", () => {
|
|
549
|
-
const navBarSummary = "Screen summary";
|
|
550
|
-
const action = setNavBarSummary(navBarSummary);
|
|
551
|
-
const newState = reducer(initialState, action);
|
|
552
|
-
|
|
553
|
-
it("updates the navbar title", () => {
|
|
554
|
-
expect(newState.options.navBar).toHaveProperty("summary", navBarSummary);
|
|
555
|
-
});
|
|
556
|
-
|
|
557
|
-
it("leaves the other properties of the state unchanged", () => {
|
|
558
|
-
expect(newState.options.navBar).toHaveProperty(
|
|
559
|
-
"visible",
|
|
560
|
-
initialState.options.navBar.visible
|
|
561
|
-
);
|
|
562
|
-
|
|
563
|
-
expect(newState.options.navBar).toHaveProperty(
|
|
564
|
-
"title",
|
|
565
|
-
initialState.options.navBar.title
|
|
566
|
-
);
|
|
567
|
-
|
|
568
|
-
expect(newState.stack).toEqual(initialState.stack);
|
|
569
|
-
expect(newState.location).toEqual(initialState.location);
|
|
570
|
-
});
|
|
571
396
|
});
|
|
572
397
|
});
|
|
@@ -20,11 +20,6 @@ export const initialState: NavigationReducerState = {
|
|
|
20
20
|
},
|
|
21
21
|
location: { key: "", pathname: "/", state: null },
|
|
22
22
|
options: {
|
|
23
|
-
navBar: {
|
|
24
|
-
visible: true,
|
|
25
|
-
title: "",
|
|
26
|
-
summary: "",
|
|
27
|
-
},
|
|
28
23
|
videoModal: {
|
|
29
24
|
visible: false,
|
|
30
25
|
mode: MAXIMIZED, // VideoModalMode => MAXIMIZED | MINIMIZED | FULLSCREEN
|
|
@@ -43,9 +38,6 @@ export enum ACTIONS {
|
|
|
43
38
|
BACK_PLAYER_NESTED_CONTENT = "BACK_PLAYER_NESTED_CONTENT",
|
|
44
39
|
REPLACE_TOP = "REPLACE_TOP",
|
|
45
40
|
SET_NESTED_CONTENT = "SET_NESTED_CONTENT",
|
|
46
|
-
SET_NAV_BAR_VISIBILITY = "SET_NAV_BAR_VISIBILITY",
|
|
47
|
-
SET_NAV_BAR_TITLE = "SET_NAV_BAR_TITLE",
|
|
48
|
-
SET_NAV_BAR_SUMMARY = "SET_NAV_BAR_SUMMARY",
|
|
49
41
|
SET_LOCATION = "SET_LOCATION",
|
|
50
42
|
OPEN_VIDEO_MODAL = "OPEN_VIDEO_MODAL",
|
|
51
43
|
CLOSE_VIDEO_MODAL = "CLOSE_VIDEO_MODAL",
|
|
@@ -147,12 +139,16 @@ function updatePopActions(state) {
|
|
|
147
139
|
|
|
148
140
|
function removeTop(state, payload) {
|
|
149
141
|
let playNextState = [...state.mainStack];
|
|
150
|
-
|
|
151
|
-
const
|
|
142
|
+
|
|
143
|
+
const preloadHooks =
|
|
144
|
+
payload.entry?.targetScreen?.hooks?.preload_plugins || [];
|
|
145
|
+
|
|
146
|
+
const postloadHooks =
|
|
147
|
+
payload.entry?.targetScreen?.hooks?.postload_plugins || [];
|
|
152
148
|
|
|
153
149
|
const hooksScreenIds = new Set([
|
|
154
150
|
...preloadHooks.map((hook) => hook.screen_id),
|
|
155
|
-
...
|
|
151
|
+
...postloadHooks.map((hook) => hook.screen_id),
|
|
156
152
|
]);
|
|
157
153
|
|
|
158
154
|
playNextState = playNextState.filter(
|
|
@@ -398,39 +394,6 @@ export const videoModalReducer = (
|
|
|
398
394
|
}
|
|
399
395
|
};
|
|
400
396
|
|
|
401
|
-
/* Nav Bar reducer */
|
|
402
|
-
export const setNavBarVisibility = (payload) => ({
|
|
403
|
-
type: ACTIONS.SET_NAV_BAR_VISIBILITY,
|
|
404
|
-
payload,
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
export const setNavBarTitle = (payload) => ({
|
|
408
|
-
type: ACTIONS.SET_NAV_BAR_TITLE,
|
|
409
|
-
payload,
|
|
410
|
-
});
|
|
411
|
-
|
|
412
|
-
export const setNavBarSummary = (payload) => ({
|
|
413
|
-
type: ACTIONS.SET_NAV_BAR_SUMMARY,
|
|
414
|
-
payload,
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
const NAV_BAR_ACTIONS_PROPERTIES = {
|
|
418
|
-
[ACTIONS.SET_NAV_BAR_VISIBILITY]: "visible",
|
|
419
|
-
[ACTIONS.SET_NAV_BAR_TITLE]: "title",
|
|
420
|
-
[ACTIONS.SET_NAV_BAR_SUMMARY]: "summary",
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
export function navBarReducer(
|
|
424
|
-
state = initialState.options.navBar,
|
|
425
|
-
{ type, payload }
|
|
426
|
-
) {
|
|
427
|
-
if (R.includes(type, R.keys(NAV_BAR_ACTIONS_PROPERTIES))) {
|
|
428
|
-
return R.assoc(R.prop(type, NAV_BAR_ACTIONS_PROPERTIES), payload, state);
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
return state;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
397
|
const applyReducer = (reducer, action) => (state) => reducer(state, action);
|
|
435
398
|
|
|
436
399
|
export default function navigationReducer(
|
|
@@ -472,16 +435,6 @@ export default function navigationReducer(
|
|
|
472
435
|
state
|
|
473
436
|
);
|
|
474
437
|
|
|
475
|
-
case ACTIONS.SET_NAV_BAR_VISIBILITY:
|
|
476
|
-
case ACTIONS.SET_NAV_BAR_TITLE:
|
|
477
|
-
case ACTIONS.SET_NAV_BAR_SUMMARY:
|
|
478
|
-
return R.evolve(
|
|
479
|
-
{
|
|
480
|
-
options: { navBar: applyReducer(navBarReducer, { type, payload }) },
|
|
481
|
-
},
|
|
482
|
-
state
|
|
483
|
-
);
|
|
484
|
-
|
|
485
438
|
case ACTIONS.OPEN_VIDEO_MODAL:
|
|
486
439
|
case ACTIONS.CLOSE_VIDEO_MODAL:
|
|
487
440
|
case ACTIONS.SET_VIDEO_MODAL_ITEM:
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @flow
|
|
2
1
|
import * as R from "ramda";
|
|
3
2
|
import * as React from "react";
|
|
4
3
|
|
|
@@ -10,19 +9,16 @@ import {
|
|
|
10
9
|
} from "@applicaster/zapp-react-native-utils/objectUtils";
|
|
11
10
|
|
|
12
11
|
type Plugin = {
|
|
13
|
-
name: string
|
|
14
|
-
identifier: string
|
|
15
|
-
module: any
|
|
16
|
-
type:
|
|
17
|
-
configuration: { [string]: any }
|
|
12
|
+
name: string;
|
|
13
|
+
identifier: string;
|
|
14
|
+
module: any;
|
|
15
|
+
type: string;
|
|
16
|
+
configuration: { [key: string]: any };
|
|
18
17
|
};
|
|
19
18
|
|
|
20
19
|
type Props = {
|
|
21
|
-
children: React.
|
|
22
|
-
plugins: [
|
|
23
|
-
themes: { [string]: { [string]: any } },
|
|
24
|
-
selectedThemeId: string,
|
|
25
|
-
setSelectedThemeId: string,
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
plugins: Plugin[];
|
|
26
22
|
};
|
|
27
23
|
|
|
28
24
|
const DEFAULT_THEME_ID = "base-theme";
|
|
@@ -83,7 +79,7 @@ const ThemeContextProvider = ({
|
|
|
83
79
|
selectedThemeId,
|
|
84
80
|
setSelectedThemeId,
|
|
85
81
|
children,
|
|
86
|
-
}:
|
|
82
|
+
}: any) => {
|
|
87
83
|
const value = React.useMemo(
|
|
88
84
|
() => ({ themes, selectedThemeId, setSelectedThemeId }),
|
|
89
85
|
[themes, selectedThemeId, setSelectedThemeId]
|
|
@@ -94,7 +90,7 @@ const ThemeContextProvider = ({
|
|
|
94
90
|
);
|
|
95
91
|
};
|
|
96
92
|
|
|
97
|
-
function ThemeManagerComponent({ children, plugins }: Props)
|
|
93
|
+
function ThemeManagerComponent({ children, plugins }: Props) {
|
|
98
94
|
const dimensions = useDimensions("screen", { deviceInfo: true });
|
|
99
95
|
const [themes, setThemes] = React.useState(selectThemes(dimensions, plugins));
|
|
100
96
|
|