import { Injectable } from '@angular/core';
import { LoadingController } from '@ionic/angular';

@Injectable({
  providedIn: 'root'
})
export class LoadingService {
  loading:any;

  constructor(public loadingController: LoadingController) { }

  async simpleLoading() {
    this.loading = await this.loadingController.create({
      cssClass: 'my-custom-class',
      message:'A carregar!...',
      duration: 2000
    });
    await this.loading.present();
  }

  async customizedLoading() {
    const loading = await this.loadingController.create({
      cssClass: 'my-custom-class',
      spinner: null,
      duration: 5000,
      message: 'Click the backdrop to dismiss early...',
      translucent: true,
      backdropDismiss: true
    });
    await loading.present();

    const { role, data } = await loading.onDidDismiss();
  }

}
