JT
2 years ago
committed by
GitHub
14 changed files with 216 additions and 67 deletions
@ -0,0 +1,12 @@
|
||||
using System.Threading.Tasks; |
||||
using Refit; |
||||
using StabilityMatrix.Models.Api; |
||||
|
||||
namespace StabilityMatrix.Api; |
||||
|
||||
[Headers("User-Agent: StabilityMatrix")] |
||||
public interface IGithubApi |
||||
{ |
||||
[Get("/repos/{username}/{repository}/releases/latest")] |
||||
Task<GithubRelease> GetLatestRelease(string username, string repository); |
||||
} |
@ -0,0 +1,9 @@
|
||||
using System.Text.Json.Serialization; |
||||
|
||||
namespace StabilityMatrix.Models.Api; |
||||
|
||||
public class GithubRelease |
||||
{ |
||||
[JsonPropertyName("tag_name")] |
||||
public string TagName { get; set; } |
||||
} |
@ -0,0 +1,50 @@
|
||||
using System.Windows; |
||||
using CommunityToolkit.Mvvm.ComponentModel; |
||||
using CommunityToolkit.Mvvm.Input; |
||||
using StabilityMatrix.Helper; |
||||
using Wpf.Ui.Appearance; |
||||
|
||||
namespace StabilityMatrix.ViewModels; |
||||
|
||||
public partial class MainWindowViewModel : ObservableObject |
||||
{ |
||||
private readonly ISettingsManager settingsManager; |
||||
|
||||
public MainWindowViewModel(ISettingsManager settingsManager) |
||||
{ |
||||
this.settingsManager = settingsManager; |
||||
} |
||||
|
||||
[ObservableProperty] |
||||
private Visibility advancedModeVisibility; |
||||
|
||||
[ObservableProperty] |
||||
private Visibility simpleModeVisibility; |
||||
|
||||
public void OnLoaded() |
||||
{ |
||||
SetTheme(); |
||||
GoAdvancedMode(); |
||||
} |
||||
|
||||
[RelayCommand] |
||||
private void GoAdvancedMode() |
||||
{ |
||||
AdvancedModeVisibility = Visibility.Visible; |
||||
SimpleModeVisibility = Visibility.Hidden; |
||||
} |
||||
|
||||
private void SetTheme() |
||||
{ |
||||
var theme = settingsManager.Settings.Theme; |
||||
switch (theme) |
||||
{ |
||||
case "Dark": |
||||
Theme.Apply(ThemeType.Dark); |
||||
break; |
||||
case "Light": |
||||
Theme.Apply(ThemeType.Light); |
||||
break; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue