-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d4ba04
commit 8d68576
Showing
9 changed files
with
224 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.