Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/Files.App/Actions/Global/SearchAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,35 @@ public HotKey SecondHotKey
public RichGlyph Glyph
=> new(themedIconStyle: "App.ThemedIcons.Omnibar.Search");

public bool IsExecutable
=> context.ShellPage is not null;

public SearchAction()
{
context = Ioc.Default.GetRequiredService<IContentPageContext>();

context.PropertyChanged += Context_PropertyChanged;
}

public Task ExecuteAsync(object? parameter = null)
{
context.ShellPage!.ToolbarViewModel.SwitchToSearchMode();
// Check if ShellPage is available before executing the action
if (context.ShellPage is null)
return Task.CompletedTask;

context.ShellPage.ToolbarViewModel.SwitchToSearchMode();

return Task.CompletedTask;
}

private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
{
switch (e.PropertyName)
{
case nameof(IContentPageContext.ShellPage):
OnPropertyChanged(nameof(IsExecutable));
break;
}
}
}
}
Loading