Added continue learning support!!!
This commit is contained in:
parent
b5870a4279
commit
2264087322
3 changed files with 106 additions and 14 deletions
|
@ -15,7 +15,17 @@
|
|||
}
|
||||
</MudSelect>
|
||||
<MudContainer Class="justify-center d-flex pb-16 pt-4">
|
||||
<MudButton Variant="Variant.Filled" OnClick=StartLearning Color="Color.Primary">Start learning!</MudButton>
|
||||
<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">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Success" OnClick="ContinueLearning" Disabled="@(!continueDataExists)">Continue</MudButton>
|
||||
@if (continueDataExists)
|
||||
{
|
||||
<MudStack Row=true Spacing="0">
|
||||
<MudText Class="pa-0 ma-0" Typo="Typo.body1">@($"CChars left: {continueCharectersLeft}")</MudText>
|
||||
<MudIconButton Class="pa-0 ma-0" OnClick="DeleteContinueData" Color="Color.Error" Icon="@Icons.Material.Filled.Close"></MudIconButton>
|
||||
</MudStack>
|
||||
}
|
||||
</MudStack>
|
||||
</MudContainer>
|
||||
|
||||
<MudContainer Class="justify-center d-flex">
|
||||
|
@ -63,9 +73,13 @@
|
|||
int numOfChunks = 197; //Exclusive index 0
|
||||
int selectedChunk = 0;
|
||||
int savedChunks = 0;
|
||||
const int chunkSize = 50;
|
||||
|
||||
bool isLoading = false;
|
||||
bool isSavedLocally = false;
|
||||
bool continueDataExists = false;
|
||||
int continueCharectersLeft = -1;
|
||||
|
||||
|
||||
protected async override Task OnInitializedAsync()
|
||||
{
|
||||
|
@ -79,9 +93,25 @@
|
|||
async void StartLearning()
|
||||
{
|
||||
await localStorage.SetItemAsync("SelectedChunk", selectedChunk);
|
||||
await localStorage.SetItemAsync("ContinueLearning", false);
|
||||
navigator.NavigateTo("/Learn");
|
||||
}
|
||||
|
||||
async void ContinueLearning()
|
||||
{
|
||||
await localStorage.SetItemAsync("ContinueLearning", true);
|
||||
navigator.NavigateTo("/Learn");
|
||||
}
|
||||
|
||||
async void DeleteContinueData()
|
||||
{
|
||||
string[] continueDataKeys = { "ContinueLearning", "ContinueData", "ContinueCharectersLeft" };
|
||||
await localStorage.RemoveItemsAsync(continueDataKeys);
|
||||
continueDataExists = false;
|
||||
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
CChar[]? Charecters;
|
||||
async void SelectedChunk()
|
||||
{
|
||||
|
@ -142,4 +172,17 @@
|
|||
isSavedLocally = true;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
continueDataExists = await localStorage.ContainKeyAsync("ContinueData");
|
||||
}
|
||||
|
||||
if (continueDataExists)
|
||||
{
|
||||
continueCharectersLeft = await localStorage.GetItemAsync<int>("ContinueCharectersLeft");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue