-
Notifications
You must be signed in to change notification settings - Fork 455
Feature/animation samples #1527
Feature/animation samples #1527
Conversation
|
|
||
| namespace Xamarin.CommunityToolkit.Animations | ||
| { | ||
| public class TadaAnimation : AnimationBase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If happy with the approach in TadaAnimationType this entire class and folder can disappear
pictos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bijington sorry for the delay
| protected virtual Animation CreateAnimation(params View[] views) | ||
| { | ||
| return new Animation(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be abstract?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes good spot!
| return taskCompletionSource.Task; | ||
| } | ||
|
|
||
| protected override Animation CreateAnimation(params View[] views) => Create(RotationAngle, MinimumScale, MaximumScale, views); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we have a situation. If you do something like
public Test()
{
var tada = new TadaAnimationType();
tada.IsRepeated = true;
tada.MaximumScale = 1;
var lbl = new Label();
var entry = new Entry();
// This works with more than one view
var animation = tada.CreateAnimation(16, null, null, lbl, entry);
animation.Commit();
animation.Abort();
// This just works with one view
tada.Animate(lbl); // Task
}This can lead to confusion about which method should I call? Just Animate or CreateAnimation?
Also, if I call Animate I can't Abort it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, if we want to use the BehaviorAnimation API, we need to make those animations simpler and drop the CreateAnimation, Commit, and Abort methods, which works for me.
If you see that those methods, at least Commit, and Abort, we can :
- Try to add those methods in BehaviorAnimation API;
- Create another API, to hold those animations.
Just to point out, that these animations are more complex than the animations that we have, so makes sense to be another implementation if the existing one doesn't fit well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I completely agree on the confusion this creates. What do you think to keeping the BehaviorAnimation support but creating a second underlying type that BehaviorAnimation can use?
Currently we have AnimationBase, could this stay but then we create 2 abstract classes inheriting from this; SimpleAnimation and ComplexAnimation (or possibly AsyncAnimation and Animation). Then the BehaviorAnimation class could call them based on which is supplied.
Or an alternative could be to bend the complex to work in the existing approach by allowing a CancellationToken to be passed in for the aborting. This all feels a bit wrong considering non of the animations are actually async.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess there are good use cases for both async and non async still. I was going to suggest we could replace the async parts with implementing these directly in an on async manner: https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Core/ViewExtensions.cs but I am not sure that is a good idea now
# Conflicts: # src/CommunityToolkit/Xamarin.CommunityToolkit/Animations/AnimationBase.shared.cs # src/CommunityToolkit/Xamarin.CommunityToolkit/Behaviors/Animations/AnimationTypes/TadaAnimationType.shared.cs
|
This PR now covers:
I need to think on how to test this stuff and I am also keen to write up the docs for this stuff which I think should be fairly safe now given the approach? |
|
@pictos i have noticed that the other CI builds aren't running against this PR. I assume it is because it isn't going in to develop or main. Is this ok? I guess it will be run when we eventually merge to develop |
|
@bijington you're correct. The CI will just run when we do a merge to |
|
@pictos what do you think to adding a |
I would say that use the |
|
@pictos is there anything you need from me in order to get this PR in? I need to write up some documentation but I assumed I could do this when we eventually merge in to |
|
@bijington thanks for you hard work, I'll update this branch and open the official PR ASAP. |
Awesome. Thank you for this |
* Initial attempt at an Animations sample section * Move all responsibility to AnimationTypes * Code tidy up * changed the null and empty verification to be more performant * Inverted `if` to make the code more readable * An attempt at async with cancellation * Remove the need for Task.Delay * Removed the Type suffix * Code tidy up and xml docs Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com>
* Add tada animation (#1468) * Base class implementation for pre-built animations * TADA! Added the first animation * Max and Min scales for Tada * Added the RubberBand animation Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com> * Feature/animation samples (#1527) * Initial attempt at an Animations sample section * Move all responsibility to AnimationTypes * Code tidy up * changed the null and empty verification to be more performant * Inverted `if` to make the code more readable * An attempt at async with cancellation * Remove the need for Task.Delay * Removed the Type suffix * Code tidy up and xml docs Co-authored-by: Pedro Jesus <pedrojesus.cefet@gmail.com> * Consolidate AnimationViewModel, Remove Unnecessary Nullables * TaskExtensions tidy up * AnimationWrapper tidy up Remove default parameters * Rename to CompoundAnimationBase * Unit tests added around animations * Reversed the >= check to keep the constant on the right * Switched to TimeSpan * Disabled/removed inconsistent tests * No longer share a ticker instance * Clear PlatformServices after each animation test * Code tidy up * Remove the inconsistent asserts * Further test ticker changes - only use AsyncTicker when really needed. - extra protection around enabling - set and clear default ticker before/after each test * Add Missing Asserts * Update Unit Test NuGet Packages * Update for Nullable Co-authored-by: Shaun Lawrence <shaunrlawrence@gmail.com> Co-authored-by: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>
Description of Change
This is very much a work in progress but it is here to show some progress on the pre-built animations along with a samples section.
Screen.Recording.2021-07-21.at.21.34.56.mov
Bugs Fixed
API Changes
Behavioral Changes
PR Checklist
approved