@applicaster/zapp-react-native-app 12.0.0-rc.1 → 12.0.0-rc.100

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.
@@ -8,7 +8,7 @@ import {
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
- import { usePickFromState } from "@applicaster/zapp-react-native-redux/hooks";
11
+ import { useRivers } from "@applicaster/zapp-react-native-utils/reactHooks/state";
12
12
 
13
13
  type Props = {
14
14
  children: React.CElement,
@@ -19,7 +19,7 @@ const getHome = R.compose(R.find(R.propEq("home", true)), R.values);
19
19
  const InteractionManagerComponent = (props: Props) => {
20
20
  const { children } = props;
21
21
  const { sendHardwareBackButtonClickEvent } = useAnalytics();
22
- const { rivers } = usePickFromState(["rivers"]);
22
+ const rivers = useRivers();
23
23
  const navigator = useNavigation();
24
24
 
25
25
  const isHomeScreen = () => {
@@ -0,0 +1,7 @@
1
+ describe("Layout", () => {
2
+ it.todo("should match snapshot when appReady is true");
3
+ it.todo("should not render transitioner with screen when appReady is false");
4
+ it.todo("should render menu when showMenu is true");
5
+ it.todo("should render VideoModal when visible & VideoModal is true");
6
+ it.todo("should render ZappHooksModal");
7
+ });
@@ -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 {
7
+ getNavigationProps,
8
+ resolveNavigationPlugin,
9
+ } from "@applicaster/zapp-react-native-utils/navigationUtils";
10
+ import {
11
+ useDimensions,
8
12
  useGetBottomTabBarHeight,
13
+ useNavbarState,
9
14
  useNavigation,
10
- useDimensions,
11
- useIsNavBarVisible,
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,29 +23,30 @@ 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";
32
+ import {
33
+ withModalAnimationProvider,
34
+ useModalAnimationContext,
35
+ } from "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation";
26
36
 
27
37
  import { ZappHooksModal } from "@applicaster/zapp-react-dom-ui-components/Components/ZappHooksModal";
28
- import { useNavbarState } from "@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext";
29
-
30
- type Props = {
31
- children: React.ReactNode;
32
- toggleMenu: any;
33
- setToggleMenu: () => void;
34
- openMenu: any;
35
- setOpenMenu: () => void;
36
- closeMenu: any;
37
- setCloseMenu: () => void;
38
- navigator: QuickBrickAppNavigator;
39
- };
38
+ import { useListenEventBusEvent } from "@applicaster/zapp-react-native-utils/reactHooks/useListenEventBusEvent";
39
+ import {
40
+ PushTopicManager,
41
+ PushTopicManagerConsts,
42
+ PushTopicManagerEvents,
43
+ } from "@applicaster/zapp-react-native-bridge/PushNotifications/PushTopicManager";
40
44
 
41
45
  const containerStyle = {
42
46
  height: "100%",
43
47
  };
44
48
 
45
- const LayoutWithMenu = (props: Props) => {
49
+ const LayoutWithMenu = () => {
46
50
  const {
47
51
  plugins,
48
52
  appState: { appReady },
@@ -55,44 +59,65 @@ const LayoutWithMenu = (props: Props) => {
55
59
  setOpenMenu,
56
60
  closeMenu,
57
61
  setCloseMenu,
58
- } = props;
62
+ } = useMenuToggleContext();
59
63
 
60
64
  const dimensions = useDimensions("screen", { fullDimensions: true });
61
65
  const isRTL = useIsRTL();
62
-
63
66
  const navigator = useNavigation();
64
67
  const bottomTabBarHeight = useGetBottomTabBarHeight();
65
-
66
- const {
67
- activeRiver,
68
- currentRoute,
69
- screenData,
70
- videoModalState,
71
- isVideoModalDocked,
72
- videoModalState: { visible },
73
- } = navigator;
74
-
75
- const isNavBarVisible = useIsNavBarVisible();
76
68
  const { title } = useNavbarState();
77
69
 
78
- const NavBar = React.useMemo(
79
- () => getNavigationPluginModule("nav_bar", activeRiver, plugins),
80
- []
81
- );
70
+ const { activeRiver, videoModalState, isVideoModalDocked } = navigator;
71
+
72
+ const plugin = resolveNavigationPlugin({
73
+ category: "menu",
74
+ navigations: activeRiver?.navigations,
75
+ plugins,
76
+ });
82
77
 
83
78
  const Menu = React.useMemo(
84
- () => getNavigationPluginModule("menu", activeRiver, plugins),
85
- []
79
+ () =>
80
+ getNavigationPluginModule(
81
+ "menu",
82
+ activeRiver,
83
+ plugins
84
+ ) as React.ComponentType<
85
+ MobileNavBarPluginProps &
86
+ MenuToggleContextType & {
87
+ navigator: QuickBrickAppNavigator;
88
+ }
89
+ >,
90
+ [activeRiver]
86
91
  );
87
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
+ */
88
99
  const showMenu = React.useMemo(
89
- () => isMenuVisible(navigator.currentRoute, navigator.screenData),
90
- [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
+ ]
91
112
  );
92
113
 
114
+ const isBottomTabsPlugin = plugin?.identifier === "quick-brick-bottom-tabs";
115
+
116
+ const shouldApplyStyleForBottomTabs = showMenu && isBottomTabsPlugin;
117
+
93
118
  const contentStyle = React.useMemo(
94
119
  () => ({
95
- ...(showMenu
120
+ ...(shouldApplyStyleForBottomTabs
96
121
  ? {
97
122
  paddingBottom: bottomTabBarHeight,
98
123
  }
@@ -103,37 +128,43 @@ const LayoutWithMenu = (props: Props) => {
103
128
  [bottomTabBarHeight, videoModalState.visible, isVideoModalDocked, showMenu]
104
129
  );
105
130
 
106
- const navBarProps = React.useMemo(
107
- () => ({
108
- setToggleMenu,
109
- toggleMenu,
110
- openMenu,
111
- setOpenMenu,
112
- closeMenu,
113
- setCloseMenu,
114
- navigator,
115
- ...getNavigationProps({ navigator, title, category: "nav_bar" }),
116
- }),
117
- [navigator.currentRoute]
118
- );
119
-
120
- const menuProps = {
121
- setToggleMenu: setToggleMenu,
122
- toggleMenu: toggleMenu,
123
- openMenu: openMenu,
124
- setOpenMenu: setOpenMenu,
125
- closeMenu: closeMenu,
126
- setCloseMenu: setCloseMenu,
127
- dimensions: { window: dimensions },
128
- navigator: navigator,
129
- ...getNavigationProps({
131
+ const menuProps = React.useMemo(() => {
132
+ const navigationProps = getNavigationProps({
130
133
  navigator,
131
134
  title,
132
135
  category: "menu",
133
- }),
134
- bottomTabBarHeight,
135
- isRTL,
136
- };
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]);
156
+
157
+ useListenEventBusEvent(
158
+ PushTopicManagerConsts.PushTopicManagerSubscriptionID,
159
+ PushTopicManagerConsts.PushTopicManagerSource,
160
+ Object.keys(PushTopicManagerEvents),
161
+ PushTopicManager.getInstance().routeEvent
162
+ );
163
+
164
+ React.useEffect(() => {
165
+ // getting tags right after subscription
166
+ PushTopicManager.getInstance().prepareTags();
167
+ }, []);
137
168
 
138
169
  return (
139
170
  <>
@@ -141,31 +172,36 @@ const LayoutWithMenu = (props: Props) => {
141
172
  <View style={contentStyle}>
142
173
  <Transitioner
143
174
  transitionConfig={transitionConfig}
144
- contentStyle={showMenu ? contentStyle : {}}
175
+ contentStyle={{}}
145
176
  isRTL={isRTL}
146
177
  >
147
178
  <Screen
148
179
  key={navigator.currentRoute}
149
- NavBar={NavBar}
150
- navBarProps={navBarProps}
151
- Menu={Menu}
152
- menuProps={menuProps}
153
- pathname={currentRoute}
154
- screenData={screenData}
155
- isNavBarVisible={isNavBarVisible}
180
+ pathname={navigator.currentRoute} // required by TransitionerComponent
181
+ screenData={navigator.data} // required by TransitionerComponent
156
182
  />
157
183
  </Transitioner>
158
184
  </View>
159
185
  ) : null}
160
- {showMenu && <Menu {...menuProps} />}
161
- {VideoModal && visible && <VideoModal />}
162
-
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
+ )}
197
+ {/* depends on active river. @TODO move below screen context */}
198
+ {VideoModal && videoModalState.visible && <VideoModal />}
163
199
  <ZappHooksModal />
164
200
  </>
165
201
  );
166
202
  };
167
203
 
168
204
  export const Layout = R.compose(
169
- MenuToggleContext.withConsumer,
170
- withDimensionsProvider
205
+ withDimensionsProvider,
206
+ withModalAnimationProvider
171
207
  )(LayoutWithMenu);
@@ -54,6 +54,11 @@ jest.mock(
54
54
  () => () => null
55
55
  );
56
56
 
57
+ jest.mock(
58
+ "@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation",
59
+ () => ({ withModalAnimationProvider: () => null })
60
+ );
61
+
57
62
  jest.mock("react-native-safe-area-context", () => ({
58
63
  SafeAreaProvider: jest.fn(
59
64
  () =>
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-app",
3
- "version": "12.0.0-rc.1",
3
+ "version": "12.0.0-rc.100",
4
4
  "description": "Zapp App Component for Applicaster's Quick Brick React Native App",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "jest -w=2",
8
+ "build": "echo 'skipping ts build for core packages'",
8
9
  "flow-types": "node_modules/.bin/flow-copy-source -v -i '**/__tests__**' . ."
9
10
  },
10
11
  "repository": {
@@ -28,12 +29,12 @@
28
29
  },
29
30
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
31
  "dependencies": {
31
- "@applicaster/quick-brick-core": "12.0.0-rc.1",
32
- "@applicaster/zapp-react-native-bridge": "12.0.0-rc.1",
33
- "@applicaster/zapp-react-native-redux": "12.0.0-rc.1",
34
- "@applicaster/zapp-react-native-ui-components": "12.0.0-rc.1",
35
- "@applicaster/zapp-react-native-utils": "12.0.0-rc.1",
36
- "axios": "^0.21.2",
32
+ "@applicaster/quick-brick-core": "12.0.0-rc.100",
33
+ "@applicaster/zapp-react-native-bridge": "12.0.0-rc.100",
34
+ "@applicaster/zapp-react-native-redux": "12.0.0-rc.100",
35
+ "@applicaster/zapp-react-native-ui-components": "12.0.0-rc.100",
36
+ "@applicaster/zapp-react-native-utils": "12.0.0-rc.100",
37
+ "axios": "^0.28.0",
37
38
  "camelize": "^1.0.0",
38
39
  "query-string": "7.1.3",
39
40
  "react-router-native": "5.1.2",
@@ -44,7 +45,6 @@
44
45
  "react-native": "0.68.6"
45
46
  },
46
47
  "devDependencies": {
47
- "@applicaster/zapp-react-native-flow-types": "1.5.0",
48
48
  "nock": "^10.0.0",
49
49
  "redux-mock-store": "^1.5.3"
50
50
  },
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+
4
+ "compilerOptions": {
5
+ "outDir": "./lib",
6
+ "rootDir": "./src"
7
+ },
8
+
9
+ "include": ["src/**/*"],
10
+ "exclude": ["src/**/*.test.ts", "src/**/*.test.tsx"]
11
+ }