Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the new Skottie animation builder #277

Merged
merged 3 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/SkiaSharpDemo/Demos/Lottie/LottiePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Grid RowDefinitions="*,Auto">

<controls:SKLottieView x:Name="lottieView"
Source="Lottie/trophy.json"
Source="Lottie/dotnetbot.json"
Duration="{Binding Duration}"
Progress="{Binding Progress}"
IsAnimationEnabled="{Binding IsBusy}"
Expand Down
1 change: 1 addition & 0 deletions samples/SkiaSharpDemo/Resources/Raw/Lottie/dotnetbot.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override async Task<SKLottieAnimation> LoadAnimationAsync(CancellationTok
if (stream is null)
throw new FileLoadException($"Unable to load Lottie animation file \"{File}\".");

var animation = Skottie.Animation.Create(stream);
var animation = CreateAnimationBuilder().Build(stream);
if (animation is null)
throw new FileLoadException($"Unable to parse Lottie animation \"{File}\".");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

using SkiaSharp.Resources;

namespace SkiaSharp.Extended.UI.Controls;

[TypeConverter(typeof(Converters.SKLottieImageSourceConverter))]
Expand All @@ -10,6 +11,11 @@ public abstract class SKLottieImageSource : Element

public abstract Task<SKLottieAnimation> LoadAnimationAsync(CancellationToken cancellationToken = default);

internal Skottie.AnimationBuilder CreateAnimationBuilder() =>
Skottie.Animation.CreateBuilder()
.SetResourceProvider(new CachingResourceProvider(new DataUriResourceProvider()))
.SetFontManager(SKFontManager.Default);

public static object FromUri(Uri uri) =>
new SKUriLottieImageSource { Uri = uri };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public override async Task<SKLottieAnimation> LoadAnimationAsync(CancellationTok
if (stream is null)
throw new FileLoadException($"Unable to load Lottie animation stream.");

var animation = Skottie.Animation.Create(stream);
var animation = CreateAnimationBuilder().Build(stream);
if (animation is null)
throw new FileLoadException($"Unable to parse Lottie animation.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override async Task<SKLottieAnimation> LoadAnimationAsync(CancellationTok
if (stream is null)
throw new FileLoadException($"Unable to load Lottie animation uri \"{Uri}\".");

var animation = Skottie.Animation.Create(stream);
var animation = CreateAnimationBuilder().Build(stream);
if (animation is null)
throw new FileLoadException($"Unable to parse Lottie animation \"{Uri}\".");

Expand Down
Loading