-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
be6d689
commit 1dc5480
Showing
4 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using DynamicData; | ||
using DynamicData.Binding; | ||
using ReactiveUI; | ||
using ReactiveUI.Fody.Helpers; | ||
using System; | ||
using Vocup.Settings; | ||
|
||
namespace Vocup.Models; | ||
|
||
public class BookPracticeState : ReactiveObject | ||
{ | ||
private readonly IObservableList<PracticeState> practiceStates; | ||
|
||
public BookPracticeState(Book book, IVocupSettings settings) | ||
{ | ||
book.Words.ToObservableChangeSet() | ||
.AutoRefresh(word => word.ForeignLanguagePracticeState) | ||
.AutoRefresh(word => word.MotherTonguePracticeState) | ||
.AutoRefreshOnObservable(_ => book.WhenAnyValue(x => x.PracticeMode)) | ||
.AutoRefreshOnObservable(_ => settings.WhenAnyValue(x => x.MaxPracticeCount)) | ||
.Transform(word => book.PracticeMode != PracticeMode.AskForMotherTongue ? word.ForeignLanguagePracticeState : word.MotherTonguePracticeState) | ||
.Transform(practiceStateNumber => PracticeStateHelper.Parse(practiceStateNumber, settings.MaxPracticeCount)) | ||
.BindToObservableList(out practiceStates) | ||
.Subscribe(); | ||
} | ||
|
||
public WordPracticeState this[Word word] => null; | ||
Check warning on line 27 in src/Vocup.Core/Models/BookPracticeState.cs GitHub Actions / build (Debug)
Check warning on line 27 in src/Vocup.Core/Models/BookPracticeState.cs GitHub Actions / build (Release)
|
||
|
||
[ObservableAsProperty] public int Unpracticed { get; } | ||
[ObservableAsProperty] public int WronglyPracticed { get; } | ||
[ObservableAsProperty] public int CorrectlyPracticed { get; } | ||
[ObservableAsProperty] public int FullyPracticed { get; } | ||
[ObservableAsProperty] public int NotFullyPracticed { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using ReactiveUI; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
using System.Reactive.Linq; | ||
using Vocup.Settings; | ||
|
||
namespace Vocup.Models; | ||
|
||
public class WordPracticeState : ReactiveObject | ||
{ | ||
public WordPracticeState(Book book, Word word, IVocupSettings settings) | ||
{ | ||
book.WhenAnyValue(x => x.PracticeMode) | ||
.Select(practiceMode => practiceMode != PracticeMode.AskForMotherTongue ? word.ForeignLanguage : word.MotherTongue); | ||
|
||
//PracticeState = Reactive(() => | ||
//{ | ||
// ObservableCollection<Synonym> synonyms = book.PracticeMode != PracticeMode.AskForMotherTongue ? word.ForeignLanguage : word.MotherTongue; | ||
// int practiceStateNumber = synonyms.MaxBy(synonym => synonym.PracticeState)?.PracticeState ?? 0; | ||
// return PracticeStateHelper.Parse(practiceStateNumber, settings.MaxPracticeCount); | ||
//}); | ||
} | ||
|
||
PracticeState PracticeState { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters