mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-15 09:21:24 +08:00
db64810a20
* refactor: change confirm return * feat(module: drawer): add DrawerService * fix: change type EventCallback in configs to Func * fix: typo Co-authored-by: ElderJames <shunjiey@hotmail.com>
50 lines
1.2 KiB
C#
50 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace AntDesign
|
|
{
|
|
public partial class DrawerContainer
|
|
{
|
|
[Inject]
|
|
private DrawerService DrawerService { get; set; }
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
DrawerService.OnCreate += DrawerService_OnCreate;
|
|
DrawerService.OnClose += DrawerService_OnClose;
|
|
}
|
|
|
|
protected override void Dispose(bool disposing)
|
|
{
|
|
DrawerService.OnCreate -= DrawerService_OnCreate;
|
|
DrawerService.OnClose -= DrawerService_OnClose;
|
|
base.Dispose(disposing);
|
|
}
|
|
|
|
|
|
private List<DrawerConfig> _drawerConfigs = new List<DrawerConfig>();
|
|
|
|
|
|
private async Task DrawerService_OnClose(DrawerConfig arg)
|
|
{
|
|
arg.Visible = false;
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
private async Task DrawerService_OnCreate(DrawerConfig arg)
|
|
{
|
|
arg.Visible = true;
|
|
if (!_drawerConfigs.Contains(arg))
|
|
{
|
|
_drawerConfigs.Add(arg);
|
|
}
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
}
|
|
}
|