Skip to content

Commit 392d5b1

Browse files
committed
Packages: restyle the Manage menu as a themed flyout
The per-package Manage menu is now a Flyout of themed buttons (new FlyoutPresenter and Button.menuItem styles) rather than a Fluent MenuFlyout, matching the app's dark cards, and the Available list/grid max height is increased.
1 parent 5886d5f commit 392d5b1

3 files changed

Lines changed: 55 additions & 20 deletions

File tree

src/BasisPM.App/Styles/BasisTheme.axaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,4 +403,39 @@
403403
<Style Selector="Expander /template/ Border#ExpanderContent">
404404
<Setter Property="Padding" Value="20,6,20,18"/>
405405
</Style>
406+
407+
<!-- Flyout popup (e.g. the package "Manage" menu): a dark panel matching the cards. -->
408+
<Style Selector="FlyoutPresenter">
409+
<Setter Property="Background" Value="{StaticResource BasisPanelBrush}"/>
410+
<Setter Property="BorderBrush" Value="{StaticResource BasisBorderStrongBrush}"/>
411+
<Setter Property="BorderThickness" Value="1"/>
412+
<Setter Property="CornerRadius" Value="12"/>
413+
<Setter Property="Padding" Value="5"/>
414+
<Setter Property="MinWidth" Value="0"/>
415+
</Style>
416+
417+
<!-- Menu-style buttons stacked inside a Flyout (the code-built Manage menu). -->
418+
<Style Selector="Button.menuItem">
419+
<Setter Property="HorizontalAlignment" Value="Stretch"/>
420+
<Setter Property="HorizontalContentAlignment" Value="Left"/>
421+
<Setter Property="Background" Value="Transparent"/>
422+
<Setter Property="BorderThickness" Value="0"/>
423+
<Setter Property="CornerRadius" Value="8"/>
424+
<Setter Property="Padding" Value="12,9"/>
425+
<Setter Property="FontWeight" Value="Medium"/>
426+
<Setter Property="FontSize" Value="13"/>
427+
<Setter Property="Foreground" Value="{StaticResource BasisTextPrimaryBrush}"/>
428+
</Style>
429+
<Style Selector="Button.menuItem:pointerover /template/ ContentPresenter">
430+
<Setter Property="Background" Value="{StaticResource BasisSurfaceHoverBrush}"/>
431+
<Setter Property="BorderBrush" Value="Transparent"/>
432+
<Setter Property="TextElement.Foreground" Value="{StaticResource BasisTextPrimaryBrush}"/>
433+
</Style>
434+
<Style Selector="Button.menuItem.destructive">
435+
<Setter Property="Foreground" Value="{StaticResource BasisBrandBrush}"/>
436+
</Style>
437+
<Style Selector="Button.menuItem.destructive:pointerover /template/ ContentPresenter">
438+
<Setter Property="Background" Value="{StaticResource BasisSurfaceHoverBrush}"/>
439+
<Setter Property="TextElement.Foreground" Value="{StaticResource BasisBrandBrush}"/>
440+
</Style>
406441
</Styles>

src/BasisPM.App/Views/PackagesView.axaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
<TextBox Watermark="{loc:Tr packages.filter.watermark}" Text="{Binding Filter}"/>
7070
</Border>
7171
<!-- List layout: one roomy row per package, with a wide action column. -->
72-
<ScrollViewer Grid.Row="2" MaxHeight="360" IsVisible="{Binding IsListView}">
72+
<ScrollViewer Grid.Row="2" MaxHeight="720" IsVisible="{Binding IsListView}">
7373
<ItemsControl ItemsSource="{Binding Available}">
7474
<ItemsControl.ItemTemplate>
7575
<DataTemplate DataType="vm:PackageRow">
@@ -122,7 +122,7 @@
122122
</ScrollViewer>
123123

124124
<!-- Grid layout: cards that wrap; toggled from the header. -->
125-
<ScrollViewer Grid.Row="2" MaxHeight="420" IsVisible="{Binding IsGridView}">
125+
<ScrollViewer Grid.Row="2" MaxHeight="840" IsVisible="{Binding IsGridView}">
126126
<ItemsControl ItemsSource="{Binding Available}" Margin="10,7">
127127
<ItemsControl.ItemsPanel>
128128
<ItemsPanelTemplate>
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using Avalonia.Controls;
23
using Avalonia.Interactivity;
34
using BasisPM.App.Localization;
@@ -9,32 +10,31 @@ public partial class PackagesView : UserControl
910
{
1011
public PackagesView() => InitializeComponent();
1112

12-
// The "Manage" menu for an installed package is built in code and its commands invoked
13-
// directly, so it doesn't rely on binding resolution inside the flyout popup.
13+
// The "Manage" menu for an installed package is built in code from a Flyout of themed buttons
14+
// (so it matches the app styling), and its commands are invoked directly — no reliance on binding
15+
// resolution or Fluent menu-item theming inside the popup.
1416
private void OnManageClick(object? sender, RoutedEventArgs e)
1517
{
1618
if (sender is not Control control || control.DataContext is not PackageRow row) return;
1719
if (DataContext is not PackagesViewModel vm) return;
1820

19-
var flyout = new MenuFlyout();
20-
21-
var update = new MenuItem { Header = L.Tr("packages.button.update") };
22-
update.Click += (_, _) => vm.InstallCommand.Execute(row.Entry);
23-
flyout.Items.Add(update);
21+
var panel = new StackPanel { Spacing = 2, MinWidth = 168 };
22+
var flyout = new Flyout { Content = panel };
2423

24+
panel.Children.Add(MenuButton(L.Tr("packages.button.update"), false, flyout, () => vm.InstallCommand.Execute(row.Entry)));
2525
if (row.HasGit)
26-
{
27-
var choose = new MenuItem { Header = L.Tr("packages.button.chooseVersion") };
28-
choose.Click += (_, _) => vm.ChooseVersionCommand.Execute(row.Entry);
29-
flyout.Items.Add(choose);
30-
}
31-
32-
flyout.Items.Add(new Separator());
33-
34-
var remove = new MenuItem { Header = L.Tr("packages.button.remove") };
35-
remove.Click += (_, _) => vm.RemoveCommand.Execute(row.Entry);
36-
flyout.Items.Add(remove);
26+
panel.Children.Add(MenuButton(L.Tr("packages.button.chooseVersion"), false, flyout, () => vm.ChooseVersionCommand.Execute(row.Entry)));
27+
panel.Children.Add(MenuButton(L.Tr("packages.button.remove"), true, flyout, () => vm.RemoveCommand.Execute(row.Entry)));
3728

3829
flyout.ShowAt(control);
3930
}
31+
32+
private static Button MenuButton(string text, bool destructive, Flyout flyout, Action action)
33+
{
34+
var btn = new Button { Content = text };
35+
btn.Classes.Add("menuItem");
36+
if (destructive) btn.Classes.Add("destructive");
37+
btn.Click += (_, _) => { flyout.Hide(); action(); };
38+
return btn;
39+
}
4040
}

0 commit comments

Comments
 (0)