mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
impl #896
This commit is contained in:
@@ -30,7 +30,7 @@ internal static class AchievementFinishPercent
|
||||
throw HutaoException.InvalidCast<IEnumerable<AchievementView>, List<AchievementView>>("AchievementViewModel.Achievements.SourceCollection");
|
||||
}
|
||||
|
||||
Dictionary<AchievementGoalId, AchievementGoalStatistics> counter = achievementGoals.ToDictionary(x => x.Id, AchievementGoalStatistics.From);
|
||||
Dictionary<AchievementGoalId, AchievementGoalStatistics> counter = achievementGoals.SourceCollection.ToDictionary(x => x.Id, AchievementGoalStatistics.From);
|
||||
|
||||
foreach (ref readonly AchievementView achievementView in CollectionsMarshal.AsSpan(list))
|
||||
{
|
||||
|
||||
@@ -43,6 +43,8 @@ internal sealed class AchievementView : ObservableObject, IEntityWithMetadata<Mo
|
||||
/// </summary>
|
||||
public Model.Metadata.Achievement.Achievement Inner { get; }
|
||||
|
||||
public uint Order => Inner.Order;
|
||||
|
||||
/// <summary>
|
||||
/// 是否选中
|
||||
/// </summary>
|
||||
|
||||
@@ -28,13 +28,17 @@ namespace Snap.Hutao.ViewModel.Achievement;
|
||||
[Injection(InjectAs.Scoped)]
|
||||
internal sealed partial class AchievementViewModel : Abstraction.ViewModel, INavigationRecipient
|
||||
{
|
||||
private readonly SortDescription uncompletedItemsFirstSortDescription = new(nameof(AchievementView.IsChecked), SortDirection.Ascending);
|
||||
private readonly SortDescription completionTimeSortDescription = new(nameof(AchievementView.Time), SortDirection.Descending);
|
||||
private readonly SortDescription achievementUncompletedItemsFirstSortDescription = new(nameof(AchievementView.IsChecked), SortDirection.Ascending);
|
||||
private readonly SortDescription achievementCompletionTimeSortDescription = new(nameof(AchievementView.Time), SortDirection.Descending);
|
||||
private readonly SortDescription achievementGoalUncompletedItemsFirstSortDescription = new(nameof(AchievementGoalView.FinishPercent), SortDirection.Ascending);
|
||||
|
||||
private readonly SortDescription achievementDefaultSortDescription = new(nameof(AchievementView.Order), SortDirection.Ascending);
|
||||
private readonly SortDescription achievementGoalDefaultSortDescription = new(nameof(AchievementGoalView.Order), SortDirection.Ascending);
|
||||
|
||||
private readonly AchievementViewModelDependencies dependencies;
|
||||
|
||||
private AdvancedCollectionView<AchievementView>? achievements;
|
||||
private List<AchievementGoalView>? achievementGoals;
|
||||
private AdvancedCollectionView<AchievementGoalView>? achievementGoals;
|
||||
private AchievementGoalView? selectedAchievementGoal;
|
||||
private ObservableCollection<EntityAchievementArchive>? archives;
|
||||
private EntityAchievementArchive? selectedArchive;
|
||||
@@ -67,7 +71,7 @@ internal sealed partial class AchievementViewModel : Abstraction.ViewModel, INav
|
||||
set => SetProperty(ref achievements, value);
|
||||
}
|
||||
|
||||
public List<AchievementGoalView>? AchievementGoals
|
||||
public AdvancedCollectionView<AchievementGoalView>? AchievementGoals
|
||||
{
|
||||
get => achievementGoals;
|
||||
set => SetProperty(ref achievementGoals, value);
|
||||
@@ -141,7 +145,7 @@ internal sealed partial class AchievementViewModel : Abstraction.ViewModel, INav
|
||||
|
||||
await dependencies.TaskContext.SwitchToMainThreadAsync();
|
||||
|
||||
AchievementGoals = sortedGoals;
|
||||
AchievementGoals = new(sortedGoals, true);
|
||||
Archives = archives;
|
||||
SelectedArchive = dependencies.AchievementService.CurrentArchive;
|
||||
return true;
|
||||
@@ -299,20 +303,23 @@ internal sealed partial class AchievementViewModel : Abstraction.ViewModel, INav
|
||||
[Command("SortUncompletedSwitchCommand")]
|
||||
private void UpdateAchievementsSort()
|
||||
{
|
||||
if (Achievements is null)
|
||||
if (Achievements is null || AchievementGoals is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Achievements.SortDescriptions.Clear();
|
||||
AchievementGoals.SortDescriptions.Clear();
|
||||
|
||||
if (IsUncompletedItemsFirst)
|
||||
{
|
||||
Achievements.SortDescriptions.Add(uncompletedItemsFirstSortDescription);
|
||||
Achievements.SortDescriptions.Add(completionTimeSortDescription);
|
||||
}
|
||||
else
|
||||
{
|
||||
Achievements.SortDescriptions.Clear();
|
||||
Achievements.SortDescriptions.Add(achievementUncompletedItemsFirstSortDescription);
|
||||
Achievements.SortDescriptions.Add(achievementCompletionTimeSortDescription);
|
||||
AchievementGoals.SortDescriptions.Add(achievementGoalUncompletedItemsFirstSortDescription);
|
||||
}
|
||||
|
||||
Achievements.SortDescriptions.Add(achievementDefaultSortDescription);
|
||||
AchievementGoals.SortDescriptions.Add(achievementGoalDefaultSortDescription);
|
||||
}
|
||||
|
||||
private void UpdateAchievementsFilterByGoal(AchievementGoalView? goal)
|
||||
|
||||
Reference in New Issue
Block a user