<Modal @ref="modal"
       title="Modal title"
       OnShowing="OnModalShowing"
       OnShown="OnModalShown"
       OnHiding="OnModalHiding"
       OnHidden="OnModalHidden"
       OnHidePrevented="OnModalHidePrevented">

    <BodyTemplate>
        Modal body text goes here.
    </BodyTemplate>

    <FooterTemplate>
        <Button Color="ButtonColor.Secondary" @onclick="OnHideModalClick">Close</Button>
        <Button Color="ButtonColor.Primary">Save changes</Button>
    </FooterTemplate>

</Modal>

<Button Color="ButtonColor.Primary" @onclick="OnShowModalClick">Show Modal</Button>

@code {
    private Modal modal = default!;

    [Inject] ToastService ToastService { get; set; } = default!;

    private async Task OnShowModalClick()
    {
        await modal.ShowAsync();
    }

    private async Task OnHideModalClick()
    {
        await modal.HideAsync();
    }

    private void OnModalShowing()
    {
        ToastService.Notify(new(ToastType.Primary, $"Event: Showing called. DateTime: {DateTime.Now}"));
    }

    private void OnModalShown()
    {
        ToastService.Notify(new(ToastType.Success, $"Event: Show called. DateTime: {DateTime.Now}"));
    }

    private void OnModalHiding()
    {
        ToastService.Notify(new(ToastType.Danger, $"Event: Hiding called. DateTime: {DateTime.Now}"));
    }

    private void OnModalHidden()
    {
        ToastService.Notify(new(ToastType.Warning, $"Event: Hide called. DateTime: {DateTime.Now}"));
    }

    private void OnModalHidePrevented()
    {
        ToastService.Notify(new(ToastType.Info, $"Event: Hide Prevented called. DateTime: {DateTime.Now}"));
    }
}