Maui icon indicating copy to clipboard operation
Maui copied to clipboard

[Proposal] Animation Behavior

Open brminnick opened this issue 3 years ago • 6 comments

Animation Behavior

  • [x] Proposed
  • [x] Prototype
  • [x] Implementation
    • [x] iOS Support
    • [x] Android Support
    • [x] macOS Support
    • [x] Windows Support
  • [x] Unit Tests
  • [ ] Documentation: Not Started
  • [ ] Sample: Not Started

Summary

AnimationBehavor is a Behavior that can be attached to any VisualElement, allowing developers to trigger the following animations via ICommand AnimateCommand:

  • [x] #519
  • [ ] FlipHorizontalAnimation
  • [ ] FlipVerticalAnimation
  • [ ] RotateAnimation
  • [ ] ScaleAnimation
  • [ ] ShakeAnimation

Motivation

AnimationBehavior solves the following challenges:

  • [x] Animations are not easily accomplished in XAML
  • [x] Animations are not easily accomplished using ICommand

Following the implementation of AnimationBehavior, developers will easily be able to create bindable animations for any VisualElement

Detailed Design

AnimationBehavior.shared.cs

AnimationBehavior is a Behavior can be attached to any VisualElement.

AnimationBehavior implements EventToCommandBehavior.

public class AnimationBehavior : EventToCommandBehavior
{
    public static readonly BindableProperty AnimationTypeProperty;
    public static readonly BindableProperty AnimateCommandProperty;

    public AnimationBase? AnimationType { get; set; }
    public ICommand AnimateCommand { get; }
}

AnimationBase<TView>

AnimationBase is an abstract class implementing BindableObject that allows for creating animations.

public abstract class AnimationBase<TView> : BindableObject where TView : View
{
    public static readonly BindableProperty DurationProperty;
    public static readonly BindableProperty EasingTypeProperty

    public uint Duration { get; set; }
    public Easing Easing { get; set; }

    public abstract Task Animate(TView? view);
}

brminnick avatar Sep 23 '21 20:09 brminnick

Hi @brminnick, I love this feature. I can have a go at implementing it if you like.

stefanbogaard86 avatar Nov 02 '21 14:11 stefanbogaard86

Thanks @stefanbogaard86! Assigned 👍

brminnick avatar Nov 02 '21 15:11 brminnick

Reopening Proposal.

Only Proposals moved to the Closed Project Column and Completed Project Column can be closed.

ghost avatar Mar 20 '22 22:03 ghost

I am happy to get the remaining parts implemented for the next milestone unless @stefanbogaard86 you still wanted to work on this?

bijington avatar May 31 '22 10:05 bijington

Hi @bijington, I've unassigned myself so go for it!

stefanbogaard86 avatar May 31 '22 10:05 stefanbogaard86

Hi @bijington, I've unassigned myself so go for it!

Thank you and thanks for all the hard work in getting it to this stage it really is appreciated!

bijington avatar May 31 '22 10:05 bijington