misc: revert high-contrast Theme feat.

This commit is contained in:
Zhang Dian
2024-12-02 16:52:03 +08:00
parent bac851a87f
commit 62935eee6a
123 changed files with 240 additions and 1046 deletions

View File

@@ -1,10 +1,8 @@
using System;
using System.Collections.ObjectModel;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Styling;
using CommunityToolkit.Mvvm.ComponentModel;
namespace Semi.Avalonia.Demo.Views;
@@ -13,7 +11,6 @@ public partial class MainView : UserControl
public MainView()
{
InitializeComponent();
this.DataContext = new MainViewModel();
}
private void ToggleButton_OnIsCheckedChanged(object sender, RoutedEventArgs e)
@@ -41,36 +38,4 @@ public partial class MainView : UserControl
var launcher = top.Launcher;
await launcher.LaunchUriAsync(new Uri("https://docs.irihi.tech/semi"));
}
}
public partial class MainViewModel: ObservableObject
{
public ObservableCollection<ThemeItem> Themes { get; } = new()
{
new ThemeItem("Light", ThemeVariant.Light),
new ThemeItem("Dark", ThemeVariant.Dark),
new ThemeItem("Aquatic", SemiTheme.Aquatic),
new ThemeItem("Desert", SemiTheme.Desert),
new ThemeItem("Dust", SemiTheme.Dust),
new ThemeItem("NightSky", SemiTheme.NightSky),
};
[ObservableProperty] private ThemeItem? _selectedTheme;
partial void OnSelectedThemeChanged(ThemeItem? oldValue, ThemeItem? newValue)
{
if (newValue is null) return;
var app = Application.Current;
if (app is not null)
{
app.RequestedThemeVariant = newValue.Theme;
}
}
}
public class ThemeItem(string name, ThemeVariant theme)
{
public string Name { get; set; } = name;
public ThemeVariant Theme { get; set; } = theme;
}