Skip to content

Commit

Permalink
Tag Support Added To Themes
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor committed Oct 24, 2023
1 parent 665012c commit e5ffb49
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using SMR = Sucrose.Memory.Readonly;
using SPMI = Sucrose.Portal.Manage.Internal;
using SPVCLC = Sucrose.Portal.Views.Controls.LibraryCard;
using SSSHT = Sucrose.Shared.Space.Helper.Tags;
using SSTHI = Sucrose.Shared.Theme.Helper.Info;

namespace Sucrose.Portal.Views.Pages.Library
Expand Down Expand Up @@ -64,9 +65,9 @@ private async Task AddThemes(string Search, int Page)
{
SSTHI Info = SSTHI.ReadJson(Path.Combine(SMMM.LibraryLocation, Theme, SMR.SucroseInfo));

string Tags = string.Join($"{SMR.SearchSplit}", Info.Tags.Where(Tag => !string.IsNullOrEmpty(Tag))).ToLowerInvariant();
string Description = Info.Description.ToLowerInvariant();
string Title = Info.Title.ToLowerInvariant();
string Tags = SSSHT.Join(Info.Tags);

if (Tags.Contains(Search) || Title.Contains(Search) || Description.Contains(Search))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using SPVCSC = Sucrose.Portal.Views.Controls.StoreCard;
using SSRER = Sucrose.Shared.Resources.Extension.Resources;
using SSSHC = Sucrose.Shared.Space.Helper.Clean;
using SSSHT = Sucrose.Shared.Space.Helper.Tags;
using SSSIC = Sucrose.Shared.Store.Interface.Category;
using SSSIR = Sucrose.Shared.Store.Interface.Root;
using SSSIW = Sucrose.Shared.Store.Interface.Wallpaper;
Expand Down Expand Up @@ -205,9 +206,9 @@ private bool SearchControl(string Search, string Theme, string Title)
{
SSTHI Info = SSTHI.ReadJson(InfoPath);

string Tags = SSSHT.Join(Info.Tags);
Title = Info.Title.ToLowerInvariant();
string Description = Info.Description.ToLowerInvariant();
string Tags = string.Join($"{SMR.SearchSplit}", Info.Tags.Where(Tag => !string.IsNullOrEmpty(Tag))).ToLowerInvariant();

if (Tags.Contains(Search) || Title.Contains(Search) || Description.Contains(Search))
{
Expand Down
19 changes: 19 additions & 0 deletions src/Shared/Sucrose.Shared.Space/Helper/Tags.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using SMR = Sucrose.Memory.Readonly;

namespace Sucrose.Shared.Space.Helper
{
internal static class Tags
{
public static string Join(string[] Tags)
{
if (Tags == null || !Tags.Any())
{
return string.Empty;
}
else
{
return string.Join($"{SMR.SearchSplit}", Tags.Where(Tag => !string.IsNullOrEmpty(Tag))).ToLowerInvariant();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Helper\Reset.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helper\Graphic.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helper\Management.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helper\Tags.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helper\Versionly.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helper\Watchdog.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helper\Virtual.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/Shared/Sucrose.Shared.Theme/Helper/Info.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal partial class Info
public string Source { get; set; }

[JsonProperty("Tags", Required = Required.Default)]
public string[] Tags { get; set; } = Array.Empty<string>();
public string[] Tags { get; set; }

[JsonProperty("Arguments", Required = Required.AllowNull)]
public string Arguments { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions src/Shared/Sucrose.Shared.Zip/Helper/Archive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ public static SSDECT Check(string Archive)
return SSDECT.InvalidContact;
}

if (Info.Tags.Any() && (Info.Tags.Count() < 1 || Info.Tags.Count() > 5))
if (Info.Tags != null && Info.Tags.Any() && (Info.Tags.Count() < 1 || Info.Tags.Count() > 5))
{
return SSDECT.Tags;
}

if (Info.Tags.Any() && Info.Tags.Any(Tag => Tag.Length is < 1 or > 20))
if (Info.Tags != null && Info.Tags.Any() && Info.Tags.Any(Tag => Tag.Length is < 1 or > 20))
{
return SSDECT.InvalidTags;
}
Expand Down

0 comments on commit e5ffb49

Please sign in to comment.