-
Notifications
You must be signed in to change notification settings - Fork 469
Expand file tree
/
Copy pathFluentToastIndeterminateProgress.razor
More file actions
41 lines (36 loc) · 1.42 KB
/
FluentToastIndeterminateProgress.razor
File metadata and controls
41 lines (36 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
@inject IToastService ToastService
<FluentStack HorizontalGap="16">
<FluentButton @ref="openToastButton" OnClick="@OpenToastAsync">
Make toast
</FluentButton>
<FluentButton OnClick="@FinishProcessAsync">
Finish process
</FluentButton>
</FluentStack>
@code {
int clickCount = 0;
FluentButton openToastButton = default!;
private async Task OpenToastAsync()
{
// Disable the button to prevent multiple toasts from being opened.
// In a real app, you would likely want to track the toast ID and only disable if that specific toast is open.
openToastButton.SetDisabled(true);
var result = await ToastService.ShowToastAsync(options =>
{
options.Id = "indeterminate-toast";
options.Timeout = 0;
options.Type = ToastType.IndeterminateProgress;
options.Intent = ToastIntent.Success;
options.Title = $"Toast title {++clickCount}";
options.Body = "No idea when this will be finished...";
});
Console.WriteLine($"Toast result: {result}");
}
private async Task FinishProcessAsync()
{
// In a real app, you would likely keep track of the toast ID and update that specific toast.
await ToastService.DismissAsync("indeterminate-toast");
// Enable the button again so a new toast can be opened.
openToastButton.SetDisabled(false);
}
}