/
selection-modes-model.ts
58 lines (50 loc) · 1.73 KB
/
selection-modes-model.ts
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
import calendarModule = require("nativescript-ui-calendar");
import observableModule = require("tns-core-modules/data/observable");
import frameModule = require("tns-core-modules/ui/frame");
export class ViewModel extends observableModule.Observable{
private _selectionInfo;
constructor(){
super();
this._selectionInfo = {
options: ["None", "Single", "Multiple", "Range"],
index: 0
};
}
set selectionMode(value: string){
this.set("SelectionMode", value);
}
get selectionMode() : string{
return this.get("SelectionMode");
}
public setSelectionMode(selectionMode : string){
this.selectionMode = selectionMode;
}
public updateSelectionMode() {
var index: number = this._selectionInfo.index;
if(index == 0) {
this.selectionMode = calendarModule.CalendarSelectionMode.None;
} else if (index == 1) {
this.selectionMode = calendarModule.CalendarSelectionMode.Single;
} else if (index == 2) {
this.selectionMode = calendarModule.CalendarSelectionMode.Multiple;
} else {
this.selectionMode = calendarModule.CalendarSelectionMode.Range;
}
this.resetSelection();
}
public resetSelection() {
var calendar: calendarModule.RadCalendar = <calendarModule.RadCalendar>(frameModule.topmost().getViewById("calendar"));
if (!calendar) {
return;
}
calendar.reload();
}
public onOptionsTapped() {
var navigationEntry = {
moduleName: "navigation/options-menu/options",
context: this._selectionInfo,
animated: true
};
frameModule.topmost().navigate(navigationEntry);
}
}