-
Notifications
You must be signed in to change notification settings - Fork 468
Expand file tree
/
Copy pathFluentToastDeterminateProgress.razor
More file actions
40 lines (32 loc) · 1.11 KB
/
FluentToastDeterminateProgress.razor
File metadata and controls
40 lines (32 loc) · 1.11 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
@inject IToastService ToastService
<FluentButton @ref="openToastButton" OnClick="@OpenToastAsync">
Make toast
</FluentButton>
@code {
FluentButton openToastButton = default!;
private static RenderFragment BuildProgressContent(int value) =>
@<div>
<FluentProgressBar Min="0" Max="100" Value="value" Width="100%" />
@($"{value}% complete")
</div>;
private async Task OpenToastAsync()
{
openToastButton.SetDisabled(true);
var instance = await ToastService.ShowToastInstanceAsync(options =>
{
options.Type = ToastType.DeterminateProgress;
options.Icon = new Icons.Regular.Size20.ArrowDownload();
options.Title = "Downloading file";
options.BodyContent = BuildProgressContent(0);
});
for (int i = 0; i <= 100; i += 10)
{
await Task.Delay(500); // Simulate work being done
await instance.UpdateAsync(options =>
{
options.BodyContent = BuildProgressContent(i);
});
}
openToastButton.SetDisabled(false);
}
}