@using Iceshrimp.Assets.PhosphorIcons @using Iceshrimp.Frontend.Core.Services @using Iceshrimp.Frontend.Localization @using Microsoft.Extensions.Localization @inject GlobalComponentSvc GlobalComponentSvc; @inject IJSRuntime Js; @inject IStringLocalizer Loc;
@switch (Type) { case NoticeType.Warning: break; case NoticeType.Error: break; case NoticeType.Notice: break; default: throw new ArgumentOutOfRangeException(); } @Text
@code { private ElementReference Dialog { get; set; } private IJSObjectReference _module = null!; private NoticeType Type { get; set; } private string Text { get; set; } = ""; public enum NoticeType { Notice, Warning, Error } private async Task CloseDialog() { await _module.InvokeVoidAsync("closeDialog", Dialog); } public async Task Display(string text, NoticeType type = NoticeType.Notice) { Type = type; Text = text; StateHasChanged(); await _module.InvokeVoidAsync("openDialog", Dialog); } protected override async Task OnInitializedAsync() { _module = await Js.InvokeAsync("import", "./Components/NoticeDialog.razor.js"); GlobalComponentSvc.NoticeDialog = this; } }