Ejemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="config"></param>
 public async Task Info(VantNotifyConfig config)
 {
     if (config != null)
     {
         config.NotificationType = VantNotifyType.Info;
         await Open(config);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="config"></param>
 public async Task Warning(VantNotifyConfig config)
 {
     if (config != null)
     {
         config.NotificationType = VantNotifyType.Warning;
         await Open(config);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="config"></param>
 public async Task Error(VantNotifyConfig config)
 {
     if (config != null)
     {
         config.NotificationType = VantNotifyType.Error;
         await Open(config);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="config"></param>
 public async Task Success(VantNotifyConfig config)
 {
     if (config != null)
     {
         config.NotificationType = VantNotifyType.Success;
         await Open(config);
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="config"></param>
 public async Task Warn(VantNotifyConfig config)
 {
     await Warning(config);
 }