55 lines
1.2 KiB
C#
55 lines
1.2 KiB
C#
namespace Shogi.UI.Shared.Modal
|
|
{
|
|
/// <summary>
|
|
/// An injectible service which can be invoked to display preset modals via the <Modals /> razor component.
|
|
/// Only one modal me be visible at a time.
|
|
/// </summary>
|
|
public class ModalService
|
|
{
|
|
public event EventHandler<ModalVisibilityChangedEventArgs>? ModalVisibilityChangedEvent;
|
|
|
|
public ModalService()
|
|
{
|
|
}
|
|
|
|
public bool LoginModalIsVisible { get; private set; }
|
|
public bool GuestAccountDescriptionIsVisible { get; private set; }
|
|
|
|
public void ShowLoginModal()
|
|
{
|
|
SetAllVisibilitiesToFalse();
|
|
LoginModalIsVisible = true;
|
|
EmitCurrentState();
|
|
}
|
|
|
|
public void ShowGuestAccountDescriptionModal()
|
|
{
|
|
SetAllVisibilitiesToFalse();
|
|
GuestAccountDescriptionIsVisible = true;
|
|
EmitCurrentState();
|
|
}
|
|
|
|
public void HideAllModals()
|
|
{
|
|
SetAllVisibilitiesToFalse();
|
|
EmitCurrentState();
|
|
}
|
|
|
|
private void EmitCurrentState()
|
|
{
|
|
ModalVisibilityChangedEvent?.Invoke(this, new()
|
|
{
|
|
LoginModalIsVisible = LoginModalIsVisible,
|
|
GuestAccountDescriptionIsVisible = GuestAccountDescriptionIsVisible
|
|
});
|
|
}
|
|
|
|
private void SetAllVisibilitiesToFalse()
|
|
{
|
|
LoginModalIsVisible = false;
|
|
GuestAccountDescriptionIsVisible = false;
|
|
}
|
|
|
|
}
|
|
}
|