@applicaster/zapp-react-native-ui-components 14.0.0-alpha.1101330035 → 14.0.0-alpha.1118824347

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.
@@ -146,10 +146,14 @@ export class BaseFocusable<
146
146
  * @param {Object} scrollDirection
147
147
  * @returns {Promise}
148
148
  */
149
- onFocus: FocusManager.FocusEventCB = (focusable, scrollDirection) => {
149
+ onFocus: FocusManager.FocusEventCB = (
150
+ focusable,
151
+ scrollDirection,
152
+ context
153
+ ) => {
150
154
  const { onFocus = noop } = this.props;
151
155
  this.setFocusedState(true);
152
- onFocus(focusable, scrollDirection);
156
+ onFocus(focusable, scrollDirection, context);
153
157
  };
154
158
 
155
159
  /**
@@ -247,8 +251,8 @@ export class BaseFocusable<
247
251
  * @param {Object} scrollDirection
248
252
  * @returns {Promise}
249
253
  */
250
- focus(_, scrollDirection) {
251
- return this.onFocus(this, scrollDirection); // invokeComponentMethod(this, "onFocus", scrollDirection);
254
+ focus(_, scrollDirection, context?: FocusManager.FocusContext) {
255
+ return this.onFocus(this, scrollDirection, context); // invokeComponentMethod(this, "onFocus", scrollDirection, context);
252
256
  }
253
257
 
254
258
  /**
@@ -258,9 +262,10 @@ export class BaseFocusable<
258
262
  */
259
263
  blur(
260
264
  _,
261
- scrollDirection?: FocusManager.Web.Direction | FocusManager.IOS.Direction
265
+ scrollDirection?: FocusManager.Web.Direction | FocusManager.IOS.Direction,
266
+ context?: FocusManager.FocusContext
262
267
  ) {
263
- return this.onBlur(this, scrollDirection);
268
+ return this.onBlur(this, scrollDirection, context);
264
269
  }
265
270
 
266
271
  /**
@@ -272,7 +277,7 @@ export class BaseFocusable<
272
277
  * @param {string} scrollDirection string representation of the direction of the navigation which landed
273
278
  * to this item being focused
274
279
  */
275
- _executeFocusSequence(methodNames, scrollDirection) {
280
+ _executeFocusSequence(methodNames, scrollDirection, context) {
276
281
  return R.reduce(
277
282
  (sequence, methodName) => {
278
283
  const method = this[methodName]; // Access the method by name
@@ -284,7 +289,9 @@ export class BaseFocusable<
284
289
  }
285
290
 
286
291
  return sequence
287
- .then(() => method.call(this, scrollDirection))
292
+ .then(() => {
293
+ return method.call(this, this, scrollDirection, context);
294
+ })
288
295
  .catch((e) => {
289
296
  throw e; // Re-throw for consistent error handling
290
297
  });
@@ -294,15 +301,21 @@ export class BaseFocusable<
294
301
  );
295
302
  }
296
303
 
297
- setFocus(scrollDirection) {
304
+ setFocus(
305
+ scrollDirection?: ScrollDirection,
306
+ context?: FocusManager.FocusContext
307
+ ) {
298
308
  const focusMethods = ["willReceiveFocus", "focus", "hasReceivedFocus"];
299
309
 
300
- return this._executeFocusSequence(focusMethods, scrollDirection);
310
+ return this._executeFocusSequence(focusMethods, scrollDirection, context);
301
311
  }
302
312
 
303
- setBlur(scrollDirection) {
313
+ setBlur(
314
+ scrollDirection?: ScrollDirection,
315
+ context?: FocusManager.FocusContext
316
+ ) {
304
317
  const blurMethods = ["willLoseFocus", "blur", "hasLostFocus"];
305
318
 
306
- return this._executeFocusSequence(blurMethods, scrollDirection);
319
+ return this._executeFocusSequence(blurMethods, scrollDirection, context);
307
320
  }
308
321
  }
@@ -12,4 +12,4 @@ function FocusableiOSComponent({ children }: Props) {
12
12
  return children;
13
13
  }
14
14
 
15
- export const FocusableiOS = React.forwardRef(FocusableiOSComponent);
15
+ export const FocusableiOS = FocusableiOSComponent;
@@ -1,58 +1,28 @@
1
1
  import { playerManager } from "@applicaster/zapp-react-native-utils/appUtils";
2
- import { StorageSingleValueProvider } from "@applicaster/zapp-react-native-utils/storage/StorageSingleSelectProvider";
2
+ import { StorageSingleValueProvider } from "@applicaster/zapp-react-native-bridge/ZappStorage/StorageSingleSelectProvider";
3
3
  import { PushTopicManager } from "@applicaster/zapp-react-native-bridge/PushNotifications/PushTopicManager";
4
- import { StorageMultiSelectProvider } from "@applicaster/zapp-react-native-utils/storage/StorageMultiSelectProvider";
4
+ import { StorageMultiSelectProvider } from "@applicaster/zapp-react-native-bridge/ZappStorage/StorageMultiSelectProvider";
5
5
  import React, { useEffect } from "react";
6
6
  import { usePlayer } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayer";
7
7
  import { BehaviorSubject } from "rxjs";
8
8
  import { masterCellLogger } from "../logger";
9
9
  import get from "lodash/get";
10
- import { ScreenMultiSelectProvider } from "@applicaster/zapp-react-native-utils/storage/ScreenStateMultiSelectProvider";
11
- import { ScreenSingleValueProvider } from "@applicaster/zapp-react-native-utils/storage/ScreenSingleValueProvider";
12
- import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks";
13
- import { useScreenStateStore } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useScreenStateStore";
14
-
15
- const parseContextKey = (
16
- key: string,
17
- context: string = "ctx"
18
- ): string | null => {
19
- if (!key?.startsWith(`@{${context}/`)) return null;
20
-
21
- return key.substring(`@{${context}/`.length, key.length - 1);
10
+
11
+ const parseContextKey = (key: string): string | null => {
12
+ if (!key?.startsWith("@{ctx/")) return null;
13
+
14
+ return key.substring("@{ctx/".length, key.length - 1);
22
15
  };
23
16
 
24
17
  const getDataSourceProvider = (
25
- behavior: Behavior,
26
- screenRoute: string,
27
- screenStateStore: ScreenStateStore
18
+ behavior: Behavior
28
19
  ): BehaviorSubject<string[] | string> | null => {
29
20
  if (!behavior) return null;
30
21
 
31
22
  const selection = String(behavior.current_selection);
32
- const screenKey = parseContextKey(selection, "screen");
33
-
34
- if (screenKey) {
35
- if (behavior.select_mode === "multi") {
36
- return ScreenMultiSelectProvider.getProvider(
37
- screenKey,
38
- screenRoute,
39
- screenStateStore
40
- ).getObservable();
41
- }
42
-
43
- if (behavior.select_mode === "single") {
44
- return ScreenSingleValueProvider.getProvider(
45
- screenKey,
46
- screenRoute,
47
- screenStateStore
48
- ).getObservable();
49
- }
50
- }
51
-
52
23
  const contextKey = parseContextKey(selection);
53
24
 
54
25
  if (contextKey) {
55
- // TODO: Add storage scope to behavior
56
26
  if (behavior.select_mode === "multi") {
57
27
  return StorageMultiSelectProvider.getProvider(contextKey).getObservable();
58
28
  }
@@ -71,8 +41,6 @@ const getDataSourceProvider = (
71
41
 
72
42
  export const useBehaviorUpdate = (behavior: Behavior) => {
73
43
  const [lastUpdate, setLastUpdate] = React.useState<number | null>(null);
74
- const screenRoute = useRoute()?.pathname || "";
75
- const screenStateStore = useScreenStateStore();
76
44
  const player = usePlayer();
77
45
 
78
46
  const triggerUpdate = () => setLastUpdate(Date.now());
@@ -80,11 +48,7 @@ export const useBehaviorUpdate = (behavior: Behavior) => {
80
48
  useEffect(() => {
81
49
  if (!behavior) return;
82
50
 
83
- const dataSource = getDataSourceProvider(
84
- behavior,
85
- screenRoute,
86
- screenStateStore
87
- );
51
+ const dataSource = getDataSourceProvider(behavior);
88
52
 
89
53
  if (dataSource) {
90
54
  const subscription = dataSource.subscribe(triggerUpdate);
@@ -108,17 +72,10 @@ export const useBehaviorUpdate = (behavior: Behavior) => {
108
72
 
109
73
  // We cant use async in this function (its inside render),
110
74
  // so we rely on useBehaviorUpdate to update current value and trigger re-render
111
- export const isCellSelected = ({
112
- item,
113
- screenRoute,
114
- screenStateStore,
115
- behavior,
116
- }: {
117
- item: ZappEntry;
118
- screenRoute: string;
119
- screenStateStore: ScreenStateStore;
120
- behavior?: Behavior;
121
- }): boolean => {
75
+ export const isCellSelected = (
76
+ item: ZappEntry,
77
+ behavior?: Behavior
78
+ ): boolean => {
122
79
  if (!behavior) return false;
123
80
 
124
81
  const id = behavior.selector ? get(item, behavior.selector) : item.id;
@@ -142,32 +99,7 @@ export const isCellSelected = ({
142
99
  }
143
100
 
144
101
  const selection = String(behavior.current_selection);
145
-
146
- const screenKey = parseContextKey(selection, "screen");
147
-
148
- if (screenKey) {
149
- if (behavior.select_mode === "single") {
150
- const selectedItem = ScreenSingleValueProvider.getProvider(
151
- screenKey,
152
- screenRoute,
153
- screenStateStore
154
- ).getValue();
155
-
156
- return selectedItem === String(id);
157
- }
158
-
159
- if (behavior.select_mode === "multi") {
160
- const selectedItems = ScreenMultiSelectProvider.getProvider(
161
- screenKey,
162
- screenRoute,
163
- screenStateStore
164
- ).getSelectedItems();
165
-
166
- return selectedItems?.includes(String(id));
167
- }
168
- }
169
-
170
- const contextKey = parseContextKey(selection, "ctx");
102
+ const contextKey = parseContextKey(selection);
171
103
 
172
104
  if (contextKey) {
173
105
  if (behavior.select_mode === "single") {
@@ -8,8 +8,6 @@ import { masterCellLogger } from "../logger";
8
8
  import { getCellState } from "../../Cell/utils";
9
9
  import { getColorFromData } from "@applicaster/zapp-react-native-utils/cellUtils";
10
10
  import { isCellSelected, useBehaviorUpdate } from "./behaviorProvider";
11
- import { useRoute } from "@applicaster/zapp-react-native-utils/reactHooks";
12
- import { useScreenStateStore } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useScreenStateStore";
13
11
 
14
12
  const hasElementSpecificViewType = (viewType) => (element) => {
15
13
  if (R.isNil(element)) {
@@ -192,18 +190,8 @@ export const getFocusedButtonId = (focusable) => {
192
190
  });
193
191
  };
194
192
 
195
- export const isSelected = ({
196
- item,
197
- screenRoute,
198
- screenStateStore,
199
- behavior,
200
- }: {
201
- item: ZappEntry;
202
- screenRoute: string;
203
- screenStateStore: ScreenStateStore;
204
- behavior?: Behavior;
205
- }) => {
206
- return isCellSelected({ item, screenRoute, screenStateStore, behavior });
193
+ export const isSelected = (item: ZappEntry, behavior?: Behavior) => {
194
+ return isCellSelected(item, behavior);
207
195
  };
208
196
 
209
197
  export const useCellState = ({
@@ -216,17 +204,9 @@ export const useCellState = ({
216
204
  focused: boolean;
217
205
  }): CellState => {
218
206
  const lastUpdate = useBehaviorUpdate(behavior);
219
- const router = useRoute();
220
- const screenStateStore = useScreenStateStore();
221
207
 
222
208
  const _isSelected = useMemo(
223
- () =>
224
- isSelected({
225
- item,
226
- screenRoute: router?.pathname,
227
- screenStateStore,
228
- behavior,
229
- }),
209
+ () => isSelected(item, behavior),
230
210
  [behavior, item, lastUpdate]
231
211
  );
232
212
 
@@ -0,0 +1,76 @@
1
+ import { makeListOf } from "@applicaster/zapp-react-native-utils/arrayUtils";
2
+ import { isFirstComponentGallery } from "@applicaster/zapp-react-native-utils/componentsUtils";
3
+ import { once } from "ramda";
4
+
5
+ const INITIAL_NUMBER_TO_LOAD = 3;
6
+
7
+ // Infer the values of COMPONENT_LOADING_STATE as a type
8
+ type ComponentLoadingState =
9
+ (typeof COMPONENT_LOADING_STATE)[keyof typeof COMPONENT_LOADING_STATE];
10
+
11
+ export const COMPONENT_LOADING_STATE = {
12
+ UNKNOWN: "UNKNOWN",
13
+ LOADED_WITH_SUCCESS: "LOADED_WITH_SUCCESS",
14
+ LOADED_WITH_FAILURE: "LOADED_WITH_FAILURE",
15
+ } as const;
16
+
17
+ // Function to get the number of loaded components
18
+ const getNumberOfLoaded = (states: ComponentLoadingState[]): number => {
19
+ return states.filter((value) => value !== COMPONENT_LOADING_STATE.UNKNOWN)
20
+ .length;
21
+ };
22
+
23
+ const getNumberOfComponentsWaitToLoadBeforePresent = (
24
+ componentsToRender: ZappUIComponent[]
25
+ ): number => {
26
+ // when Gallery is the first component, no need to wait the others
27
+ if (isFirstComponentGallery(componentsToRender)) {
28
+ return 1;
29
+ }
30
+
31
+ return Math.min(INITIAL_NUMBER_TO_LOAD, componentsToRender.length);
32
+ };
33
+
34
+ export class ScreenRevealManager {
35
+ public numberOfComponentsWaitToLoadBeforePresent: number;
36
+ private renderingState: Array<ComponentLoadingState>;
37
+ private callback: Callback;
38
+
39
+ constructor(componentsToRender: ZappUIComponent[], callback: Callback) {
40
+ this.numberOfComponentsWaitToLoadBeforePresent =
41
+ getNumberOfComponentsWaitToLoadBeforePresent(componentsToRender);
42
+
43
+ this.renderingState = makeListOf<ComponentLoadingState>(
44
+ COMPONENT_LOADING_STATE.UNKNOWN,
45
+ this.numberOfComponentsWaitToLoadBeforePresent
46
+ );
47
+
48
+ this.callback = once(callback);
49
+ }
50
+
51
+ onLoadFinished = (index: number): void => {
52
+ this.renderingState[index] = COMPONENT_LOADING_STATE.LOADED_WITH_SUCCESS;
53
+
54
+ if (
55
+ getNumberOfLoaded(this.renderingState) >=
56
+ this.numberOfComponentsWaitToLoadBeforePresent
57
+ ) {
58
+ this.setIsReadyToShow();
59
+ }
60
+ };
61
+
62
+ onLoadFailed = (index: number): void => {
63
+ this.renderingState[index] = COMPONENT_LOADING_STATE.LOADED_WITH_FAILURE;
64
+
65
+ if (
66
+ getNumberOfLoaded(this.renderingState) >=
67
+ this.numberOfComponentsWaitToLoadBeforePresent
68
+ ) {
69
+ this.setIsReadyToShow();
70
+ }
71
+ };
72
+
73
+ setIsReadyToShow = (): void => {
74
+ this.callback();
75
+ };
76
+ }
@@ -0,0 +1,107 @@
1
+ import {
2
+ ScreenRevealManager,
3
+ COMPONENT_LOADING_STATE,
4
+ } from "../ScreenRevealManager";
5
+
6
+ describe("ScreenRevealManager", () => {
7
+ const mockCallback = jest.fn();
8
+
9
+ beforeEach(() => {
10
+ jest.clearAllMocks();
11
+ });
12
+
13
+ it("should initialize with the correct number of components to wait for", () => {
14
+ const componentsToRender: ZappUIComponent[] = [
15
+ { component_type: "component1" },
16
+ { component_type: "component2" },
17
+ { component_type: "component3" },
18
+ ];
19
+
20
+ const manager = new ScreenRevealManager(componentsToRender, mockCallback);
21
+
22
+ expect(manager["numberOfComponentsWaitToLoadBeforePresent"]).toBe(3);
23
+
24
+ expect(manager["renderingState"]).toEqual([
25
+ COMPONENT_LOADING_STATE.UNKNOWN,
26
+ COMPONENT_LOADING_STATE.UNKNOWN,
27
+ COMPONENT_LOADING_STATE.UNKNOWN,
28
+ ]);
29
+ });
30
+
31
+ it("should call the callback when the required number of components are loaded successfully", () => {
32
+ const componentsToRender: ZappUIComponent[] = [
33
+ { component_type: "component1" },
34
+ { component_type: "component2" },
35
+ { component_type: "component3" },
36
+ ];
37
+
38
+ const manager = new ScreenRevealManager(componentsToRender, mockCallback);
39
+
40
+ manager.onLoadFinished(0);
41
+ manager.onLoadFinished(1);
42
+ manager.onLoadFinished(2);
43
+
44
+ expect(mockCallback).toHaveBeenCalledTimes(1);
45
+ });
46
+
47
+ it("should call the callback when the required number of components fail to load", () => {
48
+ const componentsToRender: ZappUIComponent[] = [
49
+ { component_type: "component1" },
50
+ { component_type: "component2" },
51
+ { component_type: "component3" },
52
+ ];
53
+
54
+ const manager = new ScreenRevealManager(componentsToRender, mockCallback);
55
+
56
+ manager.onLoadFailed(0);
57
+ manager.onLoadFailed(1);
58
+ manager.onLoadFailed(2);
59
+
60
+ expect(mockCallback).toHaveBeenCalledTimes(1);
61
+ });
62
+
63
+ it("should call the callback when a mix of successful and failed loads meet the required number", () => {
64
+ const componentsToRender: ZappUIComponent[] = [
65
+ { component_type: "component1" },
66
+ { component_type: "component2" },
67
+ { component_type: "component3" },
68
+ ];
69
+
70
+ const manager = new ScreenRevealManager(componentsToRender, mockCallback);
71
+
72
+ manager.onLoadFinished(0);
73
+ manager.onLoadFailed(1);
74
+ manager.onLoadFinished(2);
75
+
76
+ expect(mockCallback).toHaveBeenCalledTimes(1);
77
+ });
78
+
79
+ it("should not call the callback if the required number of components are not loaded", () => {
80
+ const componentsToRender: ZappUIComponent[] = [
81
+ { component_type: "component1" },
82
+ { component_type: "component2" },
83
+ { component_type: "component3" },
84
+ ];
85
+
86
+ const manager = new ScreenRevealManager(componentsToRender, mockCallback);
87
+
88
+ manager.onLoadFinished(0);
89
+ manager.onLoadFailed(1);
90
+
91
+ expect(mockCallback).not.toHaveBeenCalled();
92
+ });
93
+
94
+ it("should call the callback when the when first component is gallery and it was loaded successfully", () => {
95
+ const componentsToRender: ZappUIComponent[] = [
96
+ { component_type: "gallery-qb" },
97
+ { component_type: "component2" },
98
+ { component_type: "component3" },
99
+ ];
100
+
101
+ const manager = new ScreenRevealManager(componentsToRender, mockCallback);
102
+
103
+ manager.onLoadFinished(0);
104
+
105
+ expect(mockCallback).toHaveBeenCalledTimes(1);
106
+ });
107
+ });
@@ -0,0 +1,96 @@
1
+ /* eslint-disable react/prop-types */
2
+
3
+ import * as React from "react";
4
+ import { render, screen, act } from "@testing-library/react-native";
5
+ import { View } from "react-native";
6
+ import {
7
+ withScreenRevealManager,
8
+ SHOWN,
9
+ TIMEOUT,
10
+ } from "../withScreenRevealManager";
11
+
12
+ jest.mock("react-native/Libraries/Animated/NativeAnimatedHelper");
13
+
14
+ const MockComponent = ({
15
+ initialNumberToLoad,
16
+ onLoadFinishedFromScreenRevealManager,
17
+ onLoadFailedFromScreenRevealManager,
18
+ }) => {
19
+ React.useEffect(() => {
20
+ // Simulate loading components
21
+ for (let i = 0; i < initialNumberToLoad; i++) {
22
+ onLoadFinishedFromScreenRevealManager(i);
23
+ }
24
+ }, [initialNumberToLoad, onLoadFinishedFromScreenRevealManager]);
25
+
26
+ return (
27
+ <View
28
+ testID="mock-component"
29
+ initialNumberToLoad={initialNumberToLoad}
30
+ onLoadFinishedFromScreenRevealManager={
31
+ onLoadFinishedFromScreenRevealManager
32
+ }
33
+ onLoadFailedFromScreenRevealManager={onLoadFailedFromScreenRevealManager}
34
+ />
35
+ );
36
+ };
37
+
38
+ const WrappedComponent = withScreenRevealManager(MockComponent);
39
+
40
+ describe("withScreenRevealManager", () => {
41
+ beforeEach(() => {
42
+ jest.clearAllMocks();
43
+ jest.useFakeTimers();
44
+ });
45
+
46
+ afterEach(() => {
47
+ jest.runOnlyPendingTimers();
48
+ jest.useRealTimers();
49
+ });
50
+
51
+ it("should render the wrapped component", () => {
52
+ render(
53
+ <WrappedComponent
54
+ componentsToRender={[{ id: "1" }, { id: "2" }, { id: "3" }]}
55
+ />
56
+ );
57
+
58
+ expect(screen.getByTestId("mock-component")).toBeTruthy();
59
+ });
60
+
61
+ it("should animate opacity when ready to show", () => {
62
+ render(
63
+ <WrappedComponent
64
+ componentsToRender={[{ id: "1" }, { id: "2" }, { id: "3" }]}
65
+ />
66
+ );
67
+
68
+ const animatedView = screen.getByTestId("animated-component");
69
+
70
+ act(() => {
71
+ jest.advanceTimersByTime(TIMEOUT + 100);
72
+ });
73
+
74
+ expect(animatedView.props.style.opacity).toBe(SHOWN);
75
+ });
76
+
77
+ it("should pass initialNumberToLoad, onLoadFinishedFromScreenRevealManager, and onLoadFailedFromScreenRevealManager to the wrapped component", () => {
78
+ render(
79
+ <WrappedComponent
80
+ componentsToRender={[{ id: "1" }, { id: "2" }, { id: "3" }]}
81
+ />
82
+ );
83
+
84
+ const mockComponent = screen.getByTestId("mock-component");
85
+
86
+ expect(mockComponent.props.initialNumberToLoad).toBe(3);
87
+
88
+ expect(
89
+ mockComponent.props.onLoadFinishedFromScreenRevealManager
90
+ ).toBeInstanceOf(Function);
91
+
92
+ expect(
93
+ mockComponent.props.onLoadFailedFromScreenRevealManager
94
+ ).toBeInstanceOf(Function);
95
+ });
96
+ });
@@ -0,0 +1 @@
1
+ export { withScreenRevealManager } from "./withScreenRevealManager";
@@ -0,0 +1,79 @@
1
+ import * as React from "react";
2
+ import { Animated } from "react-native";
3
+ import { isFirstComponentScreenPicker } from "@applicaster/zapp-react-native-utils/componentsUtils";
4
+ import { platformSelect } from "@applicaster/zapp-react-native-utils/reactUtils";
5
+ import { useRefWithInitialValue } from "@applicaster/zapp-react-native-utils/reactHooks/state/useRefWithInitialValue";
6
+
7
+ import { ScreenRevealManager } from "./ScreenRevealManager";
8
+
9
+ const flex = platformSelect({
10
+ tvos: 1,
11
+ android_tv: 1,
12
+ web: undefined,
13
+ samsung_tv: undefined,
14
+ lg_tv: undefined,
15
+ default: undefined,
16
+ });
17
+
18
+ export const TIMEOUT = 500; // 500 ms
19
+
20
+ const HIDDEN = 0; // opacity = 0
21
+
22
+ export const SHOWN = 1; // opacity = 1
23
+
24
+ type Props = {
25
+ componentsToRender: ZappUIComponent[];
26
+ };
27
+
28
+ export const withScreenRevealManager = (Component) => {
29
+ return function WithScreenRevealManager(props: Props) {
30
+ const { componentsToRender } = props;
31
+
32
+ const [isReadyToShow, setIsReadyToShow] = React.useState(false);
33
+
34
+ const handleSetIsReadyToShow = React.useCallback(() => {
35
+ setIsReadyToShow(true);
36
+ }, []);
37
+
38
+ const managerRef = useRefWithInitialValue<ScreenRevealManager>(
39
+ () => new ScreenRevealManager(componentsToRender, handleSetIsReadyToShow)
40
+ );
41
+
42
+ const opacityRef = useRefWithInitialValue<Animated.Value>(
43
+ () => new Animated.Value(HIDDEN)
44
+ );
45
+
46
+ React.useEffect(() => {
47
+ if (isReadyToShow) {
48
+ Animated.timing(opacityRef.current, {
49
+ toValue: SHOWN,
50
+ duration: TIMEOUT,
51
+ useNativeDriver: true,
52
+ }).start();
53
+ }
54
+ }, [isReadyToShow]);
55
+
56
+ if (isFirstComponentScreenPicker(componentsToRender)) {
57
+ // for screen-picker with have additional internal ComponentsMap, no need to add this wrapper
58
+ return <Component {...props} />;
59
+ }
60
+
61
+ return (
62
+ <Animated.View
63
+ style={{ opacity: opacityRef.current, flex }}
64
+ testID="animated-component"
65
+ >
66
+ <Component
67
+ {...props}
68
+ initialNumberToLoad={
69
+ managerRef.current.numberOfComponentsWaitToLoadBeforePresent
70
+ }
71
+ onLoadFinishedFromScreenRevealManager={
72
+ managerRef.current.onLoadFinished
73
+ }
74
+ onLoadFailedFromScreenRevealManager={managerRef.current.onLoadFailed}
75
+ />
76
+ </Animated.View>
77
+ );
78
+ };
79
+ };
@@ -36,7 +36,6 @@ export function CurrentScreenContextProvider({
36
36
  screenData: NavigationScreenData;
37
37
  }) {
38
38
  const { pathname, isActive = false, screenData } = props;
39
- console.log("CurrentScreenContextProvider", { screenData });
40
39
 
41
40
  const [initialScreenData, setInitialScreenData] = React.useState(screenData);
42
41
 
@@ -13,7 +13,6 @@ import {
13
13
  loadDatasources,
14
14
  usePipesContexts,
15
15
  } from "./utils";
16
- import { useScreenResolvers } from "@applicaster/zapp-react-native-utils/actionsExecutor/screenResolver";
17
16
 
18
17
  type RiverProps = {
19
18
  dispatch: DispatchProp;
@@ -26,7 +25,7 @@ export function WithRiverFeedLoader(Component: ZappComponent) {
26
25
  return function WrappedWithRiverFeedLoader(props: RiverProps) {
27
26
  const { river } = props;
28
27
  const { screenData, pathname } = useRoute();
29
- const resolvers = useScreenResolvers();
28
+
30
29
  const pipesContexts = usePipesContexts(river.id, pathname);
31
30
 
32
31
  const componentsToLoad = ignoreComponentsWithClearCacheFlag(
@@ -50,12 +49,7 @@ export function WithRiverFeedLoader(Component: ZappComponent) {
50
49
  item?.filter((item2) => item2 !== undefined)
51
50
  );
52
51
 
53
- loadDatasources(
54
- nonEmptyDataSources,
55
- river?.id,
56
- props.dispatch,
57
- resolvers
58
- );
52
+ loadDatasources(nonEmptyDataSources, river?.id, props.dispatch);
59
53
  }, []);
60
54
 
61
55
  return <Component {...props} />;
@@ -12,16 +12,11 @@ export { getDatasourceUrl } from "./getDatasourceUrl";
12
12
 
13
13
  export const DATASOURCE_CHUNKS = 10;
14
14
 
15
- export async function loadDatasources(
16
- urls: string[][],
17
- riverId,
18
- dispatch,
19
- resolvers
20
- ) {
15
+ export async function loadDatasources(urls: string[][], riverId, dispatch) {
21
16
  return reducePromises<string, void>(
22
17
  mapPromises<string, void>((url) => {
23
18
  if (url) {
24
- return dispatch(loadPipesData(url, { riverId, resolvers }));
19
+ return dispatch(loadPipesData(url, { riverId }));
25
20
  }
26
21
  }),
27
22
  undefined,
@@ -19,11 +19,7 @@ import { ZappPipesSearchContext } from "@applicaster/zapp-react-native-ui-compon
19
19
  import { useScreenContext } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
20
20
 
21
21
  import { isVerticalListOrGrid } from "./utils";
22
- import {
23
- subscribeForUrlContextKeyChanges,
24
- subscribeForUrlScreenKeyChanges,
25
- } from "@applicaster/zapp-pipes-v2-client";
26
- import { useScreenStateStore } from "@applicaster/zapp-react-native-utils/reactHooks/navigation/useScreenStateStore";
22
+ import { subscribeForUrlContextKeyChanges } from "@applicaster/zapp-pipes-v2-client";
27
23
 
28
24
  type Props = {
29
25
  component: ZappUIComponent;
@@ -208,9 +204,7 @@ export function zappPipesDataConnector(
208
204
  Component: React.FC<any> | React.ComponentClass<any>
209
205
  ) {
210
206
  return function WrappedWithZappPipesData(props: Props) {
211
- const { screenData, pathname } = useRoute();
212
- const screenStateStore = useScreenStateStore();
213
-
207
+ const { screenData } = useRoute();
214
208
  const { plugins } = usePickFromState(["plugins"]);
215
209
 
216
210
  const screenContextData = useScreenContext();
@@ -292,18 +286,6 @@ export function zappPipesDataConnector(
292
286
  componentIndex
293
287
  );
294
288
 
295
- useEffect(() => {
296
- if (!(dataSourceUrl?.includes("pipesv2://") && reloadData)) {
297
- return subscribeForUrlScreenKeyChanges(
298
- dataSourceUrl,
299
- pathname,
300
- screenStateStore,
301
- {},
302
- reloadData
303
- );
304
- }
305
- }, [dataSourceUrl, reloadData]);
306
-
307
289
  useEffect(() => {
308
290
  if (dataSourceUrl?.includes("pipesv2://") && reloadData) {
309
291
  const addListener = getListenerFromPlugin(dataSourceUrl, plugins);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "14.0.0-alpha.1101330035",
3
+ "version": "14.0.0-alpha.1118824347",
4
4
  "description": "Applicaster Zapp React Native ui components for the Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,10 +28,10 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "14.0.0-alpha.1101330035",
32
- "@applicaster/zapp-react-native-bridge": "14.0.0-alpha.1101330035",
33
- "@applicaster/zapp-react-native-redux": "14.0.0-alpha.1101330035",
34
- "@applicaster/zapp-react-native-utils": "14.0.0-alpha.1101330035",
31
+ "@applicaster/applicaster-types": "14.0.0-alpha.1118824347",
32
+ "@applicaster/zapp-react-native-bridge": "14.0.0-alpha.1118824347",
33
+ "@applicaster/zapp-react-native-redux": "14.0.0-alpha.1118824347",
34
+ "@applicaster/zapp-react-native-utils": "14.0.0-alpha.1118824347",
35
35
  "promise": "^8.3.0",
36
36
  "url": "^0.11.0",
37
37
  "uuid": "^3.3.2"