@applicaster/zapp-react-native-app 12.0.0-alpha.4433422595 → 12.0.0-alpha.4440903139
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 +3 -20
- package/App/Layout/__tests__/__snapshots__/index.test.tsx.snap +99 -0
- package/App/Layout/__tests__/index.test.tsx +197 -0
- package/App/Layout/index.tsx +90 -49
- package/App/__tests__/app.test.js +5 -0
- package/App/index.ts +3 -3
- package/package.json +6 -6
- package/App/Layout/__tests__/index.test.ts +0 -7
|
@@ -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 = (
|
|
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
|
|
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,99 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Layout should match snapshot when appReady is true 1`] = `
|
|
4
|
+
<RNCSafeAreaProvider
|
|
5
|
+
onInsetsChange={[Function]}
|
|
6
|
+
style={
|
|
7
|
+
Array [
|
|
8
|
+
Object {
|
|
9
|
+
"flex": 1,
|
|
10
|
+
},
|
|
11
|
+
undefined,
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
>
|
|
15
|
+
<View
|
|
16
|
+
onLayout={[Function]}
|
|
17
|
+
style={
|
|
18
|
+
Object {
|
|
19
|
+
"flex": 1,
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
testID="on-layout-view"
|
|
23
|
+
>
|
|
24
|
+
<View
|
|
25
|
+
style={
|
|
26
|
+
Object {
|
|
27
|
+
"display": "none",
|
|
28
|
+
"flex": 1,
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
>
|
|
32
|
+
<View
|
|
33
|
+
style={
|
|
34
|
+
Object {
|
|
35
|
+
"height": "100%",
|
|
36
|
+
"opacity": 1,
|
|
37
|
+
"paddingBottom": 50,
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
>
|
|
41
|
+
<View
|
|
42
|
+
contentStyle={
|
|
43
|
+
Object {
|
|
44
|
+
"height": "100%",
|
|
45
|
+
"opacity": 1,
|
|
46
|
+
"paddingBottom": 50,
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
isRTL={false}
|
|
50
|
+
testID="transitioner"
|
|
51
|
+
transitionConfig={[Function]}
|
|
52
|
+
>
|
|
53
|
+
<View
|
|
54
|
+
pathname="home"
|
|
55
|
+
screenData={Object {}}
|
|
56
|
+
/>
|
|
57
|
+
</View>
|
|
58
|
+
</View>
|
|
59
|
+
<View
|
|
60
|
+
bottomTabBarHeight={50}
|
|
61
|
+
closeMenu={[MockFunction]}
|
|
62
|
+
dimensions={
|
|
63
|
+
Object {
|
|
64
|
+
"window": Object {
|
|
65
|
+
"height": 100,
|
|
66
|
+
"width": 100,
|
|
67
|
+
},
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
id="home"
|
|
71
|
+
isRTL={false}
|
|
72
|
+
navigator={
|
|
73
|
+
Object {
|
|
74
|
+
"activeRiver": Object {
|
|
75
|
+
"navigations": Array [],
|
|
76
|
+
},
|
|
77
|
+
"currentRoute": "home",
|
|
78
|
+
"data": Object {},
|
|
79
|
+
"isVideoModalDocked": false,
|
|
80
|
+
"videoModalState": Object {
|
|
81
|
+
"mode": "MINIMIZED",
|
|
82
|
+
"visible": false,
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
openMenu={[MockFunction]}
|
|
87
|
+
setCloseMenu={[MockFunction]}
|
|
88
|
+
setOpenMenu={[MockFunction]}
|
|
89
|
+
setToggleMenu={[MockFunction]}
|
|
90
|
+
testID="menu"
|
|
91
|
+
toggleMenu={[MockFunction]}
|
|
92
|
+
/>
|
|
93
|
+
<View
|
|
94
|
+
testID="zappHooksModal"
|
|
95
|
+
/>
|
|
96
|
+
</View>
|
|
97
|
+
</View>
|
|
98
|
+
</RNCSafeAreaProvider>
|
|
99
|
+
`;
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { renderWithProviders } from "@applicaster/zapp-react-native-utils/testUtils";
|
|
4
|
+
|
|
5
|
+
const mockUseMenuToggleContext = jest.fn(() => ({
|
|
6
|
+
toggleMenu: jest.fn(),
|
|
7
|
+
setToggleMenu: jest.fn(),
|
|
8
|
+
openMenu: jest.fn(),
|
|
9
|
+
setOpenMenu: jest.fn(),
|
|
10
|
+
closeMenu: jest.fn(),
|
|
11
|
+
setCloseMenu: jest.fn(),
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
jest.mock("../layoutHelpers", () => ({
|
|
15
|
+
// eslint-disable-next-line react/display-name
|
|
16
|
+
getNavigationPluginModule: () => (props) => <View testID="menu" {...props} />,
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
jest.mock(
|
|
20
|
+
"@applicaster/zapp-react-native-ui-components/Components/Transitioner",
|
|
21
|
+
() => ({
|
|
22
|
+
// eslint-disable-next-line react/display-name
|
|
23
|
+
Transitioner: (props) => <View testID="transitioner" {...props} />,
|
|
24
|
+
})
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
jest.mock(
|
|
28
|
+
"@applicaster/zapp-react-native-ui-components/Components/Screen",
|
|
29
|
+
() => ({
|
|
30
|
+
// eslint-disable-next-line react/display-name
|
|
31
|
+
Screen: (props) => <View {...props} />,
|
|
32
|
+
})
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
jest.mock(
|
|
36
|
+
"@applicaster/zapp-react-native-ui-components/Contexts/MenuToggleContext",
|
|
37
|
+
() => ({
|
|
38
|
+
useMenuToggleContext: mockUseMenuToggleContext,
|
|
39
|
+
})
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const mockUseNavigation = jest.fn();
|
|
43
|
+
|
|
44
|
+
jest.mock(
|
|
45
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation/useNavigation",
|
|
46
|
+
() => ({
|
|
47
|
+
useNavigation: mockUseNavigation,
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
jest.mock("@applicaster/zapp-react-native-utils/reactHooks/navigation", () => ({
|
|
52
|
+
...(jest.requireActual(
|
|
53
|
+
"@applicaster/zapp-react-native-utils/reactHooks/navigation"
|
|
54
|
+
) as {}),
|
|
55
|
+
useGetBottomTabBarHeight: jest.fn(() => 50),
|
|
56
|
+
}));
|
|
57
|
+
|
|
58
|
+
jest.mock(
|
|
59
|
+
"@applicaster/zapp-react-native-utils/reactHooks/layout/useDimensions",
|
|
60
|
+
() => ({
|
|
61
|
+
useDimensions: jest.fn(() => ({ width: 100, height: 100 })),
|
|
62
|
+
})
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
jest.mock(
|
|
66
|
+
"@applicaster/zapp-react-native-utils/reactHooks/screen/useScreenContext",
|
|
67
|
+
() => ({
|
|
68
|
+
useNavbarState: jest.fn(() => ({ title: "Test Title" })),
|
|
69
|
+
})
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
jest.mock("@applicaster/zapp-react-native-utils/localizationUtils", () => ({
|
|
73
|
+
useIsRTL: jest.fn(() => false),
|
|
74
|
+
}));
|
|
75
|
+
|
|
76
|
+
jest.mock(
|
|
77
|
+
"@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/ModalAnimationContext",
|
|
78
|
+
() => ({
|
|
79
|
+
...(jest.requireActual(
|
|
80
|
+
"@applicaster/zapp-react-native-ui-components/Components/VideoModal/ModalAnimation/ModalAnimationContext"
|
|
81
|
+
) as {}),
|
|
82
|
+
useModalAnimationContext: jest.fn(() => ({
|
|
83
|
+
isActiveGesture: false,
|
|
84
|
+
})),
|
|
85
|
+
})
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
jest.mock(
|
|
89
|
+
"@applicaster/zapp-react-native-ui-components/Components/Screen/navigationHandler",
|
|
90
|
+
() => ({
|
|
91
|
+
isMenuVisible: jest.fn(() => true),
|
|
92
|
+
})
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
jest.mock(
|
|
96
|
+
"@applicaster/zapp-react-dom-ui-components/Components/ZappHooksModal",
|
|
97
|
+
() => ({
|
|
98
|
+
// eslint-disable-next-line react/display-name
|
|
99
|
+
ZappHooksModal: (props) => <View testID="zappHooksModal" {...props} />,
|
|
100
|
+
})
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
jest.mock(
|
|
104
|
+
"@applicaster/zapp-react-native-ui-components/Components/VideoModal",
|
|
105
|
+
() => ({
|
|
106
|
+
// eslint-disable-next-line react/display-name
|
|
107
|
+
VideoModal: (props) => <View testID="videoModal" {...props} />,
|
|
108
|
+
})
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
jest.mock("@applicaster/zapp-react-native-utils/navigationUtils", () => ({
|
|
112
|
+
getNavigationProps: () => ({}),
|
|
113
|
+
resolveNavigationPlugin: () => ({
|
|
114
|
+
identifier: "quick-brick-bottom-tabs",
|
|
115
|
+
}),
|
|
116
|
+
}));
|
|
117
|
+
|
|
118
|
+
const { Layout } = require("../");
|
|
119
|
+
|
|
120
|
+
describe("Layout", () => {
|
|
121
|
+
beforeEach(() => {
|
|
122
|
+
jest.clearAllMocks();
|
|
123
|
+
|
|
124
|
+
mockUseNavigation.mockImplementation(() => ({
|
|
125
|
+
activeRiver: { navigations: [] },
|
|
126
|
+
videoModalState: { visible: false, mode: "MINIMIZED" },
|
|
127
|
+
isVideoModalDocked: false,
|
|
128
|
+
currentRoute: "home",
|
|
129
|
+
data: {},
|
|
130
|
+
}));
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it("should match snapshot when appReady is true", () => {
|
|
134
|
+
const { toJSON } = renderWithProviders(<Layout />);
|
|
135
|
+
expect(toJSON()).toMatchSnapshot();
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it("should not render transitioner with screen when appReady is false", () => {
|
|
139
|
+
const { queryByTestId } = renderWithProviders(<Layout />, {
|
|
140
|
+
appState: {
|
|
141
|
+
appReady: false,
|
|
142
|
+
appLaunched: true,
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
expect(queryByTestId("transitioner")).toBeNull();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("should render menu when showMenu is true", () => {
|
|
150
|
+
const { getByTestId } = renderWithProviders(<Layout />);
|
|
151
|
+
expect(getByTestId("menu")).toBeTruthy();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it("should render VideoModal when visible & VideoModal is true", () => {
|
|
155
|
+
mockUseNavigation.mockReturnValue({
|
|
156
|
+
activeRiver: { navigations: [] },
|
|
157
|
+
videoModalState: { visible: true, mode: "MINIMIZED" },
|
|
158
|
+
isVideoModalDocked: false,
|
|
159
|
+
currentRoute: "home",
|
|
160
|
+
data: {},
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
const { getByTestId } = renderWithProviders(<Layout />);
|
|
164
|
+
expect(getByTestId("videoModal")).toBeTruthy();
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it("should render ZappHooksModal", () => {
|
|
168
|
+
const { getByTestId } = renderWithProviders(<Layout />);
|
|
169
|
+
expect(getByTestId("zappHooksModal")).toBeTruthy();
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("padding should be non-0 when showMenu is true and isBottomTabsPlugin is true", () => {
|
|
173
|
+
mockUseNavigation.mockReturnValueOnce({
|
|
174
|
+
activeRiver: { navigations: [{ identifier: "quick-brick-bottom-tabs" }] },
|
|
175
|
+
videoModalState: { visible: false, mode: "MINIMIZED" },
|
|
176
|
+
isVideoModalDocked: false,
|
|
177
|
+
currentRoute: "home",
|
|
178
|
+
data: {},
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
const { getByTestId } = renderWithProviders(<Layout />);
|
|
182
|
+
|
|
183
|
+
expect(getByTestId("transitioner").props.contentStyle.paddingBottom).toBe(
|
|
184
|
+
50
|
|
185
|
+
);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it("transitioner should have contentStyle with specific styles", () => {
|
|
189
|
+
const { getByTestId } = renderWithProviders(<Layout />);
|
|
190
|
+
|
|
191
|
+
expect(getByTestId("transitioner").props.contentStyle).toEqual({
|
|
192
|
+
height: "100%",
|
|
193
|
+
paddingBottom: 50,
|
|
194
|
+
opacity: 1,
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
});
|
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 {
|
|
8
|
-
|
|
9
|
-
|
|
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,9 +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 {
|
|
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
38
|
import { useListenEventBusEvent } from "@applicaster/zapp-react-native-utils/reactHooks/useListenEventBusEvent";
|
|
@@ -32,22 +42,11 @@ import {
|
|
|
32
42
|
PushTopicManagerEvents,
|
|
33
43
|
} from "@applicaster/zapp-react-native-bridge/PushNotifications/PushTopicManager";
|
|
34
44
|
|
|
35
|
-
type Props = {
|
|
36
|
-
children: React.ReactNode;
|
|
37
|
-
toggleMenu: any;
|
|
38
|
-
setToggleMenu: () => void;
|
|
39
|
-
openMenu: any;
|
|
40
|
-
setOpenMenu: () => void;
|
|
41
|
-
closeMenu: any;
|
|
42
|
-
setCloseMenu: () => void;
|
|
43
|
-
navigator: QuickBrickAppNavigator;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
45
|
const containerStyle = {
|
|
47
46
|
height: "100%",
|
|
48
47
|
};
|
|
49
48
|
|
|
50
|
-
const LayoutWithMenu = (
|
|
49
|
+
const LayoutWithMenu = () => {
|
|
51
50
|
const {
|
|
52
51
|
plugins,
|
|
53
52
|
appState: { appReady },
|
|
@@ -60,7 +59,7 @@ const LayoutWithMenu = (props: Props) => {
|
|
|
60
59
|
setOpenMenu,
|
|
61
60
|
closeMenu,
|
|
62
61
|
setCloseMenu,
|
|
63
|
-
} =
|
|
62
|
+
} = useMenuToggleContext();
|
|
64
63
|
|
|
65
64
|
const dimensions = useDimensions("screen", { fullDimensions: true });
|
|
66
65
|
const isRTL = useIsRTL();
|
|
@@ -70,6 +69,12 @@ const LayoutWithMenu = (props: Props) => {
|
|
|
70
69
|
|
|
71
70
|
const { activeRiver, videoModalState, isVideoModalDocked } = navigator;
|
|
72
71
|
|
|
72
|
+
const plugin = resolveNavigationPlugin({
|
|
73
|
+
category: "menu",
|
|
74
|
+
navigations: activeRiver?.navigations,
|
|
75
|
+
plugins,
|
|
76
|
+
});
|
|
77
|
+
|
|
73
78
|
const Menu = React.useMemo(
|
|
74
79
|
() =>
|
|
75
80
|
getNavigationPluginModule(
|
|
@@ -77,46 +82,75 @@ const LayoutWithMenu = (props: Props) => {
|
|
|
77
82
|
activeRiver,
|
|
78
83
|
plugins
|
|
79
84
|
) as React.ComponentType<
|
|
80
|
-
MobileNavBarPluginProps &
|
|
85
|
+
MobileNavBarPluginProps &
|
|
86
|
+
MenuToggleContextType & {
|
|
87
|
+
navigator: QuickBrickAppNavigator;
|
|
88
|
+
}
|
|
81
89
|
>,
|
|
82
|
-
[]
|
|
90
|
+
[activeRiver]
|
|
83
91
|
);
|
|
84
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
|
+
*/
|
|
85
99
|
const showMenu = React.useMemo(
|
|
86
|
-
() =>
|
|
87
|
-
|
|
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
|
+
]
|
|
88
112
|
);
|
|
89
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
|
+
|
|
90
120
|
const contentStyle = React.useMemo(
|
|
91
121
|
() => ({
|
|
92
|
-
...(showMenu
|
|
93
|
-
? {
|
|
94
|
-
paddingBottom: bottomTabBarHeight,
|
|
95
|
-
}
|
|
96
|
-
: {}),
|
|
97
122
|
...containerStyle,
|
|
123
|
+
paddingBottom,
|
|
98
124
|
opacity: videoModalState.visible && !isVideoModalDocked ? 0 : 1,
|
|
99
125
|
}),
|
|
100
|
-
[
|
|
126
|
+
[videoModalState.visible, isVideoModalDocked, paddingBottom]
|
|
101
127
|
);
|
|
102
128
|
|
|
103
|
-
const menuProps = {
|
|
104
|
-
|
|
105
|
-
toggleMenu: toggleMenu,
|
|
106
|
-
openMenu: openMenu,
|
|
107
|
-
setOpenMenu: setOpenMenu,
|
|
108
|
-
closeMenu: closeMenu,
|
|
109
|
-
setCloseMenu: setCloseMenu,
|
|
110
|
-
dimensions: { window: dimensions },
|
|
111
|
-
navigator,
|
|
112
|
-
...getNavigationProps({
|
|
129
|
+
const menuProps = React.useMemo(() => {
|
|
130
|
+
const navigationProps = getNavigationProps({
|
|
113
131
|
navigator,
|
|
114
132
|
title,
|
|
115
133
|
category: "menu",
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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]);
|
|
120
154
|
|
|
121
155
|
useListenEventBusEvent(
|
|
122
156
|
PushTopicManagerConsts.PushTopicManagerSubscriptionID,
|
|
@@ -136,21 +170,28 @@ const LayoutWithMenu = (props: Props) => {
|
|
|
136
170
|
<View style={contentStyle}>
|
|
137
171
|
<Transitioner
|
|
138
172
|
transitionConfig={transitionConfig}
|
|
139
|
-
contentStyle={
|
|
173
|
+
contentStyle={contentStyle}
|
|
140
174
|
isRTL={isRTL}
|
|
141
175
|
>
|
|
142
|
-
{/* has pathname context */}
|
|
143
176
|
<Screen
|
|
144
177
|
key={navigator.currentRoute}
|
|
145
178
|
pathname={navigator.currentRoute} // required by TransitionerComponent
|
|
146
|
-
screenData={navigator.
|
|
147
|
-
setToggleMenu={setToggleMenu}
|
|
148
|
-
setCloseMenu={setCloseMenu}
|
|
179
|
+
screenData={navigator.data} // required by TransitionerComponent
|
|
149
180
|
/>
|
|
150
181
|
</Transitioner>
|
|
151
182
|
</View>
|
|
152
183
|
) : null}
|
|
153
|
-
{showMenu &&
|
|
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
|
+
)}
|
|
154
195
|
{/* depends on active river. @TODO move below screen context */}
|
|
155
196
|
{VideoModal && videoModalState.visible && <VideoModal />}
|
|
156
197
|
<ZappHooksModal />
|
|
@@ -159,6 +200,6 @@ const LayoutWithMenu = (props: Props) => {
|
|
|
159
200
|
};
|
|
160
201
|
|
|
161
202
|
export const Layout = R.compose(
|
|
162
|
-
|
|
163
|
-
|
|
203
|
+
withDimensionsProvider,
|
|
204
|
+
withModalAnimationProvider
|
|
164
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applicaster/zapp-react-native-app",
|
|
3
|
-
"version": "12.0.0-alpha.
|
|
3
|
+
"version": "12.0.0-alpha.4440903139",
|
|
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.
|
|
33
|
-
"@applicaster/zapp-react-native-bridge": "12.0.0-alpha.
|
|
34
|
-
"@applicaster/zapp-react-native-redux": "12.0.0-alpha.
|
|
35
|
-
"@applicaster/zapp-react-native-ui-components": "12.0.0-alpha.
|
|
36
|
-
"@applicaster/zapp-react-native-utils": "12.0.0-alpha.
|
|
32
|
+
"@applicaster/quick-brick-core": "12.0.0-alpha.4440903139",
|
|
33
|
+
"@applicaster/zapp-react-native-bridge": "12.0.0-alpha.4440903139",
|
|
34
|
+
"@applicaster/zapp-react-native-redux": "12.0.0-alpha.4440903139",
|
|
35
|
+
"@applicaster/zapp-react-native-ui-components": "12.0.0-alpha.4440903139",
|
|
36
|
+
"@applicaster/zapp-react-native-utils": "12.0.0-alpha.4440903139",
|
|
37
37
|
"axios": "^0.28.0",
|
|
38
38
|
"camelize": "^1.0.0",
|
|
39
39
|
"query-string": "7.1.3",
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
});
|