2020-05-10 22:43:58 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
|
|
|
|
2020-05-29 00:33:49 +08:00
|
|
|
|
namespace AntDesign
|
2020-05-10 22:43:58 +08:00
|
|
|
|
{
|
2020-05-16 16:52:44 +08:00
|
|
|
|
public partial class NotificationItem
|
2020-05-10 22:43:58 +08:00
|
|
|
|
{
|
|
|
|
|
[Parameter]
|
2020-05-16 16:52:44 +08:00
|
|
|
|
public NotificationConfig Config { get; set; }
|
2020-05-10 22:43:58 +08:00
|
|
|
|
|
|
|
|
|
[Parameter]
|
2020-05-16 16:52:44 +08:00
|
|
|
|
public Func<NotificationConfig, Task> OnClose { get; set; }
|
2020-05-10 22:43:58 +08:00
|
|
|
|
|
|
|
|
|
private string GetIconClassName()
|
|
|
|
|
{
|
2020-05-16 16:52:44 +08:00
|
|
|
|
if (Config.NotificationType != NotificationType.None
|
2020-05-10 22:43:58 +08:00
|
|
|
|
|| Config.Icon != null
|
|
|
|
|
)
|
|
|
|
|
{
|
2020-05-16 16:52:44 +08:00
|
|
|
|
return $"{ClassPrefix}-notice-with-icon";
|
2020-05-10 22:43:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string GetClassName()
|
|
|
|
|
{
|
|
|
|
|
if (Config.ClassName != null)
|
|
|
|
|
{
|
|
|
|
|
return Config.ClassName + Config.AnimationClass;
|
|
|
|
|
}
|
|
|
|
|
return Config.AnimationClass;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-18 00:15:58 +08:00
|
|
|
|
private async Task Close(MouseEventArgs e)
|
2020-05-10 22:43:58 +08:00
|
|
|
|
{
|
2020-05-18 00:15:58 +08:00
|
|
|
|
var task = OnClose?.Invoke(Config);
|
|
|
|
|
if (task != null)
|
|
|
|
|
{
|
|
|
|
|
await task;
|
|
|
|
|
}
|
2020-05-10 22:43:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnClick()
|
|
|
|
|
{
|
|
|
|
|
Config.InvokeOnClick();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|