mirror of
https://git.ryujinx.app/projects/Kenji-NX.git
synced 2026-11-19 09:21:15 +01:00
Add CommunityToolkit.Mvvm
Use [ObservableProperty] attribute, which greatly reduces or eliminates boilerplate code needed to generate observable properties Co-authored-by: GreemDev <greemdev@ryujinx.app>
This commit is contained in:
1 parent
0d29b77a14
commit
7d0947cac6
25 files changed
+433
-1883
No files matched your search
@@ -2,6 +2,7 @@ using Avalonia.Collections;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Platform.Storage;
|
||||
using Avalonia.Threading;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using DynamicData;
|
||||
using FluentAvalonia.UI.Controls;
|
||||
using Ryujinx.Ava.Common.Locale;
|
||||
@@ -16,13 +17,18 @@ using Application = Avalonia.Application;
|
||||
|
||||
namespace Ryujinx.Ava.UI.ViewModels
|
||||
{
|
||||
public class DownloadableContentManagerViewModel : BaseModel
|
||||
public partial class DownloadableContentManagerViewModel : BaseModel
|
||||
{
|
||||
private readonly ApplicationLibrary _applicationLibrary;
|
||||
private AvaloniaList<DownloadableContentModel> _downloadableContents = [];
|
||||
|
||||
[ObservableProperty]
|
||||
private AvaloniaList<DownloadableContentModel> _selectedDownloadableContents = [];
|
||||
|
||||
[ObservableProperty]
|
||||
private AvaloniaList<DownloadableContentModel> _views = [];
|
||||
private bool _showBundledContentNotice = false;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _showBundledContentNotice;
|
||||
|
||||
private string _search;
|
||||
private readonly ApplicationData _applicationData;
|
||||
@@ -30,35 +36,15 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
|
||||
public AvaloniaList<DownloadableContentModel> DownloadableContents
|
||||
{
|
||||
get => _downloadableContents;
|
||||
get;
|
||||
set
|
||||
{
|
||||
_downloadableContents = value;
|
||||
field = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(UpdateCount));
|
||||
Sort();
|
||||
}
|
||||
}
|
||||
|
||||
public AvaloniaList<DownloadableContentModel> Views
|
||||
{
|
||||
get => _views;
|
||||
set
|
||||
{
|
||||
_views = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public AvaloniaList<DownloadableContentModel> SelectedDownloadableContents
|
||||
{
|
||||
get => _selectedDownloadableContents;
|
||||
set
|
||||
{
|
||||
_selectedDownloadableContents = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
} = [];
|
||||
|
||||
public string Search
|
||||
{
|
||||
@@ -76,16 +62,6 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
get => string.Format(LocaleManager.Instance[LocaleKeys.DlcWindowHeading], DownloadableContents.Count);
|
||||
}
|
||||
|
||||
public bool ShowBundledContentNotice
|
||||
{
|
||||
get => _showBundledContentNotice;
|
||||
set
|
||||
{
|
||||
_showBundledContentNotice = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public DownloadableContentManagerViewModel(ApplicationLibrary applicationLibrary, ApplicationData applicationData)
|
||||
{
|
||||
_applicationLibrary = applicationLibrary;
|
||||
@@ -138,8 +114,8 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||
// some reason. so we save the items here and add them back after
|
||||
var items = SelectedDownloadableContents.ToArray();
|
||||
|
||||
_views.Clear();
|
||||
_views.AddRange(view);
|
||||
Views.Clear();
|
||||
Views.AddRange(view);
|
||||
|
||||
foreach (DownloadableContentModel item in items)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user