<!--
  ~ Copyright (C) 2023 StApps
  ~ This program is free software: you can redistribute it and/or modify it
  ~ under the terms of the GNU General Public License as published by the Free
  ~ Software Foundation, version 3.
  ~
  ~ This program is distributed in the hope that it will be useful, but WITHOUT
  ~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  ~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  ~ more details.
  ~
  ~ You should have received a copy of the GNU General Public License along with
  ~ this program. If not, see <https://www.gnu.org/licenses/>.
  -->

<ng-container *ngIf="items as items; else loading">
  <ion-list>
    <ng-container *ngIf="!listHeader; else header"></ng-container>
    <ng-container *ngFor="let item of items | async">
      <ng-container
        *ngTemplateOutlet="listItemTemplateRef || defaultListItem; context: {$implicit: item}"
      ></ng-container>
    </ng-container>
  </ion-list>
  <ion-label class="empty-list-message" *ngIf="emptyListMessage && (items | async)?.length === 0"
    >{{ emptyListMessage }}</ion-label
  >
</ng-container>
<ng-template #loading>
  <ion-list>
    <stapps-skeleton-list-item
      [hideThumbnail]="singleType"
      *ngFor="let skeleton of [].constructor(skeletonItems)"
    >
    </stapps-skeleton-list-item>
  </ion-list>
</ng-template>
<ng-template #header>
  <ion-list-header lines="inset">
    <ion-text color="dark">
      <h3>{{ listHeader }}</h3>
    </ion-text>
  </ion-list-header>
</ng-template>
<ng-template let-item #defaultListItem>
  <stapps-data-list-item [item]="item" [hideThumbnail]="singleType"></stapps-data-list-item>
</ng-template>
