-
Notifications
You must be signed in to change notification settings - Fork 129
/
Copy pathcalendar-events-view-modes.component.ts
82 lines (74 loc) · 3.02 KB
/
calendar-events-view-modes.component.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import { OptionsExampleBase } from "../../options-example-base";
import { Component, OnInit, Injectable } from "@angular/core";
import { Router } from '@angular/router';
import { CalendarEventsService } from "../calendar-events.service";
import { OptionsService } from "../../navigation/options/options.service";
import { RadCalendar, CalendarEvent, CalendarEventsViewMode } from "nativescript-ui-calendar";
import { Page } from "ui/page";
import * as applicationModule from "application";
@Component({
moduleId: module.id,
selector: "tk-calendar-events-view-modes",
templateUrl: "calendar-events-view-modes.component.html",
providers: [CalendarEventsService]
})
@Injectable()
export class CalendarEventsViewModesComponent extends OptionsExampleBase implements OnInit {
private _events: Array<CalendarEvent>;
private _optionsParamName: string;
private _eventsViewMode;
constructor(private _page: Page, private _calendarService: CalendarEventsService,
private _optionsService: OptionsService, private _router: Router) {
super();
if (applicationModule.ios) {
this._page.on("navigatingTo", this.onNavigatingTo, this);
this._optionsParamName = "eventsViewMode";
this._optionsService.paramName = this._optionsParamName;
this.router = _router;
this.navigationParameters = { selectedIndex: 0, paramName: this._optionsParamName, items: ["None", "Inline", "Popover (iPad only)"] };
}
this._eventsViewMode = CalendarEventsViewMode.None;
}
get eventSource() {
return this._events;
}
get eventsViewMode() {
return this._eventsViewMode;
}
ngOnInit() {
this._events = this._calendarService.getCalendarEvents();
}
onNoneTap() {
this._eventsViewMode = CalendarEventsViewMode.None;
}
onInlineTap() {
this._eventsViewMode = CalendarEventsViewMode.Inline;
}
onPopoverTap() {
this._eventsViewMode = CalendarEventsViewMode.Popover;
}
public onNavigatingTo(args) {
if (args.isBackNavigation) {
if (this._optionsService.paramName === this._optionsParamName) {
switch (this._optionsService.paramValue) {
case "None":
this.onNoneTap();
this.navigationParameters.selectedIndex = 0;
break;
case "Inline":
this.onInlineTap();
this.navigationParameters.selectedIndex = 1;
break;
case "Popover":
if (UIDevice.currentDevice().userInterfaceIdiom === UIUserInterfaceIdiomPad) {
this.onPopoverTap();
this.navigationParameters.selectedIndex = 2;
}
break;
default:
break;
}
}
}
}
}