using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace AntDesign
{
///
///
///
public class ModalRef : FeedbackRefWithOkCancelBase
{
public ModalOptions Config { get; private set; }
private readonly ModalService _service;
internal ModalRef(ModalOptions config, ModalService modalService)
{
Config = config;
_service = modalService;
}
///
/// open the Modal dialog
///
///
public override async Task OpenAsync()
{
if (!Config.Visible)
{
Config.Visible = true;
}
await _service.CreateOrOpenModalAsync(this);
}
///
/// close the Modal dialog
///
///
public override async Task CloseAsync()
{
await _service.CloseModalAsync(this);
}
///
/// Update modal
///
///
public override async Task UpdateConfigAsync()
{
await _service.UpdateModalAsync(this);
}
}
///
/// ModalRef with return value
///
///
public class ModalRef : ModalRef, IOkCancelRef
{
internal ModalRef(ModalOptions config, ModalService modalService) : base(config, modalService)
{
}
///
public new Func OnCancel { get; set; }
///
public new Func OnOk { get; set; }
///
public async Task OkAsync(TResult result)
{
await (OnOk?.Invoke(result) ?? Task.CompletedTask);
}
///
public async Task CancelAsync(TResult result)
{
await (OnOk?.Invoke(result) ?? Task.CompletedTask);
}
}
}