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 e5ffb49 commit f4785f3
Show file tree
Hide file tree
Showing 28 changed files with 137 additions and 17 deletions.
6 changes: 6 additions & 0 deletions src/Portal/Sucrose.Portal/Views/Controls/ThemeDelete.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@
<TextBlock x:Name="ThemeVersion" Text="{DynamicResource Portal.ThemeDelete.ThemeVersion}" TextWrapping="WrapWithOverflow" FontSize="16" Margin="0 12 0 0" Foreground="{DynamicResource TextFillColorPrimaryBrush}" />
<TextBlock x:Name="ThemeVersionText" Text="{DynamicResource Portal.ThemeDelete.ThemeVersionText}" TextWrapping="WrapWithOverflow" FontSize="14" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />

<TextBlock x:Name="ThemeTags" Text="{DynamicResource Portal.ThemeDelete.ThemeTags}" TextWrapping="WrapWithOverflow" FontSize="16" Margin="0 12 0 0" Foreground="{DynamicResource TextFillColorPrimaryBrush}" />
<TextBlock x:Name="ThemeTagsText" Text="{DynamicResource Portal.ThemeDelete.ThemeTagsText}" TextWrapping="WrapWithOverflow" FontSize="14" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />

<TextBlock x:Name="ThemeCreate" Text="{DynamicResource Portal.ThemeDelete.ThemeCreate}" TextWrapping="WrapWithOverflow" FontSize="16" Margin="0 12 0 0" Foreground="{DynamicResource TextFillColorPrimaryBrush}" />
<TextBlock x:Name="ThemeCreateDate" Text="{DynamicResource Portal.ThemeDelete.ThemeCreateDate}" TextWrapping="WrapWithOverflow" FontSize="14" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />

<TextBlock x:Name="ThemeModify" Text="{DynamicResource Portal.ThemeDelete.ThemeModify}" TextWrapping="WrapWithOverflow" FontSize="16" Margin="0 12 0 0" Foreground="{DynamicResource TextFillColorPrimaryBrush}" />
<TextBlock x:Name="ThemeModifyDate" Text="{DynamicResource Portal.ThemeDelete.ThemeModifyDate}" TextWrapping="WrapWithOverflow" FontSize="14" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />
</StackPanel>
</ui:ContentDialog>
9 changes: 9 additions & 0 deletions src/Portal/Sucrose.Portal/Views/Controls/ThemeDelete.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
using SHC = Skylark.Helper.Culture;
using SHN = Skylark.Helper.Numeric;
using SMMM = Sucrose.Manager.Manage.Manager;
using SMR = Sucrose.Memory.Readonly;
using SPEIL = Sucrose.Portal.Extension.ImageLoader;
using SPMI = Sucrose.Portal.Manage.Internal;
using SSESSE = Skylark.Standard.Extension.Storage.StorageExtension;
using SSRER = Sucrose.Shared.Resources.Extension.Resources;
using SSSHL = Sucrose.Shared.Space.Helper.Live;
using SSSHS = Sucrose.Shared.Space.Helper.Size;
using SSSHT = Sucrose.Shared.Space.Helper.Tags;
using SSSSS = Skylark.Struct.Storage.StorageStruct;
using SSTHI = Sucrose.Shared.Theme.Helper.Info;

Expand Down Expand Up @@ -51,10 +54,16 @@ private void ContentDialog_Loaded(object sender, RoutedEventArgs e)

ThemeVersionText.Text = $"{Info.Version} ({Info.AppVersion})";

ThemeTagsText.Text = SSSHT.Join(Info.Tags, ", ", SSRER.GetValue("Portal", "ThemeDelete", "ThemeTagsText"));

DateTime CreationTime = Directory.GetCreationTime(Theme);

ThemeCreateDate.Text = CreationTime.ToString(SHC.CurrentUI);

DateTime ModificationTime = Directory.GetLastWriteTime(Path.Combine(Theme, SMR.SucroseInfo));

ThemeModifyDate.Text = ModificationTime.ToString(SHC.CurrentUI);

string ImagePath = Path.Combine(Theme, Info.Thumbnail);

if (File.Exists(ImagePath))
Expand Down
5 changes: 4 additions & 1 deletion src/Portal/Sucrose.Portal/Views/Controls/ThemeEdit.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
<ui:TextBox x:Name="ThemeAuthor" PlaceholderText="{DynamicResource Portal.ThemeEdit.ThemeAuthor.Hint}" Margin="0 3 0 0" MaxLength="50" AcceptsReturn="False" AcceptsTab="False" />

<TextBlock Text="{DynamicResource Portal.ThemeEdit.ThemeContact}" Margin="0 12 0 0" TextWrapping="WrapWithOverflow" FontSize="16" Foreground="{DynamicResource TextFillColorPrimaryBrush}" />
<ui:TextBox x:Name="ThemeContact" PlaceholderText="{DynamicResource Portal.ThemeEdit.ThemeContact.Hint}" Margin="0 3 0 0" MaxLength="250" AcceptsReturn="False" AcceptsTab="False" Cursor="IBeam" />
<ui:TextBox x:Name="ThemeContact" PlaceholderText="{DynamicResource Portal.ThemeEdit.ThemeContact.Hint}" Margin="0 3 0 0" MaxLength="250" AcceptsReturn="False" AcceptsTab="False" />

<TextBlock Text="{DynamicResource Portal.ThemeEdit.ThemeTags}" Margin="0 12 0 0" TextWrapping="WrapWithOverflow" FontSize="16" Foreground="{DynamicResource TextFillColorPrimaryBrush}" />
<ui:TextBox x:Name="ThemeTags" PlaceholderText="{DynamicResource Portal.ThemeEdit.ThemeTags.Hint}" Margin="0 3 0 0" MaxLength="104" AcceptsReturn="False" AcceptsTab="False" />

<StackPanel x:Name="Arguments">
<TextBlock Margin="0 12 0 0" Text="{DynamicResource Portal.ThemeEdit.ThemeArguments}" TextWrapping="WrapWithOverflow" FontSize="16" Foreground="{DynamicResource TextFillColorPrimaryBrush}" />
Expand Down
61 changes: 55 additions & 6 deletions src/Portal/Sucrose.Portal/Views/Controls/ThemeEdit.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using SPEIL = Sucrose.Portal.Extension.ImageLoader;
using SPMI = Sucrose.Portal.Manage.Internal;
using SSDEWT = Sucrose.Shared.Dependency.Enum.WallpaperType;
using SSSHT = Sucrose.Shared.Space.Helper.Tags;
using SSSHV = Sucrose.Shared.Space.Helper.Versionly;
using SSTHI = Sucrose.Shared.Theme.Helper.Info;
using SSTHV = Sucrose.Shared.Theme.Helper.Various;
Expand Down Expand Up @@ -33,6 +34,7 @@ private void ContentDialog_Loaded(object sender, RoutedEventArgs e)
ThemeContact.Text = Info.Contact;
ThemeArguments.Text = Info.Arguments;
ThemeDescription.Text = Info.Description;
ThemeTags.Text = SSSHT.Join(Info.Tags, ", ", string.Empty);

if (Info.Type != SSDEWT.Application)
{
Expand Down Expand Up @@ -81,21 +83,68 @@ protected override void OnButtonClick(ContentDialogButton Button)
}
else
{
Info.Title = ThemeTitle.Text;
Info.Author = ThemeAuthor.Text;
Info.Contact = ThemeContact.Text;
Info.Description = ThemeDescription.Text;
Info.Version = SSSHV.Increment(Info.Version);
if (string.IsNullOrEmpty(ThemeTags.Text))
{
Info.Tags = null;
}
else
{
if (ThemeTags.Text.Contains(','))
{
Info.Tags = ThemeTags.Text.Split(',').Select(Tag => Tag.TrimStart().TrimEnd()).ToArray();

if (Info.Tags.Count() is < 1 or > 5)
{
ThemeTags.Focus();
return;
}
else if (Info.Tags.Any(Tag => Tag.Length is < 1 or > 20 || string.IsNullOrWhiteSpace(Tag)))
{
ThemeTags.Focus();
return;
}
}
else
{
if (ThemeTags.Text.Length is < 1 or > 20 || string.IsNullOrWhiteSpace(ThemeTags.Text))
{
ThemeTags.Focus();
return;
}
else
{
Info.Tags = new[]
{
ThemeTags.Text.TrimStart().TrimEnd()
};
}
}
}

if (string.IsNullOrEmpty(ThemeArguments.Text))
{
Info.Arguments = null;
}
else
{
Info.Arguments = ThemeArguments.Text;
if (ThemeArguments.Text.Length is > 250 || string.IsNullOrWhiteSpace(ThemeArguments.Text))
{
ThemeTags.Focus();
return;
}
else
{
Info.Arguments = ThemeArguments.Text;
}
}


Info.Title = ThemeTitle.Text;
Info.Author = ThemeAuthor.Text;
Info.Contact = ThemeContact.Text;
Info.Description = ThemeDescription.Text;
Info.Version = SSSHV.Increment(Info.Version);

SSTHI.WriteJson(Path.Combine(Theme, SMR.SucroseInfo), Info);
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/Portal/Sucrose.Portal/Views/Controls/ThemeReview.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<TextBlock x:Name="ThemeVersion" Text="{DynamicResource Portal.ThemeReview.ThemeVersion}" TextWrapping="WrapWithOverflow" FontSize="16" Margin="0 12 0 0" Foreground="{DynamicResource TextFillColorPrimaryBrush}" />
<TextBlock x:Name="ThemeVersionText" Text="{DynamicResource Portal.ThemeReview.ThemeVersionText}" TextWrapping="WrapWithOverflow" FontSize="14" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />

<TextBlock x:Name="ThemeTags" Text="{DynamicResource Portal.ThemeReview.ThemeTags}" TextWrapping="WrapWithOverflow" FontSize="16" Margin="0 12 0 0" Foreground="{DynamicResource TextFillColorPrimaryBrush}" />
<TextBlock x:Name="ThemeTagsText" Text="{DynamicResource Portal.ThemeReview.ThemeTagsText}" TextWrapping="WrapWithOverflow" FontSize="14" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />

<TextBlock x:Name="ThemeCreate" Text="{DynamicResource Portal.ThemeReview.ThemeCreate}" TextWrapping="WrapWithOverflow" FontSize="16" Margin="0 12 0 0" Foreground="{DynamicResource TextFillColorPrimaryBrush}" />
<TextBlock x:Name="ThemeCreateDate" Text="{DynamicResource Portal.ThemeReview.ThemeCreateDate}" TextWrapping="WrapWithOverflow" FontSize="14" Foreground="{DynamicResource TextFillColorSecondaryBrush}" />

Expand Down
4 changes: 4 additions & 0 deletions src/Portal/Sucrose.Portal/Views/Controls/ThemeReview.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
using SPEIL = Sucrose.Portal.Extension.ImageLoader;
using SPMI = Sucrose.Portal.Manage.Internal;
using SSESSE = Skylark.Standard.Extension.Storage.StorageExtension;
using SSRER = Sucrose.Shared.Resources.Extension.Resources;
using SSSHS = Sucrose.Shared.Space.Helper.Size;
using SSSHT = Sucrose.Shared.Space.Helper.Tags;
using SSSSS = Skylark.Struct.Storage.StorageStruct;
using SSTHI = Sucrose.Shared.Theme.Helper.Info;
using SSTHV = Sucrose.Shared.Theme.Helper.Various;
Expand Down Expand Up @@ -51,6 +53,8 @@ private void ContentDialog_Loaded(object sender, RoutedEventArgs e)

ThemeVersionText.Text = $"{Info.Version} ({Info.AppVersion})";

ThemeTagsText.Text = SSSHT.Join(Info.Tags, ", ", SSRER.GetValue("Portal", "ThemeReview", "ThemeTagsText"));

DateTime CreationTime = Directory.GetCreationTime(Theme);

ThemeCreateDate.Text = CreationTime.ToString(SHC.CurrentUI);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ private async Task AddThemes(string Search, int Page)
{
SSTHI Info = SSTHI.ReadJson(Path.Combine(SMMM.LibraryLocation, Theme, SMR.SucroseInfo));

string Tags = SSSHT.Join(Info.Tags, SMR.SearchSplit, string.Empty);
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 @@ -206,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 = SSSHT.Join(Info.Tags, SMR.SearchSplit, string.Empty);

if (Tags.Contains(Search) || Title.Contains(Search) || Description.Contains(Search))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<system:String x:Key="Portal.ThemeDelete.ThemeSizeTotal">0 b</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeVersion">Version</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeVersionText">0.0.0.0 (0.0.0.0)</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeTags">Schlagwörter</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeTagsText">Keine</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeCreate">Erstellt</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeCreateDate">Unbekannt</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeModify">Änderung</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeModifyDate">Unbekannt</system:String>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<system:String x:Key="Portal.ThemeDelete.ThemeSizeTotal">0 b</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeVersion">Version</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeVersionText">0.0.0.0 (0.0.0.0)</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeTags">Tags</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeTagsText">None</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeCreate">Creation</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeCreateDate">Unknown</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeModify">Modification</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeModifyDate">Unknown</system:String>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<system:String x:Key="Portal.ThemeDelete.ThemeSizeTotal">0 b</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeVersion">Versión</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeVersionText">0.0.0.0 (0.0.0.0)</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeTags">Etiquetas</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeTagsText">Ninguna</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeCreate">Creación</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeCreateDate">Desconocido</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeModify">Modificación</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeModifyDate">Desconocido</system:String>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<system:String x:Key="Portal.ThemeDelete.ThemeSizeTotal">0 b</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeVersion">Version</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeVersionText">0.0.0.0 (0.0.0.0)</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeTags">Mots-Clés</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeTagsText">Aucun</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeCreate">Création</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeCreateDate">Inconnue</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeModify">Modification</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeModifyDate">Inconnue</system:String>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<system:String x:Key="Portal.ThemeDelete.ThemeSizeTotal">0 b</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeVersion">Wersja</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeVersionText">0.0.0.0 (0.0.0.0)</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeTags">Tagi</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeTagsText">Brak</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeCreate">Utworzenie</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeCreateDate">Nieznane</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeModify">Modyfikacji</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeModifyDate">Nieznana</system:String>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
<system:String x:Key="Portal.ThemeDelete.ThemeSizeTotal">0 b</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeVersion">Sürüm</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeVersionText">0.0.0.0 (0.0.0.0)</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeTags">Etiketler</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeTagsText">Yok</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeCreate">Oluşturulma</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeCreateDate">Bilinmiyor</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeModify">Değiştirilme</system:String>
<system:String x:Key="Portal.ThemeDelete.ThemeModifyDate">Bilinmiyor</system:String>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
<system:String x:Key="Portal.ThemeEdit.ThemeDescription">Beschreibung</system:String>
<system:String x:Key="Portal.ThemeEdit.ThemeAuthor">Autor</system:String>
<system:String x:Key="Portal.ThemeEdit.ThemeContact">Kontakt</system:String>
<system:String x:Key="Portal.ThemeEdit.ThemeTags">Schlagwörter</system:String>
<system:String x:Key="Portal.ThemeEdit.ThemeArguments">Argumente</system:String>

<system:String x:Key="Portal.ThemeEdit.ThemeTitle.Hint">Bitte geben Sie einen gültigen Titel ein</system:String>
<system:String x:Key="Portal.ThemeEdit.ThemeDescription.Hint">Bitte geben Sie eine gültige Beschreibung ein</system:String>
<system:String x:Key="Portal.ThemeEdit.ThemeAuthor.Hint">Bitte geben Sie einen gültigen Autorennamen ein</system:String>
<system:String x:Key="Portal.ThemeEdit.ThemeContact.Hint">Bitte geben Sie eine gültige Kontaktadresse ein</system:String>
<system:String x:Key="Portal.ThemeEdit.ThemeTags.Hint">Bitte geben Sie gültige Themen-Tags ein</system:String>
<system:String x:Key="Portal.ThemeEdit.ThemeArguments.Hint">Bitte geben Sie gültige Anwendungsargumente ein</system:String>
</ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
<system:String x:Key="Portal.ThemeEdit.ThemeDescription">Description</system:String>
<system:String x:Key="Portal.ThemeEdit.ThemeAuthor">Author</system:String>
<system:String x:Key="Portal.ThemeEdit.ThemeContact">Contact</system:String>
<system:String x:Key="Portal.ThemeEdit.ThemeTags">Tags</system:String>
<system:String x:Key="Portal.ThemeEdit.ThemeArguments">Arguments</system:String>

<system:String x:Key="Portal.ThemeEdit.ThemeTitle.Hint">Please enter a valid title</system:String>
<system:String x:Key="Portal.ThemeEdit.ThemeDescription.Hint">Please enter a valid description</system:String>
<system:String x:Key="Portal.ThemeEdit.ThemeAuthor.Hint">Please enter a valid author name</system:String>
<system:String x:Key="Portal.ThemeEdit.ThemeContact.Hint">Please enter a valid contact address</system:String>
<system:String x:Key="Portal.ThemeEdit.ThemeTags.Hint">Please enter valid theme tags</system:String>
<system:String x:Key="Portal.ThemeEdit.ThemeArguments.Hint">Please enter valid application arguments</system:String>
</ResourceDictionary>
Loading

0 comments on commit f4785f3

Please sign in to comment.