@applicaster/zapp-react-native-ui-components 12.0.0-alpha.5432134741 → 12.0.0-alpha.5471145113

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 (130) hide show
  1. package/Components/AudioPlayer/AudioPlayer.tsx +9 -1
  2. package/Components/AudioPlayer/__tests__/__snapshots__/audioPlayer.test.js.snap +5 -0
  3. package/Components/AudioPlayer/helpers.tsx +1 -0
  4. package/Components/BaseFocusable/index.tsx +1 -1
  5. package/Components/Cell/Cell.tsx +7 -7
  6. package/Components/Cell/CellWithFocusable.tsx +38 -19
  7. package/Components/Cell/TvOSCellComponent.tsx +2 -2
  8. package/Components/ErrorScreen/index.tsx +1 -1
  9. package/Components/FocusableCell/index.tsx +7 -7
  10. package/Components/FocusableGroup/index.tsx +1 -0
  11. package/Components/FocusableList/FocusableChild.ts +24 -14
  12. package/Components/FocusableList/FocusableItem.tsx +1 -1
  13. package/Components/FocusableList/FocusableListItemWrapper.tsx +76 -0
  14. package/Components/FocusableList/hooks/useCellState.android.ts +3 -1
  15. package/Components/FocusableList/index.tsx +26 -25
  16. package/Components/GeneralContentScreen/GeneralContentScreen.tsx +11 -8
  17. package/Components/GeneralContentScreen/utils/__tests__/useCurationAPI.test.js +13 -6
  18. package/Components/GeneralContentScreen/utils/useCurationAPI.ts +1 -1
  19. package/Components/HandlePlayable/HandlePlayable.tsx +4 -1
  20. package/Components/HookRenderer/index.tsx +1 -6
  21. package/Components/Image/Image.android.tsx +3 -25
  22. package/Components/Image/Image.tsx +18 -2
  23. package/Components/Image/utils/index.ts +39 -0
  24. package/Components/Layout/TV/ScreenLayoutContextProvider.tsx +2 -2
  25. package/Components/Layout/TV/__tests__/__snapshots__/index.test.tsx.snap +10 -50
  26. package/Components/Layout/TV/__tests__/index.test.tsx +19 -108
  27. package/Components/Layout/TV/index.tsx +28 -43
  28. package/Components/Layout/TV/index.web.tsx +33 -0
  29. package/Components/Layout/index.tsx +15 -11
  30. package/Components/MasterCell/DefaultComponents/ActionButton.tsx +2 -0
  31. package/Components/MasterCell/DefaultComponents/BorderContainerView/index.tsx +80 -110
  32. package/Components/MasterCell/DefaultComponents/CellBadge/index.tsx +21 -8
  33. package/Components/MasterCell/DefaultComponents/DynamicBadge.tsx +4 -2
  34. package/Components/MasterCell/DefaultComponents/Image/Image.android.tsx +9 -26
  35. package/Components/MasterCell/DefaultComponents/Image/Image.ios.tsx +5 -3
  36. package/Components/MasterCell/DefaultComponents/Image/hooks/useImageSize.ts +65 -0
  37. package/Components/MasterCell/DefaultComponents/ImageContainer/index.tsx +5 -1
  38. package/Components/MasterCell/DefaultComponents/LiveImage/index.tsx +17 -2
  39. package/Components/MasterCell/DefaultComponents/SecondaryImage/Image.tsx +3 -2
  40. package/Components/MasterCell/DefaultComponents/Text/index.tsx +14 -2
  41. package/Components/MasterCell/DefaultComponents/Toggle.tsx +5 -1
  42. package/Components/MasterCell/DefaultComponents/__tests__/image.test.js +1 -1
  43. package/Components/MasterCell/DefaultComponents/__tests__/text.test.tsx +24 -9
  44. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.android.tsx +4 -1
  45. package/Components/MasterCell/DefaultComponents/tv/ButtonContainerView/index.tsx +4 -1
  46. package/Components/MasterCell/SharedUI/CollapsibleTextContainer/index.ts +6 -10
  47. package/Components/MasterCell/hooks/useAsyncRendering/index.ts +1 -1
  48. package/Components/MasterCell/utils/index.ts +28 -34
  49. package/Components/MeasurmentsPortal/BasicMeasurementsPortal.tsx +11 -7
  50. package/Components/MeasurmentsPortal/MeasurementsPortal.tsx +10 -1
  51. package/Components/ModalComponent/BottomSheetModalContent.tsx +121 -0
  52. package/Components/ModalComponent/Button/Item.tsx +82 -0
  53. package/Components/ModalComponent/Button/ItemIcon.tsx +60 -0
  54. package/Components/ModalComponent/Button/ItemLabel.tsx +101 -0
  55. package/Components/ModalComponent/Button/assets.ts +4 -0
  56. package/Components/ModalComponent/Button/index.tsx +111 -0
  57. package/Components/ModalComponent/Header/CloseButton.tsx +59 -0
  58. package/Components/ModalComponent/Header/Title.tsx +70 -0
  59. package/Components/ModalComponent/Header/assets.ts +4 -0
  60. package/Components/ModalComponent/Header/index.tsx +71 -0
  61. package/Components/ModalComponent/Header/utils.ts +79 -0
  62. package/Components/ModalComponent/index.tsx +38 -0
  63. package/Components/ModalComponent/utils.ts +126 -0
  64. package/Components/Navigator/StackNavigator.tsx +48 -0
  65. package/Components/Navigator/index.ts +1 -0
  66. package/Components/PlayerContainer/PlayerContainer.tsx +69 -31
  67. package/Components/PlayerContainer/ProgramInfo/index.tsx +3 -1
  68. package/Components/PlayerImageBackground/index.tsx +34 -8
  69. package/Components/River/ComponentsMap/ComponentsMap.tsx +97 -2
  70. package/Components/River/RefreshControl.tsx +55 -1
  71. package/Components/River/TV/River.tsx +2 -25
  72. package/Components/River/__tests__/__snapshots__/componentsMap.test.js.snap +1 -1
  73. package/Components/River/__tests__/componentsMap.test.js +7 -0
  74. package/Components/River/useScreenConfiguration.ts +2 -2
  75. package/Components/RouteManager/__tests__/__snapshots__/routeManager.test.js.snap +1 -0
  76. package/Components/RouteManager/__tests__/routeManager.test.js +9 -2
  77. package/Components/RouteManager/index.tsx +4 -2
  78. package/Components/Screen/TV/hooks/index.ts +3 -0
  79. package/Components/Screen/TV/hooks/useInitialFocus.ts +70 -0
  80. package/Components/Screen/TV/hooks/useRestoreFocus.ts +22 -0
  81. package/Components/Screen/TV/index.web.tsx +179 -0
  82. package/Components/Screen/__tests__/Screen.test.tsx +91 -74
  83. package/Components/Screen/__tests__/__snapshots__/Screen.test.tsx.snap +24 -6
  84. package/Components/Screen/__tests__/navigationHandler.test.ts +1 -178
  85. package/Components/Screen/index.tsx +131 -43
  86. package/Components/Screen/navigationHandler.ts +0 -82
  87. package/Components/ScreenResolver/index.tsx +4 -2
  88. package/Components/Tabs/TV/styles.ts +1 -1
  89. package/Components/TrackedView/index.tsx +6 -3
  90. package/Components/Transitioner/Scene.tsx +24 -19
  91. package/Components/Transitioner/Transitioner.tsx +21 -28
  92. package/Components/Transitioner/__tests__/__snapshots__/Scene.test.js.snap +6 -2
  93. package/Components/Transitioner/__tests__/__snapshots__/transitioner.test.js.snap +1 -0
  94. package/Components/VideoLive/LiveImageManager.ts +55 -11
  95. package/Components/VideoLive/PlayerLiveImageComponent.tsx +81 -72
  96. package/Components/VideoLive/__tests__/PlayerLiveImageComponent.test.tsx +45 -3
  97. package/Components/VideoLive/__tests__/__snapshots__/PlayerLiveImageComponent.test.tsx.snap +18 -28
  98. package/Components/VideoModal/ModalAnimation/AnimatedPlayerModalWrapper.tsx +78 -0
  99. package/Components/VideoModal/ModalAnimation/AnimatedScrollModal.tsx +342 -0
  100. package/Components/VideoModal/ModalAnimation/AnimatedVideoPlayerComponent.tsx +151 -0
  101. package/Components/VideoModal/ModalAnimation/AnimationComponent.tsx +438 -0
  102. package/Components/VideoModal/ModalAnimation/ModalAnimationContext.tsx +154 -0
  103. package/Components/VideoModal/ModalAnimation/index.ts +15 -0
  104. package/Components/VideoModal/ModalAnimation/utils.ts +299 -0
  105. package/Components/VideoModal/PlayerDetails.tsx +6 -3
  106. package/Components/VideoModal/PlayerWrapper.tsx +78 -48
  107. package/Components/VideoModal/VideoModal.tsx +23 -40
  108. package/Components/VideoModal/__tests__/PlayerDetails.test.tsx +0 -2
  109. package/Components/VideoModal/__tests__/PlayerWrapper.test.tsx +12 -1
  110. package/Components/VideoModal/__tests__/__snapshots__/PlayerWrapper.test.tsx.snap +246 -166
  111. package/Components/VideoModal/utils.ts +3 -3
  112. package/Components/Viewport/ViewportAware/__tests__/viewportAware.test.js +26 -21
  113. package/Components/Viewport/ViewportTracker/ViewportTracker.tsx +31 -40
  114. package/Components/Viewport/ViewportTracker/__tests__/viewportTracker.test.js +4 -5
  115. package/Components/Viewport/ViewportTracker/index.tsx +1 -0
  116. package/Components/Viewport/utils.js +1 -1
  117. package/Components/ZappUIComponent/index.tsx +22 -12
  118. package/Components/index.js +2 -0
  119. package/Contexts/MenuToggleContext/{index.js → index.ts} +16 -0
  120. package/Contexts/ScreenContext/__tests__/__snapshots__/index.test.tsx.snap +3 -0
  121. package/Contexts/ScreenContext/__tests__/index.test.tsx +27 -0
  122. package/Contexts/ScreenContext/index.tsx +101 -29
  123. package/Contexts/ScreenDataContext/index.tsx +20 -0
  124. package/Contexts/ZappPipesContext/ZappPipesEntryContext.ts +1 -1
  125. package/Decorators/ComponentsMapWrapper/withComponentsMapProvider.tsx +7 -2
  126. package/events/index.ts +1 -0
  127. package/package.json +5 -5
  128. package/Components/Layout/TV/TransitionOverlay.tsx +0 -64
  129. package/Components/VideoModal/hooks/usePosition.ts +0 -50
  130. /package/Contexts/{index.js → index.ts} +0 -0
@@ -6,23 +6,23 @@ import { callOnChildren } from "../utils";
6
6
 
7
7
  export function ViewportTracker(props) {
8
8
  const viewportEvents = useViewportEventsContext();
9
- const { children } = props;
10
- const [width, setWidth] = React.useState(0);
11
- const [height, setHeight] = React.useState(0);
12
- const [offsetX, setOffsetX] = React.useState(0);
13
- const [offsetY, setOffsetY] = React.useState(0);
14
9
  const [nodeHandle, setNodeHandle] = React.useState(null);
15
10
 
16
- const assignRef = React.useCallback(
17
- (ref) => {
18
- callOnChildren(children, "ref", ref);
19
- setNodeHandle(findNodeHandle(ref));
20
- },
21
- [children]
22
- );
11
+ const childrenRef = React.useRef(props.children);
12
+
13
+ const dimensionsRef = React.useRef({ width: 0, height: 0 });
14
+ const offsetRef = React.useRef({ offsetX: 0, offsetY: 0 });
15
+
16
+ const assignRef = React.useCallback((ref) => {
17
+ childrenRef.current?.ref?.(ref);
18
+ setNodeHandle(findNodeHandle(ref));
19
+ }, []);
23
20
 
24
21
  const onViewportChange = React.useCallback(
25
- (event, shouldMeasureLayout = true) => {
22
+ ({
23
+ event = { ...dimensionsRef.current, ...offsetRef.current },
24
+ shouldMeasureLayout = true,
25
+ } = {}) => {
26
26
  if (nodeHandle && event?.width > 0 && event?.height > 0) {
27
27
  viewportEvents?.notify?.({
28
28
  parentHandle: nodeHandle,
@@ -36,54 +36,45 @@ export function ViewportTracker(props) {
36
36
 
37
37
  const onLayout = React.useCallback(
38
38
  (event) => {
39
- callOnChildren(children, "onLayout", event);
40
- setWidth(event?.nativeEvent?.layout?.width);
41
- setHeight(event?.nativeEvent?.layout?.height);
39
+ callOnChildren(childrenRef.current, "onLayout", event);
40
+ dimensionsRef.current = event?.nativeEvent?.layout;
42
41
 
43
- onViewportChange({
44
- width: event?.nativeEvent?.layout?.width,
45
- height: event?.nativeEvent?.layout?.height,
46
- offsetX,
47
- offsetY,
48
- });
42
+ onViewportChange();
49
43
  },
50
- [offsetX, offsetY, children, onViewportChange]
44
+ [onViewportChange]
51
45
  );
52
46
 
53
47
  const onContentSizeChange = React.useCallback(
54
48
  (contentWidth, contentHeight) => {
55
49
  callOnChildren(
56
- children,
50
+ childrenRef.current,
57
51
  "onContentSizeChange",
58
52
  contentWidth,
59
53
  contentHeight
60
54
  );
61
55
 
62
- onViewportChange({ width, height, offsetX, offsetY });
56
+ onViewportChange();
63
57
  },
64
- [onViewportChange, children, width, height, offsetX, offsetY]
58
+ [onViewportChange]
65
59
  );
66
60
 
67
61
  const onScroll = React.useCallback(
68
62
  (event) => {
69
- callOnChildren(children, "onScroll", event);
70
- setOffsetX(event?.nativeEvent?.contentOffset?.x);
71
- setOffsetY(event?.nativeEvent?.contentOffset?.y);
63
+ callOnChildren(childrenRef.current, "onScroll", event);
64
+ offsetRef.current = event?.nativeEvent?.contentOffset;
72
65
 
73
- onViewportChange(
74
- {
75
- width,
76
- height,
77
- offsetX: event?.nativeEvent?.contentOffset?.x,
78
- offsetY: event?.nativeEvent?.contentOffset?.y,
79
- },
80
- false
81
- );
66
+ onViewportChange({
67
+ shouldMeasureLayout: false,
68
+ });
82
69
  },
83
- [onViewportChange, width, height, children]
70
+ [onViewportChange]
84
71
  );
85
72
 
86
- return React.cloneElement(React.Children.only(children), {
73
+ React.useEffect(() => {
74
+ childrenRef.current = props.children;
75
+ }, [props.children]);
76
+
77
+ return React.cloneElement(React.Children.only(props.children), {
87
78
  ref: assignRef,
88
79
  onLayout,
89
80
  onContentSizeChange,
@@ -5,11 +5,10 @@ import { ViewportEvents } from "../../ViewportEvents";
5
5
 
6
6
  const TestComponent = () => <ScrollView />;
7
7
 
8
- jest.mock("react-native", () => {
9
- return {
10
- findNodeHandle: jest.fn(() => 1234),
11
- };
12
- });
8
+ jest.mock("react-native/Libraries/Renderer/shims/ReactNative", () => ({
9
+ ...jest.requireActual("react-native/Libraries/Renderer/shims/ReactNative"),
10
+ findNodeHandle: () => 1234,
11
+ }));
13
12
 
14
13
  const viewportEventsManager = new ViewportEvents(true);
15
14
 
@@ -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(
@@ -10,7 +10,7 @@ import {
10
10
 
11
11
  import { Placeholder } from "./Placeholder";
12
12
  import { useInitialLoading } from "./hooks";
13
- import { FocusableContext } from "../Focusable/index.android";
13
+ import { useFocusable } from "../Focusable/index.android";
14
14
 
15
15
  type ReactComponent = React.ComponentType<any>;
16
16
 
@@ -26,13 +26,23 @@ type ZappUIComponentType = {
26
26
  options?: Options;
27
27
  };
28
28
 
29
- const renderComponent = (Component: ReactComponent | undefined, props) => {
30
- if (Component) {
31
- const { component, parent } = props;
29
+ type RenderComponentProps = any;
30
+
31
+ const RenderComponent = (
32
+ Component: ReactComponent | undefined,
33
+ args: RenderComponentProps
34
+ ) => {
35
+ const { component, parent } = args;
32
36
 
37
+ const contextValue = React.useMemo(
38
+ () => ({ ...component, parent }),
39
+ [component, parent]
40
+ );
41
+
42
+ if (Component) {
33
43
  return (
34
- <UIComponentContext.Provider value={{ ...component, parent }}>
35
- <Component {...props} />
44
+ <UIComponentContext.Provider value={contextValue}>
45
+ <Component {...args} />
36
46
  </UIComponentContext.Provider>
37
47
  );
38
48
  }
@@ -117,7 +127,7 @@ New signature: {Component, ErrorComponent, LoadingComponent, options}`
117
127
  props;
118
128
 
119
129
  const parent = useUIComponentContext();
120
- const { setIsFocusable } = React.useContext(FocusableContext) || {};
130
+ const { setIsFocusable } = useFocusable();
121
131
 
122
132
  const isLoading = toBooleanWithDefaultFalse(zappPipesData?.loading);
123
133
  const isInitialLoading = useInitialLoading(isLoading);
@@ -154,11 +164,11 @@ New signature: {Component, ErrorComponent, LoadingComponent, options}`
154
164
  }, [props.component?.rules?.component_cells_focusable]);
155
165
 
156
166
  if (isDataSourceEmpty(props) && allowsEmptyDataSource) {
157
- return renderComponent(Component, componentProps);
167
+ return RenderComponent(Component, componentProps);
158
168
  }
159
169
 
160
- if (isLoading && !zappPipesData.data && isInitialLoading) {
161
- return renderComponent(LoadingComponent || Placeholder, componentProps);
170
+ if (isLoading && !zappPipesData?.data && isInitialLoading) {
171
+ return RenderComponent(LoadingComponent || Placeholder, componentProps);
162
172
  }
163
173
 
164
174
  if (zappPipesData?.error) {
@@ -167,9 +177,9 @@ New signature: {Component, ErrorComponent, LoadingComponent, options}`
167
177
  index: componentIndex,
168
178
  });
169
179
 
170
- return renderComponent(ErrorComponent, componentProps);
180
+ return RenderComponent(ErrorComponent, componentProps);
171
181
  }
172
182
 
173
- return renderComponent(Component, componentProps);
183
+ return RenderComponent(Component, componentProps);
174
184
  };
175
185
  }
@@ -4,6 +4,8 @@ export { River } from "./River";
4
4
 
5
5
  export { PlayerContainer } from "./PlayerContainer";
6
6
 
7
+ export { ModalComponent } from "./ModalComponent";
8
+
7
9
  export { ContentScreen } from "./ContentScreen";
8
10
 
9
11
  export { TextInputTv } from "./TextInputTv";
@@ -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,34 +1,80 @@
1
- import React, { createContext, ReactNode, useMemo, useState } from "react";
2
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
1
+ import React, {
2
+ createContext,
3
+ ReactNode,
4
+ useCallback,
5
+ useEffect,
6
+ useMemo,
7
+ useRef,
8
+ } from "react";
3
9
  import {
4
10
  useCurrentScreenData,
5
11
  useNavigation,
6
12
  useRoute,
13
+ isNavBarVisible,
7
14
  } from "@applicaster/zapp-react-native-utils/reactHooks";
8
15
  import { useModalNavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/ModalNavigationContext";
9
16
  import { useNestedNavigationContext } from "@applicaster/zapp-react-native-ui-components/Contexts/NestedNavigationContext";
10
- import { isNavBarVisible } from "../../Components/Screen/navigationHandler";
17
+ import { create, StoreApi, UseBoundStore } from "zustand";
18
+ import { useShallow } from "zustand/react/shallow";
19
+ import { Animated } from "react-native";
20
+
21
+ interface NavBarStoreState {
22
+ visible: boolean;
23
+ title: string;
24
+ summary: string;
25
+ setVisible: (state: boolean) => void;
26
+ setTitle: (title: string) => void;
27
+ setSummary: (subtitle: string) => void;
28
+ height: number;
29
+ scrollState: number;
30
+ contentPosition: string;
31
+ scrollYAnimated: Animated.Value;
32
+ }
33
+
34
+ interface NavBarState {
35
+ visible: boolean;
36
+ title: string;
37
+ summary: string;
38
+ setVisible: (state: boolean) => void;
39
+ setTitle: (title: string) => void;
40
+ setSummary: (subtitle: string) => void;
41
+ }
11
42
 
12
43
  type ScreenContextType = {
13
- navBar: {
14
- visible: boolean;
15
- title: string;
16
- summary: string;
17
- setVisible: (state: boolean) => void;
18
- setTitle: (title: string) => void;
19
- setSummary: (subtitle: string) => void;
20
- };
44
+ _navBarStore: UseBoundStore<StoreApi<NavBarStoreState>>;
45
+ navBar: NavBarState;
21
46
  legacyFormatScreenData: LegacyNavigationScreenData | null;
22
47
  };
23
48
 
49
+ const createStore = () =>
50
+ create<NavBarStoreState>((set) => ({
51
+ title: "",
52
+ summary: "",
53
+ visible: true,
54
+ height: 0,
55
+ scrollState: 0,
56
+ contentPosition: "",
57
+ scrollYAnimated: new Animated.Value(0),
58
+ setTitle(title) {
59
+ set({ title });
60
+ },
61
+ setSummary(summary) {
62
+ set({ summary });
63
+ },
64
+ setVisible(visible) {
65
+ set({ visible });
66
+ },
67
+ }));
68
+
24
69
  export const ScreenContext = createContext<ScreenContextType>({
70
+ _navBarStore: createStore(),
25
71
  navBar: {
26
72
  visible: true,
27
73
  title: "",
28
74
  summary: "",
29
- setVisible: (_state) => {},
30
- setTitle: (_title) => {},
31
- setSummary: (_subtitle) => {},
75
+ setVisible: (_state) => void 0,
76
+ setTitle: (_title) => void 0,
77
+ setSummary: (_subtitle) => void 0,
32
78
  },
33
79
  legacyFormatScreenData: {} as LegacyNavigationScreenData,
34
80
  });
@@ -42,8 +88,6 @@ export function ScreenContextProvider({
42
88
  }) {
43
89
  const { data, modalData, videoModalState, canGoBack } = useNavigation();
44
90
 
45
- const { rivers: _rivers } = usePickFromState(["rivers", "plugins"]);
46
-
47
91
  // There are 4 route scenarios
48
92
  // For regular screens take date from navigator stack.
49
93
  // is path is model grab screenData from modal state
@@ -56,9 +100,35 @@ export function ScreenContextProvider({
56
100
  const isNested = useNestedNavigationContext();
57
101
  const currentScreenScreenData = useCurrentScreenData();
58
102
 
59
- const [navBarTitle, setNavBarTitle] = useState("");
60
- const [navBarSummary, setNavBarSummary] = useState("");
61
- const [navBarVisible, setNavBarVisible] = useState(true);
103
+ const screenNavBarStateRef =
104
+ useRef<null | ReturnType<typeof createStore>>(null);
105
+
106
+ const getScreenNavBarState = useCallback(() => {
107
+ if (screenNavBarStateRef.current !== null) {
108
+ return screenNavBarStateRef.current;
109
+ }
110
+
111
+ const navBarState = createStore();
112
+ screenNavBarStateRef.current = navBarState;
113
+
114
+ return navBarState;
115
+ }, []);
116
+
117
+ useEffect(() => {
118
+ // purge the getScreenNavBarState store when the pathname changes
119
+ screenNavBarStateRef.current = null;
120
+ }, [pathname]);
121
+
122
+ const screenNavBarState = getScreenNavBarState()(
123
+ useShallow((state) => ({
124
+ visible: state.visible,
125
+ title: state.title,
126
+ summary: state.summary,
127
+ setTitle: state.setTitle,
128
+ setSummary: state.setSummary,
129
+ setVisible: state.setVisible,
130
+ }))
131
+ );
62
132
 
63
133
  const isHook = pathname.includes("hook");
64
134
 
@@ -76,26 +146,28 @@ export function ScreenContextProvider({
76
146
  const isVisible = isNavBarVisible(
77
147
  pathname,
78
148
  currentScreenScreenData, // what fallback should be if currentScreenData is not available?
79
- navBarVisible,
149
+ screenNavBarState.visible,
80
150
  canGoBack(isHook, pathname),
81
151
  videoModalState
82
152
  );
83
153
 
84
- const navBarState = useMemo(() => {
85
- return {
86
- title: navBarTitle,
87
- summary: navBarSummary,
154
+ const navBarState = useMemo(
155
+ () => ({
156
+ title: screenNavBarState.title,
157
+ summary: screenNavBarState.summary,
88
158
  visible: isVisible,
89
- setTitle: setNavBarTitle,
90
- setSummary: setNavBarSummary,
91
- setVisible: setNavBarVisible,
92
- };
93
- }, [isVisible, navBarTitle, navBarSummary]);
159
+ setTitle: screenNavBarState.setTitle,
160
+ setSummary: screenNavBarState.setSummary,
161
+ setVisible: screenNavBarState.setVisible,
162
+ }),
163
+ [isVisible, screenNavBarState.title, screenNavBarState.summary]
164
+ );
94
165
 
95
166
  return (
96
167
  <ScreenContext.Provider
97
168
  value={useMemo(
98
169
  () => ({
170
+ _navBarStore: getScreenNavBarState(),
99
171
  navBar: navBarState,
100
172
  legacyFormatScreenData: routeScreenData,
101
173
  }),
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks";
3
+
4
+ export const ScreenDataContext = React.createContext<any>(null);
5
+
6
+ // Use this only to provide initial screenData context, before the Transitioner and Screen is rendered.
7
+ export const withScreenDataContextProvider = (Component: any) => {
8
+ return function ScreenDataContextProvider(props: any) {
9
+ const { activeRiver } = useNavigation();
10
+
11
+ // use only initial activeRiver as this context should only be used for "Home", initial route
12
+ const screenData = React.useMemo(() => ({ screen: activeRiver }), []);
13
+
14
+ return (
15
+ <ScreenDataContext.Provider value={screenData}>
16
+ <Component {...props} />
17
+ </ScreenDataContext.Provider>
18
+ );
19
+ };
20
+ };
@@ -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;
@@ -12,11 +12,16 @@ export function withComponentsMapProvider(Component: React.ComponentType<any>) {
12
12
  };
13
13
 
14
14
  const setComponentHeightById = (id: string | number, height: number) => {
15
- componentsHeightMapRef.current = { ...componentsHeightMapRef.current, [id]: height };
15
+ componentsHeightMapRef.current = {
16
+ ...componentsHeightMapRef.current,
17
+ [id]: height,
18
+ };
16
19
  };
17
20
 
18
21
  return (
19
- <ComponentsMapProvider {...{ setComponentHeightById, getComponentHeightById }}>
22
+ <ComponentsMapProvider
23
+ {...{ setComponentHeightById, getComponentHeightById }}
24
+ >
20
25
  <Component {...props} />
21
26
  </ComponentsMapProvider>
22
27
  );
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.5432134741",
3
+ "version": "12.0.0-alpha.5471145113",
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.5432134741",
38
- "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.5432134741",
39
- "@applicaster/zapp-react-native-redux": "12.0.0-alpha.5432134741",
40
- "@applicaster/zapp-react-native-utils": "12.0.0-alpha.5432134741",
37
+ "@applicaster/applicaster-types": "12.0.0-alpha.5471145113",
38
+ "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.5471145113",
39
+ "@applicaster/zapp-react-native-redux": "12.0.0-alpha.5471145113",
40
+ "@applicaster/zapp-react-native-utils": "12.0.0-alpha.5471145113",
41
41
  "promise": "^8.3.0",
42
42
  "react-router-native": "^5.1.2",
43
43
  "url": "^0.11.0",
@@ -1,64 +0,0 @@
1
- import * as React from "react";
2
- import { View, StyleSheet } from "react-native";
3
- import { useCurrentScreenData } from "@applicaster/zapp-react-native-utils/reactHooks/screen";
4
- import { ifEmptyUseFallback } from "@applicaster/zapp-react-native-utils/cellUtils";
5
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
6
- import { isWeb } from "@applicaster/zapp-react-native-utils/reactUtils";
7
- import { Spinner } from "@applicaster/zapp-react-native-ui-components/Components/Spinner";
8
- import { useTheme } from "@applicaster/zapp-react-native-utils/theme";
9
-
10
- import { useScreenConfiguration } from "../../River/useScreenConfiguration";
11
-
12
- const styles = StyleSheet.create({
13
- container: {
14
- position: "absolute",
15
- top: 0,
16
- left: 0,
17
- right: 0,
18
- bottom: 0,
19
-
20
- alignItems: "center",
21
- justifyContent: "center",
22
- },
23
- });
24
-
25
- export const TransitionOverlay = () => {
26
- const screen = useCurrentScreenData();
27
-
28
- const { backgroundColor: screenBackgroundColor } = useScreenConfiguration(
29
- screen?.id
30
- );
31
-
32
- const theme = useTheme();
33
-
34
- const themeBackgroundColor = React.useMemo(
35
- () => theme.app_background_color,
36
- [theme.app_background_color]
37
- );
38
-
39
- const backgroundColor = ifEmptyUseFallback(
40
- screenBackgroundColor,
41
- themeBackgroundColor
42
- );
43
-
44
- const {
45
- appState: { isTransitioning },
46
- } = usePickFromState(["appState"]);
47
-
48
- if (!isWeb() || !isTransitioning) {
49
- return null;
50
- }
51
-
52
- return (
53
- <View
54
- style={[
55
- styles.container,
56
- {
57
- backgroundColor,
58
- },
59
- ]}
60
- >
61
- <Spinner size={"large"} />
62
- </View>
63
- );
64
- };
@@ -1,50 +0,0 @@
1
- import {
2
- useNavigation,
3
- useNavigationType,
4
- MenuTypes,
5
- useGetBottomTabBarHeight,
6
- } from "@applicaster/zapp-react-native-utils/reactHooks";
7
- import { useSafeAreaInsets } from "react-native-safe-area-context";
8
- import { isMenuVisible } from "@applicaster/zapp-react-native-ui-components/Components/Screen/navigationHandler";
9
-
10
- import { useConfiguration } from "../utils";
11
-
12
- type Option<T> = T | undefined;
13
-
14
- type Return = {
15
- top: Option<number>;
16
- height: Option<number>;
17
- bottom: Option<number>;
18
- };
19
-
20
- export const usePosition = (): Return => {
21
- const { minimised_height: minimisedHeight } = useConfiguration();
22
- const insets = useSafeAreaInsets();
23
- const bottomTabBarHeight = useGetBottomTabBarHeight();
24
-
25
- const {
26
- videoModalState: { mode },
27
- currentRoute,
28
- screenData,
29
- } = useNavigation();
30
-
31
- const docked = mode === "MINIMIZED";
32
-
33
- const navType = useNavigationType();
34
- const isBottomBarNavigation = navType === MenuTypes.bottomTabBar;
35
-
36
- const minimisedMarginBottom =
37
- isMenuVisible(currentRoute, screenData) && isBottomBarNavigation
38
- ? bottomTabBarHeight
39
- : insets.bottom;
40
-
41
- if (docked) {
42
- return {
43
- top: undefined,
44
- height: minimisedHeight,
45
- bottom: minimisedMarginBottom,
46
- };
47
- }
48
-
49
- return { top: 0, height: undefined, bottom: 0 };
50
- };
File without changes