refactor(module: modal): update ConfirmService to use interface (#3083)

* ConfirmService To Interface

* backwards compatibility
This commit is contained in:
wss-awachowicz 2023-02-10 00:30:41 -05:00 committed by GitHub
parent 881f66d402
commit 1b48d862e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 33 additions and 9 deletions

View File

@ -32,6 +32,7 @@ namespace Microsoft.Extensions.DependencyInjection
services.TryAddScoped<ModalService>();
services.TryAddScoped<DrawerService>();
services.TryAddScoped<ConfirmService>();
services.TryAddScoped<IConfirmService>(provider => provider.GetRequiredService<ConfirmService>());
services.TryAddScoped<ImageService>();
services.TryAddScoped<ConfigService>();
services.TryAddSingleton<ReuseTabsService>();

View File

@ -10,7 +10,7 @@ namespace AntDesign
/// <summary>
/// show a simple Confirm dialog like MessageBox of Windows, it's different from ModalService. ModalService can only create OK-Cancel Confirm dialog and return ConfirmRef, but ConfirmService return ConfirmResult
/// </summary>
public class ConfirmService
public class ConfirmService : IConfirmService
{
internal event Func<ConfirmRef, Task> OnOpenEvent;

View File

@ -0,0 +1,23 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components;
using OneOf;
namespace AntDesign;
public interface IConfirmService
{
Task<ConfirmResult> Show(
OneOf<string, RenderFragment> content,
OneOf<string, RenderFragment> title,
ConfirmButtons confirmButtons,
ConfirmIcon confirmIcon,
ConfirmButtonOptions options,
ConfirmAutoFocusButton? autoFocusButton = ConfirmAutoFocusButton.Ok);
Task<ConfirmResult> Show
(OneOf<string, RenderFragment> content,
OneOf<string, RenderFragment> title,
ConfirmButtons confirmButtons = ConfirmButtons.OKCancel,
ConfirmIcon confirmIcon = ConfirmIcon.Info);
}

View File

@ -1,5 +1,5 @@
@inject DrawerService DrawerService
@inject ConfirmService confirmService
@inject IConfirmService confirmService
<Space Direction="DirectionVHType.Vertical">
<SpaceItem>

View File

@ -1,5 +1,5 @@
@inject IMessageService _message
@inject ConfirmService _confirmService
@inject IConfirmService _confirmService
<Divider>Buttons</Divider>

View File

@ -1,4 +1,4 @@
@inject ConfirmService _confirmService
@inject IConfirmService _confirmService
@inject ModalService _modalService

View File

@ -7,8 +7,8 @@ title:
## zh-CN
使用 `ConfirmService.Show` 可以快捷地弹出一个内置的确认框,类似于 Windows MessageBox。
使用 `IConfirmService.Show` 可以快捷地弹出一个内置的确认框,类似于 Windows MessageBox。
## en-US
Use `ConfirmService.Show` to show a built-in confirm dialog, similar to Windows MessageBox.
Use `IConfirmService.Show` to show a built-in confirm dialog, similar to Windows MessageBox.

View File

@ -87,7 +87,7 @@ There are some ways to display the information based on the content's nature:
### ConfirmService
`ConfirmService.Show` to show a simple Confirm dialog like MessageBox of Windows, it's different from ModalService. ModalService can only create OK-Cancel Confirm dialog and return ConfirmRef or OK button is clicked, but ConfirmService return ConfirmResult.
`IConfirmService.Show` to show a simple Confirm dialog like MessageBox of Windows, it's different from ModalService. ModalService can only create OK-Cancel Confirm dialog and return ConfirmRef or OK button is clicked, but ConfirmService return ConfirmResult.
#### ConfirmOptions

View File

@ -89,7 +89,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/3StSdUlSH/Modal.svg
### ConfirmService
`ConfirmService.Show` 用于弹出类似于在WinForm中使用 MessageBox 方式弹出的对话框。这和 ModalService 不同的是ModalService 只可以创建 具有 OK-Cancel 按钮的对话框并返回 ConfirmRef 对象或者是否OK按钮被点击而 ConfirmService 总是返回 ConfirmResult ,以指示哪个按钮被点击。
`IConfirmService.Show` 用于弹出类似于在WinForm中使用 MessageBox 方式弹出的对话框。这和 ModalService 不同的是ModalService 只可以创建 具有 OK-Cancel 按钮的对话框并返回 ConfirmRef 对象或者是否OK按钮被点击而 ConfirmService 总是返回 ConfirmResult ,以指示哪个按钮被点击。
#### ConfirmOptions

View File

@ -1,4 +1,4 @@
@inject ConfirmService _confirmService
@inject IConfirmService _confirmService
<div>
<Tag Closable OnClosing="async e=>await onClosing(e)" OnClose="onClose">onClosing</Tag>