mirror of
https://github.com/Ryubing/Ryujinx.git
synced 2025-03-15 05:44:47 +00:00
misc: chore: [ci skip] Reduce duplicated close button & command space styling for dialogs
This commit is contained in:
parent
f7976753fd
commit
57c22a1f32
5 changed files with 26 additions and 44 deletions
|
@ -4,6 +4,7 @@ using Avalonia.Controls.ApplicationLifetimes;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using Avalonia.Layout;
|
using Avalonia.Layout;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
|
using Avalonia.Styling;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using FluentAvalonia.Core;
|
using FluentAvalonia.Core;
|
||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
|
@ -21,6 +22,23 @@ namespace Ryujinx.Ava.UI.Helpers
|
||||||
private static bool _isChoiceDialogOpen;
|
private static bool _isChoiceDialogOpen;
|
||||||
private static ContentDialogOverlayWindow _contentDialogOverlayWindow;
|
private static ContentDialogOverlayWindow _contentDialogOverlayWindow;
|
||||||
|
|
||||||
|
public static ContentDialog ApplyStyles(
|
||||||
|
this ContentDialog contentDialog,
|
||||||
|
double closeButtonWidth = 80,
|
||||||
|
HorizontalAlignment buttonSpaceAlignment = HorizontalAlignment.Right)
|
||||||
|
{
|
||||||
|
Style closeButton = new(x => x.Name("CloseButton"));
|
||||||
|
closeButton.Setters.Add(new Setter(Layoutable.WidthProperty, closeButtonWidth));
|
||||||
|
|
||||||
|
Style closeButtonParent = new(x => x.Name("CommandSpace"));
|
||||||
|
closeButtonParent.Setters.Add(new Setter(Layoutable.HorizontalAlignmentProperty, buttonSpaceAlignment));
|
||||||
|
|
||||||
|
contentDialog.Styles.Add(closeButton);
|
||||||
|
contentDialog.Styles.Add(closeButtonParent);
|
||||||
|
|
||||||
|
return contentDialog;
|
||||||
|
}
|
||||||
|
|
||||||
private async static Task<UserResult> ShowContentDialog(
|
private async static Task<UserResult> ShowContentDialog(
|
||||||
string title,
|
string title,
|
||||||
object content,
|
object content,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Input.Platform;
|
using Avalonia.Input.Platform;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
|
using Avalonia.Layout;
|
||||||
using Avalonia.Styling;
|
using Avalonia.Styling;
|
||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
|
@ -29,17 +30,7 @@ namespace Ryujinx.Ava.UI.Views.Misc
|
||||||
Content = new ApplicationDataView { ViewModel = new ApplicationDataViewModel(appData) }
|
Content = new ApplicationDataView { ViewModel = new ApplicationDataViewModel(appData) }
|
||||||
};
|
};
|
||||||
|
|
||||||
Style closeButton = new(x => x.Name("CloseButton"));
|
await ContentDialogHelper.ShowAsync(contentDialog.ApplyStyles(160, HorizontalAlignment.Center));
|
||||||
closeButton.Setters.Add(new Setter(WidthProperty, 160d));
|
|
||||||
|
|
||||||
Style closeButtonParent = new(x => x.Name("CommandSpace"));
|
|
||||||
closeButtonParent.Setters.Add(new Setter(HorizontalAlignmentProperty,
|
|
||||||
Avalonia.Layout.HorizontalAlignment.Center));
|
|
||||||
|
|
||||||
contentDialog.Styles.Add(closeButton);
|
|
||||||
contentDialog.Styles.Add(closeButtonParent);
|
|
||||||
|
|
||||||
await ContentDialogHelper.ShowAsync(contentDialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApplicationDataView()
|
public ApplicationDataView()
|
||||||
|
|
|
@ -32,17 +32,7 @@ namespace Ryujinx.Ava.UI.Views.Misc
|
||||||
Content = new DlcSelectView { ViewModel = viewModel }
|
Content = new DlcSelectView { ViewModel = viewModel }
|
||||||
};
|
};
|
||||||
|
|
||||||
Style closeButton = new(x => x.Name("CloseButton"));
|
await ContentDialogHelper.ShowAsync(contentDialog.ApplyStyles());
|
||||||
closeButton.Setters.Add(new Setter(WidthProperty, 80d));
|
|
||||||
|
|
||||||
Style closeButtonParent = new(x => x.Name("CommandSpace"));
|
|
||||||
closeButtonParent.Setters.Add(new Setter(HorizontalAlignmentProperty,
|
|
||||||
Avalonia.Layout.HorizontalAlignment.Right));
|
|
||||||
|
|
||||||
contentDialog.Styles.Add(closeButton);
|
|
||||||
contentDialog.Styles.Add(closeButtonParent);
|
|
||||||
|
|
||||||
await ContentDialogHelper.ShowAsync(contentDialog);
|
|
||||||
|
|
||||||
return viewModel.SelectedDlc;
|
return viewModel.SelectedDlc;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ using Avalonia.Layout;
|
||||||
using Avalonia.Styling;
|
using Avalonia.Styling;
|
||||||
using FluentAvalonia.UI.Controls;
|
using FluentAvalonia.UI.Controls;
|
||||||
using Ryujinx.Ava.Common.Locale;
|
using Ryujinx.Ava.Common.Locale;
|
||||||
|
using Ryujinx.Ava.UI.Controls;
|
||||||
using Ryujinx.Ava.UI.Helpers;
|
using Ryujinx.Ava.UI.Helpers;
|
||||||
using Ryujinx.Ava.UI.ViewModels;
|
using Ryujinx.Ava.UI.ViewModels;
|
||||||
using Ryujinx.Common;
|
using Ryujinx.Common;
|
||||||
|
@ -14,7 +15,7 @@ using Button = Avalonia.Controls.Button;
|
||||||
|
|
||||||
namespace Ryujinx.Ava.UI.Windows
|
namespace Ryujinx.Ava.UI.Windows
|
||||||
{
|
{
|
||||||
public partial class AboutWindow : UserControl
|
public partial class AboutWindow : RyujinxControl<AboutWindowViewModel>
|
||||||
{
|
{
|
||||||
public AboutWindow()
|
public AboutWindow()
|
||||||
{
|
{
|
||||||
|
@ -33,19 +34,10 @@ namespace Ryujinx.Ava.UI.Windows
|
||||||
PrimaryButtonText = string.Empty,
|
PrimaryButtonText = string.Empty,
|
||||||
SecondaryButtonText = string.Empty,
|
SecondaryButtonText = string.Empty,
|
||||||
CloseButtonText = LocaleManager.Instance[LocaleKeys.UserProfilesClose],
|
CloseButtonText = LocaleManager.Instance[LocaleKeys.UserProfilesClose],
|
||||||
Content = new AboutWindow { DataContext = viewModel }
|
Content = new AboutWindow { ViewModel = viewModel }
|
||||||
};
|
};
|
||||||
|
|
||||||
Style closeButton = new(x => x.Name("CloseButton"));
|
await ContentDialogHelper.ShowAsync(contentDialog.ApplyStyles());
|
||||||
closeButton.Setters.Add(new Setter(WidthProperty, 80d));
|
|
||||||
|
|
||||||
Style closeButtonParent = new(x => x.Name("CommandSpace"));
|
|
||||||
closeButtonParent.Setters.Add(new Setter(HorizontalAlignmentProperty, HorizontalAlignment.Right));
|
|
||||||
|
|
||||||
contentDialog.Styles.Add(closeButton);
|
|
||||||
contentDialog.Styles.Add(closeButtonParent);
|
|
||||||
|
|
||||||
await ContentDialogHelper.ShowAsync(contentDialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Button_OnClick(object sender, RoutedEventArgs e)
|
private void Button_OnClick(object sender, RoutedEventArgs e)
|
||||||
|
|
|
@ -25,16 +25,7 @@ namespace Ryujinx.Ava.Utilities.Compat
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Style closeButton = new(x => x.Name("CloseButton"));
|
await ContentDialogHelper.ShowAsync(contentDialog.ApplyStyles());
|
||||||
closeButton.Setters.Add(new Setter(WidthProperty, 80d));
|
|
||||||
|
|
||||||
Style closeButtonParent = new(x => x.Name("CommandSpace"));
|
|
||||||
closeButtonParent.Setters.Add(new Setter(HorizontalAlignmentProperty, Avalonia.Layout.HorizontalAlignment.Right));
|
|
||||||
|
|
||||||
contentDialog.Styles.Add(closeButton);
|
|
||||||
contentDialog.Styles.Add(closeButtonParent);
|
|
||||||
|
|
||||||
await ContentDialogHelper.ShowAsync(contentDialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompatibilityList()
|
public CompatibilityList()
|
||||||
|
|
Loading…
Add table
Reference in a new issue