diff --git a/src/providers/alert/alert.ts b/src/providers/alert/alert.ts index fae21c1..510dc28 100644 --- a/src/providers/alert/alert.ts +++ b/src/providers/alert/alert.ts @@ -1,5 +1,5 @@ -import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; +import { AlertController } from 'ionic-angular/components/alert/alert-controller'; /* Generated class for the AlertProvider provider. @@ -10,8 +10,49 @@ import { Injectable } from '@angular/core'; @Injectable() export class AlertProvider { - constructor(public http: HttpClient) { - console.log('Hello AlertProvider Provider'); - } + constructor(private _alertCtrl: AlertController) { + } + + public showSuccessAlert(message: string): void { + let successAlert = this._alertCtrl.create({ + buttons: ["Ok"], + message: message, + enableBackdropDismiss: false, + title: "Success!" + }); + + successAlert.present(); + } + + public showErrorAlert(message: string): void { + let errorAlert = this._alertCtrl.create({ + buttons: ["Ok"], + message: message, + enableBackdropDismiss: false, + title: "Error!", + subTitle: "An error occurred" + }); + + errorAlert.present(); + } + + public showPrompt(message: string, confirmHandler: (value: any) => boolean | void, cancelHandler: (value: any) => boolean | void): void { + let promptAlert = this._alertCtrl.create({ + buttons: [{ + role: "confirm", + handler: confirmHandler, + text: "Confirm" + }, { + role: "cancel", + handler: cancelHandler, + text: "Cancel" + }], + message: message, + enableBackdropDismiss: false, + title: "Please confirm your action" + }); + + promptAlert.present(); + } }