@@ -24,18 +24,6 @@ public partial class SidebarViewModel : ViewModelBase
2424 partial void OnUpdatesBadgeCountChanged ( int value ) =>
2525 UpdatesBadgeVisible = value > 0 ;
2626
27- partial void OnUpdatesBadgeVisibleChanged ( bool value )
28- {
29- OnPropertyChanged ( nameof ( UpdatesBadgeExpandedVisible ) ) ;
30- OnPropertyChanged ( nameof ( UpdatesBadgeCompactVisible ) ) ;
31- }
32-
33- partial void OnBundlesBadgeVisibleChanged ( bool value )
34- {
35- OnPropertyChanged ( nameof ( BundlesBadgeExpandedVisible ) ) ;
36- OnPropertyChanged ( nameof ( BundlesBadgeCompactVisible ) ) ;
37- }
38-
3927 // ─── Loading indicators ───────────────────────────────────────────────────
4028 [ ObservableProperty ]
4129 private bool _discoverIsLoading ;
@@ -47,31 +35,84 @@ partial void OnBundlesBadgeVisibleChanged(bool value)
4735 private bool _installedIsLoading ;
4836
4937 // ─── Pane open/closed ─────────────────────────────────────────────────────
50- // Starts collapsed: the pane is a floating overlay in every size class (see MainWindow's
51- // adaptive logic), so there is no persistent open-on-launch state.
38+ // NavMenuMode: Automatic mirrors WinUI (dock ≥1600px, else rail+overlay), Docked = always
39+ // inline, Overlay = always rail+overlay. IsPaneOpen = labeled pane showing, in any mode.
40+ public enum NavMode { Automatic , Docked , Overlay }
41+
42+ private const double ExpandedThreshold = 1600 ; // WinUI ExpandedModeThresholdWidth
43+ private const double CompactThreshold = 800 ; // WinUI CompactModeThresholdWidth
44+
45+ // Live window width, pushed by MainWindow's bounds observer.
5246 [ ObservableProperty ]
53- private bool isPaneOpen ;
47+ private double _windowWidth = 1450 ;
48+
49+ [ ObservableProperty ]
50+ private NavMode _mode = ParseMode ( Settings . GetValue ( Settings . K . NavMenuMode ) ) ;
51+
52+ [ ObservableProperty ]
53+ private bool _isPaneOpen ;
54+
55+ public static NavMode ParseMode ( string value ) => value switch
56+ {
57+ "docked" => NavMode . Docked ,
58+ "overlay" => NavMode . Overlay ,
59+ _ => NavMode . Automatic ,
60+ } ;
61+
62+ // Whether the pane docks inline (vs. the rail + sliding overlay).
63+ public bool Docked => Mode switch
64+ {
65+ NavMode . Docked => true ,
66+ NavMode . Overlay => false ,
67+ _ => WindowWidth >= ExpandedThreshold ,
68+ } ;
69+
70+ private bool RailAllowed => WindowWidth >= CompactThreshold ;
71+
72+ // Icon rail vs docked labeled pane vs sliding overlay — mutually exclusive.
73+ public bool NavDockVisible => Docked && IsPaneOpen ;
74+ public bool RailVisible => ( Docked && ! IsPaneOpen ) || ( ! Docked && RailAllowed ) ;
75+ public bool OverlayActive => ! Docked && IsPaneOpen ;
76+
77+ private bool _wasDocked ;
78+
79+ public SidebarViewModel ( )
80+ {
81+ _wasDocked = Docked ;
82+ _isPaneOpen = Docked && ! Settings . Get ( Settings . K . CollapseNavMenuOnWideScreen ) ;
83+ }
84+
85+ partial void OnWindowWidthChanged ( double value ) => ReconcileDock ( ) ;
5486
55- // Only persist the open/closed choice as the "collapse on wide screen" preference
56- // while the pane is inline (Expanded mode). In the overlay modes used on smaller
57- // windows, opening/closing is transient and must not overwrite the saved preference.
58- // The MainWindow's adaptive logic keeps this in sync with the SplitView display mode.
59- public bool PersistPaneCollapsePreference { get ; set ; } = true ;
87+ partial void OnModeChanged ( NavMode value ) => ReconcileDock ( ) ;
88+
89+ // On a docked-state flip, open the pane by default (unless collapsed on a wide screen), or
90+ // collapse when leaving docked mode. Mirrors WinUI's startup IsPaneOpen logic.
91+ private void ReconcileDock ( )
92+ {
93+ bool docked = Docked ;
94+ if ( docked != _wasDocked )
95+ {
96+ _wasDocked = docked ;
97+ IsPaneOpen = docked && ! Settings . Get ( Settings . K . CollapseNavMenuOnWideScreen ) ;
98+ }
99+ RaiseLayoutChanged ( ) ;
100+ }
60101
61102 partial void OnIsPaneOpenChanged ( bool value )
62103 {
63- if ( PersistPaneCollapsePreference )
104+ // Persist the collapse choice only while docked (WinUI persisted only at ≥1600px).
105+ if ( Docked )
64106 Settings . Set ( Settings . K . CollapseNavMenuOnWideScreen , ! value ) ;
65- OnPropertyChanged ( nameof ( UpdatesBadgeExpandedVisible ) ) ;
66- OnPropertyChanged ( nameof ( UpdatesBadgeCompactVisible ) ) ;
67- OnPropertyChanged ( nameof ( BundlesBadgeExpandedVisible ) ) ;
68- OnPropertyChanged ( nameof ( BundlesBadgeCompactVisible ) ) ;
107+ RaiseLayoutChanged ( ) ;
69108 }
70109
71- public bool UpdatesBadgeExpandedVisible => UpdatesBadgeVisible && IsPaneOpen ;
72- public bool UpdatesBadgeCompactVisible => UpdatesBadgeVisible && ! IsPaneOpen ;
73- public bool BundlesBadgeExpandedVisible => BundlesBadgeVisible && IsPaneOpen ;
74- public bool BundlesBadgeCompactVisible => BundlesBadgeVisible && ! IsPaneOpen ;
110+ private void RaiseLayoutChanged ( )
111+ {
112+ OnPropertyChanged ( nameof ( NavDockVisible ) ) ;
113+ OnPropertyChanged ( nameof ( RailVisible ) ) ;
114+ OnPropertyChanged ( nameof ( OverlayActive ) ) ;
115+ }
75116
76117 // ─── Selected page ────────────────────────────────────────────────────────
77118 [ ObservableProperty ]
0 commit comments