diff --git a/Bloxstrap/Models/Supporter.cs b/Bloxstrap/Models/Supporter.cs new file mode 100644 index 00000000..6732a262 --- /dev/null +++ b/Bloxstrap/Models/Supporter.cs @@ -0,0 +1,13 @@ +namespace Bloxstrap.Models +{ + public class Supporter + { + [JsonPropertyName("imageAsset")] + public string ImageAsset { get; set; } = null!; + + [JsonPropertyName("name")] + public string Name { get; set; } = null!; + + public string Image => $"https://raw.githubusercontent.com/bloxstraplabs/config/main/assets/{ImageAsset}"; + } +} diff --git a/Bloxstrap/Models/SupporterData.cs b/Bloxstrap/Models/SupporterData.cs new file mode 100644 index 00000000..f9ef2fea --- /dev/null +++ b/Bloxstrap/Models/SupporterData.cs @@ -0,0 +1,11 @@ +namespace Bloxstrap.Models +{ + public class SupporterData + { + [JsonPropertyName("columns")] + public int Columns { get; set; } + + [JsonPropertyName("supporters")] + public List Supporters { get; set; } = null!; + } +} diff --git a/Bloxstrap/Resources/Strings.Designer.cs b/Bloxstrap/Resources/Strings.Designer.cs index 0b754caf..c6473c18 100644 --- a/Bloxstrap/Resources/Strings.Designer.cs +++ b/Bloxstrap/Resources/Strings.Designer.cs @@ -69,6 +69,24 @@ public static string About_Licenses_Title { } } + /// + /// Looks up a localized string similar to These are the people currently supporting Bloxstrap through [Ko-fi]({0}). A massive thank you to everyone here!. + /// + public static string About_Supporters_Description { + get { + return ResourceManager.GetString("About.Supporters.Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Supporters. + /// + public static string About_Supporters_Title { + get { + return ResourceManager.GetString("About.Supporters.Title", resourceCulture); + } + } + /// /// Looks up a localized string similar to About Bloxstrap. /// @@ -449,6 +467,15 @@ public static string Common_ImportJson { } } + /// + /// Looks up a localized string similar to Loading, please wait.... + /// + public static string Common_Loading { + get { + return ResourceManager.GetString("Common.Loading", resourceCulture); + } + } + /// /// Looks up a localized string similar to Miscellaneous. /// @@ -485,6 +512,15 @@ public static string Common_Navigation_Next { } } + /// + /// Looks up a localized string similar to Could not load data because of a network error.. + /// + public static string Common_NetworkError { + get { + return ResourceManager.GetString("Common.NetworkError", resourceCulture); + } + } + /// /// Looks up a localized string similar to New. /// diff --git a/Bloxstrap/Resources/Strings.resx b/Bloxstrap/Resources/Strings.resx index 8f12701b..686331e8 100644 --- a/Bloxstrap/Resources/Strings.resx +++ b/Bloxstrap/Resources/Strings.resx @@ -1150,4 +1150,16 @@ Are you sure you want to continue? Please read the following help information, which will open in your web browser when you close this dialog. + + Could not load data because of a network error. + + + Loading, please wait... + + + Supporters + + + These are the people currently supporting Bloxstrap through [Ko-fi]({0}). A massive thank you to everyone here! + \ No newline at end of file diff --git a/Bloxstrap/UI/Elements/About/Pages/AboutPage.xaml b/Bloxstrap/UI/Elements/About/Pages/AboutPage.xaml index 8e169998..d95400f1 100644 --- a/Bloxstrap/UI/Elements/About/Pages/AboutPage.xaml +++ b/Bloxstrap/UI/Elements/About/Pages/AboutPage.xaml @@ -3,7 +3,9 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:enums="clr-namespace:Bloxstrap.Enums" xmlns:models="clr-namespace:Bloxstrap.UI.ViewModels" + xmlns:dmodels="clr-namespace:Bloxstrap.UI.ViewModels.About" xmlns:controls="clr-namespace:Bloxstrap.UI.Elements.Controls" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" xmlns:resources="clr-namespace:Bloxstrap.Resources" @@ -11,7 +13,13 @@ d:DesignHeight="1500" d:DesignWidth="800" Title="AboutPage" Scrollable="True"> + + + + + + @@ -73,6 +81,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Bloxstrap/UI/Elements/About/Pages/AboutPage.xaml.cs b/Bloxstrap/UI/Elements/About/Pages/AboutPage.xaml.cs index 32942589..d6a1bdc3 100644 --- a/Bloxstrap/UI/Elements/About/Pages/AboutPage.xaml.cs +++ b/Bloxstrap/UI/Elements/About/Pages/AboutPage.xaml.cs @@ -1,4 +1,4 @@ -using Bloxstrap.UI.ViewModels.Settings; +using Bloxstrap.UI.ViewModels.About; namespace Bloxstrap.UI.Elements.About.Pages { diff --git a/Bloxstrap/UI/Elements/Dialogs/LaunchMenuDialog.xaml b/Bloxstrap/UI/Elements/Dialogs/LaunchMenuDialog.xaml index 04e89852..9ed5a5eb 100644 --- a/Bloxstrap/UI/Elements/Dialogs/LaunchMenuDialog.xaml +++ b/Bloxstrap/UI/Elements/Dialogs/LaunchMenuDialog.xaml @@ -53,7 +53,7 @@ - + diff --git a/Bloxstrap/UI/ViewModels/About/AboutViewModel.cs b/Bloxstrap/UI/ViewModels/About/AboutViewModel.cs new file mode 100644 index 00000000..6eda400e --- /dev/null +++ b/Bloxstrap/UI/ViewModels/About/AboutViewModel.cs @@ -0,0 +1,63 @@ +using System.Windows; + +namespace Bloxstrap.UI.ViewModels.About +{ + public class AboutViewModel : NotifyPropertyChangedViewModel + { + private SupporterData? _supporterData; + + public string Version => string.Format(Strings.Menu_About_Version, App.Version); + + public BuildMetadataAttribute BuildMetadata => App.BuildMetadata; + + public string BuildTimestamp => BuildMetadata.Timestamp.ToFriendlyString(); + public string BuildCommitHashUrl => $"https://github.com/{App.ProjectRepository}/commit/{BuildMetadata.CommitHash}"; + + public Visibility BuildInformationVisibility => App.IsProductionBuild ? Visibility.Collapsed : Visibility.Visible; + public Visibility BuildCommitVisibility => App.IsActionBuild ? Visibility.Visible : Visibility.Collapsed; + + public List Supporters => _supporterData?.Supporters ?? Enumerable.Empty().ToList(); + + public int SupporterColumns => _supporterData?.Columns ?? 0; + + public GenericTriState SupportersLoadedState { get; set; } = GenericTriState.Unknown; + + public string SupportersLoadError { get; set; } = ""; + + public AboutViewModel() + { + // this will cause momentary freezes only when ran under the debugger + LoadSupporterData(); + } + + public async void LoadSupporterData() + { + const string LOG_IDENT = "AboutViewModel::LoadSupporterData"; + + try + { + _supporterData = await Http.GetJson("https://raw.githubusercontent.com/bloxstraplabs/config/main/supporters.json"); + } + catch (Exception ex) + { + App.Logger.WriteLine(LOG_IDENT, "Could not load supporter data"); + App.Logger.WriteException(LOG_IDENT, ex); + + SupportersLoadedState = GenericTriState.Failed; + SupportersLoadError = ex.Message; + + OnPropertyChanged(nameof(SupportersLoadError)); + } + + if (_supporterData is not null) + { + SupportersLoadedState = GenericTriState.Successful; + + OnPropertyChanged(nameof(Supporters)); + OnPropertyChanged(nameof(SupporterColumns)); + } + + OnPropertyChanged(nameof(SupportersLoadedState)); + } + } +} diff --git a/Bloxstrap/UI/ViewModels/Settings/AboutViewModel.cs b/Bloxstrap/UI/ViewModels/Settings/AboutViewModel.cs deleted file mode 100644 index 5cfeb0d8..00000000 --- a/Bloxstrap/UI/ViewModels/Settings/AboutViewModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System.Windows; - -namespace Bloxstrap.UI.ViewModels.Settings -{ - public class AboutViewModel - { - public string Version => string.Format(Strings.Menu_About_Version, App.Version); - - public BuildMetadataAttribute BuildMetadata => App.BuildMetadata; - - public string BuildTimestamp => BuildMetadata.Timestamp.ToFriendlyString(); - public string BuildCommitHashUrl => $"https://github.com/{App.ProjectRepository}/commit/{BuildMetadata.CommitHash}"; - - public Visibility BuildInformationVisibility => App.IsProductionBuild ? Visibility.Collapsed : Visibility.Visible; - public Visibility BuildCommitVisibility => App.IsActionBuild ? Visibility.Visible : Visibility.Collapsed; - } -}