<ion-header class="ion-no-border">
  <app-header></app-header>
</ion-header>


<ion-header class="ion-no-border header-2">
  <div class="title">
    <app-btn-modal-dismiss (click)="goBack()"></app-btn-modal-dismiss>
    <div class="thetitle"><ion-label >Diplomas</ion-label></div>
    <div class="theicon btn-refresh">
      <button class="btn-no-color" (click)="doRefresh($event)">
        <ion-icon slot="end" class="title-icon font-awesome" name="reload-circle"></ion-icon>
      </button>
    </div>
  </div>
  <ion-toolbar>
    <ion-segment [(ngModel)]="segment" (ionChange)="segmentChanged($event)">
      <ion-segment-button value="validar">
        Por validar ...
      </ion-segment-button>
      <ion-segment-button value="assinados">
        Assinados PR ...
      </ion-segment-button>
    </ion-segment>
  </ion-toolbar>
</ion-header>
<ion-content>

  <div class="main-content width-100 overflow-y-auto height-100">
    <ion-refresher name="refresher" slot="fixed" (ionRefresh)="doRefresh($event)">
      <ion-refresher-content></ion-refresher-content>
    </ion-refresher>
  
    <div class="width-100" [ngSwitch]="segment">
      <ion-progress-bar type="indeterminate" *ngIf="skeletonLoader"></ion-progress-bar>
      <div *ngIf="diplomasList">

        <ion-list *ngSwitchCase="'validar'">
          <ion-item 
              class="expediente ion-no-padding cursor-pointer"  
              *ngFor = "let task of diplomasList"
              (click)="goToDiploma(task.SerialNumber)"
              lines="none"
              >
              <div class="item width-100">
                <div class="exp-top-detail">
                  <div class="subject">
                    <ion-label>{{ task.Folio }}</ion-label>
                  </div>
                  <div class="exp-icon">
                    <ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/images/icons-expediente-attachment.svg"></ion-icon>
                    <ion-icon *ngIf="ThemeService.currentTheme == 'gov' " src="assets/images/theme/gov/icons-expediente-attachment.svg"></ion-icon>
                    <label *ngIf="task.DocumentsQty != 0">{{task.DocumentsQty}}</label>
                  </div>
                </div>
                <div class="exp-bottom-detail">
                  <div class="exp-remetente">
                    <ion-label>{{task.Senders}}</ion-label>
                  </div>
                </div>
                <div class="exp-middle-detail">
                  <div class="exp-workflow">
                    <span class="label">{{task.activityInstanceName}}</span>
                  </div>
                  <div class="exp-date">
                    <ion-label>{{ task.CreateDate | date: 'dd-MM-yyyy HH:mm' }}</ion-label>
                  </div>
                </div>
              </div>
          </ion-item>
        </ion-list>
  
      </div>
      <div *ngIf="diplomasAssinadoList">
        <ion-list *ngSwitchCase="'assinados'">
          <ion-item 
            class="expediente ion-no-padding cursor-pointer"  
            *ngFor = "let task of diplomasAssinadoList"
            (click)="goToDiploma(task.SerialNumber)"
            lines="none"
          >
          <div class="item width-100">
            <div class="exp-top-detail">
              <div class="subject">
                <ion-label>{{ task.Folio }}</ion-label>
              </div>
              <div class="exp-icon">
                <ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/images/icons-expediente-attachment.svg"></ion-icon>
                <ion-icon *ngIf="ThemeService.currentTheme == 'gov' " src="assets/images/theme/gov/icons-expediente-attachment.svg"></ion-icon>
                <label *ngIf="task.DocumentsQty != 0">{{task.DocumentsQty}}</label>
              </div>
            </div>
            <div class="exp-bottom-detail">
              <div class="exp-remetente">
                <ion-label>{{task.Senders}}</ion-label>
              </div>
            </div>
            <div class="exp-middle-detail">
              <div class="exp-workflow">
                <span class="label">{{task.activityInstanceName}}</span>
              </div>
              <div class="exp-date">
                <ion-label>{{ task.CreateDate | date: 'dd-MM-yyyy HH:mm' }}</ion-label>
              </div>
            </div>
          </div>
          </ion-item>
        </ion-list>
      </div>
    </div>

    <div 
      *ngIf="!skeletonLoader && diplomasList.length == 0 && diplomasAssinadoList.length == 0" 
      class="empty-list d-flex height-100 align-center justify-content-center"
    >
      <span>Lista vazia</span>
    </div>

    <div *ngIf="skeletonLoader && diplomasAssinadoList.length == 0 && skeletonLoader && diplomasList.length == 0">
    
      <ion-list>
        <ion-item>
          <ion-thumbnail slot="end">
            <ion-skeleton-text animated></ion-skeleton-text>
          </ion-thumbnail>
          <ion-label>
            <h3><ion-skeleton-text animated style="width: 50%"></ion-skeleton-text></h3>
            <p><ion-skeleton-text animated style="width: 80%"></ion-skeleton-text></p>
            <p><ion-skeleton-text animated style="width: 60%"></ion-skeleton-text></p>
          </ion-label>
        </ion-item>
        <ion-item>
          <ion-thumbnail slot="end">
            <ion-skeleton-text animated></ion-skeleton-text>
          </ion-thumbnail>
          <ion-label>
            <h3><ion-skeleton-text animated style="width: 50%"></ion-skeleton-text></h3>
            <p><ion-skeleton-text animated style="width: 80%"></ion-skeleton-text></p>
            <p><ion-skeleton-text animated style="width: 60%"></ion-skeleton-text></p>
          </ion-label>
        </ion-item>
      </ion-list>
    </div>

  </div>

</ion-content>
