-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
91 lines (75 loc) · 1.3 KB
/
index.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
* Module dependencies.
*/
import {
NativeModules,
Text,
TouchableWithoutFeedback,
View
} from 'react-native';
import Draggable from 'react-native-draggable';
import React from 'react';
/**
* Styles.
*/
const styles = {
button: {
alignItems: 'center',
backgroundColor: 'green',
borderColor: 'white',
borderRadius: 150,
borderWidth: 1,
height: 44,
justifyContent: 'center',
opacity: 0.4,
width: 44
},
label: {
color: '#ffffff',
fontSize: 12
}
};
/**
* Handle debug menu.
*/
const handleDebugMenu = () => {
NativeModules.DevMenu.show();
};
/**
* `FloatDevMenu` component.
*/
const FloatDevMenu = props => {
if (!__DEV__) {
return props.children;
}
const { children, label, startX, startY } = props;
return (
<>
{children}
<Draggable
x={startX}
y={startY}
>
<TouchableWithoutFeedback onPress={handleDebugMenu}>
<View style={styles.button}>
<Text style={styles.label}>
{label}
</Text>
</View>
</TouchableWithoutFeedback>
</Draggable>
</>
);
};
/**
* Default props.
*/
FloatDevMenu.defaultProps = {
label: 'DEV',
startX: 50,
startY: 50
};
/**
* Export `FloatDevMenu`.
*/
export default FloatDevMenu;