Skip to content

Commit

Permalink
Merge pull request #5 from timunie/housekeeping/Remove-RxUI
Browse files Browse the repository at this point in the history
Use PropertyChanged-override instead of Observables
  • Loading branch information
punker76 authored Oct 31, 2024
2 parents d8167b9 + 8b71fe8 commit 75349cb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
1 change: 0 additions & 1 deletion src/IconPacks.Avalonia.Core/IconPacks.Avalonia.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.1.4" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.1.4" />
</ItemGroup>

<ItemGroup>
Expand Down
33 changes: 15 additions & 18 deletions src/IconPacks.Avalonia.Core/PackIconControlBase.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Reactive;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Animation;
Expand Down Expand Up @@ -43,22 +41,6 @@ public abstract class PackIconControlBase : PackIconBase
protected PackIconControlBase()
{
AffectsRender<PackIconControlBase>(SpinProperty, SpinDurationProperty, OpacityProperty, SpinEasingFunctionProperty, FlipProperty, RotationAngleProperty);

Observable.CombineLatest(
this.GetObservable(SpinProperty).Select(_ => Unit.Default),
this.GetObservable(IsVisibleProperty).Select(_ => Unit.Default),
this.GetObservable(SpinDurationProperty).Select(_ => Unit.Default),
this.GetObservable(OpacityProperty).Select(_ => Unit.Default),
this.GetObservable(SpinEasingFunctionProperty).Select(_ => Unit.Default))
.Select(_ => this.CanSpin())
.Subscribe(spin =>
{
this.StopSpinAnimation();
if (spin)
{
this.BeginSpinAnimation();
}
});
}

private bool CanSpin()
Expand Down Expand Up @@ -121,6 +103,21 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
this.UpdateRotateTransformation(change.GetNewValue<double>());
}
}

// Update Spin-Animation as needed
if (change.Property == SpinProperty
|| change.Property == IsVisibleProperty
|| change.Property == SpinDurationProperty
|| change.Property == OpacityProperty
|| change.Property == SpinEasingFunctionProperty)
{
this.StopSpinAnimation();

if (this.CanSpin())
{
this.BeginSpinAnimation();
}
}
}

private void UpdateScaleTransformation(PackIconFlipOrientation flipOrientation)
Expand Down

0 comments on commit 75349cb

Please sign in to comment.