squash a bunch of commits
This commit is contained in:
54
Shogi.UI/Shared/Modal/ModalService.cs
Normal file
54
Shogi.UI/Shared/Modal/ModalService.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user