Files
LanMountainDesktop/LanMountainDesktop.PluginSdk/PluginCornerRadiusTokens.cs

53 lines
1.5 KiB
C#
Raw Normal View History

2026-03-20 22:37:37 +08:00
using Avalonia;
using LanMountainDesktop.Shared.Contracts;
namespace LanMountainDesktop.PluginSdk;
public sealed record PluginCornerRadiusTokens(
double Micro,
double Xs,
double Sm,
double Md,
double Lg,
double Xl,
2026-03-30 15:28:51 +08:00
double Island,
double Component)
2026-03-20 22:37:37 +08:00
{
public double Get(PluginCornerRadiusPreset preset)
{
return preset switch
{
2026-03-30 15:28:51 +08:00
PluginCornerRadiusPreset.Default => Component,
2026-03-20 22:37:37 +08:00
PluginCornerRadiusPreset.Micro => Micro,
PluginCornerRadiusPreset.Xs => Xs,
PluginCornerRadiusPreset.Sm => Sm,
PluginCornerRadiusPreset.Md => Md,
PluginCornerRadiusPreset.Lg => Lg,
PluginCornerRadiusPreset.Xl => Xl,
PluginCornerRadiusPreset.Island => Island,
2026-03-30 15:28:51 +08:00
PluginCornerRadiusPreset.Component => Component,
_ => Component
2026-03-20 22:37:37 +08:00
};
}
public CornerRadius ToCornerRadius(PluginCornerRadiusPreset preset)
{
return new CornerRadius(Get(preset));
}
public static PluginCornerRadiusTokens FromShared(AppearanceCornerRadiusTokens tokens)
{
ArgumentNullException.ThrowIfNull(tokens);
return new PluginCornerRadiusTokens(
tokens.Micro.TopLeft,
tokens.Xs.TopLeft,
tokens.Sm.TopLeft,
tokens.Md.TopLeft,
tokens.Lg.TopLeft,
tokens.Xl.TopLeft,
2026-03-30 15:28:51 +08:00
tokens.Island.TopLeft,
tokens.Component.TopLeft);
2026-03-20 22:37:37 +08:00
}
}