@applicaster/quick-brick-core 14.0.0-alpha.2523527255 → 14.0.0-alpha.2893452677

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.
@@ -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
  }
@@ -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,
@@ -121,8 +122,20 @@ export function NavigationProvider({ children }: Props) {
121
122
  NavigationReducerState
122
123
  >(reducer, initialState, (x) => x);
123
124
 
125
+ const topStackRoute = last(state?.stack?.mainStack);
126
+
127
+ /** TODO: temporary variable, before we remove need for a "current".
128
+ There is no current as we are using stack navigator. Route data should be contextualised per screen
129
+ There are some cases to use a route data from top of the stack but it should be separate method.
130
+ */
131
+
132
+ const currentLocation = {
133
+ ...topStackRoute,
134
+ route: topStackRoute?.route || "/", // Fallback for initial state.
135
+ };
136
+
124
137
  const stateRef = React.useRef<NavigationReducerState>(state);
125
- const pathname = state?.location?.pathname;
138
+ const pathname = currentLocation?.route; // TODO: remove. Pathname is part of the route, not a global.
126
139
  const pathnameRef = React.useRef(pathname);
127
140
 
128
141
  const { context } = React.useContext(ZappPipesEntryContext.Context);
@@ -146,6 +159,8 @@ export function NavigationProvider({ children }: Props) {
146
159
  }
147
160
  }, [pathname]);
148
161
 
162
+ // TODO remove.
163
+ // There is no concept of active river. Multiple rivers can be rendered at the same time.
149
164
  const activeRiver = React.useMemo(
150
165
  () => activeRiverSelector({ pathname, rivers }),
151
166
  [pathname, rivers]
@@ -186,6 +201,7 @@ export function NavigationProvider({ children }: Props) {
186
201
  // TODO: Move in proper place
187
202
  const modalPresenterScreenOrientation = useGetScreenOrientation(activeRiver);
188
203
 
204
+ // TODO: Move modal state to separate store
189
205
  const closeVideoModal = () => {
190
206
  if (navigator.modalData) {
191
207
  allowedOrientationsForScreen(modalPresenterScreenOrientation);
@@ -213,13 +229,15 @@ export function NavigationProvider({ children }: Props) {
213
229
  const isVideoModalDocked = () =>
214
230
  state?.options.videoModal.mode === "MINIMIZED";
215
231
 
232
+ // TODO: Remove as it's using a concept of "current" route.
233
+ // Route is contextualised and shouldn't be used this way.
216
234
  const routeData = () => {
217
235
  // eslint-disable-next-line no-console
218
236
  console.warn(`you are retrieving screen data from navigator.routeData()
219
237
  This function will be removed in a later version of quick brick.
220
238
  You can retrieve this data from navigator.screenData`);
221
239
 
222
- return legacyScreenData(state?.location?.state as NavigationScreenData);
240
+ return legacyScreenData(currentLocation?.state as NavigationScreenData);
223
241
  };
224
242
 
225
243
  // TODO: remove it by refactoring back buttons handlers
@@ -262,7 +280,7 @@ export function NavigationProvider({ children }: Props) {
262
280
  if (
263
281
  targetRoute !== pathnameRef.current ||
264
282
  item?.id !==
265
- legacyScreenData(state?.location?.state as NavigationScreenData)?.id
283
+ legacyScreenData(currentLocation?.state as NavigationScreenData)?.id
266
284
  ) {
267
285
  replaceEvent();
268
286
  navigateTo(item, ACTIONS.REPLACE, options);
@@ -688,7 +706,8 @@ export function NavigationProvider({ children }: Props) {
688
706
  }
689
707
  }, [state?.options?.videoModal?.previousMode]);
690
708
 
691
- const getNestedEntry = () => state?.location?.state?.nested?.entry ?? null;
709
+ // TODO: remove. This shouldn't be part of navigator
710
+ const getNestedEntry = () => currentLocation?.state?.nested?.entry ?? null;
692
711
 
693
712
  // It will only work for the regular stack and pathname, It won't work for modals
694
713
  // TODO: integrate video/hook and regular modal into stack.
@@ -706,7 +725,7 @@ export function NavigationProvider({ children }: Props) {
706
725
  () => ({
707
726
  activeRiver,
708
727
  getPathname: () => pathnameRef.current, // hack use to fix issue causing broken navigation as currentRoute is unreliable
709
- currentRoute: pathname,
728
+ currentRoute: pathname, // TODO: remove. Current route shouldn't be needed
710
729
  previousAction: lastEntrySelector(state)
711
730
  ?.action as QuickBrickNavigationActionType,
712
731
  push: pushItem,
@@ -716,14 +735,15 @@ export function NavigationProvider({ children }: Props) {
716
735
  goHome,
717
736
  canGoBack,
718
737
  goBack,
719
- routeData,
738
+ routeData, // TODO: remove
720
739
  screenData: legacyScreenData(
721
- state?.location?.state as NavigationScreenData,
740
+ // TODO: remove
741
+ currentLocation?.state as NavigationScreenData,
722
742
  plugins
723
743
  ),
724
- data: state?.location?.state as NavigationScreenData,
744
+ data: currentLocation?.state as NavigationScreenData,
725
745
  getNestedEntry,
726
- key: state?.location?.key,
746
+ key: currentLocation?.key, // TODO: remove
727
747
  modalData: state.stack.modal?.state ?? null,
728
748
  openModal,
729
749
  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,31 +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
- "screenStateStore": [Function],
48
- },
49
- },
50
24
  "options": {
51
25
  "videoModal": {
52
26
  "item": null,
@@ -80,7 +54,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
80
54
  "supports_offline": false,
81
55
  "type": "general_content",
82
56
  },
83
- "screenStateStore": undefined,
84
57
  },
85
58
  },
86
59
  ],
@@ -88,37 +61,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
88
61
  },
89
62
  },
90
63
  "state2": {
91
- "location": {
92
- "key": "mocked-uuid",
93
- "pathname": "/river/A1234/river/B7890",
94
- "state": {
95
- "entry": {
96
- "id": "C0987",
97
- "title": "Entry",
98
- "type": {
99
- "value": "feed",
100
- },
101
- },
102
- "options": undefined,
103
- "screen": {
104
- "home": false,
105
- "home_offline": false,
106
- "hooks": {
107
- "preload_plugins": [],
108
- },
109
- "id": "B5678",
110
- "name": "Screen name",
111
- "navigations": [
112
- {
113
- "id": "nav_id",
114
- },
115
- ],
116
- "supports_offline": false,
117
- "type": "general_content",
118
- },
119
- "screenStateStore": [Function],
120
- },
121
- },
122
64
  "options": {
123
65
  "videoModal": {
124
66
  "item": null,
@@ -152,7 +94,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
152
94
  "supports_offline": false,
153
95
  "type": "general_content",
154
96
  },
155
- "screenStateStore": undefined,
156
97
  },
157
98
  },
158
99
  {
@@ -184,7 +125,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
184
125
  "supports_offline": false,
185
126
  "type": "general_content",
186
127
  },
187
- "screenStateStore": undefined,
188
128
  },
189
129
  },
190
130
  ],
@@ -192,37 +132,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
192
132
  },
193
133
  },
194
134
  "state3": {
195
- "location": {
196
- "key": "mocked-uuid",
197
- "pathname": "/river/A1234/river/B7890/river/C0987",
198
- "state": {
199
- "entry": {
200
- "id": "D1234",
201
- "title": "Entry 2",
202
- "type": {
203
- "value": "video",
204
- },
205
- },
206
- "options": undefined,
207
- "screen": {
208
- "home": false,
209
- "home_offline": false,
210
- "hooks": {
211
- "preload_plugins": [],
212
- },
213
- "id": "C9090",
214
- "name": "Screen 2 name",
215
- "navigations": [
216
- {
217
- "id": "nav_id",
218
- },
219
- ],
220
- "supports_offline": false,
221
- "type": "general_content",
222
- },
223
- "screenStateStore": [Function],
224
- },
225
- },
226
135
  "options": {
227
136
  "videoModal": {
228
137
  "item": null,
@@ -256,7 +165,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
256
165
  "supports_offline": false,
257
166
  "type": "general_content",
258
167
  },
259
- "screenStateStore": undefined,
260
168
  },
261
169
  },
262
170
  {
@@ -288,7 +196,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
288
196
  "supports_offline": false,
289
197
  "type": "general_content",
290
198
  },
291
- "screenStateStore": undefined,
292
199
  },
293
200
  },
294
201
  {
@@ -320,7 +227,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
320
227
  "supports_offline": false,
321
228
  "type": "general_content",
322
229
  },
323
- "screenStateStore": undefined,
324
230
  },
325
231
  },
326
232
  ],
@@ -328,38 +234,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
328
234
  },
329
235
  },
330
236
  "state4": {
331
- "location": {
332
- "action": "PUSH",
333
- "key": "mocked-uuid",
334
- "pathname": "/river/A1234/river/B7890",
335
- "state": {
336
- "entry": {
337
- "id": "C0987",
338
- "title": "Entry",
339
- "type": {
340
- "value": "feed",
341
- },
342
- },
343
- "options": undefined,
344
- "screen": {
345
- "home": false,
346
- "home_offline": false,
347
- "hooks": {
348
- "preload_plugins": [],
349
- },
350
- "id": "B5678",
351
- "name": "Screen name",
352
- "navigations": [
353
- {
354
- "id": "nav_id",
355
- },
356
- ],
357
- "supports_offline": false,
358
- "type": "general_content",
359
- },
360
- "screenStateStore": undefined,
361
- },
362
- },
363
237
  "options": {
364
238
  "videoModal": {
365
239
  "item": null,
@@ -393,7 +267,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
393
267
  "supports_offline": false,
394
268
  "type": "general_content",
395
269
  },
396
- "screenStateStore": undefined,
397
270
  },
398
271
  },
399
272
  {
@@ -425,7 +298,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
425
298
  "supports_offline": false,
426
299
  "type": "general_content",
427
300
  },
428
- "screenStateStore": undefined,
429
301
  },
430
302
  },
431
303
  ],
@@ -433,37 +305,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
433
305
  },
434
306
  },
435
307
  "state5": {
436
- "location": {
437
- "key": "mocked-uuid",
438
- "pathname": "/river/A1234/river/B7890/river/D5678",
439
- "state": {
440
- "entry": {
441
- "id": "C0987",
442
- "title": "Entry",
443
- "type": {
444
- "value": "feed",
445
- },
446
- },
447
- "options": undefined,
448
- "screen": {
449
- "home": false,
450
- "home_offline": false,
451
- "hooks": {
452
- "preload_plugins": [],
453
- },
454
- "id": "B5678",
455
- "name": "Screen name",
456
- "navigations": [
457
- {
458
- "id": "nav_id",
459
- },
460
- ],
461
- "supports_offline": false,
462
- "type": "general_content",
463
- },
464
- "screenStateStore": [Function],
465
- },
466
- },
467
308
  "options": {
468
309
  "videoModal": {
469
310
  "item": null,
@@ -497,7 +338,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
497
338
  "supports_offline": false,
498
339
  "type": "general_content",
499
340
  },
500
- "screenStateStore": undefined,
501
341
  },
502
342
  },
503
343
  {
@@ -529,7 +369,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
529
369
  "supports_offline": false,
530
370
  "type": "general_content",
531
371
  },
532
- "screenStateStore": undefined,
533
372
  },
534
373
  },
535
374
  {
@@ -561,7 +400,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
561
400
  "supports_offline": false,
562
401
  "type": "general_content",
563
402
  },
564
- "screenStateStore": undefined,
565
403
  },
566
404
  },
567
405
  ],
@@ -569,38 +407,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
569
407
  },
570
408
  },
571
409
  "state6": {
572
- "location": {
573
- "action": "PUSH",
574
- "key": "mocked-uuid",
575
- "pathname": "/river/A1234/river/B7890",
576
- "state": {
577
- "entry": {
578
- "id": "C0987",
579
- "title": "Entry",
580
- "type": {
581
- "value": "feed",
582
- },
583
- },
584
- "options": undefined,
585
- "screen": {
586
- "home": false,
587
- "home_offline": false,
588
- "hooks": {
589
- "preload_plugins": [],
590
- },
591
- "id": "B5678",
592
- "name": "Screen name",
593
- "navigations": [
594
- {
595
- "id": "nav_id",
596
- },
597
- ],
598
- "supports_offline": false,
599
- "type": "general_content",
600
- },
601
- "screenStateStore": undefined,
602
- },
603
- },
604
410
  "options": {
605
411
  "videoModal": {
606
412
  "item": null,
@@ -634,7 +440,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
634
440
  "supports_offline": false,
635
441
  "type": "general_content",
636
442
  },
637
- "screenStateStore": undefined,
638
443
  },
639
444
  },
640
445
  {
@@ -666,7 +471,6 @@ exports[`reducer when a back action is dispatched push, back, push, back does wh
666
471
  "supports_offline": false,
667
472
  "type": "general_content",
668
473
  },
669
- "screenStateStore": undefined,
670
474
  },
671
475
  },
672
476
  ],
@@ -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,11 +1,12 @@
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,
7
9
  } from "./selectors";
8
- import { create, StoreApi, UseBoundStore } from "zustand";
9
10
 
10
11
  /* initial state */
11
12
 
@@ -19,7 +20,6 @@ export const initialState: NavigationReducerState = {
19
20
  mainStack: [],
20
21
  modal: null,
21
22
  },
22
- location: { key: "", pathname: "/", state: null },
23
23
  options: {
24
24
  videoModal: {
25
25
  visible: false,
@@ -39,7 +39,6 @@ export enum ACTIONS {
39
39
  BACK_PLAYER_NESTED_CONTENT = "BACK_PLAYER_NESTED_CONTENT",
40
40
  REPLACE_TOP = "REPLACE_TOP",
41
41
  SET_NESTED_CONTENT = "SET_NESTED_CONTENT",
42
- SET_LOCATION = "SET_LOCATION",
43
42
  OPEN_VIDEO_MODAL = "OPEN_VIDEO_MODAL",
44
43
  CLOSE_VIDEO_MODAL = "CLOSE_VIDEO_MODAL",
45
44
  MINIMISE_VIDEO_MODAL = "MINIMISE_VIDEO_MODAL",
@@ -121,12 +120,12 @@ export const setNestedContent = (
121
120
 
122
121
  const navigationEntry = (
123
122
  type: ActionValues,
124
- { route, screen, entry, key, options, screenStateStore }: AnyRecord
123
+ { route, screen, entry, key, options }: AnyRecord
125
124
  ) => ({
126
125
  key,
127
126
  action: type,
128
127
  route,
129
- state: { screen, entry, options, screenStateStore },
128
+ state: { screen, entry, options },
130
129
  });
131
130
 
132
131
  function updatePopActions(state) {
@@ -175,9 +174,9 @@ function backPlayerNestedContent(state) {
175
174
  return findPlayableAndTruncate(currentState);
176
175
  }
177
176
 
178
- function addNestedContent(stack, payload, locationState: LocationReducerState) {
179
- const locationKey = locationState.key;
180
- const stackIndex = R.findIndex(R.propEq("key", locationKey))(stack);
177
+ function addNestedContent(stack, payload, targetStackEntry) {
178
+ const targetStackKey = targetStackEntry.key;
179
+ const stackIndex = R.findIndex(R.propEq("key", targetStackKey))(stack);
181
180
 
182
181
  return R.adjust(
183
182
  stackIndex,
@@ -191,7 +190,7 @@ function addNestedContent(stack, payload, locationState: LocationReducerState) {
191
190
 
192
191
  function navigationStackReducer(
193
192
  state: NavigationStackReducerState = initialState.stack,
194
- { type = "", payload, meta }: ReducerAction = { type: "" }
193
+ { type = "", payload }: ReducerAction = { type: "" }
195
194
  ) {
196
195
  switch (type) {
197
196
  case ACTIONS.SET_NESTED_CONTENT:
@@ -200,7 +199,7 @@ function navigationStackReducer(
200
199
  mainStack: addNestedContent(
201
200
  state.mainStack,
202
201
  navigationEntry(ACTIONS.REPLACE, payload as AnyRecord),
203
- meta as LocationReducerState
202
+ last(state.mainStack)
204
203
  ),
205
204
  };
206
205
  case ACTIONS.PUSH:
@@ -269,70 +268,6 @@ function navigationStackReducer(
269
268
  }
270
269
  }
271
270
 
272
- function locationReducer(
273
- state = initialState.location,
274
- { type, payload, meta = {} }
275
- ) {
276
- const { route, key, screen, entry, options } = payload;
277
-
278
- const screenStateStore: UseBoundStore<StoreApi<ScreenStateStore>> =
279
- create<ScreenStateStore>((set) => ({
280
- data: {},
281
- setValue: (key, value) =>
282
- set((state) => ({
283
- data: {
284
- ...state.data,
285
- [key]: value,
286
- },
287
- })),
288
- removeValue: (key) =>
289
- set((state) => {
290
- const newData = { ...state.data };
291
- delete newData[key];
292
-
293
- return { data: newData };
294
- }),
295
- }));
296
-
297
- switch (type) {
298
- case ACTIONS.BACK:
299
- // eslint-disable-next-line no-case-declarations
300
- const previousEntry = R.compose(
301
- R.last,
302
- payload.route ? firstStackEntriesSelector : previousStackEntriesSelector
303
- )(meta);
304
-
305
- if (previousEntry) {
306
- const { state, key, action } = previousEntry;
307
-
308
- return { pathname: previousEntry.route, state, key, action };
309
- }
310
-
311
- return state;
312
-
313
- case ACTIONS.PUSH:
314
- case ACTIONS.REPLACE:
315
- case ACTIONS.REPLACE_TOP:
316
- case ACTIONS.BACK_PLAYER_NESTED_CONTENT:
317
- return {
318
- pathname: route,
319
- state: { screen, entry, options, screenStateStore },
320
- key,
321
- };
322
-
323
- case ACTIONS.SET_NESTED_CONTENT:
324
- // eslint-disable-next-line no-case-declarations
325
- const nestedEntry = navigationEntry(ACTIONS.REPLACE, {
326
- ...payload,
327
- screenStateStore,
328
- } as AnyRecord);
329
-
330
- return R.assocPath(["state", "nested"], nestedEntry.state, state);
331
- default:
332
- return state;
333
- }
334
- }
335
-
336
271
  /* Video Modal reducer */
337
272
  export const setVideoModalOpen = (item, options, screen) => ({
338
273
  type: ACTIONS.OPEN_VIDEO_MODAL,
@@ -378,43 +313,28 @@ export const videoModalReducer = (
378
313
  switch (type) {
379
314
  case ACTIONS.OPEN_VIDEO_MODAL: {
380
315
  const { item, options } = payload;
316
+ const mode = options?.mode || MAXIMIZED;
381
317
 
382
- const mode = R.pathOr(MAXIMIZED, ["mode"], options);
383
-
384
- return R.compose(
385
- R.set(R.lensProp("mode"), mode),
386
- R.set(R.lensProp("visible"), true),
387
- R.over(
388
- R.lensProp("item"),
389
- R.unless(R.tryCatch(R.propEq("id", item?.id), R.F), () => item)
390
- )
391
- )(state);
318
+ return {
319
+ ...state,
320
+ visible: true,
321
+ mode,
322
+ item: state.item?.id !== item?.id ? item : state.item,
323
+ };
392
324
  }
393
325
 
394
326
  case ACTIONS.SET_VIDEO_MODAL_ITEM:
395
- return R.set(R.lensProp("item"), payload)(state);
327
+ return { ...state, item: payload };
396
328
  case ACTIONS.CLOSE_VIDEO_MODAL:
397
329
  return initialState.options.videoModal;
398
330
  case ACTIONS.FULLSCREEN_VIDEO_MODAL:
399
- return R.compose(
400
- R.set(R.lensProp("mode"), FULLSCREEN),
401
- R.set(R.lensProp("previousMode"), state.mode)
402
- )(state);
331
+ return { ...state, mode: FULLSCREEN, previousMode: state.mode };
403
332
  case ACTIONS.MINIMISE_VIDEO_MODAL:
404
- return R.compose(
405
- R.set(R.lensProp("mode"), MINIMIZED),
406
- R.set(R.lensProp("previousMode"), state.mode)
407
- )(state);
333
+ return { ...state, mode: MINIMIZED, previousMode: state.mode };
408
334
  case ACTIONS.MAXIMISE_VIDEO_MODAL:
409
- return R.compose(
410
- R.set(R.lensProp("mode"), MAXIMIZED),
411
- R.set(R.lensProp("previousMode"), state.mode)
412
- )(state);
335
+ return { ...state, mode: MAXIMIZED, previousMode: state.mode };
413
336
  case ACTIONS.PIP:
414
- return R.compose(
415
- R.set(R.lensProp("mode"), PIP),
416
- R.set(R.lensProp("previousMode"), state.mode)
417
- )(state);
337
+ return { ...state, mode: PIP, previousMode: state.mode };
418
338
  }
419
339
  };
420
340
 
@@ -429,51 +349,20 @@ export default function navigationReducer(
429
349
  case ACTIONS.REPLACE:
430
350
  case ACTIONS.REPLACE_TOP:
431
351
  case ACTIONS.BACK:
432
- // eslint-disable-next-line
433
- case ACTIONS.BACK_PLAYER_NESTED_CONTENT: {
434
- // TODO: Check this solution with Pawel, does not work without it on tvs
435
- const screenStateStore: UseBoundStore<StoreApi<ScreenStateStore>> =
436
- create<ScreenStateStore>((set) => ({
437
- data: {},
438
- setValue: (key, value) =>
439
- set((s) => ({ data: { ...s.data, [key]: value } })),
440
- removeValue: (key) =>
441
- set((s) => {
442
- const data = { ...s.data };
443
- delete data[key];
444
-
445
- return { data };
446
- }),
447
- }));
448
-
449
- const actionWithStore = {
450
- type,
451
- payload: { ...payload, screenStateStore },
452
- meta: state,
352
+ case ACTIONS.BACK_PLAYER_NESTED_CONTENT:
353
+ return {
354
+ ...state,
355
+ stack: navigationStackReducer(state.stack, { type, payload }),
453
356
  };
454
357
 
455
- const stack = applyReducer(navigationStackReducer, actionWithStore);
456
- const location = applyReducer(locationReducer, actionWithStore);
457
-
458
- return R.evolve({ stack, location }, state);
459
- }
460
-
461
358
  case ACTIONS.SET_NESTED_CONTENT:
462
- return R.evolve(
463
- {
464
- stack: applyReducer(navigationStackReducer, {
465
- type,
466
- payload,
467
- meta: state.location,
468
- }),
469
- location: applyReducer(locationReducer, {
470
- type,
471
- payload,
472
- meta: state.stack,
473
- }),
474
- },
475
- state
476
- );
359
+ return {
360
+ ...state,
361
+ stack: navigationStackReducer(state.stack, {
362
+ type,
363
+ payload,
364
+ }),
365
+ };
477
366
 
478
367
  case ACTIONS.OPEN_VIDEO_MODAL:
479
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 ReactTestRenderer from "react-test-renderer";
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 wrapper = ReactTestRenderer.create(<DecoratedComp foo="bar" />);
30
- expect(wrapper.toJSON()).toMatchSnapshot();
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 ReactTestRenderer from "react-test-renderer";
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 wrapper = ReactTestRenderer.create(
178
+ const { toJSON } = render(
179
179
  <Provider store={store}>
180
180
  <QuickBrickApp store={store} />
181
181
  </Provider>
182
182
  );
183
183
 
184
- expect(wrapper.toJSON()).toMatchSnapshot();
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 wrapper = ReactTestRenderer.create(
193
+ const { toJSON } = render(
194
194
  <Provider store={store}>
195
195
  <QuickBrickApp store={store} />
196
196
  </Provider>
197
197
  );
198
198
 
199
- expect(wrapper.toJSON()).toMatchSnapshot();
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 wrapper = ReactTestRenderer.create(
209
+ const { toJSON } = render(
210
210
  <Provider store={store}>
211
211
  <QuickBrickApp store={store} />
212
212
  </Provider>
213
213
  );
214
214
 
215
- expect(wrapper.toJSON()).toMatchSnapshot();
215
+ expect(toJSON()).toMatchSnapshot();
216
216
  });
217
217
  });
218
218
  });
package/App/index.tsx CHANGED
@@ -1,6 +1,8 @@
1
1
  import * as React from "react";
2
2
  import * as R from "ramda";
3
3
 
4
+ import { GestureHandlerRootView } from "react-native-gesture-handler";
5
+
4
6
  import {
5
7
  initialWindowMetrics,
6
8
  SafeAreaProvider,
@@ -59,31 +61,33 @@ const App = ({
59
61
  } = props;
60
62
 
61
63
  return (
62
- <ThemeManager plugins={plugins}>
63
- <SafeAreaProvider initialMetrics={initialWindowMetrics}>
64
- <AppContainer styles={styles}>
65
- <ErrorBoundary>
66
- <URLSchemeListener>
67
- <SplashLoader>
68
- <OfflineHandler>
69
- <Layout>
70
- <RouteManager />
71
- </Layout>
72
- </OfflineHandler>
73
- </SplashLoader>
74
- <ModalProvider />
75
- </URLSchemeListener>
76
- <LoadingOverlay />
77
- </ErrorBoundary>
78
- <LogicAggregatorContainer
79
- components={React.useMemo(
80
- () => [InteractionManager, ApplyScreenHooks],
81
- [InteractionManager, ApplyScreenHooks]
82
- )}
83
- />
84
- </AppContainer>
85
- </SafeAreaProvider>
86
- </ThemeManager>
64
+ <GestureHandlerRootView>
65
+ <ThemeManager plugins={plugins}>
66
+ <SafeAreaProvider initialMetrics={initialWindowMetrics}>
67
+ <AppContainer styles={styles}>
68
+ <ErrorBoundary>
69
+ <URLSchemeListener>
70
+ <SplashLoader>
71
+ <OfflineHandler>
72
+ <Layout>
73
+ <RouteManager />
74
+ </Layout>
75
+ </OfflineHandler>
76
+ </SplashLoader>
77
+ <ModalProvider />
78
+ </URLSchemeListener>
79
+ <LoadingOverlay />
80
+ </ErrorBoundary>
81
+ <LogicAggregatorContainer
82
+ components={React.useMemo(
83
+ () => [InteractionManager, ApplyScreenHooks],
84
+ [InteractionManager, ApplyScreenHooks]
85
+ )}
86
+ />
87
+ </AppContainer>
88
+ </SafeAreaProvider>
89
+ </ThemeManager>
90
+ </GestureHandlerRootView>
87
91
  );
88
92
  });
89
93
 
@@ -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
@@ -45,7 +45,6 @@ declare type NavigationReducerActionTypes =
45
45
  | "SET_NAV_BAR_TITLE"
46
46
  | "SET_NAV_BAR_SUMMARY"
47
47
  | "SET_BOTTOM_BAR_VISIBILITY"
48
- | "SET_LOCATION"
49
48
  | "OPEN_VIDEO_MODAL"
50
49
  | "CLOSE_VIDEO_MODAL"
51
50
  | "MINIMISE_VIDEO_MODAL"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/quick-brick-core",
3
- "version": "14.0.0-alpha.2523527255",
3
+ "version": "14.0.0-alpha.2893452677",
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.2523527255",
32
- "@applicaster/quick-brick-core-plugins": "14.0.0-alpha.2523527255",
33
- "@applicaster/zapp-pipes-v2-client": "14.0.0-alpha.2523527255",
34
- "@applicaster/zapp-react-native-bridge": "14.0.0-alpha.2523527255",
35
- "@applicaster/zapp-react-native-redux": "14.0.0-alpha.2523527255",
36
- "@applicaster/zapp-react-native-ui-components": "14.0.0-alpha.2523527255",
37
- "@applicaster/zapp-react-native-utils": "14.0.0-alpha.2523527255",
31
+ "@applicaster/applicaster-types": "14.0.0-alpha.2893452677",
32
+ "@applicaster/quick-brick-core-plugins": "14.0.0-alpha.2893452677",
33
+ "@applicaster/zapp-pipes-v2-client": "14.0.0-alpha.2893452677",
34
+ "@applicaster/zapp-react-native-bridge": "14.0.0-alpha.2893452677",
35
+ "@applicaster/zapp-react-native-redux": "14.0.0-alpha.2893452677",
36
+ "@applicaster/zapp-react-native-ui-components": "14.0.0-alpha.2893452677",
37
+ "@applicaster/zapp-react-native-utils": "14.0.0-alpha.2893452677",
38
38
  "atob": "^2.1.2",
39
39
  "axios": "^0.28.0",
40
40
  "btoa": "^1.2.1",
@@ -42,9 +42,6 @@
42
42
  "md5": "^2.3.0",
43
43
  "promise": "^8.3.0",
44
44
  "query-string": "7.1.3",
45
- "react-redux": "9.2.0",
46
- "redux": "^4.0.4",
47
- "reselect": "^4.0.0",
48
45
  "url": "^0.11.0",
49
46
  "uuid": "3.3.2"
50
47
  },
@@ -56,7 +53,6 @@
56
53
  "@applicaster/zapp-react-native-tvos-ui-components": "*",
57
54
  "@babel/runtime": "*",
58
55
  "@react-native-community/netinfo": "*",
59
- "immer": "*",
60
56
  "react": "*",
61
57
  "react-native": "*",
62
58
  "react-native-fs": "*",