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

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 (31) hide show
  1. package/Components/BaseFocusable/index.tsx +1 -1
  2. package/Components/Cell/Cell.tsx +5 -1
  3. package/Components/Cell/CellWithFocusable.tsx +17 -5
  4. package/Components/FocusableGroup/index.tsx +1 -0
  5. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +13 -6
  6. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
  7. package/Components/HandlePlayable/HandlePlayable.tsx +3 -0
  8. package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +2 -2
  9. package/Components/Layout/TV/index.tsx +124 -25
  10. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +5 -3
  11. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  12. package/Components/PlayerContainer/PlayerContainer.tsx +11 -6
  13. package/Components/River/ComponentsMap/ComponentsMap.tsx +85 -22
  14. package/Components/River/TV/River.tsx +0 -1
  15. package/Components/Screen/TV/index.web.tsx +151 -0
  16. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +4 -0
  17. package/Components/Screen/index.tsx +35 -24
  18. package/Components/ScreenResolver/index.tsx +3 -1
  19. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +0 -5
  20. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +11 -4
  21. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +9 -2
  22. package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +1 -1
  23. package/Components/Viewport/ViewportTracker/index.tsx +1 -0
  24. package/Components/Viewport/utils.js +1 -1
  25. package/Contexts/MenuToggleContext/{index.js → index.ts} +16 -0
  26. package/Contexts/ScreenContext/__tests__/__snapshots__/index.test.tsx.snap +3 -0
  27. package/Contexts/ScreenContext/__tests__/index.test.tsx +27 -0
  28. package/Contexts/ScreenContext/index.tsx +94 -25
  29. package/Contexts/ZappPipesContext/ZappPipesEntryContext.ts +1 -1
  30. package/package.json +5 -5
  31. /package/Contexts/{index.js → index.ts} +0 -0
@@ -0,0 +1,151 @@
1
+ import * as React from "react";
2
+ import { last, pathOr } from "ramda";
3
+ import { ScreenResolver } from "../../ScreenResolver";
4
+ import {
5
+ getNavigationProps,
6
+ getPathAttributes,
7
+ resolveNavigationPlugin,
8
+ } from "@applicaster/zapp-react-native-utils/navigationUtils";
9
+ import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
10
+ import { NavBarContainer } from "../../Layout/TV/NavBarContainer";
11
+ import { noop } from "@applicaster/zapp-react-native-utils/functionUtils";
12
+ import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
13
+
14
+ type Components = {
15
+ NavBar: React.ComponentType<any>;
16
+ Background: React.ComponentType<any>;
17
+ };
18
+
19
+ type Props = {
20
+ route: string;
21
+ Components: Components;
22
+ };
23
+
24
+ const isPlayer = (routeState): boolean => {
25
+ const pluginType = pathOr(
26
+ "unknown_plugin_type",
27
+ ["state", "screen", "plugin_type"],
28
+ routeState
29
+ );
30
+
31
+ return pluginType === "player";
32
+ };
33
+
34
+ const getActiveRiver = ({
35
+ screenId,
36
+ screenType,
37
+ routeState,
38
+ rivers,
39
+ fallbackActiveRiver,
40
+ }) => {
41
+ if (rivers[screenId]) {
42
+ // river presents
43
+ return screenType === "hooks"
44
+ ? routeState?.state?.entry?.payload
45
+ : routeState?.state?.screen;
46
+ }
47
+
48
+ // screenId is not presented into rivers, use fallback instead
49
+ return fallbackActiveRiver;
50
+ };
51
+
52
+ const getNavigations = ({
53
+ screenId,
54
+ screenType,
55
+ routeState,
56
+ rivers,
57
+ fallbackNavigations,
58
+ }) => {
59
+ if (rivers[screenId]) {
60
+ // river presents
61
+ return screenType === "hooks"
62
+ ? routeState?.state?.entry?.payload.navigations
63
+ : routeState?.state?.screen?.navigations;
64
+ }
65
+
66
+ // screenId is not presented into rivers, use fallback instead
67
+ return fallbackNavigations;
68
+ };
69
+
70
+ export const Screen = (props: Props) => {
71
+ if (!props.route) {
72
+ throw new Error("Required props route is missing");
73
+ }
74
+
75
+ const navigator = useNavigation();
76
+ const { plugins = [], rivers = [] } = usePickFromState(["plugins", "rivers"]);
77
+
78
+ const pathAttributes = getPathAttributes({ pathname: props.route });
79
+ const routeState = navigator.getStackForPathname(props.route);
80
+
81
+ const { screenType, screenId } = last(pathAttributes);
82
+
83
+ // console.log("debug_2", "Screen", {
84
+ // screenType,
85
+ // routeState,
86
+ // route: props.route,
87
+ // navigator,
88
+ // });
89
+
90
+ const activeRiver = getActiveRiver({
91
+ screenId,
92
+ screenType,
93
+ routeState,
94
+ rivers,
95
+ fallbackActiveRiver: navigator.activeRiver,
96
+ });
97
+
98
+ const navigationProps = getNavigationProps({
99
+ navigator: {
100
+ // @ts-ignore
101
+ activeRiver,
102
+ // @ts-ignore
103
+ screenTitle: routeState.state.entry?.title || routeState.screen?.name,
104
+ },
105
+ category: "menu",
106
+ });
107
+
108
+ const navigations = getNavigations({
109
+ screenId,
110
+ screenType,
111
+ routeState,
112
+ rivers,
113
+ fallbackNavigations: navigator.activeRiver.navigations,
114
+ });
115
+
116
+ const menuPlugin = resolveNavigationPlugin({
117
+ category: "menu",
118
+ navigations,
119
+ plugins,
120
+ }) as QuickBrickPlugin;
121
+
122
+ const NavBar = (props.Components.NavBar ||
123
+ menuPlugin.module) as React.ComponentType<any>;
124
+
125
+ const isNavBarVisible = !isPlayer(routeState);
126
+
127
+ const screenData =
128
+ screenType === "hooks"
129
+ ? routeState?.state?.entry
130
+ : routeState?.state?.screen;
131
+
132
+ return (
133
+ <>
134
+ <NavBarContainer isVisible={isNavBarVisible} onReady={noop}>
135
+ <NavBar
136
+ groupId={props.route}
137
+ isVisible={isNavBarVisible}
138
+ menuPlugin={menuPlugin}
139
+ navigationProps={navigationProps}
140
+ // Maybe activeRiver?
141
+ />
142
+ </NavBarContainer>
143
+ <ScreenResolver
144
+ screenType={screenType}
145
+ screenId={screenId}
146
+ screenData={screenData}
147
+ groupId={props.route}
148
+ />
149
+ </>
150
+ );
151
+ };
@@ -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 ? */}
@@ -32,12 +32,13 @@ type Props = {
32
32
  nextFocusLeft?: React.Ref<any>;
33
33
  nextFocusUp?: React.Ref<any>;
34
34
  };
35
+ groupId?: string;
35
36
  };
36
37
 
37
38
  export function ScreenResolverComponent(props: Props) {
38
39
  useScreenAnalytics(props);
39
40
 
40
- const { screenType, screenId, screenData } = props;
41
+ const { screenType, screenId, screenData, groupId } = props;
41
42
 
42
43
  const { hookPlugin } = screenData || {};
43
44
 
@@ -81,6 +82,7 @@ export function ScreenResolverComponent(props: Props) {
81
82
  item={screenData}
82
83
  mode={mode === "PIP" ? "PIP" : "FULLSCREEN"}
83
84
  isModal={false}
85
+ groupId={groupId}
84
86
  />
85
87
  );
86
88
  }
@@ -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}
@@ -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
+ isOnBottomNavBar: boolean;
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
+ isOnBottomNavBar: true,
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
  }),
@@ -63,7 +63,7 @@ function prepareContext(
63
63
  const parent = findParent(currentContext, route, getChildren);
64
64
 
65
65
  const newEntry = {
66
- route: route,
66
+ route,
67
67
  id: uuid(),
68
68
  data: newContext,
69
69
  } as SingleEntry;
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.5208030571",
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.5208030571",
38
+ "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.5208030571",
39
+ "@applicaster/zapp-react-native-redux": "12.0.0-alpha.5208030571",
40
+ "@applicaster/zapp-react-native-utils": "12.0.0-alpha.5208030571",
41
41
  "promise": "^8.3.0",
42
42
  "react-router-native": "^5.1.2",
43
43
  "url": "^0.11.0",
File without changes