-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
Dialogs.vue
137 lines (132 loc) · 5.64 KB
/
Dialogs.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
<template>
<Page>
<ActionBar :title="title">
<NavigationButton text="Back" android.systemIcon="ic_menu_back" @tap="onNavigationButtonTap"></NavigationButton>
</ActionBar>
<StackLayout>
<MDButton id="alert" text="alert" @tap="onTap" />
<MDButton id="prompt" text="prompt" @tap="onTap" />
<MDButton id="password" text="password" @tap="onTap" />
<MDButton id="login" text="login" @tap="onTap" />
<MDButton id="dialogCustomView" text="customView" @tap="onTap" />
<MDButton id="alertdialog" text="alertdialog" @tap="onTap" />
</StackLayout>
</Page>
</template>
<script lang="ts">
import * as frameModule from '@nativescript/core/ui/frame';
import Vue from 'vue';
import { EventData, View, Color } from '@nativescript/core/ui/frame';
import { alert, AlertDialog, login, prompt, inputType } from 'nativescript-material-dialogs';
import { StackLayout } from '@nativescript/core/ui/layouts/stack-layout/stack-layout';
import { ActivityIndicator } from '@nativescript/core/ui/activity-indicator/activity-indicator';
import { Label } from '@nativescript/core/ui/label/label';
export const title = 'Dialogs sample';
export default Vue.extend({
data() {
return {
name: 'Dialogs',
title: title
};
},
methods: {
onNavigationButtonTap() {
frameModule.topmost().goBack();
},
onTap(args: EventData) {
const obj = args.object as View;
const objId = obj.id;
console.log('onTap', objId, obj);
switch (objId) {
case 'alert': {
alert('this is test Alert!').then(result => console.log('alert result', result));;
break;
}
case 'dialogCustomView': {
const label = new Label();
label.style.padding = 20;
label.style.backgroundColor = new Color(255, 255,0,0);
label.style.fontSize = 11;
label.style.whiteSpace = 'normal';
label.text = 'Un problème technique est survenu. Notre service technique en a été informé et traitera le problème dans les plus brefs délais.';
alert({
okButtonText: 'OK',
// title: 'custom dialog view',
context: {
dataItems: this.dataItems
},
view: label
}).then(result => {
alert(`closed dialog with customview and result: ${result}`);
});
break;
}
case 'prompt': {
console.log('about to prompt');
prompt({
// message: 'this is test Prompt!',
okButtonText: 'OK',
cancelButtonText: 'Cancel',
title: null,
textFieldProperties: {
marginLeft: 20,
marginRight: 50,
hint: 'test hint text'
},
autoFocus: true
}).then(result => console.log('prompt result', result));
break;
}
case 'password': {
console.log('about to prompt');
prompt({
title: 'Enter password',
defaultText: '',
okButtonText: 'OK',
cancelButtonText: 'Cancel',
inputType:inputType.password,
}).then(result => console.log('prompt result', result));
break;
}
case 'login': {
console.log('about to login');
login({
message: 'this is test Prompt!',
okButtonText: 'OK',
cancelButtonText: 'Cancel',
title: 'title?',
userName: 'my username?',
password: 'my password?'
}).then(result => console.log('login result', result));
break;
}
case 'alertdialog':
const stack = new StackLayout();
stack.orientation = 'horizontal';
stack.verticalAlignment = 'middle';
// stack.height = {value:100, unit:'dip'};
stack.padding = 24;
// stack.margin = 30;
stack.backgroundColor = 'red';
const activityIndicator = new ActivityIndicator();
activityIndicator.className = 'activity-indicator';
activityIndicator.backgroundColor = 'yellow';
activityIndicator.busy = true;
activityIndicator.verticalAlignment = 'middle';
stack.addChild(activityIndicator);
const label = new Label();
label.verticalAlignment = 'middle';
label.backgroundColor = 'brown';
label.text = 'test';
stack.addChild(label);
const dialog = new AlertDialog({
// title: 'tsst',
// message: null,
view: stack
});
dialog.show();
}
}
}
});
</script>