22// Licensed under the MIT License.
33
44using CommunityToolkit . WinUI ;
5- using Files . App . Actions ;
65using Files . App . Controls ;
76using Files . Shared . Helpers ;
87using Microsoft . UI . Dispatching ;
@@ -155,7 +154,7 @@ public sealed partial class NavigationToolbarViewModel : ObservableObject, IAddr
155154
156155 private bool _IsDynamicOverflowEnabled ;
157156 public bool IsDynamicOverflowEnabled { get => _IsDynamicOverflowEnabled ; set => SetProperty ( ref _IsDynamicOverflowEnabled , value ) ; }
158-
157+
159158 private bool _IsUpdating ;
160159 public bool IsUpdating { get => _IsUpdating ; set => SetProperty ( ref _IsUpdating , value ) ; }
161160
@@ -228,7 +227,7 @@ public string? PathText
228227 public string ? OmnibarCommandPaletteModeText { get => _OmnibarCommandPaletteModeText ; set => SetProperty ( ref _OmnibarCommandPaletteModeText , value ) ; }
229228
230229 private bool _IsOmnibarFocused ;
231- public bool IsOmnibarFocused
230+ public bool IsOmnibarFocused
232231 {
233232 get => _IsOmnibarFocused ;
234233 set
@@ -237,7 +236,7 @@ public bool IsOmnibarFocused
237236 {
238237 if ( value )
239238 {
240- switch ( OmnibarCurrentSelectedMode . Name )
239+ switch ( OmnibarCurrentSelectedMode . Name )
241240 {
242241 case OmnibarPathModeName :
243242 PathText =
@@ -741,59 +740,79 @@ public void PathBoxItem_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
741740 switch ( e . Key )
742741 {
743742 case Windows . System . VirtualKey . Down :
744- {
745- var item = e . OriginalSource as ListViewItem ;
746- var button = item ? . FindDescendant < Button > ( ) ;
747- button ? . Flyout . ShowAt ( button ) ;
748- e . Handled = true ;
749- break ;
750- }
751- case Windows . System . VirtualKey . Space :
743+ {
744+ var item = e . OriginalSource as ListViewItem ;
745+ var button = item ? . FindDescendant < Button > ( ) ;
746+ button ? . Flyout . ShowAt ( button ) ;
747+ e . Handled = true ;
748+ break ;
749+ }
750+ case Windows . System . VirtualKey . Space :
752751 case Windows . System . VirtualKey . Enter :
753- {
754- var item = e . OriginalSource as ListViewItem ;
755- var path = ( item ? . Content as PathBoxItem ) ? . Path ;
756- if ( path == PathControlDisplayText )
757- return ;
758- ToolbarPathItemInvoked ? . Invoke ( this , new PathNavigationEventArgs ( )
759752 {
760- ItemPath = path
761- } ) ;
762- e . Handled = true ;
763- break ;
764- }
753+ var item = e . OriginalSource as ListViewItem ;
754+ var path = ( item ? . Content as PathBoxItem ) ? . Path ;
755+ if ( path == PathControlDisplayText )
756+ return ;
757+ ToolbarPathItemInvoked ? . Invoke ( this , new PathNavigationEventArgs ( )
758+ {
759+ ItemPath = path
760+ } ) ;
761+ e . Handled = true ;
762+ break ;
763+ }
765764 }
766765 }
767766
768- public void OpenCommandPalette ( )
767+ public void SwitchToCommandPaletteMode ( )
769768 {
770- PathText = ">" ;
771- IsCommandPaletteOpen = true ;
772- ManualEntryBoxLoaded = true ;
773- ClickablePathLoaded = false ;
769+ if ( EnableOmnibar )
770+ {
771+ OmnibarCurrentSelectedMode . Name = OmnibarPaletteModeName ;
772+ IsOmnibarFocused = true ;
773+ }
774+ else
775+ {
776+ PathText = ">" ;
777+ IsCommandPaletteOpen = true ;
778+ ManualEntryBoxLoaded = true ;
779+ ClickablePathLoaded = false ;
774780
775- var visiblePath = AddressToolbar ? . FindDescendant < AutoSuggestBox > ( x => x . Name == "VisiblePath" ) ;
776- AddressBarTextEntered ? . Invoke ( this , new AddressBarTextEnteredEventArgs ( ) { AddressBarTextField = visiblePath } ) ;
781+ var visiblePath = AddressToolbar ? . FindDescendant < AutoSuggestBox > ( x => x . Name == "VisiblePath" ) ;
782+ AddressBarTextEntered ? . Invoke ( this , new AddressBarTextEnteredEventArgs ( ) { AddressBarTextField = visiblePath } ) ;
783+ }
777784 }
778785
779- public void SwitchSearchBoxVisibility ( )
786+ public void SwitchToSearchMode ( )
780787 {
781- if ( IsSearchBoxVisible )
788+ if ( EnableOmnibar )
782789 {
783- CloseSearchBox ( true ) ;
790+ OmnibarCurrentSelectedMode . Name = OmnibarSearchModeName ;
791+ IsOmnibarFocused = true ;
784792 }
785793 else
786794 {
787- IsSearchBoxVisible = true ;
795+ if ( IsSearchBoxVisible )
796+ CloseSearchBox ( true ) ;
797+ else
798+ {
799+ IsSearchBoxVisible = true ;
788800
789- // Given that binding and layouting might take a few cycles, when calling UpdateLayout
790- // we can guarantee that the focus call will be able to find an open ASB
791- var searchbox = AddressToolbar ? . FindDescendant ( "SearchRegion" ) as SearchBox ;
792- searchbox ? . UpdateLayout ( ) ;
793- searchbox ? . Focus ( FocusState . Programmatic ) ;
801+ // Given that binding and layouting might take a few cycles, when calling UpdateLayout
802+ // we can guarantee that the focus call will be able to find an open ASB
803+ var searchbox = AddressToolbar ? . FindDescendant ( "SearchRegion" ) as SearchBox ;
804+ searchbox ? . UpdateLayout ( ) ;
805+ searchbox ? . Focus ( FocusState . Programmatic ) ;
806+ }
794807 }
795808 }
796809
810+ public void SwitchToPathhMode ( )
811+ {
812+ OmnibarCurrentSelectedMode . Name = OmnibarPathModeName ;
813+ IsOmnibarFocused = true ;
814+ }
815+
797816 public void UpdateAdditionalActions ( )
798817 {
799818 OnPropertyChanged ( nameof ( HasAdditionalAction ) ) ;
0 commit comments