mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add Install/New/Updated Label in plugin store
This commit is contained in:
parent
f8cef1d928
commit
26b14c4b5f
5 changed files with 137 additions and 10 deletions
|
|
@ -1,4 +1,6 @@
|
|||
namespace Flow.Launcher.Core.ExternalPlugins
|
||||
using System;
|
||||
|
||||
namespace Flow.Launcher.Core.ExternalPlugins
|
||||
{
|
||||
public record UserPlugin
|
||||
{
|
||||
|
|
@ -12,5 +14,12 @@
|
|||
public string UrlDownload { get; set; }
|
||||
public string UrlSourceCode { get; set; }
|
||||
public string IcoPath { get; set; }
|
||||
public DateTime LatestReleaseDate { get; set; }
|
||||
public DateTime DateAdded { get; set; }
|
||||
|
||||
/* Label Data for Plugin Store */
|
||||
public bool LabelNew { get; set; }
|
||||
public bool LabelInstalled { get; set; }
|
||||
public bool LabelUpdated { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
43
Flow.Launcher/Converters/BoolToVisibilityConverter.cs
Normal file
43
Flow.Launcher/Converters/BoolToVisibilityConverter.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Flow.Launcher.Converters
|
||||
{
|
||||
public class BoolToVisibilityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, System.Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (parameter != null)
|
||||
{
|
||||
if (value is true)
|
||||
{
|
||||
return Visibility.Collapsed;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return Visibility.Visible;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (value is true)
|
||||
{
|
||||
return Visibility.Visible;
|
||||
}
|
||||
|
||||
else {
|
||||
return Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, System.Type targetType, object parameter, CultureInfo culture) => throw new System.InvalidOperationException();
|
||||
}
|
||||
}
|
||||
|
|
@ -88,6 +88,14 @@
|
|||
<system:String x:Key="pluginStore">Plugin Store</system:String>
|
||||
<system:String x:Key="refresh">Refresh</system:String>
|
||||
<system:String x:Key="install">Install</system:String>
|
||||
<system:String x:Key="LabelInstalled">Installed</system:String>
|
||||
<system:String x:Key="LabelInstalledToolTip">Plug-in already installed</system:String>
|
||||
<system:String x:Key="LabelNew">New</system:String>
|
||||
<system:String x:Key="LabelNewToolTip">This is a newly registered plug-in in 7 days</system:String>
|
||||
<system:String x:Key="LabelUpdated">Updated</system:String>
|
||||
<system:String x:Key="LabelUpdatedToolTip">This plug-in has been updated within the last 5 days</system:String>
|
||||
|
||||
|
||||
|
||||
<!-- Setting Theme -->
|
||||
<system:String x:Key="theme">Theme</system:String>
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
<Window.Resources>
|
||||
<converters:BorderClipConverter x:Key="BorderClipConverter" />
|
||||
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
|
||||
<CollectionViewSource x:Key="SortedFonts" Source="{Binding Source={x:Static Fonts.SystemFontFamilies}}">
|
||||
<CollectionViewSource.SortDescriptions>
|
||||
<scm:SortDescription PropertyName="Source" />
|
||||
|
|
@ -1513,11 +1514,27 @@
|
|||
VerticalAlignment="Top"
|
||||
Background="#f14551"
|
||||
CornerRadius="4"
|
||||
Visibility="Collapsed">
|
||||
ToolTip="{DynamicResource LabelNewToolTip}"
|
||||
Visibility="{Binding LabelNew, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<TextBlock
|
||||
FontSize="11"
|
||||
Foreground="White"
|
||||
Text="New" />
|
||||
Foreground="{DynamicResource Color01B}"
|
||||
Text="{DynamicResource LabelNew}" />
|
||||
</Border>
|
||||
<Border
|
||||
x:Name="LabelUpdated"
|
||||
Margin="0,10,8,0"
|
||||
Padding="6,2,6,2"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Background="#45BD59"
|
||||
CornerRadius="4"
|
||||
ToolTip="{DynamicResource LabelUpdatedToolTip}"
|
||||
Visibility="{Binding LabelUpdated, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<TextBlock
|
||||
FontSize="11"
|
||||
Foreground="{DynamicResource Color01B}"
|
||||
Text="{DynamicResource LabelUpdated}" />
|
||||
</Border>
|
||||
<Border
|
||||
x:Name="Labelinstalled"
|
||||
|
|
@ -1527,11 +1544,12 @@
|
|||
VerticalAlignment="Top"
|
||||
Background="{DynamicResource ToggleSwitchFillOn}"
|
||||
CornerRadius="4"
|
||||
Visibility="Collapsed">
|
||||
ToolTip="{DynamicResource LabelInstalledToolTip}"
|
||||
Visibility="{Binding LabelInstalled, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<TextBlock
|
||||
FontSize="11"
|
||||
Foreground="White"
|
||||
Text="Installed" />
|
||||
Foreground="{DynamicResource Color01B}"
|
||||
Text="{DynamicResource LabelInstalled}" />
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
||||
|
|
@ -1670,7 +1688,9 @@
|
|||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
Click="OnExternalPluginInstallClick"
|
||||
Content="{DynamicResource install}" />
|
||||
Content="{DynamicResource install}"
|
||||
Visibility="{Binding LabelInstalled, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter='!'}" />
|
||||
<!-- Hide Install Button when installed Item -->
|
||||
</Border>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Flow.Launcher.Core;
|
||||
|
|
@ -19,6 +22,8 @@ using Flow.Launcher.Infrastructure.Storage;
|
|||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using Flow.Launcher.Plugin;
|
||||
using Flow.Launcher.Plugin.SharedModels;
|
||||
using Microsoft.FSharp.Data.UnitSystems.SI.UnitNames;
|
||||
using Windows.Management.Deployment.Preview;
|
||||
|
||||
namespace Flow.Launcher.ViewModel
|
||||
{
|
||||
|
|
@ -241,7 +246,8 @@ namespace Flow.Launcher.ViewModel
|
|||
|
||||
#region plugin
|
||||
|
||||
public static string Plugin => @"https://github.com/Flow-Launcher/Flow.Launcher.PluginsManifest";
|
||||
//public static string Plugin => @"https://github.com/Flow-Launcher/Flow.Launcher.PluginsManifest";
|
||||
public static string Plugin => @"https://raw.githubusercontent.com/Flow-Launcher/Flow.Launcher.PluginsManifest/plugin_api_v2/plugins.json";
|
||||
public PluginViewModel SelectedPlugin { get; set; }
|
||||
|
||||
public IList<PluginViewModel> PluginViewModels
|
||||
|
|
@ -261,10 +267,51 @@ namespace Flow.Launcher.ViewModel
|
|||
{
|
||||
get
|
||||
{
|
||||
return PluginsManifest.UserPlugins;
|
||||
return LabelMaker(PluginsManifest.UserPlugins);
|
||||
}
|
||||
}
|
||||
|
||||
private IList<UserPlugin> LabelMaker(IList<UserPlugin> list)
|
||||
{
|
||||
foreach (UserPlugin item in list)
|
||||
{
|
||||
item.LabelNew = false;
|
||||
item.LabelInstalled = false;
|
||||
item.LabelUpdated = false;
|
||||
|
||||
foreach (var vm in PluginViewModels)
|
||||
{
|
||||
|
||||
var id = vm.PluginPair.Metadata.ID;
|
||||
if (item.ID == vm.PluginPair.Metadata.ID) // Add Installed Label
|
||||
{
|
||||
item.LabelInstalled = true;
|
||||
}
|
||||
|
||||
TimeSpan UpdatedDay = DateTime.Now.Subtract(item.LatestReleaseDate);
|
||||
int LastUpdated = UpdatedDay.Days;
|
||||
|
||||
if (LastUpdated <= 5) // Add Updated Label
|
||||
{
|
||||
item.LabelUpdated = true;
|
||||
}
|
||||
}
|
||||
TimeSpan AddedDay = DateTime.Now.Subtract(item.DateAdded);
|
||||
int DateAdded = AddedDay.Days;
|
||||
if (DateAdded <= 7)
|
||||
{
|
||||
|
||||
//item.LabelNew = true; // Add New Label
|
||||
//item.LabelUpdated = false; // Hide Updated Label when Added New Label. New and Update doesn't show both same time.
|
||||
}
|
||||
}
|
||||
|
||||
// New first, Updated second. Installed to bottom of list.
|
||||
list = list.OrderByDescending(x => x.LabelNew).OrderByDescending(x => x.LabelUpdated).ThenBy(y => y.LabelInstalled).ToList();
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public Control SettingProvider
|
||||
{
|
||||
get
|
||||
|
|
|
|||
Loading…
Reference in a new issue