@applicaster/zapp-react-native-app 12.0.0-alpha.5085420612 → 12.0.0-alpha.5131585791

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.
@@ -3,21 +3,16 @@ import { BackHandler } from "react-native";
3
3
  import * as R from "ramda";
4
4
 
5
5
  import {
6
- sendQuickBrickEvent,
7
6
  QUICK_BRICK_EVENTS,
7
+ sendQuickBrickEvent,
8
8
  } from "@applicaster/zapp-react-native-bridge/QuickBrick";
9
9
  import { useNavigation } from "@applicaster/zapp-react-native-utils/reactHooks/navigation";
10
10
  import { useAnalytics } from "@applicaster/zapp-react-native-utils/analyticsUtils";
11
11
  import { useRivers } from "@applicaster/zapp-react-native-utils/reactHooks/state";
12
12
 
13
- type Props = {
14
- children: React.CElement,
15
- };
16
-
17
13
  const getHome = R.compose(R.find(R.propEq("home", true)), R.values);
18
14
 
19
- const InteractionManagerComponent = (props: Props) => {
20
- const { children } = props;
15
+ const InteractionManagerComponent = () => {
21
16
  const { sendHardwareBackButtonClickEvent } = useAnalytics();
22
17
  const rivers = useRivers();
23
18
  const navigator = useNavigation();
@@ -63,19 +58,7 @@ const InteractionManagerComponent = (props: Props) => {
63
58
  };
64
59
  }, [onHardwareBackPress]);
65
60
 
66
- return children;
61
+ return null;
67
62
  };
68
63
 
69
64
  export const InteractionManager = React.memo(InteractionManagerComponent);
70
-
71
- export function withInteractionManager(
72
- Component: React.ComponentType<any>
73
- ): React.ComponentType<any> {
74
- return function InteractionManagerComponent(props) {
75
- return (
76
- <InteractionManager>
77
- <Component {...props} />
78
- </InteractionManager>
79
- );
80
- };
81
- }
@@ -3,12 +3,15 @@ import * as R from "ramda";
3
3
 
4
4
  import { View } from "react-native";
5
5
 
6
- import { getNavigationProps } from "@applicaster/zapp-react-native-utils/navigationUtils";
7
6
  import {
8
- useGetBottomTabBarHeight,
9
- useNavigation,
7
+ getNavigationProps,
8
+ resolveNavigationPlugin,
9
+ } from "@applicaster/zapp-react-native-utils/navigationUtils";
10
+ import {
10
11
  useDimensions,
12
+ useGetBottomTabBarHeight,
11
13
  useNavbarState,
14
+ useNavigation,
12
15
  } from "@applicaster/zapp-react-native-utils/reactHooks";
13
16
  import { Transitioner } from "@applicaster/zapp-react-native-ui-components/Components/Transitioner";
14
17
  import { transitionConfig } from "@applicaster/zapp-react-native-ui-components/Components/Transitioner/config";
@@ -20,10 +23,16 @@ import { getNavigationPluginModule } from "./layoutHelpers";
20
23
  import { isMenuVisible } from "@applicaster/zapp-react-native-ui-components/Components/Screen/navigationHandler";
21
24
  import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
22
25
 
23
- import { MenuToggleContext } from "@applicaster/zapp-react-native-ui-components/Contexts";
26
+ import {
27
+ useMenuToggleContext,
28
+ MenuToggleContextType,
29
+ } from "@applicaster/zapp-react-native-ui-components/Contexts/MenuToggleContext";
24
30
  import { VideoModal } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal";
25
31
  import { withDimensionsProvider } from "@applicaster/zapp-react-native-utils/dimensionsProvider";
26
- import { withModalAnimationProvider } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
32
+ import {
33
+ withModalAnimationProvider,
34
+ useModalAnimationContext,
35
+ } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
27
36
 
28
37
  import { ZappHooksModal } from "@applicaster/zapp-react-dom-ui-components/Components/ZappHooksModal";
29
38
  import { useListenEventBusEvent } from "@applicaster/zapp-react-native-utils/reactHooks/useListenEventBusEvent";
@@ -33,22 +42,11 @@ import {
33
42
  PushTopicManagerEvents,
34
43
  } from "@applicaster/zapp-react-native-bridge/PushNotifications/PushTopicManager";
35
44
 
36
- type Props = {
37
- children: React.ReactNode;
38
- toggleMenu: any;
39
- setToggleMenu: () => void;
40
- openMenu: any;
41
- setOpenMenu: () => void;
42
- closeMenu: any;
43
- setCloseMenu: () => void;
44
- navigator: QuickBrickAppNavigator;
45
- };
46
-
47
45
  const containerStyle = {
48
46
  height: "100%",
49
47
  };
50
48
 
51
- const LayoutWithMenu = (props: Props) => {
49
+ const LayoutWithMenu = () => {
52
50
  const {
53
51
  plugins,
54
52
  appState: { appReady },
@@ -61,7 +59,7 @@ const LayoutWithMenu = (props: Props) => {
61
59
  setOpenMenu,
62
60
  closeMenu,
63
61
  setCloseMenu,
64
- } = props;
62
+ } = useMenuToggleContext();
65
63
 
66
64
  const dimensions = useDimensions("screen", { fullDimensions: true });
67
65
  const isRTL = useIsRTL();
@@ -71,6 +69,12 @@ const LayoutWithMenu = (props: Props) => {
71
69
 
72
70
  const { activeRiver, videoModalState, isVideoModalDocked } = navigator;
73
71
 
72
+ const plugin = resolveNavigationPlugin({
73
+ category: "menu",
74
+ navigations: activeRiver?.navigations,
75
+ plugins,
76
+ });
77
+
74
78
  const Menu = React.useMemo(
75
79
  () =>
76
80
  getNavigationPluginModule(
@@ -78,19 +82,42 @@ const LayoutWithMenu = (props: Props) => {
78
82
  activeRiver,
79
83
  plugins
80
84
  ) as React.ComponentType<
81
- MobileNavBarPluginProps & { navigator: ZappNavigation }
85
+ MobileNavBarPluginProps &
86
+ MenuToggleContextType & {
87
+ navigator: QuickBrickAppNavigator;
88
+ }
82
89
  >,
83
- []
90
+ [activeRiver]
84
91
  );
85
92
 
93
+ const { isActiveGesture } = useModalAnimationContext();
94
+
95
+ /** BTB shown when videoModalState - visible & minimized, maximized & animation gesture is active
96
+ * otherwise hidden if videoModalState - visible
97
+ * also check isMenuVisible
98
+ */
86
99
  const showMenu = React.useMemo(
87
- () => isMenuVisible(navigator.currentRoute, navigator.screenData),
88
- [navigator.currentRoute]
100
+ () =>
101
+ ((videoModalState.visible &&
102
+ (videoModalState.mode === "MINIMIZED" ||
103
+ (videoModalState.mode === "MAXIMIZED" && isActiveGesture))) ||
104
+ !videoModalState.visible) &&
105
+ isMenuVisible(navigator.currentRoute, navigator.screenData),
106
+ [
107
+ videoModalState.visible,
108
+ videoModalState.mode,
109
+ navigator.currentRoute,
110
+ isActiveGesture,
111
+ ]
89
112
  );
90
113
 
114
+ const isBottomTabsPlugin = plugin?.identifier === "quick-brick-bottom-tabs";
115
+
116
+ const shouldApplyStyleForBottomTabs = showMenu && isBottomTabsPlugin;
117
+
91
118
  const contentStyle = React.useMemo(
92
119
  () => ({
93
- ...(showMenu
120
+ ...(shouldApplyStyleForBottomTabs
94
121
  ? {
95
122
  paddingBottom: bottomTabBarHeight,
96
123
  }
@@ -101,23 +128,31 @@ const LayoutWithMenu = (props: Props) => {
101
128
  [bottomTabBarHeight, videoModalState.visible, isVideoModalDocked, showMenu]
102
129
  );
103
130
 
104
- const menuProps = {
105
- setToggleMenu: setToggleMenu,
106
- toggleMenu: toggleMenu,
107
- openMenu: openMenu,
108
- setOpenMenu: setOpenMenu,
109
- closeMenu: closeMenu,
110
- setCloseMenu: setCloseMenu,
111
- dimensions: { window: dimensions },
112
- navigator,
113
- ...getNavigationProps({
131
+ const menuProps = React.useMemo(() => {
132
+ const navigationProps = getNavigationProps({
114
133
  navigator,
115
134
  title,
116
135
  category: "menu",
117
- }),
118
- bottomTabBarHeight,
119
- isRTL,
120
- };
136
+ }) ?? {
137
+ selected: "",
138
+ title: "",
139
+ home: false,
140
+ rules: {} as ZappNavBarRules,
141
+ assets: {} as ZappNavBarAssets,
142
+ styles: {},
143
+ nav_items: [] as NavBarItem[],
144
+ };
145
+
146
+ const props = {
147
+ ...navigationProps,
148
+ dimensions: { window: dimensions },
149
+ bottomTabBarHeight,
150
+ isRTL,
151
+ navigator,
152
+ };
153
+
154
+ return { ...props, id: navigator.currentRoute };
155
+ }, [dimensions, isRTL, bottomTabBarHeight, navigator.currentRoute]);
121
156
 
122
157
  useListenEventBusEvent(
123
158
  PushTopicManagerConsts.PushTopicManagerSubscriptionID,
@@ -137,21 +172,28 @@ const LayoutWithMenu = (props: Props) => {
137
172
  <View style={contentStyle}>
138
173
  <Transitioner
139
174
  transitionConfig={transitionConfig}
140
- contentStyle={showMenu ? contentStyle : {}}
175
+ contentStyle={{}}
141
176
  isRTL={isRTL}
142
177
  >
143
- {/* has pathname context */}
144
178
  <Screen
145
179
  key={navigator.currentRoute}
146
180
  pathname={navigator.currentRoute} // required by TransitionerComponent
147
- screenData={navigator.screenData} // required by TransitionerComponent
148
- setToggleMenu={setToggleMenu}
149
- setCloseMenu={setCloseMenu}
181
+ screenData={navigator.data} // required by TransitionerComponent
150
182
  />
151
183
  </Transitioner>
152
184
  </View>
153
185
  ) : null}
154
- {showMenu && <Menu {...{ ...menuProps, id: navigator.currentRoute }} />}
186
+ {showMenu && (
187
+ <Menu
188
+ {...menuProps}
189
+ setToggleMenu={setToggleMenu}
190
+ toggleMenu={toggleMenu}
191
+ openMenu={openMenu}
192
+ setOpenMenu={setOpenMenu}
193
+ closeMenu={closeMenu}
194
+ setCloseMenu={setCloseMenu}
195
+ />
196
+ )}
155
197
  {/* depends on active river. @TODO move below screen context */}
156
198
  {VideoModal && videoModalState.visible && <VideoModal />}
157
199
  <ZappHooksModal />
@@ -160,7 +202,6 @@ const LayoutWithMenu = (props: Props) => {
160
202
  };
161
203
 
162
204
  export const Layout = R.compose(
163
- MenuToggleContext.withConsumer,
164
205
  withDimensionsProvider,
165
206
  withModalAnimationProvider
166
207
  )(LayoutWithMenu);
package/App/index.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import * as React from "react";
2
2
  import * as R from "ramda";
3
- import { NativeRouter, useLocation, useHistory } from "react-router-native";
3
+ import { NativeRouter, useHistory, useLocation } from "react-router-native";
4
4
  // @ts-ignore
5
5
  import { createQuickBrickApp } from "@applicaster/quick-brick-core";
6
6
  import * as Contexts from "@applicaster/zapp-react-native-ui-components/Contexts";
7
7
  import * as QuickBrickManager from "@applicaster/zapp-react-native-bridge/QuickBrick";
8
8
  import { OfflineHandler } from "@applicaster/zapp-react-native-ui-components/Components/OfflineHandler";
9
9
 
10
- import { withInteractionManager } from "./InteractionManager";
10
+ import { InteractionManager } from "./InteractionManager";
11
11
 
12
12
  import { Layout } from "./Layout";
13
13
 
@@ -22,6 +22,6 @@ export const ZappApp: React.ComponentType<Props> = createQuickBrickApp({
22
22
  QuickBrickManager,
23
23
  Layout,
24
24
  OfflineHandler,
25
- InteractionManager: withInteractionManager, // mostly back button handle in Android
25
+ InteractionManager, // mostly back button handle in Android
26
26
  ContextProviders: R.map(R.prop("withProvider"), R.values(Contexts)),
27
27
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-app",
3
- "version": "12.0.0-alpha.5085420612",
3
+ "version": "12.0.0-alpha.5131585791",
4
4
  "description": "Zapp App Component for Applicaster's Quick Brick React Native App",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -29,11 +29,11 @@
29
29
  },
30
30
  "homepage": "https://github.com/applicaster/quickbrick#readme",
31
31
  "dependencies": {
32
- "@applicaster/quick-brick-core": "12.0.0-alpha.5085420612",
33
- "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.5085420612",
34
- "@applicaster/zapp-react-native-redux": "12.0.0-alpha.5085420612",
35
- "@applicaster/zapp-react-native-ui-components": "12.0.0-alpha.5085420612",
36
- "@applicaster/zapp-react-native-utils": "12.0.0-alpha.5085420612",
32
+ "@applicaster/quick-brick-core": "12.0.0-alpha.5131585791",
33
+ "@applicaster/zapp-react-native-bridge": "12.0.0-alpha.5131585791",
34
+ "@applicaster/zapp-react-native-redux": "12.0.0-alpha.5131585791",
35
+ "@applicaster/zapp-react-native-ui-components": "12.0.0-alpha.5131585791",
36
+ "@applicaster/zapp-react-native-utils": "12.0.0-alpha.5131585791",
37
37
  "axios": "^0.28.0",
38
38
  "camelize": "^1.0.0",
39
39
  "query-string": "7.1.3",