import { Injectable , Component , Inject } from '@angular/core' ; import { MatSnackBar , MatSnackBarConfig , MatDialog , MatDialogConfig , } from '@angular/material' ; import { Observable } from 'rxjs' ; import { SimpleDialogComponent } from './simple-dialog/simple-dialog.component' ; @ Injectable ( ) export class UiService { constructor ( private snackBar , private dialog ) { } showToast ( message , action = 'Close' , config ? ) { this . snackBar . open ( message , action , config || { duration : 7000 , } ) ; } showDialog ( title , content , okText = 'OK' , cancelText ? , customConfig ? ) { const dialogRef = this . dialog . open ( SimpleDialogComponent , customConfig || { width : '300px' , data : { title : title , content : content , okText : okText , cancelText : cancelText } , } ) ; return dialogRef . afterClosed ( ) ; } }