mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-12-12 07:36:59 +00:00
renamed view models to contexts (like TKMM), however the contexts here are actually of a unique base type; containing aforementioned setup step logic. if the return value is of an error state result, it will prompt a retry of the page.
61 lines
1.6 KiB
C#
61 lines
1.6 KiB
C#
using Avalonia.Controls.Presenters;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using Ryujinx.Ava.Common.Locale;
|
|
using Ryujinx.Ava.UI.Controls;
|
|
using Ryujinx.Ava.UI.SetupWizard;
|
|
using Ryujinx.Ava.UI.ViewModels;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Ryujinx.Ava.Systems.SetupWizard
|
|
{
|
|
public partial class SetupWizardPage(ContentPresenter contentPresenter, bool isFirstPage = false) : BaseModel
|
|
{
|
|
private bool? _result;
|
|
private readonly CancellationTokenSource _cts = new();
|
|
|
|
public bool IsFirstPage { get; } = isFirstPage;
|
|
|
|
[ObservableProperty]
|
|
public partial string? Title { get; set; }
|
|
|
|
[ObservableProperty]
|
|
public partial object? Content { get; set; }
|
|
|
|
[ObservableProperty] public partial object? HelpContent { get; set; }
|
|
|
|
[ObservableProperty]
|
|
public partial object? ActionContent { get; set; } = LocaleManager.Instance[LocaleKeys.SetupWizardActionNext];
|
|
|
|
[RelayCommand]
|
|
private void MoveBack()
|
|
{
|
|
_result = false;
|
|
_cts.Cancel();
|
|
}
|
|
|
|
[RelayCommand]
|
|
private void MoveNext()
|
|
{
|
|
_result = true;
|
|
_cts.Cancel();
|
|
}
|
|
|
|
public async ValueTask<bool> Show()
|
|
{
|
|
contentPresenter.Content = new SetupWizardPageView { ViewModel = this };
|
|
|
|
try
|
|
{
|
|
await Task.Delay(-1, _cts.Token);
|
|
}
|
|
catch (TaskCanceledException)
|
|
{
|
|
return _result ?? false;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|