From d7c3c03ccfefae01042662eb50fd9815a0362ba2 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Thu, 25 Jun 2020 00:14:55 +0500 Subject: [PATCH] Rewrite check targetVal --- .../Animators/SolidColorBrushAnimator.cs | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs b/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs index 191c9631b7..8f3abcf068 100644 --- a/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs +++ b/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs @@ -10,9 +10,9 @@ namespace Avalonia.Animation.Animators /// public class SolidColorBrushAnimator : Animator { - ColorAnimator _colorAnimator; + private ColorAnimator _colorAnimator; - void InitializeColorAnimator() + private void InitializeColorAnimator() { _colorAnimator = new ColorAnimator(); @@ -38,28 +38,29 @@ namespace Avalonia.Animation.Animators } } + SolidColorBrush finalTarget; var targetVal = control.GetValue(Property); - // Add SCB if the target prop is empty. if (targetVal is null) { - targetVal = new SolidColorBrush(Colors.Transparent); - control.SetValue(Property, targetVal); + finalTarget = new SolidColorBrush(Colors.Transparent); + control.SetValue(Property, finalTarget); } - - if (!(targetVal is ISolidColorBrush)) + else if (targetVal is ImmutableSolidColorBrush immutableSolidColorBrush) + { + finalTarget = new SolidColorBrush(immutableSolidColorBrush.Color); + control.SetValue(Property, finalTarget); + } + else if (!(targetVal is ISolidColorBrush)) + { return Disposable.Empty; - - if (_colorAnimator == null) - InitializeColorAnimator(); - - // If it's ISCB, change it back to SCB. - if (targetVal is ImmutableSolidColorBrush immutableSolidColorBrush) + } + else { - targetVal = new SolidColorBrush(immutableSolidColorBrush.Color); - control.SetValue(Property, targetVal); + finalTarget = targetVal as SolidColorBrush; } - var finalTarget = targetVal as SolidColorBrush; + if (_colorAnimator == null) + InitializeColorAnimator(); return _colorAnimator.Apply(animation, finalTarget, clock ?? control.Clock, match, onComplete); }