Fan website of IMMORTAL: Gates of Pyre.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

104 lines
2.4 KiB

@implements IDisposable;
@inject IMemoryTesterService MemoryTesterService;
<div class="quizContainer">
<div class="quizListContainer">
@if (entities != null && questions != null)
{
@foreach (var entityMemory in entities)
{
<UnitMemory EntityMemory="entityMemory"></UnitMemory>
}
}
</div>
<div class="quizButtons">
<ButtonComponent MyButtonType="MyButtonType.Secondary" OnClick="OnRefreshQuiz">Refresh</ButtonComponent>
<ButtonComponent MyButtonType="MyButtonType.Primary" OnClick="OnSubmitQuiz">Submit</ButtonComponent>
</div>
</div>
<style>
.quizContainer {
display: flex;
flex-direction: column;
gap: 16px;
padding: 16px;
}
.quizListContainer {
display: flex;
flex-direction: column;
gap: 16px;
}
@@media (min-width: @SupportedWebSizes.Tablet) {
.quizContainer {
}
.quizButtons {
display: flex;
flex-direction: row;
gap: 16px;
justify-content: flex-end;
width: 100%;
}
.quizListContainer {
}
}
@@media (min-width: @SupportedWebSizes.Desktop) {
.quizListContainer {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
</style>
@code {
private List<MemoryEntityModel> entities = null!;
private List<MemoryQuestionModel> questions = null!;
protected override void OnInitialized()
{
base.OnInitialized();
MemoryTesterService.Subscribe(OnMemoryEvent);
MemoryTesterService.GenerateQuiz();
}
void IDisposable.Dispose()
{
MemoryTesterService.Unsubscribe(OnMemoryEvent);
}
void OnMemoryEvent(MemoryTesterEvent memoryTesterEvent)
{
if (memoryTesterEvent == MemoryTesterEvent.OnVerify)
{
StateHasChanged();
}
if (memoryTesterEvent == MemoryTesterEvent.OnRefresh)
{
entities = MemoryTesterService.GetEntities();
questions = MemoryTesterService.GetQuestions();
StateHasChanged();
}
}
void OnSubmitQuiz(EventArgs eventArgs)
{
MemoryTesterService.Verify();
}
void OnRefreshQuiz(EventArgs eventArgs)
{
MemoryTesterService.GenerateQuiz();
}
}