Skip to content

Commit e154b12

Browse files
committed
- Add GroupName
- Adjust Labels
1 parent b9bc700 commit e154b12

File tree

7 files changed

+106
-25
lines changed

7 files changed

+106
-25
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
using System.Windows.Controls;
9+
using System.Windows.Data;
10+
using Flow.Launcher.Core.Resource;
11+
12+
namespace Flow.Launcher.Converters
13+
{
14+
public class TextConverter : IValueConverter
15+
{
16+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
17+
{
18+
var ID = value.ToString();
19+
switch(ID)
20+
{
21+
case "NewRelease":
22+
return InternationalizationManager.Instance.GetTranslation("pluginStore_NewRelease");
23+
break;
24+
case "RecentlyUpdated":
25+
return InternationalizationManager.Instance.GetTranslation("pluginStore_RecentlyUpdated");
26+
break;
27+
case "None":
28+
return InternationalizationManager.Instance.GetTranslation("pluginStore_None");
29+
break;
30+
case "installed":
31+
return InternationalizationManager.Instance.GetTranslation("pluginStore_Installed");
32+
break;
33+
default:
34+
return ID;
35+
break;
36+
}
37+
38+
39+
}
40+
41+
public object ConvertBack(object value, System.Type targetType, object parameter, CultureInfo culture) => throw new System.InvalidOperationException();
42+
}
43+
}

Flow.Launcher/Languages/en.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@
8787

8888
<!-- Setting Plugin Store -->
8989
<system:String x:Key="pluginStore">Plugin Store</system:String>
90+
<system:String x:Key="pluginStore_NewRelease">New Release</system:String>
91+
<system:String x:Key="pluginStore_RecentlyUpdated">Recently Updated</system:String>
92+
<system:String x:Key="pluginStore_None">Plugins</system:String>
93+
<system:String x:Key="pluginStore_Installed">Installed</system:String>
9094
<system:String x:Key="refresh">Refresh</system:String>
9195
<system:String x:Key="installbtn">Install</system:String>
9296
<system:String x:Key="uninstallbtn">Uninstall</system:String>
@@ -95,7 +99,6 @@
9599
<system:String x:Key="LabelInstalledToolTip">Plug-in already installed</system:String>
96100
<system:String x:Key="LabelNew">New Version</system:String>
97101
<system:String x:Key="LabelNewToolTip">This plug-in has been updated within the last 7 days</system:String>
98-
<system:String x:Key="LabelUpdate">Update</system:String>
99102
<system:String x:Key="LabelUpdateToolTip">New Update is Available</system:String>
100103

101104

Flow.Launcher/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@
177177
AllowDrop="True"
178178
Background="Transparent"
179179
PreviewDragOver="OnPreviewDragOver"
180+
PreviewKeyUp="QueryTextBox_KeyUp"
180181
Style="{DynamicResource QueryBoxStyle}"
181182
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
182-
PreviewKeyUp="QueryTextBox_KeyUp"
183183
Visibility="Visible">
184184
<TextBox.CommandBindings>
185185
<CommandBinding Command="ApplicationCommands.Copy" Executed="OnCopy" />

Flow.Launcher/SettingWindow.xaml

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<Window.Resources>
4242
<converters:BorderClipConverter x:Key="BorderClipConverter" />
4343
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
44+
<converters:TextConverter x:Key="TextConverter" />
4445
<CollectionViewSource x:Key="SortedFonts" Source="{Binding Source={x:Static Fonts.SystemFontFamilies}}">
4546
<CollectionViewSource.SortDescriptions>
4647
<scm:SortDescription PropertyName="Source" />
@@ -1463,6 +1464,32 @@
14631464
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
14641465
SelectionMode="Single"
14651466
Style="{DynamicResource StoreListStyle}">
1467+
<ListBox.GroupStyle>
1468+
<GroupStyle>
1469+
<GroupStyle.ContainerStyle>
1470+
<Style TargetType="{x:Type GroupItem}">
1471+
<Setter Property="Template">
1472+
<Setter.Value>
1473+
<ControlTemplate>
1474+
<Grid>
1475+
<StackPanel Orientation="Vertical">
1476+
<TextBlock
1477+
Margin="0,0,0,10"
1478+
VerticalAlignment="Top"
1479+
FontSize="16"
1480+
FontWeight="Bold"
1481+
Text="{Binding Name, Converter={StaticResource TextConverter}}" />
1482+
<ItemsPresenter />
1483+
</StackPanel>
1484+
1485+
</Grid>
1486+
</ControlTemplate>
1487+
</Setter.Value>
1488+
</Setter>
1489+
</Style>
1490+
</GroupStyle.ContainerStyle>
1491+
</GroupStyle>
1492+
</ListBox.GroupStyle>
14661493
<ListBox.ItemsPanel>
14671494
<ItemsPanelTemplate>
14681495
<UniformGrid
@@ -1518,36 +1545,17 @@
15181545
Margin="0,0,2,0"
15191546
HorizontalAlignment="Right"
15201547
Orientation="Horizontal">
1521-
<Border
1522-
x:Name="LabelNew"
1523-
Margin="0,10,8,0"
1524-
Padding="6,2,6,2"
1525-
HorizontalAlignment="Right"
1526-
VerticalAlignment="Top"
1527-
Background="#f14551"
1528-
CornerRadius="4"
1529-
ToolTip="{DynamicResource LabelNewToolTip}"
1530-
Visibility="{Binding LabelNew, Converter={StaticResource BoolToVisibilityConverter}}">
1531-
<TextBlock
1532-
FontSize="11"
1533-
Foreground="{DynamicResource Color01B}"
1534-
Text="{DynamicResource LabelNew}" />
1535-
</Border>
15361548
<Border
15371549
x:Name="LabelUpdate"
1550+
Height="12"
15381551
Margin="0,10,8,0"
15391552
Padding="6,2,6,2"
15401553
HorizontalAlignment="Right"
15411554
VerticalAlignment="Top"
15421555
Background="#45BD59"
1543-
CornerRadius="4"
1556+
CornerRadius="36"
15441557
ToolTip="{DynamicResource LabelUpdateToolTip}"
1545-
Visibility="{Binding LabelUpdate, Converter={StaticResource BoolToVisibilityConverter}}">
1546-
<TextBlock
1547-
FontSize="11"
1548-
Foreground="{DynamicResource Color01B}"
1549-
Text="{DynamicResource LabelUpdate}" />
1550-
</Border>
1558+
Visibility="{Binding LabelUpdate, Converter={StaticResource BoolToVisibilityConverter}}" />
15511559
<Border
15521560
x:Name="Labelinstalled"
15531561
Margin="0,10,8,0"

Flow.Launcher/SettingWindow.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public SettingWindow(IPublicAPI api, SettingWindowViewModel viewModel)
4747
API = api;
4848
InitializePosition();
4949
InitializeComponent();
50+
51+
CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(StoreListBox.ItemsSource);
52+
PropertyGroupDescription groupDescription = new PropertyGroupDescription("Category");
53+
view.GroupDescriptions.Add(groupDescription);
5054
}
5155

5256
#region General

Flow.Launcher/ViewModel/PluginStoreItemViewModel.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,27 @@ public PluginStoreItemViewModel(UserPlugin plugin)
2929
public bool LabelInstalled => PluginManager.GetPluginForId(_plugin.ID) != null;
3030
public bool LabelUpdate => LabelInstalled && _plugin.Version != PluginManager.GetPluginForId(_plugin.ID).Metadata.Version;
3131
public bool LabelNew => DateTime.Now - _plugin.LatestReleaseDate < TimeSpan.FromDays(7) && !LabelUpdate; // Show Update Label show first.
32+
33+
public string Category
34+
{
35+
get
36+
{
37+
string category = "None";
38+
if (DateTime.Now - _plugin.LatestReleaseDate < TimeSpan.FromDays(7))
39+
{
40+
category = "RecentlyUpdated";
41+
}
42+
if (DateTime.Now - _plugin.DateAdded < TimeSpan.FromDays(7))
43+
{
44+
category = "NewRelease";
45+
}
46+
if (PluginManager.GetPluginForId(_plugin.ID) != null)
47+
{
48+
category = "Installed";
49+
}
50+
51+
return category;
52+
}
53+
}
3254
}
3355
}

Flow.Launcher/ViewModel/SettingWindowViewModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
using System.Collections;
33
using System.Collections.Generic;
44
using System.Diagnostics;
5+
using System.Globalization;
56
using System.IO;
67
using System.Linq;
78
using System.Net;
89
using System.Threading.Tasks;
910
using System.Windows;
1011
using System.Windows.Controls;
12+
using System.Windows.Data;
1113
using System.Windows.Documents;
1214
using System.Windows.Media;
1315
using System.Windows.Media.Imaging;
@@ -326,7 +328,6 @@ public async Task RefreshExternalPluginsAsync()
326328
}
327329

328330

329-
330331
#endregion
331332

332333
#region theme

0 commit comments

Comments
 (0)