@applicaster/zapp-react-native-ui-components 12.0.0-alpha.5135101838 → 12.0.0-alpha.5227180498

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.
Files changed (32) hide show
  1. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +13 -6
  2. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
  3. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -0
  4. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +5 -3
  5. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
  6. package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
  7. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  8. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +24 -9
  9. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +1 -3
  10. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
  11. package/Components/MeasurmentsPortal/BasicMeasurementsPortal.tsx +11 -7
  12. package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +10 -1
  13. package/Components/PlayerContainer/PlayerContainer.tsx +9 -5
  14. package/Components/River/ComponentsMap/ComponentsMap.tsx +86 -22
  15. package/Components/River/RefreshControl.tsx +55 -1
  16. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +4 -0
  17. package/Components/Screen/index.tsx +35 -24
  18. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +0 -5
  19. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +11 -4
  20. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +9 -2
  21. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +13 -2
  22. package/Components/VideoModal/VideoModal.tsx +19 -19
  23. package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +1 -1
  24. package/Components/Viewport/ViewportTracker/index.tsx +1 -0
  25. package/Components/Viewport/utils.js +1 -1
  26. package/Contexts/MenuToggleContext/{index.js → index.ts} +16 -0
  27. package/Contexts/ScreenContext/__tests__/__snapshots__/index.test.tsx.snap +3 -0
  28. package/Contexts/ScreenContext/__tests__/index.test.tsx +27 -0
  29. package/Contexts/ScreenContext/index.tsx +94 -25
  30. package/events/index.ts +1 -0
  31. package/package.json +5 -5
  32. /package/Contexts/{index.js → index.ts} +0 -0
@@ -50,7 +50,11 @@ describe("getTransformedPreset should return the passed components if smartCompo
50
50
  );
51
51
 
52
52
  expect(transformed_preset).toBeDefined();
53
- expect(transformed_preset.id).toEqual("comp10"); // id was transformed
53
+
54
+ expect(transformed_preset.id).toEqual(
55
+ `${mockComp.id}-${mockPreset.feed_url}-0`
56
+ ); // id was transformed
57
+
54
58
  expect(transformed_preset.data.source).toEqual(mockPreset.feed_url); // source was replaced with preset feed_url.
55
59
  });
56
60
  });
@@ -117,7 +121,10 @@ describe("getTransformedPreset should return the passed components if smartCompo
117
121
 
118
122
  expect(Array.isArray(result)).toBe(true);
119
123
  expect(result).toHaveLength(2);
120
- expect(result[0].id).toEqual("smart10");
124
+
125
+ expect(result[0].id).toEqual(
126
+ `${mockSmartComp.id}-${mockFeeds.preset_source.data.entry[0].feed_url}-0`
127
+ );
121
128
 
122
129
  expect(result[0].data.source).toEqual(
123
130
  mockFeeds.preset_source.data.entry[0].feed_url
@@ -287,7 +294,7 @@ describe("getTransformedPreset should return the passed components if smartCompo
287
294
  mockComponents[0],
288
295
  {
289
296
  ...mockLayoutPresets.preset_one,
290
- id: mockComponents[1].id + 1,
297
+ id: `${mockComponents[1].id}-${mockPresetEntry[0].feed_url}-1`,
291
298
  data: { source: mockPresetEntry[0].feed_url },
292
299
  },
293
300
  ];
@@ -344,12 +351,12 @@ describe("getTransformedPreset should return the passed components if smartCompo
344
351
  const mockTransformedComponents = [
345
352
  {
346
353
  ...mockLayoutPresets.preset_one,
347
- id: mockComponents[0].id + 0,
354
+ id: `${mockComponents[0].id}-${mockPresetEntry1[0].feed_url}-0`,
348
355
  data: { source: mockPresetEntry1[0].feed_url },
349
356
  },
350
357
  {
351
358
  ...mockLayoutPresets.preset_one,
352
- id: mockComponents[1].id + 1,
359
+ id: `${mockComponents[1].id}-${mockPresetEntry2[0].feed_url}-1`,
353
360
  data: { source: mockPresetEntry2[0].feed_url },
354
361
  },
355
362
  ];
@@ -412,7 +419,7 @@ describe("getTransformedPreset should return the passed components if smartCompo
412
419
  const mockTransformedComponents = mockPresetEntry.map((preset, i) => {
413
420
  return {
414
421
  ...mockLayoutPresets[preset.preset_name],
415
- id: mockComponents[0].id + i,
422
+ id: `${mockComponents[0].id}-${preset.feed_url}-${i}`,
416
423
  data: { source: preset.feed_url },
417
424
  };
418
425
  });
@@ -41,7 +41,7 @@ export const getTransformedPreset = (
41
41
  }
42
42
 
43
43
  const updatedPresetComponent = produce(presetComponent, (draft) => {
44
- draft.id = `${componentId}${index}`;
44
+ draft.id = `${componentId}-${preset?.feed_url}-${index}`;
45
45
  draft.data.source = preset?.feed_url;
46
46
 
47
47
  if (draft.ui_components) {
@@ -25,6 +25,7 @@ type Props = {
25
25
  testID?: string;
26
26
  accessibilityLabel?: string;
27
27
  cellUUID?: string;
28
+ extraProps?: Record<string, any>;
28
29
  };
29
30
 
30
31
  function isStringAsset(asset) {
@@ -108,6 +109,7 @@ export function ActionButton(props: Props) {
108
109
  flavour={flavour}
109
110
  asset={getAssetValue(asset, flavour)}
110
111
  cellUUID={cellUUID}
112
+ {...(props?.extraProps ?? {})}
111
113
  />
112
114
  )}
113
115
  </TouchableOpacity>
@@ -43,14 +43,16 @@ function Image({
43
43
  [source, error]
44
44
  );
45
45
 
46
+ const _source = shouldRenderImg
47
+ ? withDimensions(source)
48
+ : defaultPlaceHolderImage;
49
+
46
50
  return (
47
51
  // @ts-ignore
48
52
  <MemoizedImage
49
53
  style={style as ImageStyle}
50
54
  onError={() => setErrorState(true)}
51
- source={
52
- shouldRenderImg ? withDimensions(source) : defaultPlaceHolderImage
53
- }
55
+ source={_source?.uri ? _source : undefined}
54
56
  {...R.omit(["source"], otherProps)}
55
57
  />
56
58
  );
@@ -2,6 +2,7 @@ import React from "react";
2
2
  import { isVideoPreviewEnabled } from "@applicaster/zapp-react-native-ui-components/Components/MasterCell/utils";
3
3
  import { LiveImage } from "../LiveImage";
4
4
  import PureImage from "../Image";
5
+ import { useIsScreenActive } from "@applicaster/zapp-react-native-utils/reactHooks";
5
6
 
6
7
  type Props = {
7
8
  enable_video_preview: boolean;
@@ -9,7 +10,10 @@ type Props = {
9
10
  };
10
11
 
11
12
  export const ImageContainer = (props: Props) => {
12
- const Component = isVideoPreviewEnabled(props) ? LiveImage : PureImage;
13
+ const isActive = useIsScreenActive();
14
+
15
+ const Component =
16
+ isVideoPreviewEnabled(props) && isActive ? LiveImage : PureImage;
13
17
 
14
18
  return <Component {...props} />;
15
19
  };
@@ -1,7 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { Text } from "react-native";
3
3
  import { omit } from "ramda";
4
- import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
5
4
  import {
6
5
  textTransform,
7
6
  dateFormat,
@@ -9,6 +8,9 @@ import {
9
8
 
10
9
  import { useTextLabel, withFocusedStyles } from "./hooks";
11
10
  import { withScaledLineHeight } from "./utils";
11
+ import { toNumber } from "@applicaster/zapp-react-native-utils/numberUtils";
12
+ import { MeasurementPortalContext } from "../../../MeasurmentsPortal";
13
+ import { isNilOrEmpty } from "@applicaster/zapp-react-native-utils/reactUtils/helpers";
12
14
 
13
15
  type Props = {
14
16
  style: any;
@@ -32,14 +34,24 @@ const _Text = ({
32
34
  ...otherProps
33
35
  }: Props) => {
34
36
  const _label = useTextLabel({ label, entry });
37
+ const isMeasurement = React.useContext(MeasurementPortalContext);
35
38
 
36
39
  if (isNilOrEmpty(_label)) {
37
40
  return null;
38
41
  }
39
42
 
43
+ // set maximum possible height for the text in case of measurement
44
+ const height =
45
+ isMeasurement && otherProps.numberOfLines && style.lineHeight
46
+ ? toNumber(otherProps.numberOfLines) * toNumber(style.lineHeight)
47
+ : undefined;
48
+
40
49
  return (
41
50
  <Text
42
- style={withScaledLineHeight(withFocusedStyles({ style, otherProps }))}
51
+ style={[
52
+ withScaledLineHeight(withFocusedStyles({ style, otherProps })),
53
+ { height },
54
+ ]}
43
55
  {...withoutLabel(otherProps)}
44
56
  >
45
57
  {dateTransformEnabled
@@ -39,6 +39,6 @@ describe("image with no source", () => {
39
39
  );
40
40
 
41
41
  const testInstance = testRenderer.root;
42
- expect(testInstance.findByType(Image).props.source).toEqual({ uri: "" });
42
+ expect(testInstance.findByType(Image).props.source).toBeUndefined();
43
43
  });
44
44
  });
@@ -1,11 +1,23 @@
1
1
  import React from "react";
2
- import { Text } from "react-native";
2
+ import RN from "react-native";
3
3
  import { Provider } from "react-redux";
4
4
  import TestRenderer from "react-test-renderer";
5
- import configureStore from "redux-mock-store";
6
- import CustomText from "../Text";
5
+ import configureStoreFn from "redux-mock-store";
7
6
 
8
- const mockStore = configureStore();
7
+ const mockUseIsRTL = jest.fn(() => true);
8
+ const mockGetIsRTL = jest.fn(() => true);
9
+ const mockUseLocalizedStrings = jest.fn(() => ({}));
10
+ const mockGetUILanguage = jest.fn(() => "he-HE");
11
+
12
+ jest.mock("@applicaster/zapp-react-native-utils/localizationUtils", () => ({
13
+ useIsRTL: mockUseIsRTL,
14
+ getIsRTL: mockGetIsRTL,
15
+ useLocalizedStrings: mockUseLocalizedStrings,
16
+ getUILanguage: mockGetUILanguage,
17
+ }));
18
+
19
+ const CustomText = require("../Text").default;
20
+ const mockStore = configureStoreFn();
9
21
 
10
22
  const defaultProps = {
11
23
  entry: {},
@@ -22,7 +34,7 @@ const getRenderedText = (label: string, store: any) => {
22
34
  </Provider>
23
35
  );
24
36
 
25
- return testRenderer.root.findByType(Text).props.children;
37
+ return testRenderer.root.findByType(RN.Text).props.children;
26
38
  };
27
39
 
28
40
  describe("RTL app: Hebrew text contains english word", () => {
@@ -34,7 +46,7 @@ describe("RTL app: Hebrew text contains english word", () => {
34
46
  remoteConfigurations: { localizations: { he: {} } },
35
47
  appData: {
36
48
  languageCode: "he",
37
- countryCode: "HE",
49
+ countryCode: "IL",
38
50
  },
39
51
  });
40
52
 
@@ -47,18 +59,22 @@ describe("RTL app: Hebrew text contains english word", () => {
47
59
 
48
60
  it("Hebrew text contains not first english word", () => {
49
61
  const renderedText = getRenderedText(textWithNotFirstEnglishWord, store);
50
-
51
62
  expect(renderedText).toEqual(textWithNotFirstEnglishWord);
52
63
  });
53
64
 
54
65
  it("Hebrew text doesn't contain english word", () => {
55
66
  const renderedText = getRenderedText(textWithoutEnglishWord, store);
56
-
57
67
  expect(renderedText).toEqual(textWithoutEnglishWord);
58
68
  });
59
69
  });
60
70
 
61
71
  describe("LTR app: English text", () => {
72
+ beforeAll(() => {
73
+ mockUseIsRTL.mockReturnValue(false);
74
+ mockGetIsRTL.mockReturnValue(false);
75
+ mockGetUILanguage.mockReturnValue("en-US");
76
+ });
77
+
62
78
  const englishText = "Test sentence";
63
79
 
64
80
  const store = mockStore({
@@ -71,7 +87,6 @@ describe("LTR app: English text", () => {
71
87
 
72
88
  it("English text", () => {
73
89
  const renderedText = getRenderedText(englishText, store);
74
-
75
90
  expect(renderedText).toEqual(englishText);
76
91
  });
77
92
  });
@@ -51,9 +51,7 @@ export const CollapsibleTextContainer = ({
51
51
  func: (data) => {
52
52
  return getColorFromData({
53
53
  data,
54
- getValue,
55
- key: "background_color",
56
- defaultColor: additionalStyles.backgroundColor,
54
+ valueFromLayout: additionalStyles.backgroundColor,
57
55
  });
58
56
  },
59
57
  propName: "backgroundColor",
@@ -53,7 +53,7 @@ export const useAsyncRendering = (viewRef: React.RefObject<View>): Return => {
53
53
  measure(viewRef?.current, ({ width, height }) => {
54
54
  setDimensions({
55
55
  width,
56
- height,
56
+ height: Math.ceil(height),
57
57
  });
58
58
  });
59
59
  })
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import { View, StyleSheet } from "react-native";
3
+ import { MeasurementPortalContext } from "./MeasurementsPortal";
3
4
 
4
5
  type Props = {
5
6
  Component: React.ElementType;
@@ -19,13 +20,16 @@ const _MeasurementsPortal = (
19
20
  { Component, onLayout, componentProps, containerStyle }: Props,
20
21
  ref
21
22
  ) => (
22
- <View
23
- onLayout={onLayout}
24
- style={[styles.container, containerStyle]}
25
- ref={ref}
26
- >
27
- <Component {...componentProps} />
28
- </View>
23
+ // hack for cell to determine if cell is in measurement mode
24
+ <MeasurementPortalContext.Provider value={{}}>
25
+ <View
26
+ onLayout={onLayout}
27
+ style={[styles.container, containerStyle]}
28
+ ref={ref}
29
+ >
30
+ <Component {...componentProps} />
31
+ </View>
32
+ </MeasurementPortalContext.Provider>
29
33
  );
30
34
 
31
35
  export const MeasurementsPortal = React.forwardRef(_MeasurementsPortal);
@@ -35,7 +35,16 @@ const MeasurementsPortal = ({ Component, onLayout, componentProps }: Props) => {
35
35
  );
36
36
  };
37
37
 
38
- const MeasurementPortalContext = React.createContext(null);
38
+ type MeasurementPortalContextType = {
39
+ measureComponent?: (
40
+ comp: React.ElementType,
41
+ props: Record<any, any>
42
+ ) => Promise<any>;
43
+ measuringInProgress?: boolean;
44
+ };
45
+
46
+ const MeasurementPortalContext =
47
+ React.createContext<null | MeasurementPortalContextType>(null);
39
48
 
40
49
  const MeasurementsPortalContextProvider = ({ children }) => {
41
50
  const Component = React.useRef(View);
@@ -54,7 +54,10 @@ import { toNumber } from "@applicaster/zapp-react-native-utils/numberUtils";
54
54
  import { usePlayNextOverlay } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/usePlayNextOverlay";
55
55
  import { PlayNextState } from "@applicaster/zapp-react-native-utils/appUtils/playerManager/OverlayObserver/OverlaysObserver";
56
56
 
57
- import { useModalAnimationContext } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
57
+ import {
58
+ useModalAnimationContext,
59
+ PlayerAnimationStateEnum,
60
+ } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
58
61
 
59
62
  type Props = {
60
63
  Player: React.ComponentType<any>;
@@ -231,6 +234,9 @@ const PlayerContainerComponent = (props: Props) => {
231
234
  const screenData = useTargetScreenData(item);
232
235
  const { setVisible: showNavBar } = useSetNavbarState();
233
236
 
237
+ const { isActiveGesture, startComponentsAnimation, setPlayerAnimationState } =
238
+ useModalAnimationContext();
239
+
234
240
  const playerEvent = (event, ...args) => {
235
241
  playerManager.invokeHandler(event, ...args);
236
242
  };
@@ -448,7 +454,7 @@ const PlayerContainerComponent = (props: Props) => {
448
454
  if (disableMiniPlayer) {
449
455
  navigator.closeVideoModal();
450
456
  } else {
451
- navigator.minimiseVideoModal();
457
+ setPlayerAnimationState(PlayerAnimationStateEnum.minimize);
452
458
  }
453
459
  }
454
460
 
@@ -600,9 +606,6 @@ const PlayerContainerComponent = (props: Props) => {
600
606
  pluginConfiguration,
601
607
  };
602
608
 
603
- const { isActiveGesture, startComponentsAnimation } =
604
- useModalAnimationContext();
605
-
606
609
  return (
607
610
  <PlayerStateContext.Provider value={value}>
608
611
  <PlayerContainerContextProvider
@@ -668,6 +671,7 @@ const PlayerContainerComponent = (props: Props) => {
668
671
  setNextVideoPreloadThresholdPercentage={
669
672
  setNextVideoPreloadThresholdPercentage
670
673
  }
674
+ startComponentsAnimation={startComponentsAnimation}
671
675
  >
672
676
  {renderApplePlayer(applePlayerProps)}
673
677
  </Player>
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import * as R from "ramda";
3
- import { View, FlatList, StyleSheet, Platform } from "react-native";
3
+ import { View, StyleSheet, Platform, FlatList } from "react-native";
4
4
  import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
5
5
  import { RiverItem } from "../RiverItem";
6
6
  import { RiverFooter } from "../RiverFooter";
@@ -21,7 +21,8 @@ import {
21
21
  import { useScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenData";
22
22
  import { isLast } from "@applicaster/zapp-react-native-utils/arrayUtils";
23
23
  import { withComponentsMapProvider } from "@applicaster/zapp-react-native-ui-components/Decorators/ComponentsMapWrapper";
24
- import { useScreenScrollStore } from "@applicaster/zapp-react-native-utils/screenState";
24
+ import { useScreenContextV2 } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
25
+ import { useShallow } from "zustand/react/shallow";
25
26
 
26
27
  type Props = {
27
28
  feed: ZappFeed;
@@ -41,8 +42,10 @@ const styles = StyleSheet.create({
41
42
  },
42
43
  });
43
44
 
44
- const scrollIndicatorInsets = { right: 1 };
45
+ const getNearestValue = (value, optionA, optionB) =>
46
+ Math.abs(value - optionA) < Math.abs(value - optionB) ? optionA : optionB;
45
47
 
48
+ const scrollIndicatorInsets = { right: 1 };
46
49
  const keyExtractor = R.compose(String, R.prop("id"));
47
50
 
48
51
  function ComponentsMapComponent(props: Props) {
@@ -60,6 +63,7 @@ function ComponentsMapComponent(props: Props) {
60
63
  refreshingPipesV1,
61
64
  } = props;
62
65
 
66
+ const flatListRef = React.useRef<FlatList | null>(null);
63
67
  const screenConfig = useScreenConfiguration(riverId);
64
68
  const screenData = useScreenData(riverId);
65
69
  const pullToRefreshEnabled = screenData?.rules?.pull_to_refresh_enabled;
@@ -194,26 +198,81 @@ function ComponentsMapComponent(props: Props) {
194
198
  []
195
199
  );
196
200
 
197
- const onScrollFlatList = React.useCallback(
198
- ({ nativeEvent }, isScrollingDone = false) => {
199
- const {
200
- contentOffset: { y },
201
- } = nativeEvent;
201
+ const navBarStore = useScreenContextV2()._navBarStore;
202
202
 
203
- useScreenScrollStore.setState({
204
- scrollingVelocity: isScrollingDone ? 0 : 1,
205
- scrollPosition: y,
206
- });
207
- },
208
- []
203
+ const scrollY = navBarStore(
204
+ useShallow(({ scrollYAnimated }) => scrollYAnimated)
209
205
  );
210
206
 
211
- const onMomentumScrollEnd = React.useCallback(
212
- ({ nativeEvent }) => {
213
- onScrollFlatList({ nativeEvent }, true);
214
- },
215
- [onScrollFlatList]
216
- );
207
+ const canMomentum = React.useRef(false);
208
+
209
+ const onScrollBeginDrag = React.useCallback(() => {
210
+ canMomentum.current = true;
211
+ }, []);
212
+
213
+ /* onMomentumScrollEnd: Handling snap to expanded/collapsed state ( for navbar ) */
214
+ const _onMomentumScrollEnd = React.useCallback(({ nativeEvent }) => {
215
+ if (!canMomentum.current) return;
216
+ canMomentum.current = false;
217
+
218
+ const { height: headerHeight, scrollState } = navBarStore.getState();
219
+
220
+ const offsetY = Math.max(0, nativeEvent.contentOffset.y);
221
+
222
+ if (
223
+ !(scrollState === 0 || scrollState === -headerHeight) &&
224
+ flatListRef.current
225
+ ) {
226
+ const offset =
227
+ getNearestValue(Math.round(scrollState), -headerHeight, 0) ===
228
+ -headerHeight
229
+ ? Math.round(offsetY + scrollState + headerHeight)
230
+ : Math.round(offsetY + scrollState);
231
+
232
+ flatListRef.current.scrollToOffset({
233
+ animated: true,
234
+ offset,
235
+ });
236
+ }
237
+ }, []);
238
+
239
+ /* onScrollEnd: Handling snap to expanded/collapsed state ( for navbar ) */
240
+ const _onScrollEndDrag = React.useCallback(({ nativeEvent }) => {
241
+ const { height: headerHeight, scrollState } = navBarStore.getState();
242
+
243
+ const offsetY = Math.max(0, nativeEvent.contentOffset.y);
244
+
245
+ if (
246
+ !(scrollState === 0 || scrollState === -headerHeight) &&
247
+ flatListRef.current &&
248
+ nativeEvent.velocity.y === 0
249
+ ) {
250
+ const offset =
251
+ getNearestValue(Math.round(scrollState), -headerHeight, 0) ===
252
+ -headerHeight
253
+ ? Math.round(offsetY + scrollState + headerHeight)
254
+ : Math.round(offsetY + scrollState);
255
+
256
+ flatListRef.current.scrollToOffset({
257
+ animated: true,
258
+ offset,
259
+ });
260
+ }
261
+ }, []);
262
+
263
+ const onScroll = React.useCallback((event) => {
264
+ const {
265
+ nativeEvent: {
266
+ contentOffset: { y },
267
+ layoutMeasurement: { height },
268
+ contentSize: { height: contentHeight },
269
+ },
270
+ } = event;
271
+
272
+ if (y >= 0 && y + height <= contentHeight) {
273
+ scrollY.setValue(y);
274
+ }
275
+ }, []);
217
276
 
218
277
  if (shouldShowLoadingError) {
219
278
  return <RiverError />;
@@ -230,6 +289,9 @@ function ComponentsMapComponent(props: Props) {
230
289
  >
231
290
  <ViewportTracker>
232
291
  <FlatList
292
+ ref={(ref) => {
293
+ flatListRef.current = ref;
294
+ }}
233
295
  // Fix for WebView rerender crashes on Android API 28+
234
296
  // https://github.com/react-native-webview/react-native-webview/issues/1915#issuecomment-964035468
235
297
  overScrollMode={Platform.OS === "android" ? "never" : "auto"}
@@ -249,8 +311,10 @@ function ComponentsMapComponent(props: Props) {
249
311
  }
250
312
  ListFooterComponent={renderFooter}
251
313
  refreshControl={refreshControl}
252
- onScroll={onScrollFlatList}
253
- onMomentumScrollEnd={onMomentumScrollEnd}
314
+ onScrollBeginDrag={onScrollBeginDrag}
315
+ onScroll={onScroll}
316
+ onMomentumScrollEnd={_onMomentumScrollEnd}
317
+ onScrollEndDrag={_onScrollEndDrag}
254
318
  scrollEventThrottle={16}
255
319
  {...scrollViewExtraProps}
256
320
  />
@@ -1,5 +1,9 @@
1
1
  import * as React from "react";
2
- import { RefreshControl as RNRefreshControl } from "react-native";
2
+ import {
3
+ Platform,
4
+ RefreshControl as RNRefreshControl,
5
+ StyleSheet,
6
+ } from "react-native";
3
7
  import * as R from "ramda";
4
8
  import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
5
9
  import { useLocalizedStrings } from "@applicaster/zapp-react-native-utils/localizationUtils";
@@ -8,10 +12,30 @@ import { useSendAnalyticsEventWithFunction } from "@applicaster/zapp-react-nativ
8
12
  import { useCurrentScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
9
13
  import { loadPipesData } from "@applicaster/zapp-react-native-redux/ZappPipes";
10
14
  import { useDispatch } from "react-redux";
15
+ import { useShallow } from "zustand/react/shallow";
16
+ import { useScreenContextV2 } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
17
+ import { useSafeAreaInsets } from "react-native-safe-area-context";
11
18
 
12
19
  const BRIGHTNESS_THRESHOLD = 160;
13
20
  const ABOVE_DEFAULT_COLOR = "gray";
14
21
  const BELOW_DEFAULT_COLOR = "white";
22
+ const BASE_INDICATOR_HEIGHT = 40;
23
+ const BASE_INDICATOR_OFFSET = 16;
24
+
25
+ /** Return spacing required to position indicator below the navbar bottom line (Android only) */
26
+ const getRefreshControlOffset = () => {
27
+ return Platform.OS === "ios"
28
+ ? 0
29
+ : BASE_INDICATOR_HEIGHT + BASE_INDICATOR_OFFSET;
30
+ };
31
+
32
+ const styles = StyleSheet.create({
33
+ // eslint-disable-next-line react-native/no-color-literals
34
+ control: {
35
+ zIndex: 1,
36
+ backgroundColor: "transparent",
37
+ },
38
+ });
15
39
 
16
40
  const getBrightness = (RGBcolor) => {
17
41
  const RGBvalues = RGBcolor.substring(
@@ -91,6 +115,34 @@ export const usePullToRefresh = (
91
115
  };
92
116
  };
93
117
 
118
+ /** Returns the offset for the progress view of the RefreshControl component
119
+ * based on navbar content position */
120
+ export const useGetProgressViewOffset = () => {
121
+ const { _navBarStore } = useScreenContextV2();
122
+ const { top } = useSafeAreaInsets();
123
+
124
+ const offset = getRefreshControlOffset();
125
+
126
+ const { height, contentPosition } = _navBarStore(
127
+ useShallow(({ contentPosition, height }) => ({ contentPosition, height }))
128
+ );
129
+
130
+ if (height === 0) {
131
+ return offset;
132
+ }
133
+
134
+ switch (contentPosition) {
135
+ case "on_bottom_status_bar":
136
+ // navbar height
137
+ return offset + height - top;
138
+ case "on_top_screen":
139
+ // navbar height + status bar height
140
+ return offset + height;
141
+ default:
142
+ return offset;
143
+ }
144
+ };
145
+
94
146
  export function RefreshControl(props: {
95
147
  pullToRefreshPipesV1RefreshingStateUpdater?: (refreshing: boolean) => void;
96
148
  refreshingPipesV1?: boolean;
@@ -211,6 +263,7 @@ export function RefreshControl(props: {
211
263
  refreshing={refreshing}
212
264
  onRefresh={onRefreshHandler}
213
265
  colors={[preparedIndicatorColor]}
266
+ progressViewOffset={useGetProgressViewOffset()}
214
267
  progressBackgroundColor={preparedIndicatorBackgroundColor}
215
268
  // @ts-ignore in RN68 this `size` became string
216
269
  size={indicatorSize}
@@ -222,6 +275,7 @@ export function RefreshControl(props: {
222
275
  : null
223
276
  }
224
277
  titleColor={preparedTitleUnderIndicatorColor}
278
+ style={styles.control}
225
279
  />
226
280
  );
227
281
  }
@@ -11,7 +11,9 @@ exports[`<Screen Component /> when the navbar should be hidden renders correctly
11
11
  }
12
12
  >
13
13
  <View
14
+ hasMenu={false}
14
15
  id="/river/testId"
16
+ pathname="/river/testId"
15
17
  selected="testId"
16
18
  testID="navBar"
17
19
  title=""
@@ -41,7 +43,9 @@ exports[`<Screen Component /> when the navbar should show renders correctly 1`]
41
43
  }
42
44
  >
43
45
  <View
46
+ hasMenu={false}
44
47
  id="/river/testId"
48
+ pathname="/river/testId"
45
49
  selected="testId"
46
50
  testID="navBar"
47
51
  title=""
@@ -6,7 +6,10 @@ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
6
6
 
7
7
  import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
8
8
  import { getComponentModule } from "@applicaster/zapp-react-native-utils/pluginUtils";
9
- import { getNavigationPropsV2 } from "@applicaster/zapp-react-native-utils/navigationUtils";
9
+ import {
10
+ getNavigationPropsV2,
11
+ resolveNavigationPlugin,
12
+ } from "@applicaster/zapp-react-native-utils/navigationUtils";
10
13
  import { useSafeAreaInsets } from "react-native-safe-area-context";
11
14
  import {
12
15
  useDimensions,
@@ -52,11 +55,11 @@ function isValidColor(string) {
52
55
  }
53
56
 
54
57
  type Props = {
55
- setToggleMenu: () => void;
56
- setCloseMenu: () => void;
58
+ pathname: unknown;
59
+ screenData: unknown;
57
60
  };
58
61
 
59
- export function Screen({ setToggleMenu, setCloseMenu }: Props) {
62
+ export function Screen(_props: Props) {
60
63
  const theme = useTheme<BaseThemePropertiesMobile>();
61
64
  const navigation = useNavigation();
62
65
  const { plugins } = usePickFromState(["plugins"]);
@@ -70,26 +73,38 @@ export function Screen({ setToggleMenu, setCloseMenu }: Props) {
70
73
  fullDimensions: true,
71
74
  });
72
75
 
73
- const routeData = useRoute();
76
+ const { screenData, pathname } = useRoute();
74
77
 
75
78
  const currentRiver = useScreenData(
76
- getScreenId(routeData.screenData, navigation.activeRiver)
79
+ getScreenId(screenData, navigation.activeRiver)
77
80
  );
78
81
 
79
82
  const { title } = useNavbarState();
80
83
 
81
- const navBarProps = React.useMemo(
82
- () => ({
83
- ...getNavigationPropsV2({
84
- currentRiver,
85
- title,
86
- category: "nav_bar",
87
- }),
88
- setToggleMenu,
89
- setCloseMenu,
90
- }),
91
- [currentRiver, setCloseMenu, setToggleMenu]
92
- );
84
+ const hasMenu =
85
+ resolveNavigationPlugin({
86
+ category: "menu",
87
+ navigations: currentRiver.navigations,
88
+ plugins,
89
+ })?.identifier === "quick_brick_side_menu";
90
+
91
+ const navBarProps = React.useMemo<MobileNavBarPluginProps | null>(() => {
92
+ const props = getNavigationPropsV2({
93
+ currentRiver,
94
+ title,
95
+ category: "nav_bar",
96
+ });
97
+
98
+ if (props) {
99
+ return {
100
+ ...props,
101
+ id: pathname,
102
+ pathname: pathname,
103
+ };
104
+ }
105
+
106
+ return null;
107
+ }, [currentRiver, pathname]);
93
108
 
94
109
  const NavBar = React.useMemo(
95
110
  () =>
@@ -97,12 +112,10 @@ export function Screen({ setToggleMenu, setCloseMenu }: Props) {
97
112
  "nav_bar",
98
113
  currentRiver,
99
114
  plugins
100
- ) as React.ComponentType<MobileNavBarPluginProps>,
115
+ ) as React.ComponentType<MobileNavBarPluginProps & { hasMenu: boolean }>,
101
116
  []
102
117
  );
103
118
 
104
- const { screenData, pathname } = routeData;
105
-
106
119
  const offlinePlugin = getComponentModule({
107
120
  plugins,
108
121
  components: {},
@@ -133,9 +146,7 @@ export function Screen({ setToggleMenu, setCloseMenu }: Props) {
133
146
  return (
134
147
  <ScreenContextProvider pathname={pathname}>
135
148
  <View style={style}>
136
- <NavBar
137
- {...{ ...(navBarProps as MobileNavBarPluginProps), id: pathname }}
138
- />
149
+ {navBarProps && <NavBar {...navBarProps} hasMenu={hasMenu} />}
139
150
 
140
151
  <OfflineFallbackScreen screenData={targetScreenData}>
141
152
  {/* @TODO RouteManager doesn't use props, can they be removed ? */}
@@ -30,11 +30,6 @@ exports[`PlayerLiveImageComponent should render correctly with default props 1`]
30
30
  playerId="player1"
31
31
  resizeMode="cover"
32
32
  screenConfig={Object {}}
33
- source={
34
- Object {
35
- "uri": "",
36
- }
37
- }
38
33
  style={Object {}}
39
34
  />
40
35
  </View>
@@ -9,6 +9,8 @@ import {
9
9
  TapGestureHandler,
10
10
  GestureHandlerRootView,
11
11
  } from "react-native-gesture-handler";
12
+
13
+ import { PlayerContainerContext } from "@applicaster/zapp-react-native-ui-components/Components/PlayerContainer/PlayerContainerContext";
12
14
  import {
13
15
  useModalAnimationContext,
14
16
  PlayerAnimationStateEnum,
@@ -58,6 +60,8 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
58
60
  setLastSnap,
59
61
  } = useModalAnimationContext();
60
62
 
63
+ const { isLanguageOverlayVisible } = React.useContext(PlayerContainerContext);
64
+
61
65
  const { maximiseVideoModal, minimiseVideoModal, videoModalState } =
62
66
  useNavigation();
63
67
 
@@ -69,6 +73,11 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
69
73
  playerAnimationState !== PlayerAnimationStateEnum.minimize &&
70
74
  playerAnimationState !== PlayerAnimationStateEnum.maximaze;
71
75
 
76
+ const isEnablePanGesture =
77
+ !isLanguageOverlayVisible &&
78
+ isNotMinimizeMaximazeAnimation &&
79
+ (isMaximazedModal || isMinimizedModal);
80
+
72
81
  const isAudioItem = React.useMemo(
73
82
  () =>
74
83
  videoModalState.item?.content?.type?.includes?.("audio") ||
@@ -290,15 +299,13 @@ export const AnimatedScrollModalComponent = ({ children }: Props) => {
290
299
  >
291
300
  <View pointerEvents="box-none">
292
301
  <PanGestureHandler
293
- enabled={
294
- (isMaximazedModal || isMinimizedModal) &&
295
- isNotMinimizeMaximazeAnimation
296
- }
302
+ enabled={isEnablePanGesture}
297
303
  ref={panHandlerRef}
298
304
  simultaneousHandlers={[scrollRef, tapHandlerRef]}
299
305
  shouldCancelWhenOutside={isMaximazedModal}
300
306
  onGestureEvent={onGestureEvent}
301
307
  onHandlerStateChange={onHandlerStateChange}
308
+ activeOffsetY={[-5, 5]}
302
309
  >
303
310
  <Animated.View>
304
311
  <NativeViewGestureHandler
@@ -3,6 +3,8 @@ import { Animated, StyleSheet } from "react-native";
3
3
 
4
4
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
5
5
  import { PanGestureHandler, State } from "react-native-gesture-handler";
6
+
7
+ import { PlayerContainerContext } from "@applicaster/zapp-react-native-ui-components/Components/PlayerContainer/PlayerContainerContext";
6
8
  import {
7
9
  useModalAnimationContext,
8
10
  PlayerAnimationStateEnum,
@@ -35,9 +37,14 @@ export const AnimatedVideoPlayer = ({ children }: Props) => {
35
37
  } = useModalAnimationContext();
36
38
 
37
39
  const { videoModalState } = useNavigation();
40
+ const { isLanguageOverlayVisible } = React.useContext(PlayerContainerContext);
41
+
38
42
  const isMaximazedModal = videoModalState.mode === "MAXIMIZED";
39
43
  const isMinimizedModal = videoModalState.mode === "MINIMIZED";
40
44
 
45
+ const isEnablePanGesture =
46
+ !isLanguageOverlayVisible && (isMaximazedModal || isMinimizedModal);
47
+
41
48
  const onGestureEvent = Animated.event(
42
49
  [{ nativeEvent: { translationY: dragVideoPlayerY } }],
43
50
  { useNativeDriver: true }
@@ -53,7 +60,7 @@ export const AnimatedVideoPlayer = ({ children }: Props) => {
53
60
  if (videoModalState.mode === "MAXIMIZED") {
54
61
  if (translationY > 0) {
55
62
  const endOffsetY =
56
- lastSnap + preparedTranslationY + dragToss * velocityY + 150;
63
+ lastSnap + preparedTranslationY + dragToss * velocityY + 200;
57
64
 
58
65
  let destSnapPoint = modalSnapPoints[0];
59
66
 
@@ -127,7 +134,7 @@ export const AnimatedVideoPlayer = ({ children }: Props) => {
127
134
 
128
135
  return (
129
136
  <PanGestureHandler
130
- enabled={isMaximazedModal || isMinimizedModal}
137
+ enabled={isEnablePanGesture}
131
138
  shouldCancelWhenOutside={isMaximazedModal}
132
139
  onGestureEvent={onGestureEvent}
133
140
  onHandlerStateChange={onHandlerStateChange}
@@ -1,7 +1,10 @@
1
1
  import React, { useContext } from "react";
2
2
  import { Animated } from "react-native";
3
3
 
4
- import { useSafeAreaFrame } from "react-native-safe-area-context";
4
+ import {
5
+ useSafeAreaFrame,
6
+ useSafeAreaInsets,
7
+ } from "react-native-safe-area-context";
5
8
  import { useGetBottomTabBarHeight } from "@applicaster/zapp-react-native-utils/reactHooks";
6
9
 
7
10
  import { useConfiguration } from "../utils";
@@ -91,8 +94,16 @@ const Provider = ({ children }: { children: React.ReactNode }) => {
91
94
  const dragVideoPlayerY = React.useRef(new Animated.Value(0)).current;
92
95
 
93
96
  const { height } = useSafeAreaFrame();
97
+ const { bottom: bottomSafeArea } = useSafeAreaInsets();
94
98
  const bottomTabBarHeight = useGetBottomTabBarHeight();
95
- const minValue = height - minimisedHeight - bottomTabBarHeight;
99
+
100
+ /*
101
+ If bottomTabBarHeight is equal 0 it means an app does not use bottomTabBar.
102
+ Because of this we need to minus bottom SafeArea offset.
103
+ */
104
+ const minValue =
105
+ height - minimisedHeight - (bottomTabBarHeight || bottomSafeArea);
106
+
96
107
  const modalSnapPoints = React.useMemo(() => [0, minValue], [minValue]);
97
108
  // Last snap state which will helps us to make smooth responder to scrollview animation
98
109
  const [lastSnap, setLastSnap] = React.useState<number>(modalSnapPoints[0]);
@@ -129,17 +129,17 @@ const VideoModalComponent = () => {
129
129
  const pathname = `${ROUTE_TYPES.VIDEO_MODAL}/${item?.id}`;
130
130
 
131
131
  return (
132
- <AnimatedPlayerModalWrapper
133
- style={[
134
- styles.container,
135
- {
136
- backgroundColor,
137
- },
138
- ]}
139
- >
140
- <ScreenContextProvider pathname={pathname}>
141
- <PathnameContext.Provider value={pathname}>
142
- {itemIdHooksFinished === item?.id ? (
132
+ <ScreenContextProvider pathname={pathname}>
133
+ <PathnameContext.Provider value={pathname}>
134
+ {itemIdHooksFinished === item?.id ? (
135
+ <AnimatedPlayerModalWrapper
136
+ style={[
137
+ styles.container,
138
+ {
139
+ backgroundColor,
140
+ },
141
+ ]}
142
+ >
143
143
  <HandlePlayable
144
144
  item={item}
145
145
  isModal={mode !== "PIP"}
@@ -147,14 +147,14 @@ const VideoModalComponent = () => {
147
147
  modalWidth={modalSize.width}
148
148
  mode={mode}
149
149
  />
150
- ) : (
151
- <View style={styles.loaderContainer}>
152
- <Spinner />
153
- </View>
154
- )}
155
- </PathnameContext.Provider>
156
- </ScreenContextProvider>
157
- </AnimatedPlayerModalWrapper>
150
+ </AnimatedPlayerModalWrapper>
151
+ ) : (
152
+ <View style={styles.loaderContainer}>
153
+ <Spinner />
154
+ </View>
155
+ )}
156
+ </PathnameContext.Provider>
157
+ </ScreenContextProvider>
158
158
  );
159
159
  };
160
160
 
@@ -15,7 +15,7 @@ export function ViewportTracker(props) {
15
15
 
16
16
  const assignRef = React.useCallback(
17
17
  (ref) => {
18
- callOnChildren(children, "ref", ref);
18
+ children?.ref?.(ref);
19
19
  setNodeHandle(findNodeHandle(ref));
20
20
  },
21
21
  [children]
@@ -6,6 +6,7 @@ import { ViewportEventContext, ViewportEvents } from "../ViewportEvents";
6
6
  type Props = {
7
7
  viewportEventsManager?: any;
8
8
  children: React.ReactNode;
9
+ flatListRef?: any; // this ref is used to bind to children component
9
10
  };
10
11
 
11
12
  export function ViewportTracker(props: Props) {
@@ -2,7 +2,7 @@ import * as React from "react";
2
2
 
3
3
  export function callOnChildren(children, method, ...args) {
4
4
  const childMethod = React.Children.only(children).props[method];
5
- childMethod && childMethod(...args);
5
+ typeof childMethod === "function" && childMethod?.(...args);
6
6
  }
7
7
 
8
8
  export function isInViewport(
@@ -1,4 +1,5 @@
1
1
  import { createContext } from "@applicaster/zapp-react-native-utils/reactUtils/createContext";
2
+ import React from "react";
2
3
 
3
4
  const initialContext = { toggleMenu: {}, closeMenu: {}, openMenu: {} };
4
5
 
@@ -16,3 +17,18 @@ const stateValidator = ({ property }) =>
16
17
  property === "openMenu";
17
18
 
18
19
  export const MenuToggleContext = createContext(initialContext, stateValidator);
20
+
21
+ export type MenuToggleContextType = {
22
+ toggleMenu: any;
23
+ setToggleMenu: () => void;
24
+ openMenu: any;
25
+ setOpenMenu: () => void;
26
+ closeMenu: any;
27
+ setCloseMenu: () => void;
28
+ };
29
+
30
+ export const useMenuToggleContext = () => {
31
+ return React.useContext<MenuToggleContextType>(
32
+ MenuToggleContext.ReactContext
33
+ );
34
+ };
@@ -0,0 +1,3 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ScreenContext withScreenContext should return the context 1`] = `null`;
@@ -0,0 +1,27 @@
1
+ import { render } from "@testing-library/react-native";
2
+ import { ScreenContext, ScreenContextProvider, withScreenContext } from "../";
3
+ import React from "react";
4
+
5
+ describe("ScreenContext", () => {
6
+ describe("ScreneContext context", () => {
7
+ it("should return the context", () => {
8
+ expect(ScreenContext).toBeDefined();
9
+ });
10
+ });
11
+
12
+ describe("ScreenContextProvider", () => {
13
+ it("should return the provider", () => {
14
+ expect(ScreenContextProvider).toBeDefined();
15
+ });
16
+ });
17
+
18
+ describe("withScreenContext", () => {
19
+ it("should return the context", () => {
20
+ const Component = () => null;
21
+ const WrappedComponent = withScreenContext(Component);
22
+ const { toJSON } = render(<WrappedComponent />);
23
+
24
+ expect(toJSON()).toMatchSnapshot();
25
+ });
26
+ });
27
+ });
@@ -1,4 +1,10 @@
1
- import React, { createContext, ReactNode, useMemo, useState } from "react";
1
+ import React, {
2
+ createContext,
3
+ ReactNode,
4
+ useCallback,
5
+ useMemo,
6
+ useRef,
7
+ } from "react";
2
8
  import {
3
9
  useCurrentScreenData,
4
10
  useNavigation,
@@ -7,27 +13,67 @@ import {
7
13
  } from "@applicaster/zapp-react-native-utils/reactHooks";
8
14
  import { useModalNavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ModalNavigationContext";
9
15
  import { useNestedNavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NestedNavigationContext";
16
+ import { create, StoreApi, UseBoundStore } from "zustand";
17
+ import { useShallow } from "zustand/react/shallow";
18
+ import { Animated } from "react-native";
19
+
20
+ interface NavBarStoreState {
21
+ visible: boolean;
22
+ title: string;
23
+ summary: string;
24
+ setVisible: (state: boolean) => void;
25
+ setTitle: (title: string) => void;
26
+ setSummary: (subtitle: string) => void;
27
+ height: number;
28
+ scrollState: number;
29
+ contentPosition: string;
30
+ scrollYAnimated: Animated.Value;
31
+ }
32
+
33
+ interface NavBarState {
34
+ visible: boolean;
35
+ title: string;
36
+ summary: string;
37
+ setVisible: (state: boolean) => void;
38
+ setTitle: (title: string) => void;
39
+ setSummary: (subtitle: string) => void;
40
+ }
10
41
 
11
42
  type ScreenContextType = {
12
- navBar: {
13
- visible: boolean;
14
- title: string;
15
- summary: string;
16
- setVisible: (state: boolean) => void;
17
- setTitle: (title: string) => void;
18
- setSummary: (subtitle: string) => void;
19
- };
43
+ _navBarStore: UseBoundStore<StoreApi<NavBarStoreState>>;
44
+ navBar: NavBarState;
20
45
  legacyFormatScreenData: LegacyNavigationScreenData | null;
21
46
  };
22
47
 
48
+ const createStore = () =>
49
+ create<NavBarStoreState>((set) => ({
50
+ title: "",
51
+ summary: "",
52
+ visible: true,
53
+ height: 0,
54
+ scrollState: 0,
55
+ contentPosition: "",
56
+ scrollYAnimated: new Animated.Value(0),
57
+ setTitle(title) {
58
+ set({ title });
59
+ },
60
+ setSummary(summary) {
61
+ set({ summary });
62
+ },
63
+ setVisible(visible) {
64
+ set({ visible });
65
+ },
66
+ }));
67
+
23
68
  export const ScreenContext = createContext<ScreenContextType>({
69
+ _navBarStore: createStore(),
24
70
  navBar: {
25
71
  visible: true,
26
72
  title: "",
27
73
  summary: "",
28
- setVisible: (_state) => {},
29
- setTitle: (_title) => {},
30
- setSummary: (_subtitle) => {},
74
+ setVisible: (_state) => void 0,
75
+ setTitle: (_title) => void 0,
76
+ setSummary: (_subtitle) => void 0,
31
77
  },
32
78
  legacyFormatScreenData: {} as LegacyNavigationScreenData,
33
79
  });
@@ -53,9 +99,30 @@ export function ScreenContextProvider({
53
99
  const isNested = useNestedNavigationContext();
54
100
  const currentScreenScreenData = useCurrentScreenData();
55
101
 
56
- const [navBarTitle, setNavBarTitle] = useState("");
57
- const [navBarSummary, setNavBarSummary] = useState("");
58
- const [navBarVisible, setNavBarVisible] = useState(true);
102
+ const screenNavBarStateRef =
103
+ useRef<null | ReturnType<typeof createStore>>(null);
104
+
105
+ const getScreenNavBarState = useCallback(() => {
106
+ if (screenNavBarStateRef.current !== null) {
107
+ return screenNavBarStateRef.current;
108
+ }
109
+
110
+ const navBarState = createStore();
111
+ screenNavBarStateRef.current = navBarState;
112
+
113
+ return navBarState;
114
+ }, []);
115
+
116
+ const screenNavBarState = getScreenNavBarState()(
117
+ useShallow((state) => ({
118
+ visible: state.visible,
119
+ title: state.title,
120
+ summary: state.summary,
121
+ setTitle: state.setTitle,
122
+ setSummary: state.setSummary,
123
+ setVisible: state.setVisible,
124
+ }))
125
+ );
59
126
 
60
127
  const isHook = pathname.includes("hook");
61
128
 
@@ -73,26 +140,28 @@ export function ScreenContextProvider({
73
140
  const isVisible = isNavBarVisible(
74
141
  pathname,
75
142
  currentScreenScreenData, // what fallback should be if currentScreenData is not available?
76
- navBarVisible,
143
+ screenNavBarState.visible,
77
144
  canGoBack(isHook, pathname),
78
145
  videoModalState
79
146
  );
80
147
 
81
- const navBarState = useMemo(() => {
82
- return {
83
- title: navBarTitle,
84
- summary: navBarSummary,
148
+ const navBarState = useMemo(
149
+ () => ({
150
+ title: screenNavBarState.title,
151
+ summary: screenNavBarState.summary,
85
152
  visible: isVisible,
86
- setTitle: setNavBarTitle,
87
- setSummary: setNavBarSummary,
88
- setVisible: setNavBarVisible,
89
- };
90
- }, [isVisible, navBarTitle, navBarSummary]);
153
+ setTitle: screenNavBarState.setTitle,
154
+ setSummary: screenNavBarState.setSummary,
155
+ setVisible: screenNavBarState.setVisible,
156
+ }),
157
+ [isVisible, screenNavBarState.title, screenNavBarState.summary]
158
+ );
91
159
 
92
160
  return (
93
161
  <ScreenContext.Provider
94
162
  value={useMemo(
95
163
  () => ({
164
+ _navBarStore: getScreenNavBarState(),
96
165
  navBar: navBarState,
97
166
  legacyFormatScreenData: routeScreenData,
98
167
  }),
package/events/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export enum QBUIComponentEvents {
2
2
  toggleGradient = "toggleGradient",
3
3
  topMenuBarTV_onFocus = "topMenuBarTV_onFocus",
4
+ navigatorReplaceItem = "navigatorReplaceItem",
4
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "12.0.0-alpha.5135101838",
3
+ "version": "12.0.0-alpha.5227180498",
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",
@@ -34,10 +34,10 @@
34
34
  "redux-mock-store": "^1.5.3"
35
35
  },
36
36
  "dependencies": {
37
- "@applicaster/applicaster-types": "12.0.0-alpha.5135101838",
38
- "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.5135101838",
39
- "@applicaster/zapp-react-native-redux": "12.0.0-alpha.5135101838",
40
- "@applicaster/zapp-react-native-utils": "12.0.0-alpha.5135101838",
37
+ "@applicaster/applicaster-types": "12.0.0-alpha.5227180498",
38
+ "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.5227180498",
39
+ "@applicaster/zapp-react-native-redux": "12.0.0-alpha.5227180498",
40
+ "@applicaster/zapp-react-native-utils": "12.0.0-alpha.5227180498",
41
41
  "promise": "^8.3.0",
42
42
  "react-router-native": "^5.1.2",
43
43
  "url": "^0.11.0",
File without changes