@@ -22,21 +22,38 @@ public bool IsCommitSearchPanelVisible
2222 set
2323 {
2424 if ( SetAndRaise ( IsCommitSearchPanelVisibleProperty , ref _isCommitSearchPanelVisible , value ) )
25- {
26- var layout = ViewModels . Preferences . Instance . Layout ;
27- if ( value )
28- {
29- SidebarWidth = new GridLength ( layout . RepositorySearchCommitWidth , GridUnitType . Pixel ) ;
30- }
31- else
32- {
33- SidebarWidth = new GridLength ( layout . RepositorySidebarWidth , GridUnitType . Pixel ) ;
34- UpdateLeftSidebarLayout ( ) ;
35- }
36- }
25+ CalculateSidebarWidth ( ) ;
26+ }
27+ }
28+
29+ public static readonly DirectProperty < Repository , bool > IsNormalSidebarVisibleProperty =
30+ AvaloniaProperty . RegisterDirect < Repository , bool > (
31+ nameof ( IsNormalSidebarVisible ) ,
32+ static o => o . IsNormalSidebarVisible ,
33+ static ( o , v ) => o . IsNormalSidebarVisible = v ) ;
34+
35+ public bool IsNormalSidebarVisible
36+ {
37+ get => _isNormalSidebarVisible ;
38+ set
39+ {
40+ if ( SetAndRaise ( IsNormalSidebarVisibleProperty , ref _isNormalSidebarVisible , value ) )
41+ CalculateSidebarWidth ( ) ;
3742 }
3843 }
3944
45+ public static readonly DirectProperty < Repository , double > SidebarMinWidthProperty =
46+ AvaloniaProperty . RegisterDirect < Repository , double > (
47+ nameof ( SidebarMinWidth ) ,
48+ static o => o . SidebarMinWidth ,
49+ static ( o , v ) => o . SidebarMinWidth = v ) ;
50+
51+ public double SidebarMinWidth
52+ {
53+ get => _sidebarMinWidth ;
54+ set => SetAndRaise ( SidebarMinWidthProperty , ref _sidebarMinWidth , value ) ;
55+ }
56+
4057 public static readonly DirectProperty < Repository , GridLength > SidebarWidthProperty =
4158 AvaloniaProperty . RegisterDirect < Repository , GridLength > (
4259 nameof ( SidebarWidth ) ,
@@ -53,7 +70,7 @@ public GridLength SidebarWidth
5370 var layout = ViewModels . Preferences . Instance . Layout ;
5471 if ( _isCommitSearchPanelVisible )
5572 layout . RepositorySearchCommitWidth = value . Value ;
56- else
73+ else if ( _isNormalSidebarVisible )
5774 layout . RepositorySidebarWidth = value . Value ;
5875 }
5976 }
@@ -493,7 +510,29 @@ private void OnRightPagePropertyChanged(object sender, AvaloniaPropertyChangedEv
493510 }
494511 }
495512
513+ private void CalculateSidebarWidth ( )
514+ {
515+ var layout = ViewModels . Preferences . Instance . Layout ;
516+ if ( _isCommitSearchPanelVisible )
517+ {
518+ SidebarMinWidth = 200 ;
519+ SidebarWidth = new GridLength ( layout . RepositorySearchCommitWidth , GridUnitType . Pixel ) ;
520+ }
521+ else if ( _isNormalSidebarVisible )
522+ {
523+ SidebarMinWidth = 200 ;
524+ SidebarWidth = new GridLength ( layout . RepositorySidebarWidth , GridUnitType . Pixel ) ;
525+ }
526+ else
527+ {
528+ SidebarMinWidth = 0 ;
529+ SidebarWidth = new GridLength ( 0 , GridUnitType . Pixel ) ;
530+ }
531+ }
532+
533+ private bool _isNormalSidebarVisible = true ;
496534 private bool _isCommitSearchPanelVisible = false ;
535+ private double _sidebarMinWidth = 200 ;
497536 private GridLength _sidebarWidth ;
498537 }
499538}
0 commit comments