예제 #1
0
        public MatToast(string message, string title, string icon, MatToastOptions options)
        {
            Message = message;
            Title   = title;
            Icon    = icon;

            if (string.IsNullOrEmpty(icon))
            {
                Icon = options.Type switch
                {
                    MatToastType.Danger => "error",
                    MatToastType.Dark => "error",
                    MatToastType.Info => "info",
                    MatToastType.Light => "notification_important",
                    MatToastType.Link => "link",
                    MatToastType.Primary => "announcement",
                    MatToastType.Secondary => "notification_important",
                    MatToastType.Success => "check_circle",
                    MatToastType.Warning => "warning",
                    _ => "notification_important",
                };
            }

            Options = options;
        }
예제 #2
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);
        }
예제 #3
0
        public MatToast(string message, string title, string icon, MatToastOptions options)
        {
            Message = message;
            Title   = title;
            Icon    = icon;

            if (string.IsNullOrEmpty(icon))
            {
                switch (options.Type)
                {
                case MatToastType.Danger:
                    Icon = "error";
                    break;

                case MatToastType.Dark:
                    Icon = "error";
                    break;

                case MatToastType.Info:
                    Icon = "info";
                    break;

                case MatToastType.Light:
                    Icon = "notification_important";
                    break;

                case MatToastType.Link:
                    Icon = "link";
                    break;

                case MatToastType.Primary:
                    Icon = "announcement";
                    break;

                case MatToastType.Secondary:
                    Icon = "notification_important";
                    break;

                case MatToastType.Success:
                    Icon = "check_circle";
                    break;

                case MatToastType.Warning:
                    Icon = "warning";
                    break;

                default:
                    Icon = "notification_important";
                    break;
                }
                ;
            }

            Options = options;
        }