Exemplo n.º 1
0
 public async Task NotifyAsync(NoticeOption option)
 {
     if (Notice.Instance != null)
     {
         await Notice.Instance.NotifyAsync(option);
     }
 }
Exemplo n.º 2
0
 private async Task Remove(NoticeOption option)
 {
     if (option.KeepTime.TotalMilliseconds > 0)
     {
         await Task.Delay(option.KeepTime);
         await RemoveChild(option);
     }
 }
Exemplo n.º 3
0
        private Task RemoveChild(NoticeOption option)
        {
            //avoid use do click and option.KeepTime toggle twice
            if (string.IsNullOrEmpty(option.ClassName))
            {
                option.ClassName = $"{_classPrefix}-fade-out";
                StateHasChanged();
                option.OnClose?.Invoke(option);

                switch (option.Placement)
                {
                case NoticePlacement.TopLeft:
                    _topLeftNoticeItems.Remove(option);
                    break;

                case NoticePlacement.BottomLeft:
                    _bottomLeftNoticeItems.Remove(option);
                    break;

                case NoticePlacement.BottomRight:
                    _bottomRightNoticeItems.Remove(option);
                    break;

                default:
                    _topRightNoticeItems.Remove(option);
                    break;
                }
                //when next notice item fade out or add new notice item, item will toggle StateHasChanged
                //but if width is not  the default width, StateHasChanged
                if (!string.IsNullOrEmpty(option.Width))
                {
                    StateHasChanged();
                }
            }

            return(Task.CompletedTask);
        }
Exemplo n.º 4
0
        public async Task NotifyAsync(NoticeOption option)
        {
            switch (option.Placement)
            {
            case NoticePlacement.TopLeft:
                _topLeftNoticeItems.Add(option);
                break;

            case NoticePlacement.BottomLeft:
                _bottomLeftNoticeItems.Add(option);
                break;

            case NoticePlacement.BottomRight:
                _bottomRightNoticeItems.Add(option);
                break;

            default:
                _topRightNoticeItems.Add(option);
                break;
            }

            StateHasChanged();
            await Remove(option);
        }
Exemplo n.º 5
0
 public async Task NotifyErrorAsync(NoticeOption option)
 {
     option.IconType = IconType.Error;
     await NotifyAsync(option);
 }
Exemplo n.º 6
0
 public async Task NotifyWarningAsync(NoticeOption option)
 {
     option.IconType = IconType.Warning;
     await NotifyAsync(option);
 }
Exemplo n.º 7
0
 public async Task NotifySuccessAsync(NoticeOption option)
 {
     option.IconType = IconType.Success;
     await NotifyAsync(option);
 }
Exemplo n.º 8
0
 public async Task NotifyInfoAsync(NoticeOption option)
 {
     option.IconType = IconType.Info;
     await NotifyAsync(option);
 }