public void AddToast(ToastOptions options, string title, string message) { if (options == null) { throw new ArgumentNullException(nameof(options), "The ToastOptions object cannot be null."); } options.Display = true; options.Title = title ?? string.Empty; options.Message = message ?? string.Empty; if (PreventDuplicates) { foreach (var option in Options) { if (options.Equals(option)) { return; } } } if (NewestOnTop) { Options.Insert(0, options); } else { Options.Add(options); } StateHasChanged(); }
public void AddToast(ToastOptions options, string title, string message) { OnAddToast?.Invoke(options, title, message); if (options.TimeOut > 0) { StartCountdown(options); } }
public static ToastOptions CreateToastOptions(ToastOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } return(new ToastOptions(options)); }
public void AddSuccessToast(string title, string message) { var options = new ToastOptions(Configuration.ToastOptions) { IconClass = "toast-success" }; AddToast(options, title, message); }
public void AddWarningToast(string title, string message) { var options = new ToastOptions(Configuration.ToastOptions) { IconClass = "toast-warning" }; AddToast(options, title, message); }
private void SetCountdown(ToastOptions options) { if (Countdown == null) { Countdown = new Timer(options.TimeOut); Countdown.Elapsed += RemoveToast; Countdown.AutoReset = false; } }
public void RemoveToast(ToastOptions options) { if (options != null) { InvokeAsync(() => { // change the CSS to fadeOut, slideDown or hide here, call StateHasChanged. Use timer, can set ease duration in Toast.cs Options.Remove(options); StateHasChanged(); }); } }
private void StartCountdown(ToastOptions options) { SetCountdown(options); Stack.Push(options); if (Countdown.Enabled) { Countdown.Stop(); Countdown.Start(); } else { Countdown.Start(); } }
internal ToastOptions(ToastOptions options) { this.CloseButton = options.CloseButton; this.CloseButtonClass = options.CloseButtonClass; this.Display = options.Display; this.FirstRendering = options.FirstRendering; this.HideClass = options.HideClass; this.IconClass = options.IconClass; this.Message = options.Message; this.MessageClass = options.MessageClass; this.RTL = options.RTL; this.ShowClass = options.ShowClass; this.TapToDismiss = options.TapToDismiss; this.TimeOut = options.TimeOut; this.Title = options.Title; this.TitleClass = options.TitleClass; this.ToastClass = options.ToastClass; // this.Type = options.Type; }