forked from wix/react-native-navigation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSideMenuLeftScreen.js
57 lines (51 loc) · 1.65 KB
/
SideMenuLeftScreen.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const React = require('react');
const { useEffect } = require('react');
const Root = require('../components/Root');
const Button = require('../components/Button')
const Navigation = require('../services/Navigation');
const Screens = require('./Screens');
const {
LEFT_SIDE_MENU_PUSH_BTN,
CLOSE_LEFT_SIDE_MENU_BTN,
LEFT_SIDE_MENU_PUSH_AND_CLOSE_BTN
} = require('../testIDs');
function SideMenuLeftScreen(props) {
useEffect(() => {
const componentDisappearListener = Navigation.events().registerComponentDidDisappearListener(
({ componentId }) => {
if (componentId === props.componentId) {
console.log('RNN', `componentDisappearListener ${componentId}/${JSON.stringify(props)}`);
}
},
);
return () => {
componentDisappearListener.remove();
};
}, []);
const push = () => Navigation.push('SideMenuCenter', Screens.Pushed);
const pushAndClose = () => Navigation.push('SideMenuCenter', {
component: {
name: Screens.Pushed,
options: {
sideMenu: {
left: {
visible: false
}
}
}
}
});
const close = () => Navigation.mergeOptions(props.componentId, {
sideMenu: {
left: { visible: false }
}
});
return (
<Root componentId={props.componentId} style={{ marginTop: props.marginTop || 0 }}>
<Button label='Push' testID={LEFT_SIDE_MENU_PUSH_BTN} onPress={push} />
<Button label='Push and Close' testID={LEFT_SIDE_MENU_PUSH_AND_CLOSE_BTN} onPress={pushAndClose} />
<Button label='Close' testID={CLOSE_LEFT_SIDE_MENU_BTN} onPress={close} />
</Root>
);
}
module.exports = SideMenuLeftScreen;