public void Add(ToastType type, string message, string title, Action <ToastOptions> configure) { if (message.IsEmpty()) { return; } message = message.Trimmed(); title = title.Trimmed(); var options = new ToastOptions(type, Configuration); configure?.Invoke(options); var toast = new Toast(title, message, options); ToastLock.EnterWriteLock(); try { if (Configuration.PreventDuplicates && ToastAlreadyPresent(toast)) { return; } toast.OnClose += Remove; Toasts.Add(toast); } finally { ToastLock.ExitWriteLock(); } OnToastsUpdated?.Invoke(); }
public void Add(string par1) { var t = new ToastItem(); t.Titel = par1; Toasts.Add(t); OnToastsUpdated?.Invoke(); }
private void OnShowToast(ShowToastMessage showToastMessage) { var toast = new ToastViewModel(showToastMessage, _chatDocumentCreator(), _bus, _activator); Toasts.Add(toast); toast.Closed.SubscribeOnceUI(_ => { Toasts.Remove(toast); toast.Dispose(); }); }
private async Task Show(ToastOption option) { Toasts.Add(option, new RenderFragment(builder => { var index = 0; builder.OpenComponent <ToastBox>(index++); builder.AddAttribute(index++, nameof(ToastBox.Category), option.Category); builder.AddAttribute(index++, nameof(ToastBox.Title), option.Title); builder.AddAttribute(index++, nameof(ToastBox.Content), option.Content); builder.AddAttribute(index++, nameof(ToastBox.IsAutoHide), option.IsAutoHide); builder.AddAttribute(index++, nameof(ToastBox.Delay), option.Delay); builder.CloseComponent(); })); await InvokeAsync(StateHasChanged); }
private async Task Show(ToastOption option) { Toasts.Add(option); await InvokeAsync(StateHasChanged); }