update category strings to constants

This commit is contained in:
Jeremy 2022-10-28 22:44:06 +11:00
parent ad3fd4a049
commit 8dd24de0c0
3 changed files with 20 additions and 33 deletions

View file

@ -1,13 +1,8 @@
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;
using Flow.Launcher.Core.Resource;
using Flow.Launcher.ViewModel;
namespace Flow.Launcher.Converters
{
@ -18,23 +13,17 @@ namespace Flow.Launcher.Converters
var ID = value.ToString();
switch(ID)
{
case "NewRelease":
case PluginStoreItemViewModel.NewRelease:
return InternationalizationManager.Instance.GetTranslation("pluginStore_NewRelease");
break;
case "RecentlyUpdated":
case PluginStoreItemViewModel.RecentlyUpdated:
return InternationalizationManager.Instance.GetTranslation("pluginStore_RecentlyUpdated");
break;
case "None":
case PluginStoreItemViewModel.None:
return InternationalizationManager.Instance.GetTranslation("pluginStore_None");
break;
case "installed":
case PluginStoreItemViewModel.Installed:
return InternationalizationManager.Instance.GetTranslation("pluginStore_Installed");
break;
default:
return ID;
break;
}
}

View file

@ -1,5 +1,4 @@
using System;
using System.Diagnostics;
using Flow.Launcher.Core.ExternalPlugins;
using Flow.Launcher.Core.Plugin;
using Flow.Launcher.Plugin;
@ -27,23 +26,29 @@ namespace Flow.Launcher.ViewModel
public string IcoPath => _plugin.IcoPath;
public bool LabelInstalled => PluginManager.GetPluginForId(_plugin.ID) != null;
public bool LabelUpdate => LabelInstalled && _plugin.Version != PluginManager.GetPluginForId(_plugin.ID).Metadata.Version;
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";
public string Category
{
get
{
string category = "None";
string category = None;
if (DateTime.Now - _plugin.LatestReleaseDate < TimeSpan.FromDays(7))
{
category = "RecentlyUpdated";
category = RecentlyUpdated;
}
if (DateTime.Now - _plugin.DateAdded < TimeSpan.FromDays(7))
{
category = "NewRelease";
category = NewRelease;
}
if (PluginManager.GetPluginForId(_plugin.ID) != null)
{
category = "Installed";
category = Installed;
}
return category;

View file

@ -1,16 +1,11 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Flow.Launcher.Core;
@ -24,8 +19,6 @@ 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
{
@ -296,10 +289,10 @@ namespace Flow.Launcher.ViewModel
private IList<PluginStoreItemViewModel> LabelMaker(IList<UserPlugin> list)
{
return list.Select(p=>new PluginStoreItemViewModel(p))
.OrderByDescending(p => p.Category == "NewRelease")
.ThenByDescending(p=>p.Category == "RecentlyUpdated")
.ThenByDescending(p => p.Category == "None")
.ThenByDescending(p => p.Category == "Installed")
.OrderByDescending(p => p.Category == PluginStoreItemViewModel.NewRelease)
.ThenByDescending(p=>p.Category == PluginStoreItemViewModel.RecentlyUpdated)
.ThenByDescending(p => p.Category == PluginStoreItemViewModel.None)
.ThenByDescending(p => p.Category == PluginStoreItemViewModel.Installed)
.ToList();
}