@applicaster/zapp-react-native-app 15.0.0-rc.5 → 15.0.0-rc.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,10 @@
1
1
  import React from "react";
2
2
  import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
3
+ import {
4
+ getMenuPlugin,
5
+ isBottomTabVisible,
6
+ SIDE_MENU_PLUGIN_ID,
7
+ } from "@applicaster/zapp-react-native-ui-components/Components/Screen/navigationHandler";
3
8
 
4
9
  const mockUseMenuToggleContext = jest.fn(() => ({
5
10
  toggleMenu: jest.fn(),
@@ -12,12 +17,14 @@ const mockUseMenuToggleContext = jest.fn(() => ({
12
17
 
13
18
  jest.mock("../layoutHelpers", () => {
14
19
  const { View } = jest.requireActual("react-native");
20
+ const { isVideoOverlayVisible } = jest.requireActual("../layoutHelpers");
15
21
 
16
22
  return {
17
23
  // eslint-disable-next-line react/display-name
18
24
  getNavigationPluginModule: () => (props) => (
19
25
  <View testID="menu" {...props} />
20
26
  ),
27
+ isVideoOverlayVisible,
21
28
  };
22
29
  });
23
30
 
@@ -110,6 +117,9 @@ jest.mock(
110
117
  "@applicaster/zapp-react-native-ui-components/Components/Screen/navigationHandler",
111
118
  () => ({
112
119
  isMenuVisible: jest.fn(() => true),
120
+ isBottomTabVisible: jest.fn(() => true),
121
+ getMenuPlugin: jest.fn(() => ({ identifier: "test-plugin" })),
122
+ SIDE_MENU_PLUGIN_ID: "quick_brick_side_menu",
113
123
  })
114
124
  );
115
125
 
@@ -237,4 +247,60 @@ describe("Layout", () => {
237
247
  opacity: 1,
238
248
  });
239
249
  });
250
+
251
+ it("should render menu when Side Menu is active and VideoModal is FULLSCREEN", () => {
252
+ (getMenuPlugin as jest.Mock).mockReturnValue({
253
+ identifier: SIDE_MENU_PLUGIN_ID,
254
+ });
255
+
256
+ mockUseNavigation.mockReturnValue({
257
+ activeRiver: { navigations: [] },
258
+ videoModalState: { visible: true, mode: "FULLSCREEN" },
259
+ isVideoModalDocked: false,
260
+ currentRoute: "home",
261
+ data: {},
262
+ });
263
+
264
+ const { queryByTestId } = renderWithProviders(<Layout />);
265
+ expect(queryByTestId("menu")).toBeTruthy();
266
+ });
267
+
268
+ it("should NOT render menu when Bottom Tabs are active and VideoModal is FULLSCREEN", () => {
269
+ (getMenuPlugin as jest.Mock).mockReturnValue({
270
+ identifier: "quick-brick-bottom-tabs",
271
+ });
272
+
273
+ mockUseNavigation.mockReturnValue({
274
+ activeRiver: { navigations: [] },
275
+ videoModalState: { visible: true, mode: "FULLSCREEN" },
276
+ isVideoModalDocked: false,
277
+ currentRoute: "home",
278
+ data: {},
279
+ });
280
+
281
+ const { queryByTestId } = renderWithProviders(<Layout />);
282
+ expect(queryByTestId("menu")).toBeNull();
283
+ });
284
+
285
+ it("should not add padding when Side Menu is active", () => {
286
+ (getMenuPlugin as jest.Mock).mockReturnValue({
287
+ identifier: SIDE_MENU_PLUGIN_ID,
288
+ });
289
+
290
+ (isBottomTabVisible as jest.Mock).mockReturnValue(false);
291
+
292
+ mockUseNavigation.mockReturnValue({
293
+ activeRiver: { navigations: [] },
294
+ videoModalState: { visible: false, mode: "MINIMIZED" },
295
+ isVideoModalDocked: false,
296
+ currentRoute: "home",
297
+ data: {},
298
+ });
299
+
300
+ const { getByTestId } = renderWithProviders(<Layout />);
301
+
302
+ expect(getByTestId("transitioner").props.contentStyle.paddingBottom).toBe(
303
+ 0
304
+ );
305
+ });
240
306
  });
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import * as R from "ramda";
3
3
 
4
- import { View, StyleSheet } from "react-native";
4
+ import { StyleSheet, View } from "react-native";
5
5
 
6
6
  import { getNavigationProps } from "@applicaster/zapp-react-native-utils/navigationUtils";
7
7
  import {
@@ -15,10 +15,23 @@ import { transitionConfig } from "@applicaster/zapp-react-native-ui-components/C
15
15
  import { Screen } from "@applicaster/zapp-react-native-ui-components/Components/Screen";
16
16
  import { useIsRTL } from "@applicaster/zapp-react-native-utils/localizationUtils";
17
17
 
18
- import { getNavigationPluginModule } from "./layoutHelpers";
18
+ import {
19
+ getNavigationPluginModule,
20
+ isVideoOverlayVisible,
21
+ } from "./layoutHelpers";
19
22
 
20
- import { isMenuVisible } from "@applicaster/zapp-react-native-ui-components/Components/Screen/navigationHandler";
21
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
23
+ import {
24
+ usePlugins,
25
+ useAppSelector,
26
+ selectAppReady,
27
+ } from "@applicaster/zapp-react-native-redux";
28
+
29
+ import {
30
+ getMenuPlugin,
31
+ isBottomTabVisible,
32
+ isMenuVisible,
33
+ SIDE_MENU_PLUGIN_ID,
34
+ } from "@applicaster/zapp-react-native-ui-components/Components/Screen/navigationHandler";
22
35
 
23
36
  import {
24
37
  MenuToggleContextType,
@@ -27,7 +40,6 @@ import {
27
40
  import { VideoModal } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal";
28
41
  import { withDimensionsProvider } from "@applicaster/zapp-react-native-utils/dimensionsProvider";
29
42
  import { withModalAnimationProvider } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
30
- import { useModalAnimationContext } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/useModalAnimationContext";
31
43
 
32
44
  import { ZappHooksModal } from "@applicaster/zapp-react-dom-ui-components/Components/ZappHooksModal";
33
45
  import { useListenEventBusEvent } from "@applicaster/zapp-react-native-utils/reactHooks/useListenEventBusEvent";
@@ -45,10 +57,8 @@ const styles = StyleSheet.create({
45
57
  });
46
58
 
47
59
  const LayoutWithMenu = () => {
48
- const {
49
- plugins,
50
- appState: { appReady },
51
- } = usePickFromState(["plugins", "appState"]);
60
+ const plugins = usePlugins();
61
+ const appReady = useAppSelector(selectAppReady);
52
62
 
53
63
  const {
54
64
  toggleMenu,
@@ -83,7 +93,11 @@ const LayoutWithMenu = () => {
83
93
  [activeRiver]
84
94
  );
85
95
 
86
- const { isActiveGesture } = useModalAnimationContext();
96
+ const isSideMenu = React.useMemo(() => {
97
+ const menuPlugin = getMenuPlugin(navigator.screenData, plugins);
98
+
99
+ return menuPlugin?.identifier === SIDE_MENU_PLUGIN_ID;
100
+ }, [navigator.screenData, plugins]);
87
101
 
88
102
  /** BTB shown when videoModalState - visible & minimized, maximized & animation gesture is active
89
103
  * otherwise hidden if videoModalState - visible
@@ -96,19 +110,38 @@ const LayoutWithMenu = () => {
96
110
  plugins
97
111
  );
98
112
 
99
- const shouldShowWithVideo =
100
- videoModalState.visible &&
101
- ["MINIMIZED", "MAXIMIZED"].includes(videoModalState.mode);
113
+ if (isSideMenu) {
114
+ return menuVisible;
115
+ }
116
+
117
+ return menuVisible && isVideoOverlayVisible(videoModalState);
118
+ }, [
119
+ plugins,
120
+ isSideMenu,
121
+ navigator.currentRoute,
122
+ navigator.screenData,
123
+ videoModalState.visible,
124
+ videoModalState.mode,
125
+ ]);
126
+
127
+ const showBottomTabs = React.useMemo(() => {
128
+ const bottomTabsVisible = isBottomTabVisible(
129
+ navigator.currentRoute,
130
+ navigator.screenData,
131
+ plugins
132
+ );
102
133
 
103
- return menuVisible && (shouldShowWithVideo || !videoModalState.visible);
134
+ return bottomTabsVisible && isVideoOverlayVisible(videoModalState);
104
135
  }, [
105
136
  videoModalState.visible,
106
137
  videoModalState.mode,
107
138
  navigator.currentRoute,
108
- isActiveGesture,
139
+ navigator.screenData,
109
140
  ]);
110
141
 
111
- const paddingBottom = showMenu ? bottomTabBarHeight + safeAreaBottomInset : 0; // if activeRiver?.navigations has quick-brick-bottom-tabs - append bottomTabBarHeight as padding
142
+ const paddingBottom = showBottomTabs
143
+ ? bottomTabBarHeight + safeAreaBottomInset
144
+ : 0; // if activeRiver?.navigations has quick-brick-bottom-tabs - append bottomTabBarHeight as padding
112
145
 
113
146
  const contentStyle = React.useMemo(
114
147
  () =>
@@ -28,3 +28,10 @@ export function getNavigationPluginModule(
28
28
 
29
29
  return plugin.module;
30
30
  }
31
+
32
+ export function isVideoOverlayVisible(videoModalState) {
33
+ return (
34
+ !videoModalState.visible ||
35
+ ["MINIMIZED", "MAXIMIZED"].includes(videoModalState.mode)
36
+ );
37
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-app",
3
- "version": "15.0.0-rc.5",
3
+ "version": "15.0.0-rc.52",
4
4
  "description": "Zapp App Component for Applicaster's Quick Brick React Native App",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -27,11 +27,11 @@
27
27
  },
28
28
  "homepage": "https://github.com/applicaster/quickbrick#readme",
29
29
  "dependencies": {
30
- "@applicaster/quick-brick-core": "15.0.0-rc.5",
31
- "@applicaster/zapp-react-native-bridge": "15.0.0-rc.5",
32
- "@applicaster/zapp-react-native-redux": "15.0.0-rc.5",
33
- "@applicaster/zapp-react-native-ui-components": "15.0.0-rc.5",
34
- "@applicaster/zapp-react-native-utils": "15.0.0-rc.5",
30
+ "@applicaster/quick-brick-core": "15.0.0-rc.52",
31
+ "@applicaster/zapp-react-native-bridge": "15.0.0-rc.52",
32
+ "@applicaster/zapp-react-native-redux": "15.0.0-rc.52",
33
+ "@applicaster/zapp-react-native-ui-components": "15.0.0-rc.52",
34
+ "@applicaster/zapp-react-native-utils": "15.0.0-rc.52",
35
35
  "axios": "^0.28.0",
36
36
  "camelize": "^1.0.0",
37
37
  "query-string": "7.1.3",