@applicaster/quick-brick-core 14.0.0-alpha.5219335081 → 14.0.0-alpha.5234792518
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/ModalProvider/ModalBottomSheet/DraggableBottomSheet/index.tsx +2 -2
- package/App/ModalProvider/ModalChildrenWrapper/index.tsx +2 -7
- package/App/ModalProvider/ModalPresenter.tsx +2 -1
- package/App/NavigationProvider/NavigationProvider.tsx +31 -9
- package/App/NavigationProvider/navigator/__tests__/__snapshots__/reducer.test.ts.snap +0 -177
- package/App/NavigationProvider/navigator/__tests__/reducer.test.ts +2 -70
- package/App/NavigationProvider/navigator/reducer.ts +30 -101
- package/App/RouterDecorator/__tests__/routerDecorator.test.js +3 -3
- package/App/__tests__/createQuickBrickApp.test.js +7 -7
- package/App/components/ZappAppWrapper.ts +3 -0
- package/App/components/ZappAppWrapper.web.ts +3 -0
- package/App/index.tsx +28 -25
- package/createZappApp/__tests__/createZappApp.test.js +11 -0
- package/index.d.ts +0 -1
- package/package.json +8 -8
|
@@ -52,9 +52,9 @@ export class DraggableBottomSheet extends Component<Props, ComponentState> {
|
|
|
52
52
|
_lastScrollYValue: number;
|
|
53
53
|
_lastScrollY: Animated.Value;
|
|
54
54
|
_dragY: Animated.Value;
|
|
55
|
-
_reverseLastScrollY: Animated.
|
|
55
|
+
_reverseLastScrollY: Animated.AnimatedInterpolation<number>;
|
|
56
56
|
_translateYOffset: Animated.Value;
|
|
57
|
-
_translateY: Animated.
|
|
57
|
+
_translateY: Animated.AnimatedInterpolation<number>;
|
|
58
58
|
_snapPoints: SnapPoints;
|
|
59
59
|
_prevContentHeight = 0;
|
|
60
60
|
|
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import React, { ReactChild } from "react";
|
|
2
|
-
import { StyleSheet, ViewProps } from "react-native";
|
|
3
|
-
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
|
2
|
+
import { View, StyleSheet, ViewProps } from "react-native";
|
|
4
3
|
|
|
5
4
|
type Props = ViewProps & { children: ReactChild };
|
|
6
5
|
|
|
7
6
|
export function ModalChildrenWrapper({ children }: Props) {
|
|
8
|
-
return
|
|
9
|
-
<GestureHandlerRootView style={StyleSheet.absoluteFill}>
|
|
10
|
-
{children}
|
|
11
|
-
</GestureHandlerRootView>
|
|
12
|
-
);
|
|
7
|
+
return <View style={StyleSheet.absoluteFill}>{children}</View>;
|
|
13
8
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Modal, ModalProps } from "react-native";
|
|
3
|
+
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
|
3
4
|
|
|
4
5
|
type Props = ModalProps & {
|
|
5
6
|
children: React.ReactChild;
|
|
@@ -13,7 +14,7 @@ export function ModalPresenter(props: Props) {
|
|
|
13
14
|
|
|
14
15
|
return (
|
|
15
16
|
<Presenter visible={visible} {...presenterOptions}>
|
|
16
|
-
{children}
|
|
17
|
+
<GestureHandlerRootView>{children}</GestureHandlerRootView>
|
|
17
18
|
</Presenter>
|
|
18
19
|
);
|
|
19
20
|
}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
getTargetRoute,
|
|
8
8
|
usesVideoModal,
|
|
9
9
|
} from "@applicaster/zapp-react-native-utils/navigationUtils";
|
|
10
|
+
import { last } from "@applicaster/zapp-react-native-utils/utils";
|
|
10
11
|
import {
|
|
11
12
|
allowedOrientationsForScreen,
|
|
12
13
|
useGetScreenOrientation,
|
|
@@ -79,6 +80,8 @@ import { URLSchemeContext } from "../DeepLinking/URLSchemeListener/URLSchemeCont
|
|
|
79
80
|
|
|
80
81
|
import { loadingOverlayManager } from "../LoadingOverlay";
|
|
81
82
|
|
|
83
|
+
|
|
84
|
+
|
|
82
85
|
const logger = coreAppLogger.addSubsystem("Navigator");
|
|
83
86
|
|
|
84
87
|
type Props = {
|
|
@@ -121,8 +124,20 @@ export function NavigationProvider({ children }: Props) {
|
|
|
121
124
|
NavigationReducerState
|
|
122
125
|
>(reducer, initialState, (x) => x);
|
|
123
126
|
|
|
127
|
+
const topStackRoute = last(state?.stack?.mainStack);
|
|
128
|
+
|
|
129
|
+
/** TODO: temporary variable, before we remove need for a "current".
|
|
130
|
+
There is no current as we are using stack navigator. Route data should be contextualised per screen
|
|
131
|
+
There are some cases to use a route data from top of the stack but it should be separate method.
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
const currentLocation = {
|
|
135
|
+
...topStackRoute,
|
|
136
|
+
route: topStackRoute?.route || "/", // Fallback for initial state.
|
|
137
|
+
};
|
|
138
|
+
|
|
124
139
|
const stateRef = React.useRef<NavigationReducerState>(state);
|
|
125
|
-
const pathname =
|
|
140
|
+
const pathname = currentLocation?.route; // TODO: remove. Pathname is part of the route, not a global.
|
|
126
141
|
const pathnameRef = React.useRef(pathname);
|
|
127
142
|
|
|
128
143
|
const { context } = React.useContext(ZappPipesEntryContext.Context);
|
|
@@ -146,6 +161,8 @@ export function NavigationProvider({ children }: Props) {
|
|
|
146
161
|
}
|
|
147
162
|
}, [pathname]);
|
|
148
163
|
|
|
164
|
+
// TODO remove.
|
|
165
|
+
// There is no concept of active river. Multiple rivers can be rendered at the same time.
|
|
149
166
|
const activeRiver = React.useMemo(
|
|
150
167
|
() => activeRiverSelector({ pathname, rivers }),
|
|
151
168
|
[pathname, rivers]
|
|
@@ -186,6 +203,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
186
203
|
// TODO: Move in proper place
|
|
187
204
|
const modalPresenterScreenOrientation = useGetScreenOrientation(activeRiver);
|
|
188
205
|
|
|
206
|
+
// TODO: Move modal state to separate store
|
|
189
207
|
const closeVideoModal = () => {
|
|
190
208
|
if (navigator.modalData) {
|
|
191
209
|
allowedOrientationsForScreen(modalPresenterScreenOrientation);
|
|
@@ -213,13 +231,15 @@ export function NavigationProvider({ children }: Props) {
|
|
|
213
231
|
const isVideoModalDocked = () =>
|
|
214
232
|
state?.options.videoModal.mode === "MINIMIZED";
|
|
215
233
|
|
|
234
|
+
// TODO: Remove as it's using a concept of "current" route.
|
|
235
|
+
// Route is contextualised and shouldn't be used this way.
|
|
216
236
|
const routeData = () => {
|
|
217
237
|
// eslint-disable-next-line no-console
|
|
218
238
|
console.warn(`you are retrieving screen data from navigator.routeData()
|
|
219
239
|
This function will be removed in a later version of quick brick.
|
|
220
240
|
You can retrieve this data from navigator.screenData`);
|
|
221
241
|
|
|
222
|
-
return legacyScreenData(
|
|
242
|
+
return legacyScreenData(currentLocation?.state as NavigationScreenData);
|
|
223
243
|
};
|
|
224
244
|
|
|
225
245
|
// TODO: remove it by refactoring back buttons handlers
|
|
@@ -262,7 +282,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
262
282
|
if (
|
|
263
283
|
targetRoute !== pathnameRef.current ||
|
|
264
284
|
item?.id !==
|
|
265
|
-
legacyScreenData(
|
|
285
|
+
legacyScreenData(currentLocation?.state as NavigationScreenData)?.id
|
|
266
286
|
) {
|
|
267
287
|
replaceEvent();
|
|
268
288
|
navigateTo(item, ACTIONS.REPLACE, options);
|
|
@@ -688,7 +708,8 @@ export function NavigationProvider({ children }: Props) {
|
|
|
688
708
|
}
|
|
689
709
|
}, [state?.options?.videoModal?.previousMode]);
|
|
690
710
|
|
|
691
|
-
|
|
711
|
+
// TODO: remove. This shouldn't be part of navigator
|
|
712
|
+
const getNestedEntry = () => currentLocation?.state?.nested?.entry ?? null;
|
|
692
713
|
|
|
693
714
|
// It will only work for the regular stack and pathname, It won't work for modals
|
|
694
715
|
// TODO: integrate video/hook and regular modal into stack.
|
|
@@ -706,7 +727,7 @@ export function NavigationProvider({ children }: Props) {
|
|
|
706
727
|
() => ({
|
|
707
728
|
activeRiver,
|
|
708
729
|
getPathname: () => pathnameRef.current, // hack use to fix issue causing broken navigation as currentRoute is unreliable
|
|
709
|
-
currentRoute: pathname,
|
|
730
|
+
currentRoute: pathname, // TODO: remove. Current route shouldn't be needed
|
|
710
731
|
previousAction: lastEntrySelector(state)
|
|
711
732
|
?.action as QuickBrickNavigationActionType,
|
|
712
733
|
push: pushItem,
|
|
@@ -716,14 +737,15 @@ export function NavigationProvider({ children }: Props) {
|
|
|
716
737
|
goHome,
|
|
717
738
|
canGoBack,
|
|
718
739
|
goBack,
|
|
719
|
-
routeData,
|
|
740
|
+
routeData, // TODO: remove
|
|
720
741
|
screenData: legacyScreenData(
|
|
721
|
-
|
|
742
|
+
// TODO: remove
|
|
743
|
+
currentLocation?.state as NavigationScreenData,
|
|
722
744
|
plugins
|
|
723
745
|
),
|
|
724
|
-
data:
|
|
746
|
+
data: currentLocation?.state as NavigationScreenData,
|
|
725
747
|
getNestedEntry,
|
|
726
|
-
key:
|
|
748
|
+
key: currentLocation?.key, // TODO: remove
|
|
727
749
|
modalData: state.stack.modal?.state ?? null,
|
|
728
750
|
openModal,
|
|
729
751
|
dismissModal,
|
|
@@ -13,7 +13,6 @@ exports[`ACTIONS matches snapshot 1`] = `
|
|
|
13
13
|
"PUSH": "PUSH",
|
|
14
14
|
"REPLACE": "REPLACE",
|
|
15
15
|
"REPLACE_TOP": "REPLACE_TOP",
|
|
16
|
-
"SET_LOCATION": "SET_LOCATION",
|
|
17
16
|
"SET_NESTED_CONTENT": "SET_NESTED_CONTENT",
|
|
18
17
|
"SET_VIDEO_MODAL_ITEM": "SET_VIDEO_MODAL_ITEM",
|
|
19
18
|
}
|
|
@@ -22,30 +21,6 @@ exports[`ACTIONS matches snapshot 1`] = `
|
|
|
22
21
|
exports[`reducer when a back action is dispatched push, back, push, back does what it's supposed to do 1`] = `
|
|
23
22
|
{
|
|
24
23
|
"state1": {
|
|
25
|
-
"location": {
|
|
26
|
-
"key": "mocked-uuid",
|
|
27
|
-
"pathname": "/river/A1234",
|
|
28
|
-
"state": {
|
|
29
|
-
"entry": undefined,
|
|
30
|
-
"options": undefined,
|
|
31
|
-
"screen": {
|
|
32
|
-
"home": true,
|
|
33
|
-
"home_offline": true,
|
|
34
|
-
"hooks": {
|
|
35
|
-
"preload_plugins": [],
|
|
36
|
-
},
|
|
37
|
-
"id": "A1234",
|
|
38
|
-
"name": "Home",
|
|
39
|
-
"navigations": [
|
|
40
|
-
{
|
|
41
|
-
"id": "nav_id",
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
"supports_offline": false,
|
|
45
|
-
"type": "general_content",
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
24
|
"options": {
|
|
50
25
|
"videoModal": {
|
|
51
26
|
"item": null,
|
|
@@ -86,36 +61,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
86
61
|
},
|
|
87
62
|
},
|
|
88
63
|
"state2": {
|
|
89
|
-
"location": {
|
|
90
|
-
"key": "mocked-uuid",
|
|
91
|
-
"pathname": "/river/A1234/river/B7890",
|
|
92
|
-
"state": {
|
|
93
|
-
"entry": {
|
|
94
|
-
"id": "C0987",
|
|
95
|
-
"title": "Entry",
|
|
96
|
-
"type": {
|
|
97
|
-
"value": "feed",
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
"options": undefined,
|
|
101
|
-
"screen": {
|
|
102
|
-
"home": false,
|
|
103
|
-
"home_offline": false,
|
|
104
|
-
"hooks": {
|
|
105
|
-
"preload_plugins": [],
|
|
106
|
-
},
|
|
107
|
-
"id": "B5678",
|
|
108
|
-
"name": "Screen name",
|
|
109
|
-
"navigations": [
|
|
110
|
-
{
|
|
111
|
-
"id": "nav_id",
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
"supports_offline": false,
|
|
115
|
-
"type": "general_content",
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
64
|
"options": {
|
|
120
65
|
"videoModal": {
|
|
121
66
|
"item": null,
|
|
@@ -187,36 +132,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
187
132
|
},
|
|
188
133
|
},
|
|
189
134
|
"state3": {
|
|
190
|
-
"location": {
|
|
191
|
-
"key": "mocked-uuid",
|
|
192
|
-
"pathname": "/river/A1234/river/B7890/river/C0987",
|
|
193
|
-
"state": {
|
|
194
|
-
"entry": {
|
|
195
|
-
"id": "D1234",
|
|
196
|
-
"title": "Entry 2",
|
|
197
|
-
"type": {
|
|
198
|
-
"value": "video",
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
"options": undefined,
|
|
202
|
-
"screen": {
|
|
203
|
-
"home": false,
|
|
204
|
-
"home_offline": false,
|
|
205
|
-
"hooks": {
|
|
206
|
-
"preload_plugins": [],
|
|
207
|
-
},
|
|
208
|
-
"id": "C9090",
|
|
209
|
-
"name": "Screen 2 name",
|
|
210
|
-
"navigations": [
|
|
211
|
-
{
|
|
212
|
-
"id": "nav_id",
|
|
213
|
-
},
|
|
214
|
-
],
|
|
215
|
-
"supports_offline": false,
|
|
216
|
-
"type": "general_content",
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
},
|
|
220
135
|
"options": {
|
|
221
136
|
"videoModal": {
|
|
222
137
|
"item": null,
|
|
@@ -319,37 +234,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
319
234
|
},
|
|
320
235
|
},
|
|
321
236
|
"state4": {
|
|
322
|
-
"location": {
|
|
323
|
-
"action": "PUSH",
|
|
324
|
-
"key": "mocked-uuid",
|
|
325
|
-
"pathname": "/river/A1234/river/B7890",
|
|
326
|
-
"state": {
|
|
327
|
-
"entry": {
|
|
328
|
-
"id": "C0987",
|
|
329
|
-
"title": "Entry",
|
|
330
|
-
"type": {
|
|
331
|
-
"value": "feed",
|
|
332
|
-
},
|
|
333
|
-
},
|
|
334
|
-
"options": undefined,
|
|
335
|
-
"screen": {
|
|
336
|
-
"home": false,
|
|
337
|
-
"home_offline": false,
|
|
338
|
-
"hooks": {
|
|
339
|
-
"preload_plugins": [],
|
|
340
|
-
},
|
|
341
|
-
"id": "B5678",
|
|
342
|
-
"name": "Screen name",
|
|
343
|
-
"navigations": [
|
|
344
|
-
{
|
|
345
|
-
"id": "nav_id",
|
|
346
|
-
},
|
|
347
|
-
],
|
|
348
|
-
"supports_offline": false,
|
|
349
|
-
"type": "general_content",
|
|
350
|
-
},
|
|
351
|
-
},
|
|
352
|
-
},
|
|
353
237
|
"options": {
|
|
354
238
|
"videoModal": {
|
|
355
239
|
"item": null,
|
|
@@ -421,36 +305,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
421
305
|
},
|
|
422
306
|
},
|
|
423
307
|
"state5": {
|
|
424
|
-
"location": {
|
|
425
|
-
"key": "mocked-uuid",
|
|
426
|
-
"pathname": "/river/A1234/river/B7890/river/D5678",
|
|
427
|
-
"state": {
|
|
428
|
-
"entry": {
|
|
429
|
-
"id": "C0987",
|
|
430
|
-
"title": "Entry",
|
|
431
|
-
"type": {
|
|
432
|
-
"value": "feed",
|
|
433
|
-
},
|
|
434
|
-
},
|
|
435
|
-
"options": undefined,
|
|
436
|
-
"screen": {
|
|
437
|
-
"home": false,
|
|
438
|
-
"home_offline": false,
|
|
439
|
-
"hooks": {
|
|
440
|
-
"preload_plugins": [],
|
|
441
|
-
},
|
|
442
|
-
"id": "B5678",
|
|
443
|
-
"name": "Screen name",
|
|
444
|
-
"navigations": [
|
|
445
|
-
{
|
|
446
|
-
"id": "nav_id",
|
|
447
|
-
},
|
|
448
|
-
],
|
|
449
|
-
"supports_offline": false,
|
|
450
|
-
"type": "general_content",
|
|
451
|
-
},
|
|
452
|
-
},
|
|
453
|
-
},
|
|
454
308
|
"options": {
|
|
455
309
|
"videoModal": {
|
|
456
310
|
"item": null,
|
|
@@ -553,37 +407,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
|
|
|
553
407
|
},
|
|
554
408
|
},
|
|
555
409
|
"state6": {
|
|
556
|
-
"location": {
|
|
557
|
-
"action": "PUSH",
|
|
558
|
-
"key": "mocked-uuid",
|
|
559
|
-
"pathname": "/river/A1234/river/B7890",
|
|
560
|
-
"state": {
|
|
561
|
-
"entry": {
|
|
562
|
-
"id": "C0987",
|
|
563
|
-
"title": "Entry",
|
|
564
|
-
"type": {
|
|
565
|
-
"value": "feed",
|
|
566
|
-
},
|
|
567
|
-
},
|
|
568
|
-
"options": undefined,
|
|
569
|
-
"screen": {
|
|
570
|
-
"home": false,
|
|
571
|
-
"home_offline": false,
|
|
572
|
-
"hooks": {
|
|
573
|
-
"preload_plugins": [],
|
|
574
|
-
},
|
|
575
|
-
"id": "B5678",
|
|
576
|
-
"name": "Screen name",
|
|
577
|
-
"navigations": [
|
|
578
|
-
{
|
|
579
|
-
"id": "nav_id",
|
|
580
|
-
},
|
|
581
|
-
],
|
|
582
|
-
"supports_offline": false,
|
|
583
|
-
"type": "general_content",
|
|
584
|
-
},
|
|
585
|
-
},
|
|
586
|
-
},
|
|
587
410
|
"options": {
|
|
588
411
|
"videoModal": {
|
|
589
412
|
"item": null,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import reducer, {
|
|
2
2
|
ACTIONS,
|
|
3
|
-
push,
|
|
4
|
-
replace,
|
|
5
3
|
back,
|
|
6
4
|
initialState,
|
|
5
|
+
push,
|
|
6
|
+
replace,
|
|
7
7
|
} from "../reducer";
|
|
8
8
|
|
|
9
9
|
jest.mock("uuid");
|
|
@@ -181,24 +181,6 @@ describe("reducer", () => {
|
|
|
181
181
|
expect(newState.options.navBar).toEqual(initialState.options.navBar);
|
|
182
182
|
expect(newState2.options.navBar).toEqual(initialState.options.navBar);
|
|
183
183
|
});
|
|
184
|
-
|
|
185
|
-
it("updates the location properties of the state", () => {
|
|
186
|
-
expect(newState).toHaveProperty("location");
|
|
187
|
-
expect(newState.location).toHaveProperty("pathname", route);
|
|
188
|
-
|
|
189
|
-
expect(newState.location).toHaveProperty("state", { screen: homeScreen });
|
|
190
|
-
|
|
191
|
-
expect(newState2).toHaveProperty("location");
|
|
192
|
-
expect(newState2.location).toHaveProperty("pathname", route2);
|
|
193
|
-
|
|
194
|
-
expect(newState2.location).toHaveProperty(
|
|
195
|
-
"state",
|
|
196
|
-
expect.objectContaining({
|
|
197
|
-
screen,
|
|
198
|
-
entry,
|
|
199
|
-
})
|
|
200
|
-
);
|
|
201
|
-
});
|
|
202
184
|
});
|
|
203
185
|
|
|
204
186
|
describe("when a replace action is dispatched", () => {
|
|
@@ -245,24 +227,6 @@ describe("reducer", () => {
|
|
|
245
227
|
expect(newState.options.navBar).toEqual(initialState.options.navBar);
|
|
246
228
|
expect(newState2.options.navBar).toEqual(initialState.options.navBar);
|
|
247
229
|
});
|
|
248
|
-
|
|
249
|
-
it("updates the location properties of the state", () => {
|
|
250
|
-
expect(newState).toHaveProperty("location");
|
|
251
|
-
expect(newState.location).toHaveProperty("pathname", route);
|
|
252
|
-
|
|
253
|
-
expect(newState.location).toHaveProperty("state", {
|
|
254
|
-
screen: homeScreen,
|
|
255
|
-
entry: undefined,
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
expect(newState2).toHaveProperty("location");
|
|
259
|
-
expect(newState2.location).toHaveProperty("pathname", route2);
|
|
260
|
-
|
|
261
|
-
expect(newState2.location).toHaveProperty("state", {
|
|
262
|
-
screen,
|
|
263
|
-
entry,
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
230
|
});
|
|
267
231
|
|
|
268
232
|
describe("when a back action is dispatched", () => {
|
|
@@ -300,30 +264,6 @@ describe("reducer", () => {
|
|
|
300
264
|
expect(newState2.options.navBar).toEqual(initialState.options.navBar);
|
|
301
265
|
expect(finalState.options.navBar).toEqual(initialState.options.navBar);
|
|
302
266
|
});
|
|
303
|
-
|
|
304
|
-
it("updates the location properties of the state", () => {
|
|
305
|
-
expect(newState).toHaveProperty("location");
|
|
306
|
-
expect(newState.location).toHaveProperty("pathname", route);
|
|
307
|
-
|
|
308
|
-
expect(newState.location).toHaveProperty("state", {
|
|
309
|
-
screen: homeScreen,
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
expect(newState2).toHaveProperty("location");
|
|
313
|
-
expect(newState2.location).toHaveProperty("pathname", route2);
|
|
314
|
-
|
|
315
|
-
expect(newState2.location).toHaveProperty("state", {
|
|
316
|
-
screen,
|
|
317
|
-
entry,
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
expect(finalState).toHaveProperty("location");
|
|
321
|
-
expect(finalState.location).toHaveProperty("pathname", route);
|
|
322
|
-
|
|
323
|
-
expect(finalState.location).toHaveProperty("state", {
|
|
324
|
-
screen: homeScreen,
|
|
325
|
-
});
|
|
326
|
-
});
|
|
327
267
|
});
|
|
328
268
|
|
|
329
269
|
describe("push, back, push, back", () => {
|
|
@@ -382,14 +322,6 @@ describe("reducer", () => {
|
|
|
382
322
|
entry: undefined,
|
|
383
323
|
});
|
|
384
324
|
|
|
385
|
-
expect(finalState).toHaveProperty("location");
|
|
386
|
-
expect(finalState.location).toHaveProperty("pathname", route);
|
|
387
|
-
|
|
388
|
-
expect(finalState.location).toHaveProperty("state", {
|
|
389
|
-
screen: homeScreen,
|
|
390
|
-
entry: undefined,
|
|
391
|
-
});
|
|
392
|
-
|
|
393
325
|
expect(finalState).toEqual(newState);
|
|
394
326
|
});
|
|
395
327
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as R from "ramda";
|
|
2
2
|
import { v4 } from "uuid";
|
|
3
3
|
|
|
4
|
+
import { last } from "@applicaster/zapp-react-native-utils/utils";
|
|
5
|
+
|
|
4
6
|
import {
|
|
5
7
|
firstStackEntriesSelector,
|
|
6
8
|
previousStackEntriesSelector,
|
|
@@ -18,7 +20,6 @@ export const initialState: NavigationReducerState = {
|
|
|
18
20
|
mainStack: [],
|
|
19
21
|
modal: null,
|
|
20
22
|
},
|
|
21
|
-
location: { key: "", pathname: "/", state: null },
|
|
22
23
|
options: {
|
|
23
24
|
videoModal: {
|
|
24
25
|
visible: false,
|
|
@@ -38,7 +39,6 @@ export enum ACTIONS {
|
|
|
38
39
|
BACK_PLAYER_NESTED_CONTENT = "BACK_PLAYER_NESTED_CONTENT",
|
|
39
40
|
REPLACE_TOP = "REPLACE_TOP",
|
|
40
41
|
SET_NESTED_CONTENT = "SET_NESTED_CONTENT",
|
|
41
|
-
SET_LOCATION = "SET_LOCATION",
|
|
42
42
|
OPEN_VIDEO_MODAL = "OPEN_VIDEO_MODAL",
|
|
43
43
|
CLOSE_VIDEO_MODAL = "CLOSE_VIDEO_MODAL",
|
|
44
44
|
MINIMISE_VIDEO_MODAL = "MINIMISE_VIDEO_MODAL",
|
|
@@ -174,9 +174,9 @@ function backPlayerNestedContent(state) {
|
|
|
174
174
|
return findPlayableAndTruncate(currentState);
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
function addNestedContent(stack, payload,
|
|
178
|
-
const
|
|
179
|
-
const stackIndex = R.findIndex(R.propEq("key",
|
|
177
|
+
function addNestedContent(stack, payload, targetStackEntry) {
|
|
178
|
+
const targetStackKey = targetStackEntry.key;
|
|
179
|
+
const stackIndex = R.findIndex(R.propEq("key", targetStackKey))(stack);
|
|
180
180
|
|
|
181
181
|
return R.adjust(
|
|
182
182
|
stackIndex,
|
|
@@ -190,7 +190,7 @@ function addNestedContent(stack, payload, locationState: LocationReducerState) {
|
|
|
190
190
|
|
|
191
191
|
function navigationStackReducer(
|
|
192
192
|
state: NavigationStackReducerState = initialState.stack,
|
|
193
|
-
{ type = "", payload
|
|
193
|
+
{ type = "", payload }: ReducerAction = { type: "" }
|
|
194
194
|
) {
|
|
195
195
|
switch (type) {
|
|
196
196
|
case ACTIONS.SET_NESTED_CONTENT:
|
|
@@ -199,7 +199,7 @@ function navigationStackReducer(
|
|
|
199
199
|
mainStack: addNestedContent(
|
|
200
200
|
state.mainStack,
|
|
201
201
|
navigationEntry(ACTIONS.REPLACE, payload as AnyRecord),
|
|
202
|
-
|
|
202
|
+
last(state.mainStack)
|
|
203
203
|
),
|
|
204
204
|
};
|
|
205
205
|
case ACTIONS.PUSH:
|
|
@@ -268,47 +268,6 @@ function navigationStackReducer(
|
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
-
function locationReducer(
|
|
272
|
-
state = initialState.location,
|
|
273
|
-
{ type, payload, meta = {} }
|
|
274
|
-
) {
|
|
275
|
-
const { route, key, screen, entry, options } = payload;
|
|
276
|
-
|
|
277
|
-
switch (type) {
|
|
278
|
-
case ACTIONS.BACK:
|
|
279
|
-
// eslint-disable-next-line no-case-declarations
|
|
280
|
-
const previousEntry = R.compose(
|
|
281
|
-
R.last,
|
|
282
|
-
payload.route ? firstStackEntriesSelector : previousStackEntriesSelector
|
|
283
|
-
)(meta);
|
|
284
|
-
|
|
285
|
-
if (previousEntry) {
|
|
286
|
-
const { state, key, action } = previousEntry;
|
|
287
|
-
|
|
288
|
-
return { pathname: previousEntry.route, state, key, action };
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
return state;
|
|
292
|
-
|
|
293
|
-
case ACTIONS.PUSH:
|
|
294
|
-
case ACTIONS.REPLACE:
|
|
295
|
-
case ACTIONS.REPLACE_TOP:
|
|
296
|
-
case ACTIONS.BACK_PLAYER_NESTED_CONTENT:
|
|
297
|
-
return { pathname: route, state: { screen, entry, options }, key };
|
|
298
|
-
|
|
299
|
-
case ACTIONS.SET_NESTED_CONTENT:
|
|
300
|
-
// eslint-disable-next-line no-case-declarations
|
|
301
|
-
const nestedEntry = navigationEntry(
|
|
302
|
-
ACTIONS.REPLACE,
|
|
303
|
-
payload as AnyRecord
|
|
304
|
-
);
|
|
305
|
-
|
|
306
|
-
return R.assocPath(["state", "nested"], nestedEntry.state, state);
|
|
307
|
-
default:
|
|
308
|
-
return state;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
271
|
/* Video Modal reducer */
|
|
313
272
|
export const setVideoModalOpen = (item, options, screen) => ({
|
|
314
273
|
type: ACTIONS.OPEN_VIDEO_MODAL,
|
|
@@ -354,43 +313,28 @@ export const videoModalReducer = (
|
|
|
354
313
|
switch (type) {
|
|
355
314
|
case ACTIONS.OPEN_VIDEO_MODAL: {
|
|
356
315
|
const { item, options } = payload;
|
|
316
|
+
const mode = options?.mode || MAXIMIZED;
|
|
357
317
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
R.lensProp("item"),
|
|
365
|
-
R.unless(R.tryCatch(R.propEq("id", item?.id), R.F), () => item)
|
|
366
|
-
)
|
|
367
|
-
)(state);
|
|
318
|
+
return {
|
|
319
|
+
...state,
|
|
320
|
+
visible: true,
|
|
321
|
+
mode,
|
|
322
|
+
item: state.item?.id !== item?.id ? item : state.item,
|
|
323
|
+
};
|
|
368
324
|
}
|
|
369
325
|
|
|
370
326
|
case ACTIONS.SET_VIDEO_MODAL_ITEM:
|
|
371
|
-
return
|
|
327
|
+
return { ...state, item: payload };
|
|
372
328
|
case ACTIONS.CLOSE_VIDEO_MODAL:
|
|
373
329
|
return initialState.options.videoModal;
|
|
374
330
|
case ACTIONS.FULLSCREEN_VIDEO_MODAL:
|
|
375
|
-
return
|
|
376
|
-
R.set(R.lensProp("mode"), FULLSCREEN),
|
|
377
|
-
R.set(R.lensProp("previousMode"), state.mode)
|
|
378
|
-
)(state);
|
|
331
|
+
return { ...state, mode: FULLSCREEN, previousMode: state.mode };
|
|
379
332
|
case ACTIONS.MINIMISE_VIDEO_MODAL:
|
|
380
|
-
return
|
|
381
|
-
R.set(R.lensProp("mode"), MINIMIZED),
|
|
382
|
-
R.set(R.lensProp("previousMode"), state.mode)
|
|
383
|
-
)(state);
|
|
333
|
+
return { ...state, mode: MINIMIZED, previousMode: state.mode };
|
|
384
334
|
case ACTIONS.MAXIMISE_VIDEO_MODAL:
|
|
385
|
-
return
|
|
386
|
-
R.set(R.lensProp("mode"), MAXIMIZED),
|
|
387
|
-
R.set(R.lensProp("previousMode"), state.mode)
|
|
388
|
-
)(state);
|
|
335
|
+
return { ...state, mode: MAXIMIZED, previousMode: state.mode };
|
|
389
336
|
case ACTIONS.PIP:
|
|
390
|
-
return
|
|
391
|
-
R.set(R.lensProp("mode"), PIP),
|
|
392
|
-
R.set(R.lensProp("previousMode"), state.mode)
|
|
393
|
-
)(state);
|
|
337
|
+
return { ...state, mode: PIP, previousMode: state.mode };
|
|
394
338
|
}
|
|
395
339
|
};
|
|
396
340
|
|
|
@@ -406,34 +350,19 @@ export default function navigationReducer(
|
|
|
406
350
|
case ACTIONS.REPLACE_TOP:
|
|
407
351
|
case ACTIONS.BACK:
|
|
408
352
|
case ACTIONS.BACK_PLAYER_NESTED_CONTENT:
|
|
409
|
-
return
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
type,
|
|
414
|
-
payload,
|
|
415
|
-
meta: state,
|
|
416
|
-
}),
|
|
417
|
-
},
|
|
418
|
-
state
|
|
419
|
-
);
|
|
353
|
+
return {
|
|
354
|
+
...state,
|
|
355
|
+
stack: navigationStackReducer(state.stack, { type, payload }),
|
|
356
|
+
};
|
|
420
357
|
|
|
421
358
|
case ACTIONS.SET_NESTED_CONTENT:
|
|
422
|
-
return
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
location: applyReducer(locationReducer, {
|
|
430
|
-
type,
|
|
431
|
-
payload,
|
|
432
|
-
meta: state.stack,
|
|
433
|
-
}),
|
|
434
|
-
},
|
|
435
|
-
state
|
|
436
|
-
);
|
|
359
|
+
return {
|
|
360
|
+
...state,
|
|
361
|
+
stack: navigationStackReducer(state.stack, {
|
|
362
|
+
type,
|
|
363
|
+
payload,
|
|
364
|
+
}),
|
|
365
|
+
};
|
|
437
366
|
|
|
438
367
|
case ACTIONS.OPEN_VIDEO_MODAL:
|
|
439
368
|
case ACTIONS.CLOSE_VIDEO_MODAL:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
import
|
|
3
|
+
import { render } from "@testing-library/react-native";
|
|
4
4
|
|
|
5
5
|
import { createRouterDecorator } from "../index";
|
|
6
6
|
|
|
@@ -26,7 +26,7 @@ describe("routerDecorator", () => {
|
|
|
26
26
|
const decorator = createRouterDecorator(Router);
|
|
27
27
|
const DecoratedComp = decorator(SomeComp);
|
|
28
28
|
|
|
29
|
-
const
|
|
30
|
-
expect(
|
|
29
|
+
const { toJSON } = render(<DecoratedComp foo="bar" />);
|
|
30
|
+
expect(toJSON()).toMatchSnapshot();
|
|
31
31
|
});
|
|
32
32
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable indent */
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import
|
|
3
|
+
import { render } from "@testing-library/react-native";
|
|
4
4
|
import { Provider } from "react-redux";
|
|
5
5
|
import thunk from "redux-thunk";
|
|
6
6
|
import configureStore from "redux-mock-store";
|
|
@@ -175,13 +175,13 @@ describe("createQuickBrickApp", () => {
|
|
|
175
175
|
it("returns a react component and it renders correctly", () => {
|
|
176
176
|
const QuickBrickApp = createQuickBrickApp(options);
|
|
177
177
|
|
|
178
|
-
const
|
|
178
|
+
const { toJSON } = render(
|
|
179
179
|
<Provider store={store}>
|
|
180
180
|
<QuickBrickApp store={store} />
|
|
181
181
|
</Provider>
|
|
182
182
|
);
|
|
183
183
|
|
|
184
|
-
expect(
|
|
184
|
+
expect(toJSON()).toMatchSnapshot();
|
|
185
185
|
});
|
|
186
186
|
|
|
187
187
|
describe("with no InteractionManager", () => {
|
|
@@ -190,13 +190,13 @@ describe("createQuickBrickApp", () => {
|
|
|
190
190
|
const { InteractionManager, ...otherOptions } = options;
|
|
191
191
|
const QuickBrickApp = createQuickBrickApp(otherOptions);
|
|
192
192
|
|
|
193
|
-
const
|
|
193
|
+
const { toJSON } = render(
|
|
194
194
|
<Provider store={store}>
|
|
195
195
|
<QuickBrickApp store={store} />
|
|
196
196
|
</Provider>
|
|
197
197
|
);
|
|
198
198
|
|
|
199
|
-
expect(
|
|
199
|
+
expect(toJSON()).toMatchSnapshot();
|
|
200
200
|
});
|
|
201
201
|
});
|
|
202
202
|
|
|
@@ -206,13 +206,13 @@ describe("createQuickBrickApp", () => {
|
|
|
206
206
|
const { ContextProviders, ...otherOptions } = options;
|
|
207
207
|
const QuickBrickApp = createQuickBrickApp(otherOptions);
|
|
208
208
|
|
|
209
|
-
const
|
|
209
|
+
const { toJSON } = render(
|
|
210
210
|
<Provider store={store}>
|
|
211
211
|
<QuickBrickApp store={store} />
|
|
212
212
|
</Provider>
|
|
213
213
|
);
|
|
214
214
|
|
|
215
|
-
expect(
|
|
215
|
+
expect(toJSON()).toMatchSnapshot();
|
|
216
216
|
});
|
|
217
217
|
});
|
|
218
218
|
});
|
package/App/index.tsx
CHANGED
|
@@ -31,6 +31,7 @@ import { withActionExecutor } from "@applicaster/zapp-react-native-utils/actions
|
|
|
31
31
|
import { withScreenDataContextProvider } from "@applicaster/zapp-react-native-ui-components/Contexts/ScreenDataContext";
|
|
32
32
|
import { LogicAggregatorContainer } from "./LogicAggregatorContainer";
|
|
33
33
|
import { LoadingOverlay } from "./LoadingOverlay";
|
|
34
|
+
import { ZappAppWrapper } from "./components/ZappAppWrapper";
|
|
34
35
|
|
|
35
36
|
interface AppOptions {
|
|
36
37
|
Layout: React.ComponentType;
|
|
@@ -59,31 +60,33 @@ const App = ({
|
|
|
59
60
|
} = props;
|
|
60
61
|
|
|
61
62
|
return (
|
|
62
|
-
<
|
|
63
|
-
<
|
|
64
|
-
<
|
|
65
|
-
<
|
|
66
|
-
<
|
|
67
|
-
<
|
|
68
|
-
<
|
|
69
|
-
<
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
63
|
+
<ZappAppWrapper>
|
|
64
|
+
<ThemeManager plugins={plugins}>
|
|
65
|
+
<SafeAreaProvider initialMetrics={initialWindowMetrics}>
|
|
66
|
+
<AppContainer styles={styles}>
|
|
67
|
+
<ErrorBoundary>
|
|
68
|
+
<URLSchemeListener>
|
|
69
|
+
<SplashLoader>
|
|
70
|
+
<OfflineHandler>
|
|
71
|
+
<Layout>
|
|
72
|
+
<RouteManager />
|
|
73
|
+
</Layout>
|
|
74
|
+
</OfflineHandler>
|
|
75
|
+
</SplashLoader>
|
|
76
|
+
<ModalProvider />
|
|
77
|
+
</URLSchemeListener>
|
|
78
|
+
<LoadingOverlay />
|
|
79
|
+
</ErrorBoundary>
|
|
80
|
+
<LogicAggregatorContainer
|
|
81
|
+
components={React.useMemo(
|
|
82
|
+
() => [InteractionManager, ApplyScreenHooks],
|
|
83
|
+
[InteractionManager, ApplyScreenHooks]
|
|
84
|
+
)}
|
|
85
|
+
/>
|
|
86
|
+
</AppContainer>
|
|
87
|
+
</SafeAreaProvider>
|
|
88
|
+
</ThemeManager>
|
|
89
|
+
</ZappAppWrapper>
|
|
87
90
|
);
|
|
88
91
|
});
|
|
89
92
|
|
|
@@ -75,6 +75,17 @@ jest.mock("@applicaster/zapp-react-native-bridge/QuickBrick", () => ({
|
|
|
75
75
|
getLegacyInitialProps: jest.fn(() => ({ initialProps: {} })),
|
|
76
76
|
}));
|
|
77
77
|
|
|
78
|
+
jest.mock(
|
|
79
|
+
"@applicaster/zapp-react-native-ui-components/Components/River",
|
|
80
|
+
() => {
|
|
81
|
+
const View = require("react-native").View;
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
River: jest.fn(() => <View testID="mock-river" />),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
|
|
78
89
|
describe("createZappApp", () => {
|
|
79
90
|
it("renders the provided React App", () => {
|
|
80
91
|
const ZappApp = createZappApp({ App });
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/quick-brick-core",
|
|
3
|
-
"version": "14.0.0-alpha.
|
|
3
|
+
"version": "14.0.0-alpha.5234792518",
|
|
4
4
|
"description": "Core package for Applicaster's Quick Brick App",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
},
|
|
29
29
|
"homepage": "https://github.com/applicaster/quickbrick#readme",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@applicaster/applicaster-types": "14.0.0-alpha.
|
|
32
|
-
"@applicaster/quick-brick-core-plugins": "14.0.0-alpha.
|
|
33
|
-
"@applicaster/zapp-pipes-v2-client": "14.0.0-alpha.
|
|
34
|
-
"@applicaster/zapp-react-native-bridge": "14.0.0-alpha.
|
|
35
|
-
"@applicaster/zapp-react-native-redux": "14.0.0-alpha.
|
|
36
|
-
"@applicaster/zapp-react-native-ui-components": "14.0.0-alpha.
|
|
37
|
-
"@applicaster/zapp-react-native-utils": "14.0.0-alpha.
|
|
31
|
+
"@applicaster/applicaster-types": "14.0.0-alpha.5234792518",
|
|
32
|
+
"@applicaster/quick-brick-core-plugins": "14.0.0-alpha.5234792518",
|
|
33
|
+
"@applicaster/zapp-pipes-v2-client": "14.0.0-alpha.5234792518",
|
|
34
|
+
"@applicaster/zapp-react-native-bridge": "14.0.0-alpha.5234792518",
|
|
35
|
+
"@applicaster/zapp-react-native-redux": "14.0.0-alpha.5234792518",
|
|
36
|
+
"@applicaster/zapp-react-native-ui-components": "14.0.0-alpha.5234792518",
|
|
37
|
+
"@applicaster/zapp-react-native-utils": "14.0.0-alpha.5234792518",
|
|
38
38
|
"atob": "^2.1.2",
|
|
39
39
|
"axios": "^0.28.0",
|
|
40
40
|
"btoa": "^1.2.1",
|