-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathBasicDrawer.tsx
84 lines (78 loc) · 3.12 KB
/
BasicDrawer.tsx
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
import { Drawer as NativeScriptDrawer } from '@nativescript-community/ui-drawer';
import { Drawer } from '@nativescript-community/ui-drawer/react';
import * as React from 'react';
import { NSVElement, StyleSheet } from 'react-nativescript';
export function BasicDrawer() {
const drawerRef = React.useRef<NSVElement<NativeScriptDrawer>>(null);
function onOpenDrawer() {
drawerRef.current.nativeView.open('left');
}
function onCloseDrawer() {
drawerRef.current.nativeView.close('left');
}
return (
<gridLayout>
<Drawer ref={drawerRef} className="drawer">
<gridLayout nodeRole="leftDrawer" backgroundColor="white" width="300">
<stackLayout row={0}>
<stackLayout backgroundColor="#eeeeee" padding="25">
<gridLayout columns="80, *" height="100">
<stackLayout col={0} style={styles.avatar}>
<label style={styles.avatarLabel}>JS</label>
</stackLayout>
</gridLayout>
<stackLayout>
<label fontWeight="bold">John Smith</label>
<label>[email protected]</label>
</stackLayout>
</stackLayout>
<stackLayout>
<button style={styles.drawerButton} onTap={onCloseDrawer}>
My Profile
</button>
<button style={styles.drawerButton} onTap={onCloseDrawer}>
Settings
</button>
<button style={styles.drawerButton} onTap={onCloseDrawer}>
Rate Us
</button>
<button style={styles.drawerButton} onTap={onCloseDrawer}>
Support
</button>
<button style={styles.drawerButton} onTap={onCloseDrawer}>
Contact
</button>
</stackLayout>
</stackLayout>
</gridLayout>
<stackLayout nodeRole="mainContent" backgroundColor="white">
<button onTap={onOpenDrawer} text="Open Drawer" width="250" marginTop="25" />
</stackLayout>
</Drawer>
</gridLayout>
);
}
const styles = StyleSheet.create({
avatar: {
backgroundColor: '#61DBFB',
borderRadius: 40,
height: 80,
verticalAlignment: 'middle'
},
avatarLabel: {
verticanAlignment: 'middle',
horizontalAlignment: 'center',
fontSize: 30,
color: 'white'
},
drawerButton: {
backgroundColor: 'transparent',
margin: 0,
padding: 0,
color: '#222222',
textAlignment: 'left',
paddingLeft: 25,
height: 50,
fontSize: 14
}
});