2020-06-23 15:19:44 +08:00
|
|
|
|
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()
|
|
|
|
|
{
|
2020-06-30 13:40:51 +08:00
|
|
|
|
DrawerService.OnCloseEvent += DrawerService_OnClose;
|
|
|
|
|
DrawerService.OnOpenEvent += DrawerService_OnCreate;
|
2020-06-23 15:19:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool disposing)
|
|
|
|
|
{
|
2020-06-30 13:40:51 +08:00
|
|
|
|
DrawerService.OnCloseEvent -= DrawerService_OnClose;
|
|
|
|
|
DrawerService.OnOpenEvent -= DrawerService_OnCreate;
|
2020-06-23 15:19:44 +08:00
|
|
|
|
base.Dispose(disposing);
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-16 19:42:48 +08:00
|
|
|
|
private List<IDrawerRef> _drawerRefs = new List<IDrawerRef>();
|
2020-06-23 15:19:44 +08:00
|
|
|
|
|
2020-06-30 13:40:51 +08:00
|
|
|
|
/// <summary>
|
2020-09-16 19:42:48 +08:00
|
|
|
|
/// Create and Open a drawer
|
2020-06-30 13:40:51 +08:00
|
|
|
|
/// </summary>
|
2020-09-16 19:42:48 +08:00
|
|
|
|
private async Task DrawerService_OnCreate(IDrawerRef drawerRef)
|
2020-06-23 15:19:44 +08:00
|
|
|
|
{
|
2020-09-16 19:42:48 +08:00
|
|
|
|
drawerRef.Options.Visible = true;
|
2020-06-30 13:40:51 +08:00
|
|
|
|
if (!_drawerRefs.Contains(drawerRef))
|
|
|
|
|
{
|
|
|
|
|
_drawerRefs.Add(drawerRef);
|
|
|
|
|
}
|
2020-06-23 15:19:44 +08:00
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-30 13:40:51 +08:00
|
|
|
|
/// <summary>
|
2020-09-16 19:42:48 +08:00
|
|
|
|
/// Close the drawer
|
2020-06-30 13:40:51 +08:00
|
|
|
|
/// </summary>
|
2020-09-16 19:42:48 +08:00
|
|
|
|
private async Task DrawerService_OnClose(IDrawerRef drawerRef)
|
2020-06-23 15:19:44 +08:00
|
|
|
|
{
|
2020-09-16 19:42:48 +08:00
|
|
|
|
drawerRef.Options.Visible = false;
|
2020-06-30 13:40:51 +08:00
|
|
|
|
await InvokeAsync(StateHasChanged);
|
|
|
|
|
await Task.Delay(300);
|
|
|
|
|
if (_drawerRefs.Contains(drawerRef))
|
2020-06-23 15:19:44 +08:00
|
|
|
|
{
|
2020-06-30 13:40:51 +08:00
|
|
|
|
_drawerRefs.Remove(drawerRef);
|
2020-06-23 15:19:44 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|