Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

Add search filter to home page recent conversions

gtxPrime8551e78e95d1
diff --git a/src/Filee.App/ViewModels/Pages/HomePageViewModel.cs b/src/Filee.App/ViewModels/Pages/HomePageViewModel.cs
index 189d3d26..07248013 100644
--- a/src/Filee.App/ViewModels/Pages/HomePageViewModel.cs
+++ b/src/Filee.App/ViewModels/Pages/HomePageViewModel.cs
@@ -101,6 +101,8 @@ public sealed partial class HomePageViewModel : ObservableObject, IDisposable
var drag = store.Settings.Triggers.FirstOrDefault(t => t.Enabled && t.Kind == TriggerKind.Drag);
DropHint = loc.Format(OperatingSystem.IsMacOS() ? "home.drop_hint_macos" : OperatingSystem.IsLinux() ? "home.drop_hint_linux" : "home.drop_hint", drag is null ? "—" : GestureText.Modifiers(drag.Modifiers));
store.HistoryChanged += OnHistoryChanged;
+ VisibleHistory = new FilteredList<HistoryItemViewModel>(History,
+ item => [item.Title, item.Subtitle]);
Reload();
}
@@ -146,12 +148,20 @@ public sealed partial class HomePageViewModel : ObservableObject, IDisposable
public ObservableCollection<HistoryItemViewModel> History { get; } = [];
+ /// <summary>The history entries visible after the search query is applied.</summary>
+ public FilteredList<HistoryItemViewModel> VisibleHistory { get; }
+
+ [ObservableProperty] private string _search = "";
+
+ partial void OnSearchChanged(string value) => VisibleHistory.Query = value;
+
[ObservableProperty] private bool _isEmpty;
private void Reload()
{
History.Clear();
- foreach (var entry in _store.History.Take(40))
+ var max = Math.Clamp(_store.Settings.MaxHistory, 50, 2000);
+ foreach (var entry in _store.History.Take(max))
History.Add(new HistoryItemViewModel(entry, _loc, _platform, _conversions));
IsEmpty = History.Count == 0;
}
diff --git a/src/Filee.App/Views/Pages/HomePage.axaml b/src/Filee.App/Views/Pages/HomePage.axaml
index 65434a92..2c4bf843 100644
--- a/src/Filee.App/Views/Pages/HomePage.axaml
+++ b/src/Filee.App/Views/Pages/HomePage.axaml
@@ -74,8 +74,14 @@
<Button DockPanel.Dock="Right" Classes="ghost" Content="{DynamicResource home.clear_history}" Command="{Binding ClearHistoryCommand}" />
<TextBlock Classes="h2" VerticalAlignment="Center" Text="{DynamicResource home.recent}" />
</DockPanel>
+ <TextBox Classes="search" Text="{Binding Search}" Watermark="{DynamicResource common.search}"
+ IsVisible="{Binding !IsEmpty}">
+ <TextBox.InnerLeftContent>
+ <PathIcon Width="14" Height="14" Margin="10,0,0,0" Data="{StaticResource Icon.Search}" Foreground="{DynamicResource TextSecondaryBrush}" />
+ </TextBox.InnerLeftContent>
+ </TextBox>
<TextBlock Classes="muted" Text="{DynamicResource home.recent_empty}" IsVisible="{Binding IsEmpty}" />
- <ItemsControl ItemsSource="{Binding History}">
+ <ItemsControl ItemsSource="{Binding VisibleHistory}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Spacing="8" />