<ion-header>
	<ion-navbar>
		<button ion-button menuToggle>
            <ion-icon name="menu"></ion-icon>
        </button>
    	<ion-title>Clientes</ion-title>
		<ion-buttons end>
			<button ion-button icon-only (click)="toggleSearch()" [disabled]="getSelectedItem()">
				<i class="fa fa-search fa-lg"></i>
			</button>
		</ion-buttons>
  	</ion-navbar>
</ion-header>
<ion-toolbar *ngIf="isSearch()">
    <ion-searchbar placeholder="Buscar" debounce="1000" (ionInput)="performSearch($event)"></ion-searchbar>
    <ion-buttons end>
        <button ion-button icon-only (click)="toggleSearch()">
            <i class="fa fa-undo fa-lg"></i>
        </button>
    </ion-buttons>
</ion-toolbar>
<ion-content>
	<ion-list>
		<ion-item *ngFor="let item of getItemsShown()" (doubleTap)="openOptions(item)" [ngClass]="{ 'selected-item': item === getSelectedItem() }">
			<ion-thumbnail item-left>
				<img src="./assets/images/customer.png" *ngIf="!item.image_medium"/>
				<img [src]="item.image_medium | sanitizeUrl" *ngIf="item.image_medium"/>
			</ion-thumbnail>
			<h2>{{ item.name }}</h2>
			<p>
				<strong>Ciudad:</strong>
				{{ item.city || "n/a" }}
			</p>
			<p>
				<strong>Celular:</strong>
				{{ item.mobile || "n/a" }}
			</p>
			<p>
				<strong>Email:</strong>
				{{ item.email || "n/a" }}
			</p>
		</ion-item>
	</ion-list>
	<ion-infinite-scroll (ionInfinite)="expand($event)">
        <ion-infinite-scroll-content></ion-infinite-scroll-content>
    </ion-infinite-scroll>
	<div class="no-items" *ngIf="!hasItemsShown()">
        <h2>Sin elementos</h2>
    </div>
	<ion-fab right bottom *ngIf="getMode() === 'list'">
        <button ion-fab (click)="goToDetails()">
            <ion-icon name="add"></ion-icon>
        </button>
    </ion-fab>
</ion-content>
<ion-footer>
	<p text-center>Se muestran {{ getItemsShown().length }} de {{ getItems().length }} elementos</p>
</ion-footer>
