Flow.Launcher/Flow.Launcher/ViewModel/PluginStoreItemViewModel.cs

59 lines
1.9 KiB
C#
Raw Normal View History

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;
public string Language => _plugin.Language;
2022-10-08 09:32:42 +00:00
public string Website => _plugin.Website;
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-08 06:57:41 +00:00
public bool LabelInstalled => PluginManager.GetPluginForId(_plugin.ID) != null;
2022-10-28 11:44:06 +00:00
public bool LabelUpdate => LabelInstalled && _plugin.Version != PluginManager.GetPluginForId(_plugin.ID).Metadata.Version;
internal const string None = "None";
internal const string RecentlyUpdated = "RecentlyUpdated";
internal const string NewRelease = "NewRelease";
internal const string Installed = "Installed";
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
}
}