<ion-header>
    <ion-toolbar>
        <ion-buttons slot="start">
            <ion-back-button [text]="'core.back' | translate"></ion-back-button>
        </ion-buttons>
        <ion-title *ngIf="title">{{ title }}</ion-title>
    </ion-toolbar>
</ion-header>
<ion-content>
    <ion-refresher slot="fixed" [disabled]="!userLoaded" (ionRefresh)="refreshUser($event.target)">
        <ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
    </ion-refresher>
    <core-loading [hideUntil]="userLoaded">
        <ion-list *ngIf="user">
            <ion-item-group *ngIf="hasContact">
                <ion-item-divider><ion-label>{{ 'core.user.contact' | translate}}</ion-label></ion-item-divider>
                <ion-item class="ion-text-wrap" *ngIf="user.email">
                    <ion-label>
                        <h2>{{ 'core.user.email' | translate }}</h2>
                        <p><a class="core-anchor" href="mailto:{{user.email}}" core-link auto-login="no">
                            {{ user.email }}
                        </a></p>
                    </ion-label>
                </ion-item>
                <ion-item class="ion-text-wrap" *ngIf="user.phone1">
                    <ion-label>
                        <h2>{{ 'core.user.phone1' | translate}}</h2>
                        <p><a class="core-anchor" href="tel:{{user.phone1}}" core-link auto-login="no">
                            {{ user.phone1 }}
                        </a></p>
                    </ion-label>
                </ion-item>
                <ion-item class="ion-text-wrap" *ngIf="user.phone2">
                    <ion-label>
                        <h2>{{ 'core.user.phone2' | translate}}</h2>
                        <p><a class="core-anchor" href="tel:{{user.phone2}}" core-link auto-login="no">
                            {{ user.phone2 }}
                        </a></p>
                    </ion-label>
                </ion-item>
                <ion-item class="ion-text-wrap" *ngIf="user.address">
                    <ion-label>
                        <h2>{{ 'core.user.address' | translate}}</h2>
                        <p><a class="core-anchor" [href]="encodedAddress" core-link auto-login="no">
                            {{ user.address }}
                        </a></p>
                    </ion-label>
                </ion-item>
                <ion-item class="ion-text-wrap" *ngIf="user.city && !user.address">
                    <ion-label>
                        <h2>{{ 'core.user.city' | translate}}</h2>
                        <p>{{ user.city }}</p>
                    </ion-label>
                </ion-item>
                <ion-item class="ion-text-wrap" *ngIf="user.country && !user.address">
                    <ion-label>
                        <h2>{{ 'core.user.country' | translate}}</h2>
                        <p>{{ user.country }}</p>
                    </ion-label>
                </ion-item>
            </ion-item-group>
            <ion-item-group *ngIf="hasDetails">
                <ion-item-divider><ion-label>{{ 'core.userdetails' | translate}}</ion-label></ion-item-divider>
                <ion-item class="ion-text-wrap" *ngIf="user.url">
                    <ion-label>
                        <h2>{{ 'core.user.webpage' | translate}}</h2>
                        <p><a class="core-anchor" href="{{user.url}}" core-link>
                            {{ user.url }}
                        </a></p>
                    </ion-label>
                </ion-item>
                <ion-item class="ion-text-wrap" *ngIf="user.interests">
                    <ion-label>
                        <h2>{{ 'core.user.interests' | translate}}</h2>
                        <p>{{ user.interests }}</p>
                    </ion-label>
                </ion-item>
                <core-user-profile-field *ngFor="let field of user.customfields" [field]="field" contextLevel="course"
                    [contextInstanceId]="courseId" [courseId]="courseId">
                </core-user-profile-field>
            </ion-item-group>
            <ion-item-group *ngIf="user.description">
                <ion-item-divider><ion-label>{{ 'core.user.description' | translate}}</ion-label></ion-item-divider>
                <ion-item class="ion-text-wrap">
                    <ion-label>
                        <p><core-format-text [text]="user.description" contextLevel="user" [contextInstanceId]="user.id">
                        </core-format-text></p>
                    </ion-label>
                </ion-item>
            </ion-item-group>
        </ion-list>

        <core-empty-box *ngIf="!user || (!hasContact && !hasDetails && !user.description)" icon="fa-user"
            [message]=" 'core.user.detailsnotavailable' | translate">
        </core-empty-box>
    </core-loading>
</ion-content>
