Exemple #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="config"></param>
 public async Task Info(VantNotifyConfig config)
 {
     if (config != null)
     {
         config.NotificationType = VantNotifyType.Info;
         await Open(config);
     }
 }
Exemple #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="config"></param>
 public async Task Warning(VantNotifyConfig config)
 {
     if (config != null)
     {
         config.NotificationType = VantNotifyType.Warning;
         await Open(config);
     }
 }
Exemple #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="config"></param>
 public async Task Error(VantNotifyConfig config)
 {
     if (config != null)
     {
         config.NotificationType = VantNotifyType.Error;
         await Open(config);
     }
 }
Exemple #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="config"></param>
 public async Task Success(VantNotifyConfig config)
 {
     if (config != null)
     {
         config.NotificationType = VantNotifyType.Success;
         await Open(config);
     }
 }
Exemple #5
0
        /// <summary>
        /// create notification box html from NotificationItem Component
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        private async ValueTask <string> CreateNotificationItem(VantNotifyConfig config)
        {
            RenderFragment renderFragment = (builder) =>
            {
                builder.OpenComponent <AntNotificationItem>(0);
                builder.AddAttribute(1, "Config", config);
                builder.CloseComponent();
            };
            string htmlStr = await RenderAsync(renderFragment);

            return(htmlStr);
        }
Exemple #6
0
        private VantNotifyConfig ExtendConfig(VantNotifyConfig config)
        {
            config.Placement ??= _defaultPlacement;
            config.Duration ??= _defaultDuration;
            config.CloseIcon ??= _defaultCloseIcon;

            if (string.IsNullOrWhiteSpace(config.Key))
            {
                config.Key = Guid.NewGuid().ToString();
            }

            return(config);
        }
Exemple #7
0
        /// <summary>
        /// Open a notification box
        /// </summary>
        /// <param name="config"></param>
        public async Task Open([NotNull] VantNotifyConfig config)
        {
            if (config == null)
            {
                return;
            }

            await CheckInit();

            config = ExtendConfig(config);
            Debug.Assert(config.Placement != null);
            string container = await GetContainer(config.Placement.Value);

            string notificationHtmlStr = await CreateNotificationItem(config);

            await _jsRuntime.InvokeVoidAsync(JSInteropConstants.addNotification,
                                             notificationHtmlStr,
                                             container, config.Key, config.Duration);

            _configDict.Add(config.Key, config);
        }
Exemple #8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="config"></param>
 public async Task Warn(VantNotifyConfig config)
 {
     await Warning(config);
 }