aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Ava/Ui/Controls/NavigationDialogHost.axaml.cs
diff options
context:
space:
mode:
authorEmmanuel Hansen <emmausssss@gmail.com>2022-07-24 17:38:38 +0000
committerGitHub <noreply@github.com>2022-07-24 14:38:38 -0300
commit6e02cac952f1a9a34d2777199dde657eba0784e6 (patch)
treebfdf6ebc5c5fb062910ffb2feaec56e1240c0596 /Ryujinx.Ava/Ui/Controls/NavigationDialogHost.axaml.cs
parent3a3380fa2578bf1731c6cd7cebdca7b7cc5681b0 (diff)
Avalonia - Use content dialog for user profile manager (#3455)1.1.187
* remove content dialog placeholder from all windows * remove redundant window argument * redesign user profile window * wip * use avalonia auto name generator * add edit and new user options * move profile image selection to content dialog * remove usings * fix updater * address review * adjust avatar dialog size * add validation for user editor * fix typo * Shorten some labels
Diffstat (limited to 'Ryujinx.Ava/Ui/Controls/NavigationDialogHost.axaml.cs')
-rw-r--r--Ryujinx.Ava/Ui/Controls/NavigationDialogHost.axaml.cs85
1 files changed, 85 insertions, 0 deletions
diff --git a/Ryujinx.Ava/Ui/Controls/NavigationDialogHost.axaml.cs b/Ryujinx.Ava/Ui/Controls/NavigationDialogHost.axaml.cs
new file mode 100644
index 00000000..9ba631ad
--- /dev/null
+++ b/Ryujinx.Ava/Ui/Controls/NavigationDialogHost.axaml.cs
@@ -0,0 +1,85 @@
+using Avalonia;
+using Avalonia.Controls;
+using FluentAvalonia.UI.Controls;
+using Ryujinx.Ava.Common.Locale;
+using Ryujinx.Ava.Ui.ViewModels;
+using Ryujinx.HLE.FileSystem;
+using Ryujinx.HLE.HOS.Services.Account.Acc;
+using System;
+using System.Threading.Tasks;
+
+namespace Ryujinx.Ava.Ui.Controls
+{
+ public partial class NavigationDialogHost : UserControl
+ {
+ public AccountManager AccountManager { get; }
+ public ContentManager ContentManager { get; }
+ public UserProfileViewModel ViewModel { get; set; }
+
+ public NavigationDialogHost()
+ {
+ InitializeComponent();
+ }
+
+ public NavigationDialogHost(AccountManager accountManager, ContentManager contentManager,
+ VirtualFileSystem virtualFileSystem)
+ {
+ AccountManager = accountManager;
+ ContentManager = contentManager;
+ ViewModel = new UserProfileViewModel(this);
+
+
+ if (contentManager.GetCurrentFirmwareVersion() != null)
+ {
+ Task.Run(() =>
+ {
+ AvatarProfileViewModel.PreloadAvatars(contentManager, virtualFileSystem);
+ });
+ }
+ InitializeComponent();
+ }
+
+ public void GoBack(object parameter = null)
+ {
+ if (ContentFrame.BackStack.Count > 0)
+ {
+ ContentFrame.GoBack();
+ }
+
+ ViewModel.LoadProfiles();
+ }
+
+ public void Navigate(Type sourcePageType, object parameter)
+ {
+ ContentFrame.Navigate(sourcePageType, parameter);
+ }
+
+ public static async Task Show(AccountManager ownerAccountManager, ContentManager ownerContentManager, VirtualFileSystem ownerVirtualFileSystem)
+ {
+ var content = new NavigationDialogHost(ownerAccountManager, ownerContentManager, ownerVirtualFileSystem);
+ ContentDialog contentDialog = new ContentDialog
+ {
+ Title = LocaleManager.Instance["UserProfileWindowTitle"],
+ PrimaryButtonText = "",
+ SecondaryButtonText = "",
+ CloseButtonText = LocaleManager.Instance["UserProfilesClose"],
+ Content = content,
+ Padding = new Thickness(0)
+ };
+
+ contentDialog.Closed += (sender, args) =>
+ {
+ content.ViewModel.Dispose();
+ };
+
+ await contentDialog.ShowAsync();
+ }
+
+ protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
+ {
+ base.OnAttachedToVisualTree(e);
+
+ Navigate(typeof(UserSelector), this);
+ }
+ }
+} \ No newline at end of file