Skip to content

Commit

Permalink
Add monthly supporter credits
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzaboxer committed Aug 31, 2024
1 parent 3d4ba04 commit 8d68576
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 19 deletions.
13 changes: 13 additions & 0 deletions Bloxstrap/Models/Supporter.cs
Original file line number Diff line number Diff line change
@@ -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}";
}
}
11 changes: 11 additions & 0 deletions Bloxstrap/Models/SupporterData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Bloxstrap.Models
{
public class SupporterData
{
[JsonPropertyName("columns")]
public int Columns { get; set; }

[JsonPropertyName("supporters")]
public List<Supporter> Supporters { get; set; } = null!;
}
}
36 changes: 36 additions & 0 deletions Bloxstrap/Resources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Bloxstrap/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1150,4 +1150,16 @@ Are you sure you want to continue?</value>
<data name="Dialog.PlayerError.HelpInformation" xml:space="preserve">
<value>Please read the following help information, which will open in your web browser when you close this dialog.</value>
</data>
<data name="Common.NetworkError" xml:space="preserve">
<value>Could not load data because of a network error.</value>
</data>
<data name="Common.Loading" xml:space="preserve">
<value>Loading, please wait...</value>
</data>
<data name="About.Supporters.Title" xml:space="preserve">
<value>Supporters</value>
</data>
<data name="About.Supporters.Description" xml:space="preserve">
<value>These are the people currently supporting Bloxstrap through [Ko-fi]({0}). A massive thank you to everyone here!</value>
</data>
</root>
87 changes: 87 additions & 0 deletions Bloxstrap/UI/Elements/About/Pages/AboutPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@
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"
mc:Ignorable="d"
d:DesignHeight="1500" d:DesignWidth="800"
Title="AboutPage"
Scrollable="True">
<!--d:DataContext="{d:DesignInstance dmodels:AboutViewModel, IsDesignTimeCreatable=True}"-->

<StackPanel Margin="0,0,14,14">
<StackPanel.Resources>
<FrameworkElement x:Key="ProxyElement" DataContext="{Binding}"/>
</StackPanel.Resources>

<Grid Margin="0,0,0,24" HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand Down Expand Up @@ -73,6 +81,85 @@
</Grid>
</StackPanel>

<TextBlock Text="{x:Static resources:Strings.About_Supporters_Title}" FontWeight="Medium" FontSize="20" Margin="0,16,0,0" />
<controls:MarkdownTextBlock MarkdownText="{Binding Source={x:Static resources:Strings.About_Supporters_Description}, Converter={StaticResource StringFormatConverter}, ConverterParameter='https://ko-fi.com/boxerpizza'}" TextWrapping="Wrap" Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
<Grid Margin="0,8,0,0">
<Grid.Style>
<Style TargetType="Grid">
<Style.Triggers>
<DataTrigger Binding="{Binding SupportersLoadedState, Mode=OneWay}" Value="{x:Static enums:GenericTriState.Unknown}">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
<Setter Property="Visibility" Value="Collapsed" />
</Style>
</Grid.Style>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ui:ProgressRing Grid.Column="0" IsIndeterminate="True" />
<TextBlock Grid.Column="1" Margin="16,0,0,0" Text="{x:Static resources:Strings.Common_Loading}" VerticalAlignment="Center" />
</Grid>
<Grid Margin="0,8,0,0">
<Grid.Style>
<Style TargetType="Grid">
<Style.Triggers>
<DataTrigger Binding="{Binding SupportersLoadedState, Mode=OneWay}" Value="{x:Static enums:GenericTriState.Failed}">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
<Setter Property="Visibility" Value="Collapsed" />
</Style>
</Grid.Style>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Source="pack://application:,,,/Resources/MessageBox/Error.png" Width="60" Height="60" RenderOptions.BitmapScalingMode="HighQuality" />
<StackPanel Grid.Column="1" Margin="16,0,0,0" VerticalAlignment="Center">
<TextBlock Text="{x:Static resources:Strings.Common_NetworkError}" />
<TextBlock Text="{Binding SupportersLoadError, Mode=OneWay}" />
</StackPanel>
</Grid>
<ListView ItemsSource="{Binding Supporters, Mode=OneWay}" Margin="0,8,0,0" ScrollViewer.CanContentScroll="False">
<ListView.Style>
<Style TargetType="ListView" BasedOn="{StaticResource {x:Type ListView}}">
<Style.Triggers>
<DataTrigger Binding="{Binding SupportersLoadedState, Mode=OneWay}" Value="{x:Static enums:GenericTriState.Successful}">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
<Setter Property="Visibility" Value="Collapsed" />
</Style>
</ListView.Style>
<ListView.ItemTemplate>
<DataTemplate>
<ui:Card Padding="8">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<Ellipse Grid.Column="0" Height="32" Width="32" VerticalAlignment="Center">
<Ellipse.Fill>
<ImageBrush ImageSource="{Binding Image, IsAsync=True}" />
</Ellipse.Fill>
</Ellipse>

<TextBlock Grid.Column="1" Margin="8,0,2,0" VerticalAlignment="Center" Text="{Binding Name}" />
</Grid>
</ui:Card>
</DataTemplate>
</ListView.ItemTemplate>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="{Binding SupporterColumns}" Margin="-4" />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>

<TextBlock Text="{x:Static resources:Strings.Menu_About_Contributors}" FontWeight="Medium" FontSize="20" Margin="0,16,0,0" />
<TextBlock Text="{x:Static resources:Strings.Menu_About_Contributors_Description}" TextWrapping="Wrap" Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
<Grid Margin="0,8,0,0">
Expand Down
2 changes: 1 addition & 1 deletion Bloxstrap/UI/Elements/About/Pages/AboutPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Bloxstrap.UI.ViewModels.Settings;
using Bloxstrap.UI.ViewModels.About;

namespace Bloxstrap.UI.Elements.About.Pages
{
Expand Down
2 changes: 1 addition & 1 deletion Bloxstrap/UI/Elements/Dialogs/LaunchMenuDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

<StackPanel Grid.Row="1" HorizontalAlignment="Center">
<ui:Hyperlink Icon="QuestionCircle48" Content="About Bloxstrap" Margin="0,0,0,8" Command="{Binding LaunchAboutCommand, Mode=OneTime}" />
<ui:Hyperlink Icon="WindowNew16" Content="Support us on Ko-fi!" NavigateUri="https://ko-fi.com/boxerpizza" />
<ui:Hyperlink Icon="Heart48" Content="Support us on Ko-fi!" NavigateUri="https://ko-fi.com/boxerpizza" />
</StackPanel>
</Grid>

Expand Down
63 changes: 63 additions & 0 deletions Bloxstrap/UI/ViewModels/About/AboutViewModel.cs
Original file line number Diff line number Diff line change
@@ -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<Supporter> Supporters => _supporterData?.Supporters ?? Enumerable.Empty<Supporter>().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<SupporterData>("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));
}
}
}
17 changes: 0 additions & 17 deletions Bloxstrap/UI/ViewModels/Settings/AboutViewModel.cs

This file was deleted.

0 comments on commit 8d68576

Please sign in to comment.