This repository has been archived by the owner on Sep 3, 2021. It is now read-only.
forked from Tinysymphony/react-native-drawer-menu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ios.js
166 lines (161 loc) · 4.08 KB
/
index.ios.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/**
* Created by wangyi27 on 2017-02-14.
*/
import React, {Component} from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Dimensions,
Easing,
TouchableHighlight
} from 'react-native';
import Drawer from './Drawer';
const {width, height} = Dimensions.get('window');
class drawer extends Component {
constructor(props) {
super(props);
this.state = {
disabled: false
};
this.toggle = this.toggle.bind(this);
}
toggle () {
this.setState({
disabled: !this.state.disabled
});
}
render () {
var leftDrawerContent = (<View style={styles.drawerContent}>
<View style={styles.leftTop}/>
<View style={styles.leftBottom}>
<View><Text>Left</Text></View>
<View><Text>Drawer</Text></View>
<View><Text>Content</Text></View>
</View>
</View>);
var rightDrawerContent = (<View style={styles.drawerContent}>
<View style={styles.leftTop}/>
<View style={styles.leftBottom}>
<View><Text>Right</Text></View>
<View><Text>Drawer</Text></View>
<View><Text>Content</Text></View>
</View>
</View>);
return (
<Drawer
ref={(comp) => {this.drawer = comp;}}
style={styles.container}
drawerWidth={width}
leftDrawerContent={leftDrawerContent}
rightDrawerContent={rightDrawerContent}
type={Drawer.types.Overlay}
customStyles={{
leftDrawer: styles.leftDrawer,
rightDrawer: styles.rightDrawer
}}
drawerWidth={300}
disabled={this.state.disabled}
drawerPosition={Drawer.positions.Both}
easingFunc={Easing.ease}
>
<View style={styles.content}>
<View style={styles.head}/>
<Text onPress={()=>{console.log(2);}}>{width} {height}</Text>
<Text>{Object.values(Drawer.positions).join(' ')}</Text>
<Text>{Object.values(Drawer.types).join(' ')}</Text>
<TouchableHighlight
style={styles.btn1}
underlayColor="#c33d19"
onPress={() => {this.drawer && this.drawer.openLeftDrawer();}}>
<Text style={styles.btnText}>Open Left Drawer</Text>
</TouchableHighlight>
<TouchableHighlight
style={styles.btn2}
underlayColor="#118d95"
onPress={() => {this.drawer && this.drawer.openRightDrawer();}}>
<Text style={styles.btnText}>Open Right Drawer</Text>
</TouchableHighlight>
<TouchableHighlight
style={styles.btn2}
underlayColor="#118d95"
onPress={this.toggle}>
<Text style={styles.btnText}>Enable / Disable Drawer</Text>
</TouchableHighlight>
</View>
</Drawer>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
},
main: {
position: 'absolute',
backgroundColor: '#2ba'
},
head: {
height: 60,
marginBottom: 200,
justifyContent: 'center',
alignItems: 'center',
alignSelf: 'stretch',
backgroundColor: '#6a0d45'
},
content: {
flex: 1,
alignItems: 'center',
alignSelf: 'stretch',
backgroundColor: '#e3b8cb'
},
drawerContent: {
flex: 1,
justifyContent: 'center',
alignItems: 'center'
},
leftTop: {
flex: 1,
justifyContent: 'space-around',
alignItems: 'stretch',
alignSelf: 'stretch',
backgroundColor: '#8ad8dd'
},
leftBottom: {
flex: 2,
justifyContent: 'space-around',
alignItems: 'center',
alignSelf: 'stretch',
backgroundColor: '#f0f0f0'
},
leftDrawer: {
borderRightWidth: 4,
borderRightColor: '#5b585a'
},
rightDrawer: {
borderLeftWidth: 4,
borderLeftColor: '#5b585a'
},
btn1: {
marginTop: 10,
padding: 10,
overflow: 'hidden',
borderRadius: 5,
backgroundColor: '#f06355'
},
btn2: {
marginTop: 10,
padding: 10,
overflow: 'hidden',
borderRadius: 5,
backgroundColor: '#37b9d5'
},
btnText: {
fontSize: 14,
color: '#f0f0f0'
}
});
AppRegistry.registerComponent('drawer', () => drawer);