public MatToast Add(string message, MatToastType type, string title, string icon, Action <MatToastOptions> configure) { if (string.IsNullOrEmpty(message)) { return(null); } message = message.Trim(); title = string.IsNullOrEmpty(title) ? "" : title.Trim(); if (Configuration.PreventDuplicates && ToastAlreadyPresent(message, title, type)) { return(null); } var options = new MatToastOptions(type, Configuration); configure?.Invoke(options); var toast = new MatToast(message, title, icon, options); toast.OnClose += Remove; Toasts.Add(toast); OnToastsUpdated?.Invoke(); return(toast); }
private bool ToastAlreadyPresent(string message, string title, MatToastType type) { return(Toasts.Any(t => message.Equals(t.Message) && title.Equals(t.Title) && type.Equals(t.Options.Type) )); }
private void ShowToastOnlyOncePerScope(string message, MatToastType type, string?title = null) { var hash = message.GetHashCode(); if (!messagesAlreadyShown.Contains(hash)) { Toaster.Add(message, type, title); messagesAlreadyShown.Add(hash); } }
private void Show(MatToastType type, string icon = "") { Toaster.Add("ok", type, "Ok", icon, config => { config.ShowCloseButton = true; config.ShowProgressBar = true; config.MaximumOpacity = 100; config.ShowTransitionDuration = 500; config.VisibleStateDuration = 5000; config.HideTransitionDuration = 500; config.RequireInteraction = false; }); }
public MatToastOptions(MatToastType type, MatToastConfiguration configuration) { Type = type; Class = configuration.Class; MaximumOpacity = configuration.MaximumOpacity; ShowTransitionDuration = configuration.ShowTransitionDuration; VisibleStateDuration = configuration.VisibleStateDuration; HideTransitionDuration = configuration.HideTransitionDuration; ShowProgressBar = configuration.ShowProgressBar; ShowCloseButton = configuration.ShowCloseButton; CloseIcon = configuration.CloseIcon; RequireInteraction = configuration.RequireInteraction; }
protected void ShowToast(string titulo, string mensagem, MatToastType type) { Toaster.Add(mensagem, type, titulo); }