@applicaster/zapp-react-native-app 12.0.0-rc.12 → 12.0.0-rc.121
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.
- package/App/InteractionManager/index.js +5 -22
- package/App/Layout/__tests__/index.test.ts +7 -0
- package/App/Layout/index.tsx +106 -86
- package/App/__tests__/app.test.js +5 -0
- package/App/index.ts +3 -3
- package/package.json +8 -7
- package/tsconfig.json +11 -0
|
@@ -3,23 +3,18 @@ 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
|
-
import {
|
|
12
|
-
|
|
13
|
-
type Props = {
|
|
14
|
-
children: React.CElement,
|
|
15
|
-
};
|
|
11
|
+
import { useRivers } from "@applicaster/zapp-react-native-utils/reactHooks/state";
|
|
16
12
|
|
|
17
13
|
const getHome = R.compose(R.find(R.propEq("home", true)), R.values);
|
|
18
14
|
|
|
19
|
-
const InteractionManagerComponent = (
|
|
20
|
-
const { children } = props;
|
|
15
|
+
const InteractionManagerComponent = () => {
|
|
21
16
|
const { sendHardwareBackButtonClickEvent } = useAnalytics();
|
|
22
|
-
const
|
|
17
|
+
const rivers = useRivers();
|
|
23
18
|
const navigator = useNavigation();
|
|
24
19
|
|
|
25
20
|
const isHomeScreen = () => {
|
|
@@ -63,19 +58,7 @@ const InteractionManagerComponent = (props: Props) => {
|
|
|
63
58
|
};
|
|
64
59
|
}, [onHardwareBackPress]);
|
|
65
60
|
|
|
66
|
-
return
|
|
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
|
-
}
|
|
@@ -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
|
+
});
|
package/App/Layout/index.tsx
CHANGED
|
@@ -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,31 +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 {
|
|
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
38
|
import { useListenEventBusEvent } from "@applicaster/zapp-react-native-utils/reactHooks/useListenEventBusEvent";
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
setToggleMenu: () => void;
|
|
36
|
-
openMenu: any;
|
|
37
|
-
setOpenMenu: () => void;
|
|
38
|
-
closeMenu: any;
|
|
39
|
-
setCloseMenu: () => void;
|
|
40
|
-
navigator: QuickBrickAppNavigator;
|
|
41
|
-
};
|
|
39
|
+
import {
|
|
40
|
+
PushTopicManager,
|
|
41
|
+
PushTopicManagerConsts,
|
|
42
|
+
PushTopicManagerEvents,
|
|
43
|
+
} from "@applicaster/zapp-react-native-bridge/PushNotifications/PushTopicManager";
|
|
42
44
|
|
|
43
45
|
const containerStyle = {
|
|
44
46
|
height: "100%",
|
|
45
47
|
};
|
|
46
48
|
|
|
47
|
-
const LayoutWithMenu = (
|
|
49
|
+
const LayoutWithMenu = () => {
|
|
48
50
|
const {
|
|
49
51
|
plugins,
|
|
50
52
|
appState: { appReady },
|
|
@@ -57,85 +59,98 @@ const LayoutWithMenu = (props: Props) => {
|
|
|
57
59
|
setOpenMenu,
|
|
58
60
|
closeMenu,
|
|
59
61
|
setCloseMenu,
|
|
60
|
-
} =
|
|
62
|
+
} = useMenuToggleContext();
|
|
61
63
|
|
|
62
64
|
const dimensions = useDimensions("screen", { fullDimensions: true });
|
|
63
65
|
const isRTL = useIsRTL();
|
|
64
|
-
|
|
65
66
|
const navigator = useNavigation();
|
|
66
67
|
const bottomTabBarHeight = useGetBottomTabBarHeight();
|
|
67
|
-
|
|
68
|
-
const {
|
|
69
|
-
activeRiver,
|
|
70
|
-
currentRoute,
|
|
71
|
-
screenData,
|
|
72
|
-
videoModalState,
|
|
73
|
-
isVideoModalDocked,
|
|
74
|
-
videoModalState: { visible },
|
|
75
|
-
} = navigator;
|
|
76
|
-
|
|
77
|
-
const isNavBarVisible = useIsNavBarVisible();
|
|
78
68
|
const { title } = useNavbarState();
|
|
79
69
|
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
70
|
+
const { activeRiver, videoModalState, isVideoModalDocked } = navigator;
|
|
71
|
+
|
|
72
|
+
const plugin = resolveNavigationPlugin({
|
|
73
|
+
category: "menu",
|
|
74
|
+
navigations: activeRiver?.navigations,
|
|
75
|
+
plugins,
|
|
76
|
+
});
|
|
84
77
|
|
|
85
78
|
const Menu = React.useMemo(
|
|
86
|
-
() =>
|
|
87
|
-
|
|
79
|
+
() =>
|
|
80
|
+
getNavigationPluginModule(
|
|
81
|
+
"menu",
|
|
82
|
+
activeRiver,
|
|
83
|
+
plugins
|
|
84
|
+
) as React.ComponentType<
|
|
85
|
+
MobileNavBarPluginProps &
|
|
86
|
+
MenuToggleContextType & {
|
|
87
|
+
navigator: QuickBrickAppNavigator;
|
|
88
|
+
}
|
|
89
|
+
>,
|
|
90
|
+
[activeRiver]
|
|
88
91
|
);
|
|
89
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
|
+
*/
|
|
90
99
|
const showMenu = React.useMemo(
|
|
91
|
-
() =>
|
|
92
|
-
|
|
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
|
+
]
|
|
93
112
|
);
|
|
94
113
|
|
|
114
|
+
const isBottomTabsPlugin = plugin?.identifier === "quick-brick-bottom-tabs";
|
|
115
|
+
|
|
116
|
+
const paddingBottom = React.useMemo(() => {
|
|
117
|
+
return showMenu && isBottomTabsPlugin ? bottomTabBarHeight : 0; // if activeRiver?.navigations has quick-brick-bottom-tabs - append bottomTabBarHeight as padding
|
|
118
|
+
}, [showMenu, isBottomTabsPlugin, bottomTabBarHeight]);
|
|
119
|
+
|
|
95
120
|
const contentStyle = React.useMemo(
|
|
96
121
|
() => ({
|
|
97
|
-
...(showMenu
|
|
98
|
-
? {
|
|
99
|
-
paddingBottom: bottomTabBarHeight,
|
|
100
|
-
}
|
|
101
|
-
: {}),
|
|
102
122
|
...containerStyle,
|
|
123
|
+
paddingBottom,
|
|
103
124
|
opacity: videoModalState.visible && !isVideoModalDocked ? 0 : 1,
|
|
104
125
|
}),
|
|
105
|
-
[
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
const navBarProps = React.useMemo(
|
|
109
|
-
() => ({
|
|
110
|
-
setToggleMenu,
|
|
111
|
-
toggleMenu,
|
|
112
|
-
openMenu,
|
|
113
|
-
setOpenMenu,
|
|
114
|
-
closeMenu,
|
|
115
|
-
setCloseMenu,
|
|
116
|
-
navigator,
|
|
117
|
-
...getNavigationProps({ navigator, title, category: "nav_bar" }),
|
|
118
|
-
}),
|
|
119
|
-
[navigator.currentRoute]
|
|
126
|
+
[videoModalState.visible, isVideoModalDocked, paddingBottom]
|
|
120
127
|
);
|
|
121
128
|
|
|
122
|
-
const menuProps = {
|
|
123
|
-
|
|
124
|
-
toggleMenu: toggleMenu,
|
|
125
|
-
openMenu: openMenu,
|
|
126
|
-
setOpenMenu: setOpenMenu,
|
|
127
|
-
closeMenu: closeMenu,
|
|
128
|
-
setCloseMenu: setCloseMenu,
|
|
129
|
-
dimensions: { window: dimensions },
|
|
130
|
-
navigator: navigator,
|
|
131
|
-
...getNavigationProps({
|
|
129
|
+
const menuProps = React.useMemo(() => {
|
|
130
|
+
const navigationProps = getNavigationProps({
|
|
132
131
|
navigator,
|
|
133
132
|
title,
|
|
134
133
|
category: "menu",
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
134
|
+
}) ?? {
|
|
135
|
+
selected: "",
|
|
136
|
+
title: "",
|
|
137
|
+
home: false,
|
|
138
|
+
rules: {} as ZappNavBarRules,
|
|
139
|
+
assets: {} as ZappNavBarAssets,
|
|
140
|
+
styles: {},
|
|
141
|
+
nav_items: [] as NavBarItem[],
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const props = {
|
|
145
|
+
...navigationProps,
|
|
146
|
+
dimensions: { window: dimensions },
|
|
147
|
+
bottomTabBarHeight,
|
|
148
|
+
isRTL,
|
|
149
|
+
navigator,
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
return { ...props, id: navigator.currentRoute };
|
|
153
|
+
}, [dimensions, isRTL, bottomTabBarHeight, navigator.currentRoute]);
|
|
139
154
|
|
|
140
155
|
useListenEventBusEvent(
|
|
141
156
|
PushTopicManagerConsts.PushTopicManagerSubscriptionID,
|
|
@@ -155,31 +170,36 @@ const LayoutWithMenu = (props: Props) => {
|
|
|
155
170
|
<View style={contentStyle}>
|
|
156
171
|
<Transitioner
|
|
157
172
|
transitionConfig={transitionConfig}
|
|
158
|
-
contentStyle={
|
|
173
|
+
contentStyle={contentStyle}
|
|
159
174
|
isRTL={isRTL}
|
|
160
175
|
>
|
|
161
176
|
<Screen
|
|
162
177
|
key={navigator.currentRoute}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
Menu={Menu}
|
|
166
|
-
menuProps={menuProps}
|
|
167
|
-
pathname={currentRoute}
|
|
168
|
-
screenData={screenData}
|
|
169
|
-
isNavBarVisible={isNavBarVisible}
|
|
178
|
+
pathname={navigator.currentRoute} // required by TransitionerComponent
|
|
179
|
+
screenData={navigator.data} // required by TransitionerComponent
|
|
170
180
|
/>
|
|
171
181
|
</Transitioner>
|
|
172
182
|
</View>
|
|
173
183
|
) : null}
|
|
174
|
-
{showMenu &&
|
|
175
|
-
|
|
176
|
-
|
|
184
|
+
{showMenu && (
|
|
185
|
+
<Menu
|
|
186
|
+
{...menuProps}
|
|
187
|
+
setToggleMenu={setToggleMenu}
|
|
188
|
+
toggleMenu={toggleMenu}
|
|
189
|
+
openMenu={openMenu}
|
|
190
|
+
setOpenMenu={setOpenMenu}
|
|
191
|
+
closeMenu={closeMenu}
|
|
192
|
+
setCloseMenu={setCloseMenu}
|
|
193
|
+
/>
|
|
194
|
+
)}
|
|
195
|
+
{/* depends on active river. @TODO move below screen context */}
|
|
196
|
+
{VideoModal && videoModalState.visible && <VideoModal />}
|
|
177
197
|
<ZappHooksModal />
|
|
178
198
|
</>
|
|
179
199
|
);
|
|
180
200
|
};
|
|
181
201
|
|
|
182
202
|
export const Layout = R.compose(
|
|
183
|
-
|
|
184
|
-
|
|
203
|
+
withDimensionsProvider,
|
|
204
|
+
withModalAnimationProvider
|
|
185
205
|
)(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/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,
|
|
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 {
|
|
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
|
|
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,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-app",
|
|
3
|
-
"version": "12.0.0-rc.
|
|
3
|
+
"version": "12.0.0-rc.121",
|
|
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.
|
|
32
|
-
"@applicaster/zapp-react-native-bridge": "12.0.0-rc.
|
|
33
|
-
"@applicaster/zapp-react-native-redux": "12.0.0-rc.
|
|
34
|
-
"@applicaster/zapp-react-native-ui-components": "12.0.0-rc.
|
|
35
|
-
"@applicaster/zapp-react-native-utils": "12.0.0-rc.
|
|
36
|
-
"axios": "^0.
|
|
32
|
+
"@applicaster/quick-brick-core": "12.0.0-rc.121",
|
|
33
|
+
"@applicaster/zapp-react-native-bridge": "12.0.0-rc.121",
|
|
34
|
+
"@applicaster/zapp-react-native-redux": "12.0.0-rc.121",
|
|
35
|
+
"@applicaster/zapp-react-native-ui-components": "12.0.0-rc.121",
|
|
36
|
+
"@applicaster/zapp-react-native-utils": "12.0.0-rc.121",
|
|
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",
|