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