mirror of
https://github.com/AtomUI/AtomUI.git
synced 2026-10-29 15:19:12 +08:00
Optimize Badge for dark mode
This commit is contained in:
@@ -85,7 +85,7 @@ internal class BadgeToken : AbstractControlDesignToken
|
||||
// 设置内部 token
|
||||
BadgeFontHeight = SharedToken.FontHeight;
|
||||
BadgeShadowSize = lineWidth;
|
||||
BadgeTextColor = SharedToken.ColorBgContainer;
|
||||
BadgeTextColor = SharedToken.ColorTextLightSolid;
|
||||
BadgeColor = SharedToken.ColorError;
|
||||
BadgeColorHover = SharedToken.ColorErrorHover;
|
||||
BadgeShadowColor = SharedToken.ColorBorderBg;
|
||||
|
||||
@@ -51,8 +51,8 @@ public class CountBadge : Control,
|
||||
public static readonly StyledProperty<bool> BadgeIsVisibleProperty =
|
||||
AvaloniaProperty.Register<CountBadge, bool>(nameof(BadgeIsVisible), true);
|
||||
|
||||
public static readonly StyledProperty<bool> IsMotionEnabledProperty
|
||||
= MotionAwareControlProperty.IsMotionEnabledProperty.AddOwner<CountBadge>();
|
||||
public static readonly StyledProperty<bool> IsMotionEnabledProperty =
|
||||
MotionAwareControlProperty.IsMotionEnabledProperty.AddOwner<CountBadge>();
|
||||
|
||||
public string? BadgeColor
|
||||
{
|
||||
|
||||
@@ -115,6 +115,7 @@ internal class RibbonBadgeAdorner : Control
|
||||
private TextBlock? _labelText;
|
||||
private Geometry? _cornerGeometry;
|
||||
private readonly BorderRenderHelper _borderRenderHelper;
|
||||
private bool _styleInitialized;
|
||||
|
||||
static RibbonBadgeAdorner()
|
||||
{
|
||||
@@ -131,15 +132,15 @@ internal class RibbonBadgeAdorner : Control
|
||||
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
|
||||
{
|
||||
base.OnAttachedToLogicalTree(e);
|
||||
if (Styles.Count == 0)
|
||||
if (!_styleInitialized)
|
||||
{
|
||||
BuildStyles();
|
||||
_styleInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildStyles()
|
||||
{
|
||||
// TODO 需要优化
|
||||
var commonStyle = new Style(selector => selector.OfType<RibbonBadgeAdorner>());
|
||||
commonStyle.Add(RibbonColorProperty, SharedTokenKey.ColorPrimary);
|
||||
commonStyle.Add(CornerRadiusProperty, SharedTokenKey.BorderRadiusSM);
|
||||
|
||||
@@ -17,12 +17,14 @@
|
||||
Name="{x:Static atom:CountBadgeAdornerThemeConstants.BadgeTextPart}"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
Text="{TemplateBinding CountText}" />
|
||||
Text="{TemplateBinding CountText}"
|
||||
Foreground="{TemplateBinding Foreground}"/>
|
||||
</Panel>
|
||||
</atom:MotionActor>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static atom:BadgeTokenKey.BadgeTextColor}}" />
|
||||
<Setter Property="ClipToBounds" Value="False" />
|
||||
<Setter Property="BadgeShadowSize" Value="{DynamicResource {x:Static atom:BadgeTokenKey.BadgeShadowSize}}" />
|
||||
<Setter Property="BadgeShadowColor" Value="{DynamicResource {x:Static atom:BadgeTokenKey.BadgeShadowColor}}" />
|
||||
@@ -42,7 +44,6 @@
|
||||
Value="{DynamicResource {x:Static atom:BadgeTokenKey.CountBadgeCornerRadius}}" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ atom|TextBlock#PART_BadgeText">
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static atom:BadgeTokenKey.BadgeTextColor}}" />
|
||||
<Setter Property="FontSize" Value="{DynamicResource {x:Static atom:BadgeTokenKey.TextFontSize}}" />
|
||||
<Setter Property="Padding" Value="{DynamicResource {x:Static atom:BadgeTokenKey.CountBadgeTextPadding}}" />
|
||||
</Style>
|
||||
|
||||
Reference in New Issue
Block a user