diff --git a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Services/MessageBoxService.cs b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Services/MessageBoxService.cs index 478777fec9..5a3faac767 100644 --- a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Services/MessageBoxService.cs +++ b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Services/MessageBoxService.cs @@ -1,12 +1,18 @@ namespace Bit.BlazorUI.Demo.Client.Core.Services; + public partial class MessageBoxService { - [AutoInject] private IPubSubService pubSubService = default!; + [AutoInject] private BitModalService modalService { get; set; } = default!; public async Task Show(string message, string title = "") { - TaskCompletionSource tcs = new(); - pubSubService.Publish(PubSubMessages.SHOW_MESSAGE, (message, title, tcs)); - await tcs.Task; + BitModalReference modalRef = default!; + Dictionary parameters = new() + { + { nameof(BitMessageBox.Title), title }, + { nameof(BitMessageBox.Body), message }, + { nameof(BitMessageBox.OnClose), EventCallback.Factory.Create(this, () => modalRef.Close()) } + }; + modalRef = await modalService.Show(parameters); } } diff --git a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Shared/MainLayout.razor b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Shared/MainLayout.razor index 4fe35fd1e1..25a4bbd437 100644 --- a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Shared/MainLayout.razor +++ b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Shared/MainLayout.razor @@ -25,4 +25,4 @@ - + \ No newline at end of file diff --git a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Shared/MessageBox.razor b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Shared/MessageBox.razor deleted file mode 100644 index b74cef4fd3..0000000000 --- a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Shared/MessageBox.razor +++ /dev/null @@ -1,18 +0,0 @@ -@inherits AppComponentBase - - -
-
- @_title - -
-
- @_body -
- -
-
diff --git a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Shared/MessageBox.razor.cs b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Shared/MessageBox.razor.cs deleted file mode 100644 index 64b5e9dc3c..0000000000 --- a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Shared/MessageBox.razor.cs +++ /dev/null @@ -1,60 +0,0 @@ -namespace Bit.BlazorUI.Demo.Client.Core.Shared; - -public partial class MessageBox : IDisposable -{ - private static event Func OnShow = default!; - - private bool _isOpen; - private string _title = string.Empty; - private string _body = string.Empty; - - private static TaskCompletionSource? _tsc; - - public static async Task Show(string message, string title = "") - { - _tsc = new TaskCompletionSource(); - - await OnShow.Invoke(message, title); - - await _tsc.Task; - } - - protected override async Task OnInitAsync() - { - OnShow += ShowMessageBox; - - await base.OnInitAsync(); - } - - private async Task ShowMessageBox(string message, string title) - { - await InvokeAsync(() => - { - _isOpen = true; - - _title = title; - _body = message; - - StateHasChanged(); - }); - } - - private void OnCloseClick() - { - _isOpen = false; - _tsc?.SetResult(null); - } - - - private void OnOkClick() - { - _isOpen = false; - _tsc?.SetResult(null); - } - - public override void Dispose() - { - OnShow -= ShowMessageBox; - base.Dispose(); - } -} diff --git a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Shared/MessageBox.razor.scss b/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Shared/MessageBox.razor.scss deleted file mode 100644 index 6f73a0fc27..0000000000 --- a/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Shared/MessageBox.razor.scss +++ /dev/null @@ -1,30 +0,0 @@ -@import '../Styles/abstracts/_functions.scss'; - -.main { - flex-grow: 1; - display: flex; - flex-direction: column; - padding: rem2(10px); -} - -.header { - display: flex; -} - -.title { - flex-grow: 1; -} - -.body { - display: flex; - flex-grow: 1; - margin: rem2(10px) 0; - white-space: pre; - overflow: auto; - max-width: rem2(960px); -} - -.footer { - display: flex; - justify-content: center; -}