mirror of
https://github.com/AtomUI/AtomUI.git
synced 2026-10-22 17:35:30 +08:00
Refactor RadioIndicator
This commit is contained in:
+1
-1
@@ -820,9 +820,9 @@ namespace AtomUI.Theme.Styling
|
||||
public static readonly TokenResourceKey IndicatorLeftModeMargin = new TokenResourceKey("Timeline.IndicatorLeftModeMargin");
|
||||
public static readonly TokenResourceKey IndicatorMiddleModeMargin = new TokenResourceKey("Timeline.IndicatorMiddleModeMargin");
|
||||
public static readonly TokenResourceKey IndicatorRightModeMargin = new TokenResourceKey("Timeline.IndicatorRightModeMargin");
|
||||
public static readonly TokenResourceKey IndicatorSize = new TokenResourceKey("Timeline.IndicatorSize");
|
||||
public static readonly TokenResourceKey IndicatorTailColor = new TokenResourceKey("Timeline.IndicatorTailColor");
|
||||
public static readonly TokenResourceKey IndicatorTailWidth = new TokenResourceKey("Timeline.IndicatorTailWidth");
|
||||
public static readonly TokenResourceKey IndicatorWidth = new TokenResourceKey("Timeline.IndicatorWidth");
|
||||
public static readonly TokenResourceKey ItemPaddingBottom = new TokenResourceKey("Timeline.ItemPaddingBottom");
|
||||
public static readonly TokenResourceKey ItemPaddingBottomLG = new TokenResourceKey("Timeline.ItemPaddingBottomLG");
|
||||
public static readonly TokenResourceKey LastItemContentMinHeight = new TokenResourceKey("Timeline.LastItemContentMinHeight");
|
||||
|
||||
@@ -10,6 +10,7 @@ using Avalonia.Animation;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Data;
|
||||
using Avalonia.LogicalTree;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.VisualTree;
|
||||
|
||||
@@ -135,16 +136,10 @@ internal class RadioIndicator : Control,
|
||||
set => SetValue(IsWaveAnimationEnabledProperty, value);
|
||||
}
|
||||
|
||||
CompositeDisposable? IResourceBindingManager.ResourceBindingsDisposable
|
||||
{
|
||||
get => _resourceBindingsDisposable;
|
||||
set => _resourceBindingsDisposable = value;
|
||||
}
|
||||
|
||||
CompositeDisposable? IResourceBindingManager.ResourceBindingsDisposable { get; set; }
|
||||
#endregion
|
||||
|
||||
private IPen? _cachedPen;
|
||||
private CompositeDisposable? _resourceBindingsDisposable;
|
||||
|
||||
static RadioIndicator()
|
||||
{
|
||||
@@ -157,24 +152,28 @@ internal class RadioIndicator : Control,
|
||||
RadioDotEffectSizeProperty);
|
||||
}
|
||||
|
||||
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
||||
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
|
||||
{
|
||||
base.OnAttachedToVisualTree(e);
|
||||
_resourceBindingsDisposable = new CompositeDisposable();
|
||||
base.OnAttachedToLogicalTree(e);
|
||||
this.AddResourceBindingDisposable(TokenResourceBinder.CreateTokenBinding(this, RadioBorderThicknessProperty,
|
||||
SharedTokenKey.BorderThickness, BindingPriority.Template,
|
||||
new RenderScaleAwareThicknessConfigure(this)));
|
||||
RadioDotEffectSize = CalculateDotSize(IsEnabled, IsChecked.HasValue && IsChecked.Value);
|
||||
ConfigureTransitions();
|
||||
UpdatePseudoClasses();
|
||||
}
|
||||
|
||||
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
|
||||
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e)
|
||||
{
|
||||
base.OnDetachedFromVisualTree(e);
|
||||
base.OnDetachedFromLogicalTree(e);
|
||||
this.DisposeTokenBindings();
|
||||
}
|
||||
|
||||
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
||||
{
|
||||
base.OnAttachedToVisualTree(e);
|
||||
RadioDotEffectSize = CalculateDotSize(IsEnabled, IsChecked.HasValue && IsChecked.Value);
|
||||
UpdatePseudoClasses();
|
||||
}
|
||||
|
||||
private void ConfigureTransitions()
|
||||
{
|
||||
if (IsMotionEnabled)
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static atom:SharedTokenKey.ColorText}}" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="IsMotionEnabled" Value="{DynamicResource {x:Static atom:SharedTokenKey.EnableMotion}}" />
|
||||
<Setter Property="IsWaveSpiritEnabled"
|
||||
Value="{DynamicResource {x:Static atom:SharedTokenKey.EnableWaveSpirit}}" />
|
||||
|
||||
<Style Selector="^ /template/ atom|TextBlock#PART_LabelText">
|
||||
<Setter Property="Margin" Value="{DynamicResource {x:Static atom:CheckBoxTokenKey.TextMargin}}" />
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:ClassModifier="internal">
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceInclude Source="SwitchKnobTheme.axaml"/>
|
||||
<ResourceInclude Source="ToggleSwitchTheme.axaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user