-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathmyview.ts
More file actions
76 lines (67 loc) · 1.87 KB
/
myview.ts
File metadata and controls
76 lines (67 loc) · 1.87 KB
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
import { View } from '@nativescript/core';
import { ViewModelBase } from './myview-base';
export class ViewModel extends ViewModelBase {
constructor() {
super();
}
// View properties
public onWidthHeight(args: { eventName: string; object: any }): void {
var view: View = <View>args.object;
if (view.width !== 30) {
super.setWidthHeight(view, 105, 55);
} else {
super.setWidthHeight(view, 0, 0);
}
}
public onMinWidthMinHeight(args: { eventName: string; object: any }): void {
var view: View = <View>args.object;
if (view.minWidth !== 105) {
super.setMinWidthHeight(view, 105, 55);
} else {
super.setMinWidthHeight(view, 0, 0);
}
}
public onMargins(args: { eventName: string; object: any }): void {
var view: View = <View>args.object;
if (view.marginLeft !== 5) {
super.setMargins(view, 5, 5, 5, 5);
} else {
super.setMargins(view, 0, 0, 0, 0);
}
}
public onAllProperties(args: { eventName: string; object: any }): void {
let child;
let layout = args.object.parent;
// WidthHeight
child = layout.getViewById('widthHeight');
if (child.width !== 30) {
super.setWidthHeight(child, 30, 50);
} else {
super.setWidthHeight(child, Number.NaN, Number.NaN);
}
// MinWidthMinHeight
child = layout.getViewById('minWidthMinHeight');
if (child.minWidth !== 105) {
super.setMinWidthHeight(child, 105, 55);
} else {
super.setMinWidthHeight(child, 0, 0);
}
// Margins
child = layout.getViewById('margins');
if (child.marginLeft !== 5) {
super.setMargins(child, 5, 5, 5, 5);
} else {
super.setMargins(child, 0, 0, 0, 0);
}
// Alignments
child = layout.getViewById('alignments');
super.setAllPositioningProperties(child);
super.toggleVisibility(child);
// Paddings
if (layout.paddingLeft !== 5) {
super.setPaddings(layout, 5, 5, 5, 5);
} else {
super.setPaddings(layout, 0, 0, 0, 0);
}
}
}