@applicaster/zapp-react-native-app 15.0.0-alpha.4368022015 → 15.0.0-alpha.4413958104

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";
22
+
23
+ import {
24
+ usePlugins,
25
+ useAppSelector,
26
+ selectAppReady,
27
+ } from "@applicaster/zapp-react-native-redux";
19
28
 
20
- import { isMenuVisible } from "@applicaster/zapp-react-native-ui-components/Components/Screen/navigationHandler";
21
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
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,
@@ -44,10 +57,8 @@ const styles = StyleSheet.create({
44
57
  });
45
58
 
46
59
  const LayoutWithMenu = () => {
47
- const {
48
- plugins,
49
- appState: { appReady },
50
- } = usePickFromState(["plugins", "appState"]);
60
+ const plugins = usePlugins();
61
+ const appReady = useAppSelector(selectAppReady);
51
62
 
52
63
  const {
53
64
  toggleMenu,
@@ -82,6 +93,12 @@ const LayoutWithMenu = () => {
82
93
  [activeRiver]
83
94
  );
84
95
 
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]);
101
+
85
102
  /** BTB shown when videoModalState - visible & minimized, maximized & animation gesture is active
86
103
  * otherwise hidden if videoModalState - visible
87
104
  * also check isMenuVisible
@@ -93,14 +110,38 @@ const LayoutWithMenu = () => {
93
110
  plugins
94
111
  );
95
112
 
96
- const shouldShowWithVideo =
97
- videoModalState.visible &&
98
- ["MINIMIZED", "MAXIMIZED"].includes(videoModalState.mode);
113
+ if (isSideMenu) {
114
+ return menuVisible;
115
+ }
99
116
 
100
- return menuVisible && (shouldShowWithVideo || !videoModalState.visible);
101
- }, [videoModalState.visible, videoModalState.mode, navigator.currentRoute]);
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
- const paddingBottom = showMenu ? bottomTabBarHeight + safeAreaBottomInset : 0; // if activeRiver?.navigations has quick-brick-bottom-tabs - append bottomTabBarHeight as padding
134
+ return bottomTabsVisible && isVideoOverlayVisible(videoModalState);
135
+ }, [
136
+ videoModalState.visible,
137
+ videoModalState.mode,
138
+ navigator.currentRoute,
139
+ navigator.screenData,
140
+ ]);
141
+
142
+ const paddingBottom = showBottomTabs
143
+ ? bottomTabBarHeight + safeAreaBottomInset
144
+ : 0; // if activeRiver?.navigations has quick-brick-bottom-tabs - append bottomTabBarHeight as padding
104
145
 
105
146
  const contentStyle = React.useMemo(
106
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-alpha.4368022015",
3
+ "version": "15.0.0-alpha.4413958104",
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-alpha.4368022015",
31
- "@applicaster/zapp-react-native-bridge": "15.0.0-alpha.4368022015",
32
- "@applicaster/zapp-react-native-redux": "15.0.0-alpha.4368022015",
33
- "@applicaster/zapp-react-native-ui-components": "15.0.0-alpha.4368022015",
34
- "@applicaster/zapp-react-native-utils": "15.0.0-alpha.4368022015",
30
+ "@applicaster/quick-brick-core": "15.0.0-alpha.4413958104",
31
+ "@applicaster/zapp-react-native-bridge": "15.0.0-alpha.4413958104",
32
+ "@applicaster/zapp-react-native-redux": "15.0.0-alpha.4413958104",
33
+ "@applicaster/zapp-react-native-ui-components": "15.0.0-alpha.4413958104",
34
+ "@applicaster/zapp-react-native-utils": "15.0.0-alpha.4413958104",
35
35
  "axios": "^0.28.0",
36
36
  "camelize": "^1.0.0",
37
37
  "query-string": "7.1.3",