Initial work on a setup wizard

Setup wizard abstraction & architecture from TKMM
This commit is contained in:
GreemDev 2025-11-21 00:20:15 -06:00
parent 52700f71dc
commit aee46e16cd
19 changed files with 743 additions and 10 deletions

View file

@ -0,0 +1,62 @@
using Avalonia.Controls.Presenters;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.UI.ViewModels;
using Ryujinx.Systems.SetupWizard;
using System.Threading;
using System.Threading.Tasks;
namespace Ryujinx.Ava.Systems.SetupWizard
{
public partial class SetupWizardPage(bool isFirstPage = false) : BaseModel
{
protected bool? _result;
protected readonly CancellationTokenSource _cancellationTokenSource = new();
public bool IsFirstPage { get; } = isFirstPage;
[ObservableProperty]
private string? _title;
[ObservableProperty]
private object? _content;
[ObservableProperty]
private object? _helpContent;
[ObservableProperty]
private object? _actionContent = LocaleManager.Instance[LocaleKeys.SetupWizardActionNext];
[RelayCommand]
private void MoveBack()
{
_result = false;
_cancellationTokenSource.Cancel();
}
[RelayCommand]
private void MoveNext()
{
_result = true;
_cancellationTokenSource.Cancel();
}
public async ValueTask<bool> Show(ContentPresenter presenter)
{
presenter.Content = new SetupWizardPageView
{
DataContext = this,
};
try {
await Task.Delay(-1, _cancellationTokenSource.Token);
}
catch (TaskCanceledException) {
return _result ?? false;
}
return false;
}
}
}