Added easy mode checkbox

This commit is contained in:
BOT Alex 2023-07-14 09:27:40 +08:00
parent 14ea6e5c06
commit 8b9bb3698a

View file

@ -14,7 +14,7 @@
<MudSelectItem T="int" Value="@i" />
}
</MudSelect>
<MudContainer Class="justify-center d-flex pb-16 pt-4">
<MudContainer Class="justify-center d-flex pt-4">
<MudButton Variant="Variant.Filled" OnClick=StartLearning Color="Color.Primary">@((!continueDataExists) ? "Start learning!" : "Start new!")</MudButton>
<MudStack Spacing="0" Class="pa-0 pl-2 ma-0">
@if (continueDataExists)
@ -35,6 +35,10 @@
</MudContainer>
<MudContainer Class="justify-center d-flex">
<MudCheckBox @bind-Checked="@IsEasyMode" Label="Easy mode" Color="Color.Primary"></MudCheckBox>
</MudContainer>
<MudContainer Class="pt-16 justify-center d-flex">
@if (Charecters != null)
{
<MudPaper Class="overflow-scroll rounded-0" Style="height: 50vh;" Elevation="1">
@ -86,6 +90,19 @@
bool continueDataExists = false;
int continueCharectersLeft = -1;
private bool isEasyMode;
public bool IsEasyMode
{
get { return isEasyMode; }
set
{
isEasyMode = value;
SetEasyMode();
}
}
protected async override Task OnInitializedAsync()
{
@ -134,6 +151,11 @@
StateHasChanged();
}
async void SetEasyMode()
{
await localStorage.SetItemAsync("EasyMode", isEasyMode);
}
async Task LoadAllChunksIntoLocalStorage()
{
isLoading = true;
@ -190,5 +212,10 @@
{
continueCharectersLeft = await localStorage.GetItemAsync<int>("ContinueCharectersLeft");
}
if (await localStorage.ContainKeyAsync("EasyMode"))
{
isEasyMode = await localStorage.GetItemAsync<bool>("EasyMode");
}
}
}