2022-10-08 06:57:41 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using Flow.Launcher.Core.ExternalPlugins;
|
|
|
|
|
|
using Flow.Launcher.Core.Plugin;
|
|
|
|
|
|
using Flow.Launcher.Plugin;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Flow.Launcher.ViewModel
|
|
|
|
|
|
{
|
|
|
|
|
|
public class PluginStoreItemViewModel : BaseModel
|
|
|
|
|
|
{
|
|
|
|
|
|
public PluginStoreItemViewModel(UserPlugin plugin)
|
|
|
|
|
|
{
|
|
|
|
|
|
_plugin = plugin;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private UserPlugin _plugin;
|
|
|
|
|
|
|
2022-10-08 09:32:42 +00:00
|
|
|
|
public string ID => _plugin.ID;
|
2022-10-08 06:57:41 +00:00
|
|
|
|
public string Name => _plugin.Name;
|
|
|
|
|
|
public string Description => _plugin.Description;
|
|
|
|
|
|
public string Author => _plugin.Author;
|
2022-10-08 09:32:42 +00:00
|
|
|
|
public string Version => _plugin.Version;
|
2022-10-08 09:27:17 +00:00
|
|
|
|
public string Language => _plugin.Language;
|
2022-10-08 09:32:42 +00:00
|
|
|
|
public string Website => _plugin.Website;
|
2022-10-08 09:27:17 +00:00
|
|
|
|
public string UrlDownload => _plugin.UrlDownload;
|
|
|
|
|
|
public string UrlSourceCode => _plugin.UrlSourceCode;
|
2022-10-08 09:32:42 +00:00
|
|
|
|
public string IcoPath => _plugin.IcoPath;
|
2022-10-11 12:37:43 +00:00
|
|
|
|
|
2022-10-08 06:57:41 +00:00
|
|
|
|
public bool LabelInstalled => PluginManager.GetPluginForId(_plugin.ID) != null;
|
2023-03-13 07:05:00 +00:00
|
|
|
|
public bool LabelUpdate => LabelInstalled && VersionConvertor(_plugin.Version) > VersionConvertor(PluginManager.GetPluginForId(_plugin.ID).Metadata.Version);
|
2022-10-28 11:44:06 +00:00
|
|
|
|
|
|
|
|
|
|
internal const string None = "None";
|
|
|
|
|
|
internal const string RecentlyUpdated = "RecentlyUpdated";
|
|
|
|
|
|
internal const string NewRelease = "NewRelease";
|
|
|
|
|
|
internal const string Installed = "Installed";
|
|
|
|
|
|
|
2023-03-13 07:05:00 +00:00
|
|
|
|
public Version VersionConvertor(string version)
|
|
|
|
|
|
{
|
|
|
|
|
|
Version ResultVersion = new Version(version);
|
|
|
|
|
|
return ResultVersion;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-10-23 07:16:26 +00:00
|
|
|
|
public string Category
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
2022-10-28 11:44:06 +00:00
|
|
|
|
string category = None;
|
2022-10-23 07:16:26 +00:00
|
|
|
|
if (DateTime.Now - _plugin.LatestReleaseDate < TimeSpan.FromDays(7))
|
|
|
|
|
|
{
|
2022-10-28 11:44:06 +00:00
|
|
|
|
category = RecentlyUpdated;
|
2022-10-23 07:16:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
if (DateTime.Now - _plugin.DateAdded < TimeSpan.FromDays(7))
|
|
|
|
|
|
{
|
2022-10-28 11:44:06 +00:00
|
|
|
|
category = NewRelease;
|
2022-10-23 07:16:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
if (PluginManager.GetPluginForId(_plugin.ID) != null)
|
|
|
|
|
|
{
|
2022-10-28 11:44:06 +00:00
|
|
|
|
category = Installed;
|
2022-10-23 07:16:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return category;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-10-08 06:57:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|