public async Task NotifyAsync(NoticeOption option) { if (Notice.Instance != null) { await Notice.Instance.NotifyAsync(option); } }
private async Task Remove(NoticeOption option) { if (option.KeepTime.TotalMilliseconds > 0) { await Task.Delay(option.KeepTime); await RemoveChild(option); } }
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); }
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); }
public async Task NotifyErrorAsync(NoticeOption option) { option.IconType = IconType.Error; await NotifyAsync(option); }
public async Task NotifyWarningAsync(NoticeOption option) { option.IconType = IconType.Warning; await NotifyAsync(option); }
public async Task NotifySuccessAsync(NoticeOption option) { option.IconType = IconType.Success; await NotifyAsync(option); }
public async Task NotifyInfoAsync(NoticeOption option) { option.IconType = IconType.Info; await NotifyAsync(option); }