Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions src/Files.App/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public static class ImageRes
public const int Libraries = 1023;
public const int Folder = 3;
public const int ShieldIcon = 78;
public const int SearchIcon = 177;
}

public static class Shell32
Expand Down
19 changes: 19 additions & 0 deletions src/Files.App/Helpers/UI/UIHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ public static void CloseAllDialogs()

private static IconFileInfo ShieldIconResource = LoadShieldIconResource();

private static IconFileInfo SearchIconResource = LoadSearchIconResource();

public static IconFileInfo GetSidebarIconResourceInfo(int index)
{
var icons = UIHelpers.SidebarIconResources;
Expand All @@ -128,6 +130,13 @@ public static IconFileInfo GetSidebarIconResourceInfo(int index)
: null;
}

public static async Task<BitmapImage?> GetSearchIconResource()
{
return SearchIconResource is not null
? await SearchIconResource.IconData.ToBitmapAsync()
: null;
}

private static IEnumerable<IconFileInfo> LoadSidebarIconResources()
{
string imageres = Path.Combine(Constants.UserEnvironmentPaths.SystemRootPath, "System32", "imageres.dll");
Expand All @@ -153,5 +162,15 @@ private static IconFileInfo LoadShieldIconResource()

return imageResList.FirstOrDefault();
}

private static IconFileInfo LoadSearchIconResource()
{
string imageres = Path.Combine(Constants.UserEnvironmentPaths.SystemRootPath, "System32", "imageres.dll");
var imageResList = Win32Helper.ExtractSelectedIconsFromDLL(imageres, new List<int>() {
Constants.ImageRes.SearchIcon
}, 48);

return imageResList.FirstOrDefault();
}
}
}
3 changes: 3 additions & 0 deletions src/Files.App/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,9 @@
<data name="SearchPagePathBoxOverrideText" xml:space="preserve">
<value>Search results in {1} for {0}</value>
</data>
<data name="SearchResultsFor" xml:space="preserve">
<value>Search results for `{0}`</value>
</data>
<data name="Details" xml:space="preserve">
<value>Details</value>
</data>
Expand Down
38 changes: 36 additions & 2 deletions src/Files.App/ViewModels/ShellViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ public ImageSource? FolderThumbnailImageSource
private set => SetProperty(ref _FolderThumbnailImageSource, value);
}

private BitmapImage? _SearchIconBitmapImage;
public BitmapImage? SearchIconBitmapImage
{
get => _SearchIconBitmapImage;
private set => SetProperty(ref _SearchIconBitmapImage, value);
}


public bool ShowFilterHeader =>
UserSettingsService.GeneralSettingsService.ShowFilterHeader &&
WorkingDirectory != "Home" &&
Expand Down Expand Up @@ -739,7 +747,26 @@ public void CancelExtendedPropertiesLoadingForItem(ListedItem item)
itemLoadQueue.TryUpdate(item.ItemPath, true, false);
}

private bool IsSearchResults { get; set; }
private bool _isSearchResults;
public bool IsSearchResults
{
get => _isSearchResults;
set
{
if (SetProperty(ref _isSearchResults, value))
{
if (!value)
SearchHeaderTitle = string.Empty;
}
}
}

private string? _searchHeaderTitle;
public string? SearchHeaderTitle
{
get => _searchHeaderTitle;
set => SetProperty(ref _searchHeaderTitle, value);
}

public void UpdateEmptyTextType()
{
Expand Down Expand Up @@ -2682,7 +2709,7 @@ public async Task AddSearchResultsToCollectionAsync(ObservableCollection<ListedI
public async Task SearchAsync(FolderSearch search)
{
ItemLoadStatusChanged?.Invoke(this, new ItemLoadStatusChangedEventArgs() { Status = ItemLoadStatusChangedEventArgs.ItemLoadStatus.Starting });

//
CancelSearch();
searchCTS = new CancellationTokenSource();
filesAndFolders.Clear();
Expand All @@ -2692,6 +2719,13 @@ public async Task SearchAsync(FolderSearch search)
await ApplyFilesAndFoldersChangesAsync();
EmptyTextType = EmptyTextType.None;

SearchHeaderTitle = !string.IsNullOrEmpty(search.Query)
? string.Format(Strings.SearchResultsFor.GetLocalizedResource(), search.Query)
: string.Empty;

if (SearchIconBitmapImage is null)
SearchIconBitmapImage ??= await UIHelpers.GetSearchIconResource();

ItemLoadStatusChanged?.Invoke(this, new ItemLoadStatusChangedEventArgs() { Status = ItemLoadStatusChangedEventArgs.ItemLoadStatus.InProgress });

var results = new List<ListedItem>();
Expand Down
32 changes: 28 additions & 4 deletions src/Files.App/Views/Shells/ModernShellPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<ThemeShadow x:Name="ShellContentThemeShadow" x:FieldModifier="public" />
</Grid.Shadow>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
Expand All @@ -58,7 +59,7 @@
<!-- Swipe Backward Icon -->
<Border
x:Name="BackIcon"
Grid.RowSpan="2"
Grid.RowSpan="3"
Width="48"
Height="48"
Margin="-4,0,0,0"
Expand All @@ -80,7 +81,7 @@
<!-- Swipe Forward Icon -->
<Border
x:Name="ForwardIcon"
Grid.RowSpan="2"
Grid.RowSpan="3"
Width="48"
Height="48"
Margin="0,0,-4,0"
Expand All @@ -99,10 +100,33 @@
Symbol="Forward" />
</Border>

<!-- Search header -->
<Grid
x:Name="SearchHeader"
Grid.Row="0"
Padding="26,16,16,16"
BorderBrush="{ThemeResource DividerStrokeColorDefaultBrush}"
BorderThickness="0,0,0,1"
Visibility="{x:Bind ShellViewModel.IsSearchResults, Mode=OneWay}">
<StackPanel
VerticalAlignment="Center"
Orientation="Horizontal"
Spacing="12">
<Image
Height="24"
VerticalAlignment="Center"
Source="{x:Bind ShellViewModel.SearchIconBitmapImage, Mode=OneWay}" />
<TextBlock
VerticalAlignment="Center"
Style="{StaticResource SubtitleTextBlockStyle}"
Text="{x:Bind ShellViewModel.SearchHeaderTitle, Mode=OneWay}" />
</StackPanel>
</Grid>

<!-- Filter header -->
<Grid
x:Name="FilterHeader"
Grid.Row="0"
Grid.Row="1"
Padding="26,8,12,8"
BorderBrush="{ThemeResource DividerStrokeColorDefaultBrush}"
BorderThickness="0,0,0,1"
Expand Down Expand Up @@ -132,7 +156,7 @@
<!-- Shell Frame -->
<Frame
x:Name="ItemDisplayFrame"
Grid.Row="1"
Grid.Row="2"
x:FieldModifier="public"
Navigated="ItemDisplayFrame_Navigated" />

Expand Down
Loading