Add nullable attributes, TimeSpan and overloads to Skottie - #2119
Merged
Conversation
mattleibow
commented
Jun 18, 2022
Comment on lines
+24
to
+27
| public static Animation? Parse (string json) => | ||
| TryParse (json, out var animation) | ||
| ? animation | ||
| : null; |
Contributor
Author
There was a problem hiding this comment.
Adding "overloads" to return the object, or null on some error that we will never know about.
Comment on lines
-56
to
+83
| public void Seek (double t, InvalidationController ic = null) | ||
| => SkottieApi.skottie_animation_seek (Handle, (float)t, ic?.Handle ?? IntPtr.Zero); | ||
| public void Seek (double percent, InvalidationController? ic = null) | ||
| => SkottieApi.skottie_animation_seek (Handle, (float)percent, ic?.Handle ?? IntPtr.Zero); |
Contributor
Author
There was a problem hiding this comment.
Renamed the parameters.
Comment on lines
-65
to
+95
| public double Duration | ||
| => SkottieApi.skottie_animation_get_duration (Handle); | ||
| public void SeekFrameTime (TimeSpan time, InvalidationController? ic = null) | ||
| => SeekFrameTime (time.TotalSeconds, ic); | ||
|
|
||
| public TimeSpan Duration | ||
| => TimeSpan.FromSeconds(SkottieApi.skottie_animation_get_duration (Handle)); |
Contributor
Author
There was a problem hiding this comment.
Added the new SeekFrameTime(TimeSpan) and changed Duration to be a TimeSpan.
Contributor
Author
|
/azp run SkiaSharp |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
Author
|
/azp run SkiaSharp |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of Change
This PR just adds some overloads and nullable annotations to the Skottie
Animationtype.While working with the new type, I was unsure what the
tin all the seek methods were, so I renamed the parameters to be more explicit: percent, frame, seconds. I also added an overload forSeekFrameTimeto take aTimeSpanbecause that was useful.I also made a change to make
DurationaTimeSpan. This was again to reduce confusion about the actual unit, but also keeps all the time concepts asTimeSpanbecause it feels more accurate?I added some "overloads" for the
TryCreateandTryParseto just return null instead (CreateandParse). The reason for null and not an exception is that for some reason, null was used to when there was an error reading things. It should have been an exception, but here we are. Skia does not really have "errors" but more it tries and then says nah, here is a big fat null for you. At least it is mostly consistent.Is the SkiaSharp API perfect? Yes. There have been no regrets in the design and naming of this perfect library. *looks for tissue to dry eyes*