-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathHome.vue
374 lines (328 loc) · 18.8 KB
/
Home.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
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
<template>
<Page class="page">
<ActionBar class="action-bar">
<Label class="action-bar-title" text="DateTimePicker Demo Vue"></Label>
</ActionBar>
<ScrollView ref="scrollView">
<StackLayout class="p-20">
<Label text="DatePickerField" id="date" class="header" @tap="onHeaderTap" :opacity="dateOpacity"></Label>
<StackLayout :visibility="dateVisibility">
<Label text="basic usage" class="content"></Label>
<DatePickerField hint="select date"></DatePickerField>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="initial values" class="content"></Label>
<DatePickerField date="2019/02/24"></DatePickerField>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="min and max date" class="content"></Label>
<DatePickerField minDate="2020/02/02" maxDate="2021/02/02" hint="tap to select"></DatePickerField>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="modified picker texts" class="content"></Label>
<DatePickerField hint="tap to choose" pickerOkText="Approve" pickerCancelText="Reject"
pickerTitle="Confirm predefined date selection" pickerDefaultDate="2019/05/15"></DatePickerField>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="preferred locale: en_US" class="content"></Label>
<DatePickerField locale="en_US" hint="select date" pickerOkText="OK"
pickerCancelText="Cancel" pickerTitle="Select date"></DatePickerField>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="preferred locale: de_DE" class="content"></Label>
<DatePickerField locale="de_DE" hint="datum auswählen" pickerOkText="Bestätigen"
pickerCancelText="Stornieren" pickerTitle="Datum auswählen"></DatePickerField>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="custom format" class="content"></Label>
<DatePickerField date="2019/02/24" dateFormat="'date': dd MMMM yyyy"></DatePickerField>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="css applied" class="content"></Label>
<DatePickerField date="2019/02/24" pickerTitle="select date" class="apply-css"></DatePickerField>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="binding" class="content"></Label>
<Label :text="dateTime1" color="#CBCBCB"></Label>
<DatePickerField @dateChange="onDateTimeChange1" :date="dateTime1"></DatePickerField>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
</StackLayout>
<Label text="TimePickerField" id="time" class="header" @tap="onHeaderTap" :opacity="timeOpacity"></Label>
<StackLayout :visibility="timeVisibility">
<Label text="basic usage" class="content"></Label>
<TimePickerField hint="select time"></TimePickerField>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="initial values" class="content"></Label>
<TimePickerField time="01:00"></TimePickerField>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="time format 12h" class="content"></Label>
<TimePickerField time="16:00" timeFormat="h:mm a" locale="en_US"></TimePickerField>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="time format 24h" class="content"></Label>
<TimePickerField time="16:00" timeFormat="HH:mm" locale="en_GB"></TimePickerField>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="modified picker texts" class="content"></Label>
<TimePickerField hint="tap to choose" pickerOkText="Approve" pickerCancelText="Reject"
pickerTitle="Confirm predefined time selection" pickerDefaultTime="22:00"></TimePickerField>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="preferred locale: en_US" class="content"></Label>
<TimePickerField locale="en_US" hint="select time" pickerOkText="OK"
pickerCancelText="Cancel" pickerTitle="Select time"></TimePickerField>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="preferred locale: de_DE" class="content"></Label>
<TimePickerField locale="de_DE" hint="zeit wählen" pickerOkText="Bestätigen"
pickerCancelText="Stornieren" pickerTitle="Zeit wählen"></TimePickerField>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="custom format" class="content"></Label>
<TimePickerField time="01:00" timeFormat="'time': HH:mm"></TimePickerField>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="css applied" class="content"></Label>
<TimePickerField time="01:00" pickerTitle="select time" class="apply-css"></TimePickerField>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="binding" class="content"></Label>
<Label :text="dateTime2" color="#CBCBCB"></Label>
<TimePickerField @timeChange="onDateTimeChange2" :time="dateTime2"></TimePickerField>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
</StackLayout>
<Label text="DateTimePickerFields" id="dateTime" class="header" @tap="onHeaderTap" :opacity="dateTimeOpacity"></Label>
<StackLayout :visibility="dateTimeVisibility">
<Label text="basic usage" class="content"></Label>
<DateTimePickerFields hintDate="select date" hintTime="select time"></DateTimePickerFields>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="initial values" class="content"></Label>
<DateTimePickerFields date="2019/02/24 01:00"></DateTimePickerFields>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="min and max date" class="content"></Label>
<DateTimePickerFields minDate="2020/02/02" maxDate="2021/02/02"
hintDate="tap to select date" hintTime="tap to select time"></DateTimePickerFields>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="time format 12h" class="content"></Label>
<DateTimePickerFields date="2019/02/24 16:00" timeFormat="h:mm a" locale="en_US"></DateTimePickerFields>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="time format 24h" class="content"></Label>
<DateTimePickerFields date="2019/02/24 16:00" timeFormat="HH:mm" locale="en_GB"></DateTimePickerFields>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="modified picker texts" class="content"></Label>
<DateTimePickerFields hintDate="tap to choose date" hintTime="tap to choose time"
pickerOkText="Approve" pickerCancelText="Reject"
pickerTitleDate="Confirm predefined date selection"
pickerTitleTime="Confirm predefined time selection"
pickerDefaultDate="2019/05/15 22:00" autoPickTime="true"></DateTimePickerFields>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="preferred locale: en_US" class="content"></Label>
<DateTimePickerFields locale="en_US" hintDate="select date" hintTime="select time"
pickerOkText="OK" pickerCancelText="Cancel" pickerTitleDate="Select date" pickerTitleTime="Select time"></DateTimePickerFields>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="preferred locale: de_DE" class="content"></Label>
<DateTimePickerFields locale="de_DE" hintDate="datum auswählen" hintTime="zeit wählen"
pickerOkText="Bestätigen" pickerCancelText="Stornieren"
pickerTitleDate="Datum auswählen" pickerTitleTime="Zeit wählen"></DateTimePickerFields>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="custom format" class="content"></Label>
<DateTimePickerFields date="2019/02/24 01:00"
dateFormat="'d': dd MMMM yyyy" timeFormat="'t': HH:mm"></DateTimePickerFields>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="css applied" class="content"></Label>
<DateTimePickerFields date="2019/02/24 01:00" class="apply-css"
pickerTitleDate="select date" pickerTitleTime="select time"></DateTimePickerFields>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="binding" class="content"></Label>
<Label :text="dateTime3" color="#CBCBCB"></Label>
<DateTimePickerFields @dateChange="onDateTimeChange3" :date="dateTime3"></DateTimePickerFields>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
<Label text="vertical orientation" class="content"></Label>
<DateTimePickerFields hintDate="select date" hintTime="select time"
orientation="vertical"></DateTimePickerFields>
<StackLayout class="hr-light m-10" android:visibility="collapse"></StackLayout>
</StackLayout>
<Label text="Custom Buttons" id="custom" class="header" @tap="onHeaderTap" :opacity="customOpacity"></Label>
<StackLayout :visibility="customVisibility">
<Button :text="dateText" @tap="onPickDateTap"></Button>
<Button :text="timeText" @tap="onPickTimeTap"></Button>
<Button :text="dateTimeText" @tap="onPickDateTimeTap"></Button>
</StackLayout>
</StackLayout>
</ScrollView>
</Page>
</template>
<script>
import { DateTimePicker } from "nativescript-datetimepicker";
import { EventData } from "tns-core-modules/data/observable";
import { Button } from "tns-core-modules/ui/button";
export default {
computed: {
message() {
return "Blank {N}-Vue app";
}
},
data() {
return {
dateText: "tap to select date",
timeText: "tap to select time",
dateTimeText: "tap to select date and time",
dateTime1: new Date(),
dateTime2: new Date(),
dateTime3: new Date(),
dateOpacity: 1,
timeOpacity: 1,
dateTimeOpacity: 1,
customOpacity: 1,
dateVisibility: 'collapse',
timeVisibility: 'collapse',
dateTimeVisibility: 'collapse',
customVisibility: 'collapse',
_expandedId: null
}
},
methods: {
onDateTimeChange1: function(args) {
this.dateTime1 = args.value;
},
onDateTimeChange2: function(args) {
this.dateTime2 = args.value;
},
onDateTimeChange3: function(args) {
this.dateTime3 = args.value;
},
onPickDateTap: function(args) {
const dateToday = new Date();
const dateTomorrow = new Date(dateToday.getFullYear(), dateToday.getMonth(), dateToday.getDate() + 1);
const dateNextWeek = new Date(dateToday.getFullYear(), dateToday.getMonth(), dateToday.getDate() + 7);
DateTimePicker
.pickDate({
context: args.object._context,
date: dateTomorrow,
minDate: dateTomorrow,
maxDate: dateNextWeek,
okButtonText: "OK",
cancelButtonText: "Cancel",
title: "choose date",
locale: "en_GB"
})
.then(selectedDate => {
if (selectedDate) {
this.dateText = this.getFormattedDate(selectedDate);
}
});
},
onPickTimeTap: function(args) {
const dateToday = new Date();
const dateTomorrow = new Date(dateToday.getFullYear(), dateToday.getMonth(), dateToday.getDate() + 1);
dateTomorrow.setHours(8);
dateTomorrow.setMinutes(0);
DateTimePicker
.pickTime({
context: args.object._context,
time: dateTomorrow,
okButtonText: "OK",
cancelButtonText: "Cancel",
title: "choose time",
locale: "en_GB",
is24Hours: true
})
.then(selectedTime => {
if (selectedTime) {
this.timeText = this.getFormattedTime(selectedTime);
}
});
},
onPickDateTimeTap: function(args) {
const dateToday = new Date();
DateTimePicker
.pickDate({
context: args.object._context,
date: dateToday,
title: "choose date",
locale: "en_GB"
})
.then(selectedDate => {
if (selectedDate) {
DateTimePicker
.pickTime({
context: args.object._context,
time: selectedDate,
title: "choose time",
locale: "en_GB"
})
.then(selectedDateTime => {
if (selectedDateTime) {
this.dateTimeText = this.getFormattedDate(selectedDateTime) + ' ' + this.getFormattedTime(selectedDateTime);
}
});
}
});
},
onHeaderTap: function(args) {
const buttonId = args.object.id;
const isCurrentlyExpanded = buttonId === this._expandedId;
if (isCurrentlyExpanded) {
this.expandCollapse(null);
} else {
this.expandCollapse(buttonId);
}
this.$refs.scrollView.nativeView.scrollToVerticalOffset(0, false);
},
expandCollapse: function(expandId) {
this.dateOpacity = expandId === 'date' ? 0.7 : 1;
this.dateVisibility = expandId === 'date' ? 'visible' : 'collapse';
this.timeOpacity = expandId === 'time' ? 0.7 : 1;
this.timeVisibility = expandId === 'time' ? 'visible' : 'collapse';
this.dateTimeOpacity = expandId === 'dateTime' ? 0.7 : 1;
this.dateTimeVisibility = expandId === 'dateTime' ? 'visible' : 'collapse';
this.customOpacity = expandId === 'custom' ? 0.7 : 1;
this.customVisibility = expandId === 'custom' ? 'visible' : 'collapse';
this._expandedId = expandId;
},
getFormattedDate: function(date) {
const d = date.getDate();
const m = date.getMonth() + 1;
const y = date.getFullYear();
return (d < 10 ? '0' : '') + d + '.' + (m < 10 ? '0' : '') + m + '.' + y;
},
getFormattedTime: function(date) {
const h = date.getHours();
const m = date.getMinutes();
return (h < 10 ? '0' : '') + h + ':' + (m < 10 ? '0' : '') + m;
}
}
};
</script>
<style scoped lang="scss">
// Start custom common variables
@import '../app-variables';
// End custom common variables
// Custom styles
.content {
font-size: 16;
font-weight: bold;
margin-top: 12;
margin-bottom: 6;
color: #303F9F;
}
.header {
font-size: 16;
margin-top: 12;
margin-bottom: 6;
color: white;
background-color: #2196F3;
text-align: center;
}
label {
padding: 6 4;
}
timepickerfield,
datepickerfield {
padding: 12 4;
}
timepickerfield.apply-css,
datepickerfield.apply-css {
color: #CDDC39;
background-color: #00796B;
font-size: 20;
font-weight: bold;
padding: 20;
}
.date-time-picker.apply-css {
color: #00796B;
background-color: #CDDC39;
}
.date-time-picker-spinners.apply-css {
color: #CDDC39;
background-color: #00796B;
}
.date-time-picker-buttons.apply-css {
color: #00796B;
}
</style>