<ion-header>
    <ion-toolbar>
        <ion-buttons slot="start">
            <ion-back-button [text]="'core.back' | translate" />
        </ion-buttons>
        <ion-title>
            <h1>{{ 'addon.calendar.calendar' | translate }}</h1>
            <p *ngIf="!showCalendar" class="subheading">{{ 'addon.calendar.upcomingevents' | translate }}</p>
        </ion-title>
        <ion-buttons slot="end">
            <ion-button fill="clear" (click)="openFilter()" [attr.aria-label]="'core.filter' | translate">
                <ion-icon slot="icon-only" name="fas-filter" aria-hidden="true" />
            </ion-button>
            <core-context-menu>
                <core-context-menu-item *ngIf="showCalendar" [priority]="800" [content]="'addon.calendar.upcomingevents' | translate"
                    iconAction="fas-table-list" (action)="toggleDisplay()" />
                <core-context-menu-item *ngIf="!showCalendar" [priority]="800" [content]="'addon.calendar.monthlyview' | translate"
                    iconAction="fas-calendar-days" (action)="toggleDisplay()" />
                <core-context-menu-item [priority]="600" [content]="'core.settings.settings' | translate" (action)="openSettings()"
                    iconAction="fas-gears" />
                <core-context-menu-item [hidden]="!loaded || !hasOffline || !isOnline" [priority]="400"
                    [content]="'core.settings.synchronizenow' | translate" (action)="doRefresh(undefined, $event, true)"
                    [iconAction]="syncIcon" [closeOnClick]="false" />
            </core-context-menu>
            <core-user-menu-button />
        </ion-buttons>
    </ion-toolbar>
</ion-header>
<ion-content>
    <ion-refresher slot="fixed" [disabled]="!loaded" (ionRefresh)="doRefresh($event.target)">
        <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}" />
    </ion-refresher>

    <!-- There is data to be synchronized -->
    <ion-card class="core-warning-card" *ngIf="hasOffline">
        <ion-item>
            <ion-icon name="fas-triangle-exclamation" slot="start" aria-hidden="true" />
            <ion-label>{{ 'core.hasdatatosync' | translate:{$a: 'addon.calendar.calendar' | translate} }}</ion-label>
        </ion-item>
    </ion-card>

    <addon-calendar-calendar [hidden]="!showCalendar" [initialYear]="year" [initialMonth]="month" [filter]="filter"
        [displayNavButtons]="showCalendar" (onEventClicked)="gotoEvent($event)" (onDayClicked)="gotoDay($event)" />

    <addon-calendar-upcoming-events *ngIf="loadUpcoming" [hidden]="showCalendar" [filter]="filter" (onEventClicked)="gotoEvent($event)" />

    <!-- Create a calendar event. -->
    <ion-fab slot="fixed" core-fab vertical="bottom" horizontal="end" *ngIf="canCreate">
        <ion-fab-button (click)="openEdit()" [attr.aria-label]="'addon.calendar.newevent' | translate">
            <ion-icon name="fas-plus" aria-hidden="true" />
            <span class="sr-only">{{ 'addon.calendar.newevent' | translate }}</span>
        </ion-fab-button>
    </ion-fab>
</ion-content>
