settings_re4

This commit is contained in:
lincube
2026-03-13 22:20:12 +08:00
parent 3b3f060f33
commit 5fdaa2539b
89 changed files with 5778 additions and 192 deletions

View File

@@ -0,0 +1,37 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:LanMountainDesktop.Controls"
xmlns:fi="using:FluentIcons.Avalonia"
x:Class="LanMountainDesktop.Controls.SettingsOptionCard"
x:Name="Root">
<Border Classes="settings-option-card">
<Grid RowDefinitions="Auto,Auto"
RowSpacing="12">
<Grid ColumnDefinitions="Auto,*,Auto"
ColumnSpacing="14">
<Border x:Name="IconHost"
Classes="settings-option-card-icon-host">
<fi:SymbolIcon x:Name="CardIcon"
Classes="icon-m" />
</Border>
<StackPanel Grid.Column="1"
Spacing="4"
VerticalAlignment="Center">
<TextBlock x:Name="TitleTextBlock"
Classes="settings-item-label" />
<TextBlock x:Name="DescriptionTextBlock"
Classes="settings-item-description" />
</StackPanel>
<ContentPresenter x:Name="ActionContentHost"
Grid.Column="2"
VerticalAlignment="Center" />
</Grid>
<ContentPresenter x:Name="DetailsContentHost"
Grid.Row="1"
Margin="54,0,0,0" />
</Grid>
</Border>
</UserControl>

View File

@@ -0,0 +1,112 @@
using Avalonia;
using Avalonia.Controls;
using FluentIcons.Common;
namespace LanMountainDesktop.Controls;
public partial class SettingsOptionCard : UserControl
{
public static readonly StyledProperty<string?> IconKeyProperty =
AvaloniaProperty.Register<SettingsOptionCard, string?>(nameof(IconKey), "Settings");
public static readonly StyledProperty<string?> TitleProperty =
AvaloniaProperty.Register<SettingsOptionCard, string?>(nameof(Title));
public static readonly StyledProperty<string?> DescriptionProperty =
AvaloniaProperty.Register<SettingsOptionCard, string?>(nameof(Description));
public static readonly StyledProperty<object?> ActionContentProperty =
AvaloniaProperty.Register<SettingsOptionCard, object?>(nameof(ActionContent));
public static readonly StyledProperty<object?> DetailsContentProperty =
AvaloniaProperty.Register<SettingsOptionCard, object?>(nameof(DetailsContent));
public SettingsOptionCard()
{
InitializeComponent();
RefreshVisualState();
}
public string? IconKey
{
get => GetValue(IconKeyProperty);
set => SetValue(IconKeyProperty, value);
}
public string? Title
{
get => GetValue(TitleProperty);
set => SetValue(TitleProperty, value);
}
public string? Description
{
get => GetValue(DescriptionProperty);
set => SetValue(DescriptionProperty, value);
}
public object? ActionContent
{
get => GetValue(ActionContentProperty);
set => SetValue(ActionContentProperty, value);
}
public object? DetailsContent
{
get => GetValue(DetailsContentProperty);
set => SetValue(DetailsContentProperty, value);
}
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);
if (change.Property == IconKeyProperty ||
change.Property == TitleProperty ||
change.Property == DescriptionProperty ||
change.Property == ActionContentProperty ||
change.Property == DetailsContentProperty)
{
RefreshVisualState();
}
}
private void RefreshVisualState()
{
if (CardIcon is null ||
IconHost is null ||
TitleTextBlock is null ||
DescriptionTextBlock is null ||
ActionContentHost is null ||
DetailsContentHost is null)
{
return;
}
CardIcon.Symbol = MapIcon(IconKey);
IconHost.IsVisible = !string.IsNullOrWhiteSpace(IconKey);
TitleTextBlock.Text = Title ?? string.Empty;
DescriptionTextBlock.Text = Description ?? string.Empty;
DescriptionTextBlock.IsVisible = !string.IsNullOrWhiteSpace(Description);
ActionContentHost.Content = ActionContent;
ActionContentHost.IsVisible = ActionContent is not null;
DetailsContentHost.Content = DetailsContent;
DetailsContentHost.IsVisible = DetailsContent is not null;
}
private static Symbol MapIcon(string? iconKey)
{
return iconKey?.Trim() switch
{
"DesignIdeas" => Symbol.Color,
"GridDots" => Symbol.GridDots,
"PuzzlePiece" => Symbol.PuzzlePiece,
"Info" => Symbol.Info,
"ArrowSync" => Symbol.ArrowSync,
_ => Symbol.Settings
};
}
}

View File

@@ -0,0 +1,33 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:LanMountainDesktop.Controls"
xmlns:fi="using:FluentIcons.Avalonia"
x:Class="LanMountainDesktop.Controls.SettingsSectionCard"
x:Name="Root">
<Border Classes="settings-section-card">
<Grid RowDefinitions="Auto,Auto"
RowSpacing="16">
<Grid ColumnDefinitions="Auto,*"
ColumnSpacing="14">
<Border x:Name="IconHost"
Classes="settings-section-card-icon-host">
<fi:SymbolIcon x:Name="CardIcon"
Classes="icon-l" />
</Border>
<StackPanel Grid.Column="1"
Spacing="4">
<TextBlock x:Name="TitleTextBlock"
Classes="settings-card-header"
Margin="0" />
<TextBlock x:Name="DescriptionTextBlock"
Classes="settings-card-description"
Margin="0" />
</StackPanel>
</Grid>
<ContentPresenter x:Name="CardContentHost"
Grid.Row="1" />
</Grid>
</Border>
</UserControl>

View File

@@ -0,0 +1,97 @@
using Avalonia;
using Avalonia.Controls;
using FluentIcons.Common;
namespace LanMountainDesktop.Controls;
public partial class SettingsSectionCard : UserControl
{
public static readonly StyledProperty<string?> IconKeyProperty =
AvaloniaProperty.Register<SettingsSectionCard, string?>(nameof(IconKey), "Settings");
public static readonly StyledProperty<string?> TitleProperty =
AvaloniaProperty.Register<SettingsSectionCard, string?>(nameof(Title));
public static readonly StyledProperty<string?> DescriptionProperty =
AvaloniaProperty.Register<SettingsSectionCard, string?>(nameof(Description));
public static readonly StyledProperty<object?> CardContentProperty =
AvaloniaProperty.Register<SettingsSectionCard, object?>(nameof(CardContent));
public SettingsSectionCard()
{
InitializeComponent();
RefreshVisualState();
}
public string? IconKey
{
get => GetValue(IconKeyProperty);
set => SetValue(IconKeyProperty, value);
}
public string? Title
{
get => GetValue(TitleProperty);
set => SetValue(TitleProperty, value);
}
public string? Description
{
get => GetValue(DescriptionProperty);
set => SetValue(DescriptionProperty, value);
}
public object? CardContent
{
get => GetValue(CardContentProperty);
set => SetValue(CardContentProperty, value);
}
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);
if (change.Property == IconKeyProperty ||
change.Property == TitleProperty ||
change.Property == DescriptionProperty ||
change.Property == CardContentProperty)
{
RefreshVisualState();
}
}
private void RefreshVisualState()
{
if (CardIcon is null ||
IconHost is null ||
TitleTextBlock is null ||
DescriptionTextBlock is null ||
CardContentHost is null)
{
return;
}
CardIcon.Symbol = MapIcon(IconKey);
IconHost.IsVisible = !string.IsNullOrWhiteSpace(IconKey);
TitleTextBlock.Text = Title ?? string.Empty;
DescriptionTextBlock.Text = Description ?? string.Empty;
DescriptionTextBlock.IsVisible = !string.IsNullOrWhiteSpace(Description);
CardContentHost.Content = CardContent;
}
private static Symbol MapIcon(string? iconKey)
{
return iconKey?.Trim() switch
{
"DesignIdeas" => Symbol.Color,
"GridDots" => Symbol.GridDots,
"PuzzlePiece" => Symbol.PuzzlePiece,
"Info" => Symbol.Info,
"ArrowSync" => Symbol.ArrowSync,
_ => Symbol.Settings
};
}
}