Esempio n. 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);
        }
Esempio n. 2
0
 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)
                       ));
 }
Esempio n. 3
0
        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);
            }
        }
Esempio n. 4
0
        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;
            });
        }
Esempio n. 5
0
        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;
        }
Esempio n. 6
0
 protected void ShowToast(string titulo, string mensagem, MatToastType type)
 {
     Toaster.Add(mensagem, type, titulo);
 }