-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathBasicDrawer.vue
115 lines (101 loc) · 2.89 KB
/
BasicDrawer.vue
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
<template>
<Page>
<ActionBar>
<NavigationButton text="Back" @tap="$navigateBack" />
<Label text="Basic Drawer" />
</ActionBar>
<Drawer ref="drawer" :gestureHandlerOptions="{
failOffsetYStart: -10,
failOffsetYEnd: 10
}">
<GridLayout ~leftDrawer class="drawer" width="80%" backgroundColor="white" rows="auto, *">
<StackLayout backgroundColor="#eeeeee" padding="25">
<GridLayout columns="80, *" height="100">
<StackLayout col="0" class="avatar">
<Label text="JS" />
</StackLayout>
</GridLayout>
<StackLayout>
<Label text="John Smith" fontWeight="bold" />
<Label text="[email protected]" />
</StackLayout>
</StackLayout>
<ScrollView row="1">
<StackLayout>
<Label v-for="(item, index) in items" :key="index" :text="item.title" @tap="onCloseDrawer" />
</StackLayout>
</ScrollView>
</GridLayout>
<StackLayout ~mainContent backgroundColor="white">
<Button @tap="onOpenDrawer('left')" text="Open Drawer" width="250" marginTop="25" />
</StackLayout>
</Drawer>
</Page>
</template>
<script lang="ts">
import { ref, $navigateBack } from "nativescript-vue"
export default {
setup() {
const drawer = ref(null);
return {
$navigateBack,
drawer
}
},
data() {
return {
items: new Array(100).fill({ title: 'My profile' })
}
},
methods: {
// note: for some reason these methods don't work if called from a function registered in setup() or <script setup>
onOpenDrawer(side: string) {
this.$refs['drawer'].nativeView.open(side);
},
onCloseDrawer() {
this.$refs['drawer'].nativeView.close();
}
}
}
</script>
<style scoped lang="scss">
ActionBar {
background-color: #42b883;
color: white;
}
Button {
background-color: #42b883;
color: white;
}
.avatar {
background-color: #42b883;
border-radius: 40;
height: 80;
vertical-align: middle;
Label {
vertical-align: middle;
horizontal-align: center;
font-size: 30;
color: white;
}
}
.drawer {
Button {
background-color: transparent;
margin: 0;
padding: 0;
border-color: #ccc;
z-index: 0;
border-width: 0 0 0.5 0;
color: #222222;
text-align: left;
padding-left: 25;
height: 50;
font-size: 14;
}
Button:highlighted {
background-color: #eeeeee;
color: #222222;
}
}
</style>