From 9e2681f2d7e9b36af30f600b79107cb9cd6aa5f1 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz <42140194+IsaacMarovitz@users.noreply.github.com> Date: Fri, 6 Jan 2023 19:29:18 -0500 Subject: Ava GUI: `AboutWindow` Refactor (#4196) * Start `AboutWindow` refactor * Redesign * Update logos + ViewModel * Fix GTK * Cleanup usings * Fix mismatched font size * Update LocaleKeys * Block scoped namespace * Fix appearence on German * Update Ryujinx.Ava/UI/ViewModels/AboutWindowViewModel.cs Co-authored-by: Ac_K * Update Ryujinx.Ava/UI/ViewModels/AboutWindowViewModel.cs Co-authored-by: Ac_K * Move version number up * Move see all contributors button left * Add a couple `\n` * Tooltips * Layout fix * Update Ryujinx.Ava/UI/ViewModels/AboutWindowViewModel.cs Co-authored-by: Ac_K Co-authored-by: Ac_K --- Ryujinx.Ava/UI/Windows/AboutWindow.axaml | 433 +++++++++++++--------------- Ryujinx.Ava/UI/Windows/AboutWindow.axaml.cs | 69 ++--- 2 files changed, 229 insertions(+), 273 deletions(-) (limited to 'Ryujinx.Ava/UI/Windows') diff --git a/Ryujinx.Ava/UI/Windows/AboutWindow.axaml b/Ryujinx.Ava/UI/Windows/AboutWindow.axaml index 08d28740..f446890c 100644 --- a/Ryujinx.Ava/UI/Windows/AboutWindow.axaml +++ b/Ryujinx.Ava/UI/Windows/AboutWindow.axaml @@ -1,282 +1,253 @@ - + + + - - - - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - + HorizontalAlignment="Center" + VerticalAlignment="Center" + Text="{Binding Version}" + TextAlignment="Center" + FontSize="10" + LineHeight="12" /> + - + Grid.Row="2" + Spacing="10" + HorizontalAlignment="Stretch" + VerticalAlignment="Stretch"> + + + - - - - + - - - - + BorderBrush="{DynamicResource ThemeControlBorderColor}" + BorderThickness="1,0,0,0" + Margin="20 0"/> - - - - - - - - - - - + FontWeight="Bold" + FontSize="15" + Text="{locale:Locale AboutRyujinxMaintainersTitle}" /> - + FontSize="10" + TextWrapping="Wrap" + Text="{Binding Developers}" /> + + + + + + + + - + \ No newline at end of file diff --git a/Ryujinx.Ava/UI/Windows/AboutWindow.axaml.cs b/Ryujinx.Ava/UI/Windows/AboutWindow.axaml.cs index 99280b87..5dbbbcdd 100644 --- a/Ryujinx.Ava/UI/Windows/AboutWindow.axaml.cs +++ b/Ryujinx.Ava/UI/Windows/AboutWindow.axaml.cs @@ -1,70 +1,55 @@ using Avalonia.Controls; using Avalonia.Input; using Avalonia.Interactivity; -using Avalonia.Threading; +using Avalonia.Styling; +using FluentAvalonia.UI.Controls; using Ryujinx.Ava.Common.Locale; -using Ryujinx.Common.Utilities; +using Ryujinx.Ava.UI.ViewModels; using Ryujinx.Ui.Common.Helper; -using System.Net.Http; -using System.Net.NetworkInformation; using System.Threading.Tasks; +using Button = Avalonia.Controls.Button; namespace Ryujinx.Ava.UI.Windows { - public partial class AboutWindow : StyleableWindow + public partial class AboutWindow : UserControl { public AboutWindow() { - if (Program.PreviewerDetached) - { - Title = $"Ryujinx {Program.Version} - " + LocaleManager.Instance[LocaleKeys.MenuBarHelpAbout]; - } - - Version = Program.Version; - - DataContext = this; + DataContext = new AboutWindowViewModel(); InitializeComponent(); - - _ = DownloadPatronsJson(); } - public string Supporters { get; set; } - public string Version { get; set; } - - public string Developers => string.Format(LocaleManager.Instance[LocaleKeys.AboutPageDeveloperListMore], "gdkchan, Ac_K, Thog, rip in peri peri, LDj3SNuD, emmaus, Thealexbarney, Xpl0itR, GoffyDude, »jD«"); - - private void Button_OnClick(object sender, RoutedEventArgs e) + public static async Task Show() { - if (sender is Button button) - { - OpenHelper.OpenUrl(button.Tag.ToString()); - } - } + var content = new AboutWindow(); - private async Task DownloadPatronsJson() - { - if (!NetworkInterface.GetIsNetworkAvailable()) + ContentDialog contentDialog = new() { - Supporters = LocaleManager.Instance[LocaleKeys.ConnectionError]; + PrimaryButtonText = "", + SecondaryButtonText = "", + CloseButtonText = LocaleManager.Instance[LocaleKeys.UserProfilesClose], + Content = content + }; - return; - } + Style closeButton = new(x => x.Name("CloseButton")); + closeButton.Setters.Add(new Setter(WidthProperty, 80d)); - HttpClient httpClient = new(); + Style closeButtonParent = new(x => x.Name("CommandSpace")); + closeButtonParent.Setters.Add(new Setter(HorizontalAlignmentProperty, Avalonia.Layout.HorizontalAlignment.Right)); - try - { - string patreonJsonString = await httpClient.GetStringAsync("https://patreon.ryujinx.org/"); + contentDialog.Styles.Add(closeButton); + contentDialog.Styles.Add(closeButtonParent); - Supporters = string.Join(", ", JsonHelper.Deserialize(patreonJsonString)); - } - catch + await contentDialog.ShowAsync(); + } + + private void Button_OnClick(object sender, RoutedEventArgs e) + { + if (sender is Button button) { - Supporters = LocaleManager.Instance[LocaleKeys.ApiError]; + OpenHelper.OpenUrl(button.Tag.ToString()); } - - await Dispatcher.UIThread.InvokeAsync(() => SupportersTextBlock.Text = Supporters); } private void AmiiboLabel_OnPointerPressed(object sender, PointerPressedEventArgs e) -- cgit v1.2.3