Skip to content

Commit a8bcda2

Browse files
committed
Implement the search functionality in PluginStore Page
1 parent 65fcbbc commit a8bcda2

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed

Flow.Launcher/SettingWindow.xaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -878,8 +878,7 @@
878878
</StackPanel>
879879
</ScrollViewer>
880880
</TabItem>
881-
<TabItem
882-
KeyDown="OnPluginSettingKeydown">
881+
<TabItem KeyDown="OnPluginSettingKeydown">
883882
<TabItem.Header>
884883
<Grid>
885884
<Grid.ColumnDefinitions>
@@ -925,10 +924,10 @@
925924
HorizontalAlignment="Right"
926925
DockPanel.Dock="Right"
927926
FontSize="14"
928-
Text=""
929-
TextAlignment="Left"
927+
KeyDown="PluginFilterTxb_OnKeyDown"
930928
LostFocus="RefreshPluginListEventHandler"
931-
KeyDown="PluginFilterTxb_OnKeyDown">
929+
Text=""
930+
TextAlignment="Left">
932931
<TextBox.Style>
933932
<Style BasedOn="{StaticResource DefaultTextBoxStyle}" TargetType="TextBox">
934933
<Style.Resources>
@@ -1344,6 +1343,9 @@
13441343
HorizontalAlignment="Right"
13451344
DockPanel.Dock="Right"
13461345
FontSize="14"
1346+
Name="pluginStoreFilterTxb"
1347+
KeyDown="PluginFilterTxb_OnKeyDown"
1348+
LostFocus="RefreshPluginStoreEventHandler"
13471349
Text=""
13481350
TextAlignment="Left">
13491351
<TextBox.Style>

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ private void OnLoaded(object sender, RoutedEventArgs e)
5959
hwndTarget.RenderMode = RenderMode.SoftwareOnly;
6060

6161
pluginListView = (CollectionView)CollectionViewSource.GetDefaultView(pluginList.ItemsSource);
62-
pluginListView.Filter = PluginFilter;
62+
pluginListView.Filter = PluginListFilter;
63+
64+
pluginStoreView = (CollectionView)CollectionViewSource.GetDefaultView(StoreListBox.ItemsSource);
65+
pluginStoreView.Filter = PluginStoreFilter;
6366
}
6467

6568
private void OnAutoStartupChecked(object sender, RoutedEventArgs e)
@@ -381,8 +384,9 @@ private void Window_StateChanged(object sender, EventArgs e)
381384
}
382385

383386
private CollectionView pluginListView;
387+
private CollectionView pluginStoreView;
384388

385-
private bool PluginFilter(object item)
389+
private bool PluginListFilter(object item)
386390
{
387391
if (string.IsNullOrEmpty(pluginFilterTxb.Text))
388392
return true;
@@ -392,22 +396,48 @@ private bool PluginFilter(object item)
392396
}
393397
return false;
394398
}
399+
private bool PluginStoreFilter(object item)
400+
{
401+
if (string.IsNullOrEmpty(pluginStoreFilterTxb.Text))
402+
return true;
403+
if (item is UserPlugin model)
404+
{
405+
return StringMatcher.FuzzySearch(pluginStoreFilterTxb.Text, model.Name).IsSearchPrecisionScoreMet();
406+
}
407+
return false;
408+
}
395409

396-
private string lastSearch = "";
410+
private string lastPluginListSearch = "";
411+
private string lastPluginStoreSearch = "";
397412

398413
private void RefreshPluginListEventHandler(object sender, RoutedEventArgs e)
399414
{
400-
if (pluginFilterTxb.Text != lastSearch)
415+
if (pluginFilterTxb.Text != lastPluginListSearch)
401416
{
402-
lastSearch = pluginFilterTxb.Text;
417+
lastPluginListSearch = pluginFilterTxb.Text;
403418
pluginListView.Refresh();
404419
}
405420
}
421+
422+
private void RefreshPluginStoreEventHandler(object sender, RoutedEventArgs e)
423+
{
424+
if (pluginStoreFilterTxb.Text != lastPluginStoreSearch)
425+
{
426+
lastPluginStoreSearch = pluginStoreFilterTxb.Text;
427+
pluginStoreView.Refresh();
428+
}
429+
}
406430
private void PluginFilterTxb_OnKeyDown(object sender, KeyEventArgs e)
407431
{
408432
if (e.Key == Key.Enter)
409433
RefreshPluginListEventHandler(sender, e);
410434
}
435+
436+
private void PluginStoreFilterTxb_OnKeyDown(object sender, KeyEventArgs e)
437+
{
438+
if (e.Key == Key.Enter)
439+
RefreshPluginListEventHandler(sender, e);
440+
}
411441
private void OnPluginSettingKeydown(object sender, KeyEventArgs e)
412442
{
413443
if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control && e.Key == Key.F)

0 commit comments

Comments
 (0)