Beispiel #1
0
        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);
        }
Beispiel #2
0
        public void Remove(MatToast toast)
        {
            toast.OnClose -= Remove;
            Toasts.Remove(toast);

            OnToastsUpdated?.Invoke();
//            toast.Dispose();
        }