feat(lottie): Add support for AnimatedVisualPlayer on net6.0 mobile and Skia targets.
This commit is contained in:
Родитель
1cbc1340b6
Коммит
61733ad9ae
|
@ -374,6 +374,9 @@
|
|||
<XmlPoke XmlInputPath="%(_NuspecFiles.Identity)" Query="/x:package/x:metadata/x:dependencies//x:dependency[@id='Uno.WinUI.Runtime.Skia.Tizen']/@id" Value="$(PackageNamePrefix).Runtime.Skia.Tizen" Namespaces="$(NugetNamespace)" />
|
||||
<XmlPoke XmlInputPath="%(_NuspecFiles.Identity)" Query="/x:package/x:metadata/x:dependencies//x:dependency[@id='Uno.WinUI.Runtime.WebAssembly']/@id" Value="$(PackageNamePrefix).Runtime.WebAssembly" Namespaces="$(NugetNamespace)" />
|
||||
|
||||
<!-- Rename skiasharp references for WinUI -->
|
||||
<XmlPoke XmlInputPath=".\Uno.WinUI.Lottie.nuspec" Query="/x:package/x:metadata/x:dependencies//x:dependency[@id='SkiaSharp.Views.Uno']/@id" Value="SkiaSharp.Views.Uno.WinUI" Namespaces="$(NugetNamespace)" Condition="'$(UNO_UWP_BUILD)'!='true'" />
|
||||
|
||||
<!-- Adjust build targets file to match WinUI / UWP-->
|
||||
<Move SourceFiles=".\uno.winui.targets" DestinationFiles=".\$(PackageNamePrefix).targets" Condition="'$(UNO_UWP_BUILD)'=='true'"/>
|
||||
<XmlPoke XmlInputPath=".\Uno.WinUI.nuspec" Query="/x:package/x:files/x:file[@src='Uno.WinUI.targets']/@src" Value="$(PackageNamePrefix).targets" Namespaces="$(NugetNamespace)" Condition="'$(UNO_UWP_BUILD)'=='true'"/>
|
||||
|
|
|
@ -1,125 +1,136 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata minClientVersion="5.0">
|
||||
<id>Uno.WinUI.Lottie</id>
|
||||
<version>0.0.1</version>
|
||||
<title>Uno.WinUI.Lottie</title>
|
||||
<authors>nventive</authors>
|
||||
<owners>nventive</owners>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<projectUrl>https://platform.uno/</projectUrl>
|
||||
<license type="expression">Apache-2.0</license>
|
||||
<icon>uno.png</icon>
|
||||
<description>
|
||||
Support for Lottie on Uno.WinUI.
|
||||
<metadata minClientVersion="5.0">
|
||||
<id>Uno.WinUI.Lottie</id>
|
||||
<version>0.0.1</version>
|
||||
<title>Uno.WinUI.Lottie</title>
|
||||
<authors>nventive</authors>
|
||||
<owners>nventive</owners>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<projectUrl>https://platform.uno/</projectUrl>
|
||||
<license type="expression">Apache-2.0</license>
|
||||
<icon>uno.png</icon>
|
||||
<description>
|
||||
Support for Lottie on Uno.WinUI.
|
||||
|
||||
This is the Uno-compatible version of the package Microsoft.Toolkit.Uwp.UI.Lottie.
|
||||
This is the Uno-compatible version of the package Microsoft.Toolkit.Uwp.UI.Lottie.
|
||||
|
||||
Original documentation: https://docs.microsoft.com/windows/communitytoolkit/animations/lottie
|
||||
</description>
|
||||
<copyright>Copyright (C) 2015-2019 nventive inc. - all rights reserved</copyright>
|
||||
<repository type="git" url="https://github.com/unoplatform/uno.git" branch="$branch$" commit="$commitid$" />
|
||||
Original documentation: https://docs.microsoft.com/windows/communitytoolkit/animations/lottie
|
||||
</description>
|
||||
<copyright>Copyright (C) 2015-2019 nventive inc. - all rights reserved</copyright>
|
||||
<repository type="git" url="https://github.com/unoplatform/uno.git" branch="$branch$" commit="$commitid$" />
|
||||
|
||||
<dependencies>
|
||||
<dependencies>
|
||||
|
||||
<group targetFramework="netstandard2.0">
|
||||
<dependency id="Uno.WinUI" version="to-be-set-by-ci" />
|
||||
<dependency id="System.Json" version="4.7.1" />
|
||||
</group>
|
||||
<group targetFramework="net6.0-ios">
|
||||
<dependency id="Uno.WinUI" version="to-be-set-by-ci" />
|
||||
<!--<dependency id="Com.Airbnb.iOS.Lottie" version="2.5.11" /> Disabled until net6 apple targets can support lottie properly -->
|
||||
<dependency id="System.Json" version="4.7.1" />
|
||||
</group>
|
||||
<group targetFramework="net6.0-maccatalyst">
|
||||
<dependency id="Uno.WinUI" version="to-be-set-by-ci" />
|
||||
<!--<dependency id="Com.Airbnb.iOS.Lottie" version="2.5.11" /> Disabled until net6 apple targets can support lottie properly -->
|
||||
<dependency id="System.Json" version="4.7.1" />
|
||||
</group>
|
||||
<group targetFramework="net6.0-macos">
|
||||
<dependency id="Uno.WinUI" version="to-be-set-by-ci" />
|
||||
<!--<dependency id="Com.Airbnb.iOS.Lottie" version="2.5.11" /> Disabled until net6 apple targets can support lottie properly -->
|
||||
<dependency id="System.Json" version="4.7.1" />
|
||||
</group>
|
||||
<group targetFramework="xamarinios10">
|
||||
<dependency id="Uno.WinUI" version="to-be-set-by-ci" />
|
||||
<dependency id="Com.Airbnb.iOS.Lottie" version="2.5.11" />
|
||||
<dependency id="System.Json" version="4.7.1" />
|
||||
</group>
|
||||
<group targetFramework="xamarinmac20">
|
||||
<dependency id="Uno.WinUI" version="to-be-set-by-ci" />
|
||||
<dependency id="Com.Airbnb.iOS.Lottie" version="2.5.11" />
|
||||
<dependency id="System.Json" version="4.7.1" />
|
||||
</group>
|
||||
<group targetFramework="net6.0-android">
|
||||
<dependency id="Uno.WinUI" version="to-be-set-by-ci" />
|
||||
<dependency id="Com.Airbnb.Android.Lottie" version="4.1.0" />
|
||||
<dependency id="Newtonsoft.Json" version="9.0.1" />
|
||||
</group>
|
||||
<group targetFramework="MonoAndroid11.0">
|
||||
<dependency id="Uno.WinUI" version="to-be-set-by-ci" />
|
||||
<dependency id="Com.Airbnb.Android.Lottie" version="4.1.0" />
|
||||
<dependency id="Newtonsoft.Json" version="9.0.1" />
|
||||
</group>
|
||||
<group targetFramework="MonoAndroid12.0">
|
||||
<dependency id="Uno.WinUI" version="to-be-set-by-ci" />
|
||||
<dependency id="Com.Airbnb.Android.Lottie" version="4.1.0" />
|
||||
<dependency id="Newtonsoft.Json" version="9.0.1" />
|
||||
</group>
|
||||
<group targetFramework="netstandard2.0">
|
||||
<dependency id="Uno.WinUI" version="to-be-set-by-ci" />
|
||||
<dependency id="System.Json" version="4.7.1" />
|
||||
</group>
|
||||
|
||||
</dependencies>
|
||||
<group targetFramework="xamarinios10">
|
||||
<dependency id="Uno.WinUI" version="to-be-set-by-ci" />
|
||||
<dependency id="Com.Airbnb.iOS.Lottie" version="2.5.11" />
|
||||
<dependency id="System.Json" version="4.7.1" />
|
||||
</group>
|
||||
<group targetFramework="xamarinmac20">
|
||||
<dependency id="Uno.WinUI" version="to-be-set-by-ci" />
|
||||
<dependency id="Com.Airbnb.iOS.Lottie" version="2.5.11" />
|
||||
<dependency id="System.Json" version="4.7.1" />
|
||||
</group>
|
||||
<group targetFramework="MonoAndroid11.0">
|
||||
<dependency id="Uno.WinUI" version="to-be-set-by-ci" />
|
||||
<dependency id="Newtonsoft.Json" version="9.0.1" />
|
||||
</group>
|
||||
<group targetFramework="MonoAndroid12.0">
|
||||
<dependency id="Uno.WinUI" version="to-be-set-by-ci" />
|
||||
<dependency id="Newtonsoft.Json" version="9.0.1" />
|
||||
</group>
|
||||
|
||||
<references>
|
||||
<group targetFramework="net6.0-ios">
|
||||
<reference file="Uno.UI.Lottie.dll" />
|
||||
</group>
|
||||
<group targetFramework="net6.0-maccatalyst">
|
||||
<reference file="Uno.UI.Lottie.dll" />
|
||||
</group>
|
||||
<group targetFramework="net6.0-macos">
|
||||
<reference file="Uno.UI.Lottie.dll" />
|
||||
</group>
|
||||
<group targetFramework="net6.0-android">
|
||||
<reference file="Uno.UI.Lottie.dll" />
|
||||
</group>
|
||||
<group targetFramework="netstandard2.0">
|
||||
<reference file="Uno.UI.Lottie.dll" />
|
||||
</group>
|
||||
<group targetFramework="xamarinios10">
|
||||
<reference file="Uno.UI.Lottie.dll" />
|
||||
</group>
|
||||
<group targetFramework="xamarinmac20">
|
||||
<reference file="Uno.UI.Lottie.dll" />
|
||||
</group>
|
||||
<group targetFramework="MonoAndroid11.0">
|
||||
<reference file="Uno.UI.Lottie.dll" />
|
||||
</group>
|
||||
<group targetFramework="MonoAndroid12.0">
|
||||
<reference file="Uno.UI.Lottie.dll" />
|
||||
</group>
|
||||
<!-- For UAP (UWP), the reference to Microsoft.Toolkit.Uwp.UI.Lottie will be added manually -->
|
||||
</references>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="..\src\Common\uno.png" target="/" />
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\bin\Release\netstandard2.0\Uno.UI.Lottie.dll" target="lib\netstandard2.0" />
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\bin\Release\xamarinios10\Uno.UI.Lottie.dll" target="lib\xamarinios10" />
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\bin\Release\xamarinmac20\Uno.UI.Lottie.dll" target="lib\xamarinmac20" />
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\bin\Release\MonoAndroid11.0\Uno.UI.Lottie.dll" target="lib\MonoAndroid11.0" />
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\bin\Release\MonoAndroid12.0\Uno.UI.Lottie.dll" target="lib\MonoAndroid12.0" />
|
||||
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\bin\Uno.UI.Lottie.net6\Release\net6.0-android\Uno.UI.Lottie.dll" target="lib\net6.0-android" />
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\bin\Uno.UI.Lottie.net6\Release\net6.0-ios\Uno.UI.Lottie.dll" target="lib\net6.0-ios" />
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\bin\Uno.UI.Lottie.net6\Release\net6.0-maccatalyst\Uno.UI.Lottie.dll" target="lib\net6.0-maccatalyst" />
|
||||
<group targetFramework="net6.0-android">
|
||||
<dependency id="SkiaSharp.Skottie" version="2.88.1-preview.71" />
|
||||
<dependency id="SkiaSharp.Views.Uno" version="2.88.1-preview.71" />
|
||||
<dependency id="SkiaSharp.NativeAssets.android" version="2.88.1-preview.71" />
|
||||
|
||||
<!-- Build targets -->
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\buildTransitive\*" target="buildTransitive" />
|
||||
<dependency id="Uno.WinUI" version="to-be-set-by-ci" />
|
||||
<dependency id="Newtonsoft.Json" version="9.0.1" />
|
||||
</group>
|
||||
<group targetFramework="net6.0-ios">
|
||||
<dependency id="SkiaSharp.Skottie" version="2.88.1-preview.71" />
|
||||
<dependency id="SkiaSharp.Views.Uno" version="2.88.1-preview.71" />
|
||||
<dependency id="SkiaSharp.NativeAssets.ios" version="2.88.1-preview.71" />
|
||||
|
||||
<!-- netstandard2.0 WebAssembly -->
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\Bin\Uno.UI.Lottie.Wasm\Release\netstandard2.0\Uno.UI.Lottie.*" target="uno-runtime\webassembly" />
|
||||
<dependency id="Uno.WinUI" version="to-be-set-by-ci" />
|
||||
<dependency id="System.Json" version="4.7.1" />
|
||||
</group>
|
||||
<group targetFramework="net6.0-maccatalyst">
|
||||
<dependency id="SkiaSharp.Skottie" version="2.88.1-preview.71" />
|
||||
<dependency id="SkiaSharp.Views.Uno" version="2.88.1-preview.71" />
|
||||
<dependency id="SkiaSharp.NativeAssets.maccatalyst" version="2.88.1-preview.71" />
|
||||
|
||||
<!-- netstandard2.0 Skia -->
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\Bin\Uno.UI.Lottie.Skia\Release\netstandard2.0\Uno.UI.Lottie.*" target="uno-runtime\skia" />
|
||||
<dependency id="Uno.WinUI" version="to-be-set-by-ci" />
|
||||
<dependency id="System.Json" version="4.7.1" />
|
||||
</group>
|
||||
<group targetFramework="net6.0-macos">
|
||||
<dependency id="SkiaSharp.Skottie" version="2.88.1-preview.71" />
|
||||
<dependency id="SkiaSharp.Views.Uno" version="2.88.1-preview.71" />
|
||||
<dependency id="SkiaSharp.NativeAssets.macos" version="2.88.1-preview.71" />
|
||||
|
||||
</files>
|
||||
<dependency id="Uno.WinUI" version="to-be-set-by-ci" />
|
||||
<dependency id="System.Json" version="4.7.1" />
|
||||
</group>
|
||||
</dependencies>
|
||||
|
||||
<references>
|
||||
<group targetFramework="net6.0-ios">
|
||||
<reference file="Uno.UI.Lottie.dll" />
|
||||
</group>
|
||||
<group targetFramework="net6.0-maccatalyst">
|
||||
<reference file="Uno.UI.Lottie.dll" />
|
||||
</group>
|
||||
<group targetFramework="net6.0-macos">
|
||||
<reference file="Uno.UI.Lottie.dll" />
|
||||
</group>
|
||||
<group targetFramework="net6.0-android">
|
||||
<reference file="Uno.UI.Lottie.dll" />
|
||||
</group>
|
||||
<group targetFramework="netstandard2.0">
|
||||
<reference file="Uno.UI.Lottie.dll" />
|
||||
</group>
|
||||
<group targetFramework="xamarinios10">
|
||||
<reference file="Uno.UI.Lottie.dll" />
|
||||
</group>
|
||||
<group targetFramework="xamarinmac20">
|
||||
<reference file="Uno.UI.Lottie.dll" />
|
||||
</group>
|
||||
<group targetFramework="MonoAndroid11.0">
|
||||
<reference file="Uno.UI.Lottie.dll" />
|
||||
</group>
|
||||
<group targetFramework="MonoAndroid12.0">
|
||||
<reference file="Uno.UI.Lottie.dll" />
|
||||
</group>
|
||||
<!-- For UAP (UWP), the reference to Microsoft.Toolkit.Uwp.UI.Lottie will be added manually -->
|
||||
</references>
|
||||
</metadata>
|
||||
<files>
|
||||
<file src="..\src\Common\uno.png" target="/" />
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\bin\Release\netstandard2.0\Uno.UI.Lottie.dll" target="lib\netstandard2.0" />
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\bin\Release\xamarinios10\Uno.UI.Lottie.dll" target="lib\xamarinios10" />
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\bin\Release\xamarinmac20\Uno.UI.Lottie.dll" target="lib\xamarinmac20" />
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\bin\Release\MonoAndroid11.0\Uno.UI.Lottie.dll" target="lib\MonoAndroid11.0" />
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\bin\Release\MonoAndroid12.0\Uno.UI.Lottie.dll" target="lib\MonoAndroid12.0" />
|
||||
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\bin\Uno.UI.Lottie.net6\Release\net6.0-android\Uno.UI.Lottie.dll" target="lib\net6.0-android" />
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\bin\Uno.UI.Lottie.net6\Release\net6.0-ios\Uno.UI.Lottie.dll" target="lib\net6.0-ios" />
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\bin\Uno.UI.Lottie.net6\Release\net6.0-maccatalyst\Uno.UI.Lottie.dll" target="lib\net6.0-maccatalyst" />
|
||||
|
||||
<!-- Build targets -->
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\buildTransitive\*" target="buildTransitive" />
|
||||
|
||||
<!-- netstandard2.0 WebAssembly -->
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\Bin\Uno.UI.Lottie.Wasm\Release\netstandard2.0\Uno.UI.Lottie.*" target="uno-runtime\webassembly" />
|
||||
|
||||
<!-- netstandard2.0 Skia -->
|
||||
<file src="..\src\AddIns\Uno.UI.Lottie\Bin\Uno.UI.Lottie.Skia\Release\netstandard2.0\Uno.UI.Lottie.*" target="uno-runtime\skia" />
|
||||
|
||||
</files>
|
||||
</package>
|
||||
|
|
|
@ -0,0 +1,456 @@
|
|||
#nullable enable
|
||||
|
||||
#if HAS_SKOTTIE
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Windows.Foundation;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using System.Threading.Tasks;
|
||||
using Uno.Disposables;
|
||||
using SkiaSharp;
|
||||
using Uno.Foundation.Logging;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.System;
|
||||
using System.Diagnostics;
|
||||
using SkiaSharp.SceneGraph;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
||||
#if HAS_UNO_WINUI
|
||||
using SkiaSharp.Views.Windows;
|
||||
#else
|
||||
using SkiaSharp.Views.UWP;
|
||||
#endif
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
||||
{
|
||||
partial class LottieVisualSourceBase
|
||||
{
|
||||
private UIElement? _renderSurface;
|
||||
private SkiaSharp.Skottie.Animation? _animation;
|
||||
private SKXamlCanvas? _softwareCanvas;
|
||||
|
||||
|
||||
private DispatcherQueueTimer? _timer;
|
||||
private object _gate = new();
|
||||
|
||||
#if !__MACCATALYST__
|
||||
private SKSwapChainPanel? _hardwareCanvas;
|
||||
#endif
|
||||
|
||||
public bool UseHardwareAcceleration { get; set; }
|
||||
#if __SKIA__
|
||||
// SkiaSharp.Views.Uno uses the underlying canvas for hardware acceleration.
|
||||
= false;
|
||||
#else
|
||||
= true;
|
||||
#endif
|
||||
|
||||
private Uri? _lastSource;
|
||||
private PlayState? _playState;
|
||||
|
||||
private record PlayState(double FromProgress, double ToProgress, bool Looped)
|
||||
{
|
||||
public TimeSpan GetFromProgressUsingDuration(TimeSpan duration)
|
||||
=> TimeSpan.FromSeconds(duration.TotalSeconds * FromProgress);
|
||||
|
||||
public TimeSpan GetToProgressUsingDuration(TimeSpan duration)
|
||||
=> TimeSpan.FromSeconds(duration.TotalSeconds * ToProgress);
|
||||
}
|
||||
|
||||
private Stopwatch _stopwatch = new Stopwatch();
|
||||
private TimeSpan? _progress;
|
||||
|
||||
private InvalidationController? _invalidationController;
|
||||
private readonly SerialDisposable _animationDataSubscription = new SerialDisposable();
|
||||
|
||||
async Task InnerUpdate(CancellationToken ct)
|
||||
{
|
||||
var player = _player;
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await SetProperties();
|
||||
|
||||
async Task SetProperties()
|
||||
{
|
||||
var sourceUri = UriSource;
|
||||
if (_lastSource == null || !_lastSource.Equals(sourceUri))
|
||||
{
|
||||
_lastSource = sourceUri;
|
||||
if ((await TryLoadDownloadJson(sourceUri, ct)) is { } jsonStream)
|
||||
{
|
||||
var cacheKey = sourceUri.OriginalString;
|
||||
_animationDataSubscription.Disposable = null;
|
||||
_animationDataSubscription.Disposable =
|
||||
LoadAndObserveAnimationData(jsonStream, cacheKey, OnJsonChanged);
|
||||
|
||||
void OnJsonChanged(string updatedJson, string updatedCacheKey)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (SkiaSharp.Skottie.Animation.TryParse(updatedJson, out var animation))
|
||||
{
|
||||
animation.Seek(0);
|
||||
|
||||
if (this.Log().IsEnabled(LogLevel.Debug))
|
||||
{
|
||||
this.Log().Debug($"Version: {animation.Version} Duration: {animation.Duration} Fps:{animation.Fps} InPoint: {animation.InPoint} OutPoint: {animation.OutPoint}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("Failed to load animation.");
|
||||
}
|
||||
|
||||
SetAnimation(animation);
|
||||
|
||||
if (_playState != null)
|
||||
{
|
||||
var (fromProgress, toProgress, looped) = _playState;
|
||||
Play(fromProgress, toProgress, looped);
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
throw new InvalidOperationException("Failed load the animation", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotSupportedException($"Failed to load animation: {sourceUri}");
|
||||
}
|
||||
|
||||
// Force layout to recalculate
|
||||
player.InvalidateMeasure();
|
||||
player.InvalidateArrange();
|
||||
|
||||
if (_playState != null)
|
||||
{
|
||||
var (fromProgress, toProgress, looped) = _playState;
|
||||
Play(fromProgress, toProgress, looped);
|
||||
}
|
||||
else if (player.AutoPlay)
|
||||
{
|
||||
Play(0, 1, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (_animation == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var duration = _animation.Duration;
|
||||
player.SetValue(AnimatedVisualPlayer.DurationProperty, duration);
|
||||
|
||||
var isLoaded = duration > TimeSpan.Zero;
|
||||
player.SetValue(AnimatedVisualPlayer.IsAnimatedVisualLoadedProperty, isLoaded);
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetAnimation(SkiaSharp.Skottie.Animation animation)
|
||||
{
|
||||
if (!ReferenceEquals(_animation, animation))
|
||||
{
|
||||
#if __IOS__ || __MACOS__
|
||||
_renderSurface?.RemoveFromSuperview();
|
||||
#elif __SKIA__ || __ANDROID__
|
||||
_player?.RemoveChild(_renderSurface);
|
||||
#endif
|
||||
}
|
||||
|
||||
_renderSurface = BuildRenderSurface();
|
||||
|
||||
#if __IOS__
|
||||
_player?.Add(_renderSurface);
|
||||
#elif __MACOS__
|
||||
_player?.AddSubview(_renderSurface);
|
||||
#elif __SKIA__ || __ANDROID__
|
||||
_player?.AddChild(_renderSurface);
|
||||
#endif
|
||||
|
||||
_animation = animation;
|
||||
}
|
||||
|
||||
private UIElement BuildRenderSurface()
|
||||
{
|
||||
ClearRenderSurface();
|
||||
|
||||
#if !__MACCATALYST__
|
||||
if (UseHardwareAcceleration)
|
||||
{
|
||||
_hardwareCanvas = new();
|
||||
_hardwareCanvas.PaintSurface += OnHardwareCanvas_PaintSurface;
|
||||
|
||||
AdjustHardwareCanvasOpacity();
|
||||
|
||||
return _hardwareCanvas;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
_softwareCanvas = new();
|
||||
_softwareCanvas.PaintSurface += OnSoftwareCanvas_PaintSurface;
|
||||
return _softwareCanvas;
|
||||
}
|
||||
}
|
||||
|
||||
private void AdjustHardwareCanvasOpacity()
|
||||
{
|
||||
#if __ANDROID__
|
||||
if (_hardwareCanvas != null)
|
||||
{
|
||||
void UpdateTransparency(object s, object e)
|
||||
{
|
||||
// The SKGLTextureView is opaque by default, so we poke at the tree
|
||||
// to change the opacity of the first view of the SKSwapChainPanel
|
||||
// to make it transparent.
|
||||
if (_hardwareCanvas.ChildCount == 1
|
||||
&& _hardwareCanvas.GetChildAt(0) is Android.Views.TextureView texture)
|
||||
{
|
||||
texture.SetOpaque(false);
|
||||
}
|
||||
|
||||
_hardwareCanvas.Loaded -= UpdateTransparency;
|
||||
}
|
||||
|
||||
_hardwareCanvas.Loaded += UpdateTransparency;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private void ClearRenderSurface()
|
||||
{
|
||||
#if !__MACCATALYST__
|
||||
if (UseHardwareAcceleration)
|
||||
{
|
||||
if (_hardwareCanvas != null)
|
||||
{
|
||||
_hardwareCanvas.PaintSurface -= OnHardwareCanvas_PaintSurface;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if(_softwareCanvas != null)
|
||||
{
|
||||
_softwareCanvas.PaintSurface -= OnSoftwareCanvas_PaintSurface;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSoftwareCanvas_PaintSurface(object? sender, SKPaintSurfaceEventArgs e)
|
||||
{
|
||||
Render(e.Surface);
|
||||
}
|
||||
|
||||
private void OnHardwareCanvas_PaintSurface(object? sender, SKPaintGLSurfaceEventArgs e)
|
||||
{
|
||||
Render(e.Surface);
|
||||
}
|
||||
|
||||
private void Render(SKSurface surface)
|
||||
{
|
||||
lock (_gate)
|
||||
{
|
||||
var canvas = surface.Canvas;
|
||||
|
||||
var animation = _animation;
|
||||
if (animation is null || _player is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_invalidationController is null)
|
||||
{
|
||||
_invalidationController = new SkiaSharp.SceneGraph.InvalidationController();
|
||||
_invalidationController.Begin();
|
||||
}
|
||||
|
||||
var frameTime = GetFrameTime();
|
||||
|
||||
var localSize = surface.Canvas.LocalClipBounds.Size;
|
||||
|
||||
var scale = ImageSizeHelper.BuildScale(_player.Stretch, localSize.ToSize(), animation.Size.ToSize());
|
||||
var scaledSize = new Windows.Foundation.Size(animation.Size.Width * scale.x, animation.Size.Height * scale.y);
|
||||
|
||||
var x = (localSize.Width - scaledSize.Width) / 2;
|
||||
var y = (localSize.Height - scaledSize.Height) / 2;
|
||||
|
||||
animation.SeekFrameTime(frameTime, _invalidationController);
|
||||
|
||||
canvas.Save();
|
||||
|
||||
// canvas.Clear(GetBackgroundColor());
|
||||
|
||||
canvas.Translate((float)x, (float)y);
|
||||
canvas.Scale((float)(scaledSize.Width / animation.Size.Width), (float)(scaledSize.Height / animation.Size.Height));
|
||||
|
||||
animation.Render(canvas, new SKRect(0, 0, animation.Size.Width, animation.Size.Height));
|
||||
|
||||
canvas.Restore();
|
||||
|
||||
_invalidationController.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
private SKColor GetBackgroundColor()
|
||||
{
|
||||
if(_player?.Background is SolidColorBrush sb)
|
||||
{
|
||||
return new SKColor(alpha: sb.ColorWithOpacity.A, red: sb.ColorWithOpacity.R, green: sb.ColorWithOpacity.G, blue: sb.ColorWithOpacity.B);
|
||||
}
|
||||
|
||||
return SKColors.Transparent;
|
||||
}
|
||||
|
||||
private TimeSpan GetFrameTime()
|
||||
{
|
||||
if (_animation is null || _timer is null || !(_playState is { } playState) || _player is null)
|
||||
{
|
||||
return _progress ?? TimeSpan.Zero;
|
||||
}
|
||||
|
||||
var frameTime = TimeSpan.FromSeconds((_stopwatch.Elapsed + playState.GetFromProgressUsingDuration(_animation.Duration)).TotalSeconds * _player.PlaybackRate);
|
||||
|
||||
if (frameTime > playState.GetToProgressUsingDuration(_animation.Duration))
|
||||
{
|
||||
if (playState.Looped)
|
||||
{
|
||||
_stopwatch.Restart();
|
||||
_invalidationController?.End();
|
||||
_invalidationController?.Begin();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Free the animation at the "to" progress value
|
||||
_progress = frameTime;
|
||||
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
|
||||
return frameTime;
|
||||
}
|
||||
|
||||
public void Play(double fromProgress, double toProgress, bool looped)
|
||||
{
|
||||
|
||||
if (_animation != null)
|
||||
{
|
||||
if (_stopwatch.IsRunning)
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
|
||||
_playState = new(fromProgress, toProgress, looped);
|
||||
|
||||
_progress = null;
|
||||
|
||||
_timer = Windows.System.DispatcherQueue.GetForCurrentThread().CreateTimer();
|
||||
_timer.Tick += (s, e) => Invalidate();
|
||||
|
||||
_timer.Interval = TimeSpan.FromSeconds(Math.Max(1 / 120d, 1 / _animation.Fps));
|
||||
_timer.Start();
|
||||
_stopwatch.Restart();
|
||||
|
||||
SetIsPlaying(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_playState = new(fromProgress, toProgress, looped);
|
||||
}
|
||||
}
|
||||
|
||||
private void Invalidate()
|
||||
{
|
||||
#if !__MACCATALYST__
|
||||
if (UseHardwareAcceleration)
|
||||
{
|
||||
_hardwareCanvas?.Invalidate();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
_softwareCanvas?.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
void DoStop()
|
||||
{
|
||||
_playState = null;
|
||||
SetIsPlaying(false);
|
||||
_timer?.Stop();
|
||||
_stopwatch.Stop();
|
||||
_invalidationController?.End();
|
||||
}
|
||||
|
||||
if (Dispatcher.HasThreadAccess)
|
||||
{
|
||||
DoStop();
|
||||
}
|
||||
else
|
||||
{
|
||||
Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, DoStop);
|
||||
}
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
_timer?.Stop();
|
||||
_stopwatch.Stop();
|
||||
|
||||
SetIsPlaying(false);
|
||||
}
|
||||
|
||||
public void Resume()
|
||||
{
|
||||
_stopwatch.Start();
|
||||
_timer?.Start();
|
||||
|
||||
SetIsPlaying(true);
|
||||
}
|
||||
|
||||
public void SetProgress(double progress)
|
||||
{
|
||||
var clampedProgress = Math.Max(0, Math.Min(1, progress));
|
||||
|
||||
if (_animation != null)
|
||||
{
|
||||
Stop();
|
||||
_progress = TimeSpan.FromSeconds(_animation.Duration.TotalSeconds * clampedProgress);
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void Load()
|
||||
{
|
||||
if (_player?.IsPlaying ?? false)
|
||||
{
|
||||
Resume();
|
||||
}
|
||||
}
|
||||
|
||||
public void Unload()
|
||||
{
|
||||
if (_player?.IsPlaying ?? false)
|
||||
{
|
||||
Pause();
|
||||
}
|
||||
}
|
||||
|
||||
private Size CompositionSize
|
||||
=> _animation?.Size is { } size
|
||||
? new Size(size.Width, size.Height)
|
||||
: default;
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -220,129 +220,4 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
private Size CompositionSize => _animation?.IntrinsicContentSize ?? default;
|
||||
}
|
||||
}
|
||||
#else
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Windows.Foundation;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Foundation;
|
||||
using System.Threading.Tasks;
|
||||
using Uno.Disposables;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml;
|
||||
using Uno.Foundation.Logging;
|
||||
|
||||
#if !__MACOS__
|
||||
using Uno.UI.Views.Controls;
|
||||
#endif
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
||||
{
|
||||
partial class LottieVisualSourceBase
|
||||
{
|
||||
#if !__MACOS__
|
||||
private BindableUIActivityIndicatorView? _nativeProgressRing;
|
||||
private IDisposable? _colorDisposable;
|
||||
#endif
|
||||
|
||||
private bool _warnOnce;
|
||||
|
||||
public bool UseHardwareAcceleration { get; set; } = true;
|
||||
|
||||
async Task InnerUpdate(CancellationToken ct)
|
||||
{
|
||||
}
|
||||
|
||||
public void Play(double fromProgress, double toProgress, bool looped)
|
||||
{
|
||||
#if !__MACOS__
|
||||
if (_nativeProgressRing != null)
|
||||
{
|
||||
_nativeProgressRing.StartAnimating();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
#if !__MACOS__
|
||||
if (_nativeProgressRing != null)
|
||||
{
|
||||
_nativeProgressRing.StopAnimating();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
}
|
||||
|
||||
public void Resume()
|
||||
{
|
||||
}
|
||||
|
||||
public void SetProgress(double progress)
|
||||
{
|
||||
}
|
||||
|
||||
public void Load()
|
||||
{
|
||||
if (!TryLoadProgressRing() && !_warnOnce)
|
||||
{
|
||||
_warnOnce = true;
|
||||
this.Log().Warn("LottieVisualSource is not available on this platform. See https://github.com/mono/SkiaSharp/issues/1787");
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryLoadProgressRing()
|
||||
{
|
||||
#if !__MACOS__
|
||||
if (_player?.TemplatedParent is Microsoft.UI.Xaml.Controls.ProgressRing progress)
|
||||
{
|
||||
_nativeProgressRing ??= new BindableUIActivityIndicatorView();
|
||||
|
||||
#if __IOS__
|
||||
_player?.Add(_nativeProgressRing);
|
||||
#else
|
||||
_player?.AddSubview(_bindableProgressBar);
|
||||
#endif
|
||||
|
||||
void UpdateColor()
|
||||
{
|
||||
if (progress.Foreground is SolidColorBrush foregroundColor)
|
||||
{
|
||||
_nativeProgressRing.Color = Brush.GetColorWithOpacity(foregroundColor);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateColorCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
|
||||
=> UpdateColor();
|
||||
|
||||
_colorDisposable = progress.RegisterDisposablePropertyChangedCallback(Microsoft.UI.Xaml.Controls.ProgressRing.ForegroundProperty, UpdateColorCallback);
|
||||
|
||||
UpdateColor();
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Unload()
|
||||
{
|
||||
#if !__MACOS__
|
||||
if (_player?.TemplatedParent is Microsoft.UI.Xaml.Controls.ProgressRing progress)
|
||||
{
|
||||
_colorDisposable?.Dispose();
|
||||
|
||||
_nativeProgressRing?.RemoveFromSuperview();
|
||||
_nativeProgressRing = null;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private Size CompositionSize => default;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -262,132 +262,4 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Windows.Foundation;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using System.Threading.Tasks;
|
||||
using Uno.Disposables;
|
||||
using Uno.UI.Controls;
|
||||
using Android.Graphics;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml;
|
||||
using Uno.Foundation.Logging;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
||||
{
|
||||
partial class LottieVisualSourceBase
|
||||
{
|
||||
private BindableProgressBar? _bindableProgressBar;
|
||||
private double _toProgress;
|
||||
private bool _looped;
|
||||
private IDisposable? _colorDisposable;
|
||||
private bool _warnOnce;
|
||||
|
||||
public bool UseHardwareAcceleration { get; set; } = true;
|
||||
|
||||
async Task InnerUpdate(CancellationToken ct)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Play(double fromProgress, double toProgress, bool looped)
|
||||
{
|
||||
_toProgress = toProgress;
|
||||
_looped = looped;
|
||||
|
||||
if(_bindableProgressBar != null)
|
||||
{
|
||||
_bindableProgressBar.SetProgress((int)(toProgress * 100), looped);
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (_bindableProgressBar != null)
|
||||
{
|
||||
_bindableProgressBar.SetProgress(0, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Resume()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void SetProgress(double progress)
|
||||
{
|
||||
if (_bindableProgressBar != null)
|
||||
{
|
||||
_bindableProgressBar.SetProgress((int)(_toProgress * 100), false);
|
||||
}
|
||||
}
|
||||
|
||||
public void Load()
|
||||
{
|
||||
if(!TryLoadProgressRing()&& !_warnOnce)
|
||||
{
|
||||
_warnOnce = true;
|
||||
this.Log().Warn("LottieVisualSource is not available on this platform. See https://github.com/mono/SkiaSharp/issues/1787");
|
||||
}
|
||||
}
|
||||
|
||||
public void Unload()
|
||||
{
|
||||
TryUnloadProgressRing();
|
||||
}
|
||||
|
||||
private bool TryLoadProgressRing()
|
||||
{
|
||||
if (_player?.TemplatedParent is Microsoft.UI.Xaml.Controls.ProgressRing progress)
|
||||
{
|
||||
_bindableProgressBar ??= new BindableProgressBar();
|
||||
|
||||
_player.AddView(_bindableProgressBar);
|
||||
|
||||
void UpdateColor()
|
||||
{
|
||||
if (progress.Foreground is SolidColorBrush foregroundColor && _bindableProgressBar?.IndeterminateDrawable != null)
|
||||
{
|
||||
#pragma warning disable 618 // SetColorFilter is deprecated
|
||||
_bindableProgressBar.IndeterminateDrawable.SetColorFilter(foregroundColor.Color, PorterDuff.Mode.SrcIn!);
|
||||
#pragma warning restore 618 // SetColorFilter is deprecated
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateColorCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args)
|
||||
=> UpdateColor();
|
||||
|
||||
_colorDisposable = progress.RegisterDisposablePropertyChangedCallback(Microsoft.UI.Xaml.Controls.ProgressRing.ForegroundProperty, UpdateColorCallback);
|
||||
|
||||
_bindableProgressBar.SetProgress((int)(_toProgress * 100), _looped);
|
||||
|
||||
UpdateColor();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void TryUnloadProgressRing()
|
||||
{
|
||||
if (_player?.TemplatedParent is Microsoft.UI.Xaml.Controls.ProgressRing progress)
|
||||
{
|
||||
_colorDisposable?.Dispose();
|
||||
_player.RemoveView(_bindableProgressBar);
|
||||
_bindableProgressBar = null;
|
||||
}
|
||||
}
|
||||
|
||||
private Size CompositionSize => default;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,8 @@ using Windows.UI.Xaml.Media;
|
|||
using Uno;
|
||||
using Uno.Disposables;
|
||||
using Uno.Foundation.Logging;
|
||||
using Uno.Extensions;
|
||||
using Uno.Helpers;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
||||
{
|
||||
|
@ -80,8 +82,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
}
|
||||
|
||||
|
||||
#if !(__WASM__ || __ANDROID__ || __IOS__ || __MACOS__)
|
||||
|
||||
#if !(__WASM__ || (__ANDROID__ && !NET6_0) || (__IOS__ && !NET6_0) || (__MACOS__ && !NET6_0) || HAS_SKOTTIE)
|
||||
public void Play(double fromProgress, double toProgress, bool looped)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
@ -123,6 +124,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
}
|
||||
|
||||
private readonly Size CompositionSize = default;
|
||||
private async Task InnerUpdate(CancellationToken ct)
|
||||
{
|
||||
throw new NotSupportedException("Lottie on this platform is not supported yet.");
|
||||
}
|
||||
#endif
|
||||
|
||||
private readonly SerialDisposable _updateDisposable = new SerialDisposable();
|
||||
|
@ -140,13 +145,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
}
|
||||
}
|
||||
|
||||
#if __NETSTD__ && !__WASM__
|
||||
private async Task InnerUpdate(CancellationToken ct)
|
||||
{
|
||||
throw new NotSupportedException("Lottie on this platform is not supported yet.");
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// If the payload needs to be altered before being feed to the player
|
||||
/// </summary>
|
||||
|
@ -242,6 +240,20 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
return json;
|
||||
}
|
||||
|
||||
if (uri.IsLocalResource())
|
||||
{
|
||||
var file = await StorageFile.GetFileFromApplicationUriAsync(uri).AsTask(ct);
|
||||
var value = await file.OpenAsync(FileAccessMode.Read).AsTask(ct);
|
||||
|
||||
return value;
|
||||
}
|
||||
else if (uri.IsAppData())
|
||||
{
|
||||
var fileStream = File.OpenRead(AppDataUriEvaluator.ToPath(uri));
|
||||
|
||||
return fileStream.AsInputStream();
|
||||
}
|
||||
|
||||
return IsPayloadNeedsToBeUpdated
|
||||
? await DownloadJsonFromUri(uri, ct)
|
||||
: null;
|
||||
|
@ -281,13 +293,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
|||
|
||||
private async Task<IInputStream?> DownloadJsonFromUri(Uri uri, CancellationToken ct)
|
||||
{
|
||||
if(uri.Scheme.Equals("ms-appx", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var storageFile = await StorageFile.GetFileFromApplicationUriAsync(uri).AsTask(ct);
|
||||
var storageFileStream = await storageFile.OpenReadAsync().AsTask(ct);
|
||||
return storageFileStream.GetInputStreamAt(0);
|
||||
}
|
||||
|
||||
using var client = new HttpClient();
|
||||
|
||||
using var response = await client.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead, ct);
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
||||
{
|
||||
partial class LottieVisualSourceBase
|
||||
{
|
||||
private async Task InnerUpdate(CancellationToken ct)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.Toolkit.Uwp.UI.Lottie
|
||||
{
|
||||
partial class LottieVisualSourceBase
|
||||
{
|
||||
private async Task InnerUpdate(CancellationToken ct)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
<Project Sdk="MSBuild.Sdk.Extras" ToolsVersion="15.0">
|
||||
<Project Sdk="MSBuild.Sdk.Extras" ToolsVersion="15.0">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="../../netcore-build.props"/>
|
||||
<Import Project="../../targetframework-override.props"/>
|
||||
<Import Project="../../netcore-build.props" />
|
||||
<Import Project="../../targetframework-override.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<NoWarn>$(NoWarn);NU1701</NoWarn>
|
||||
|
@ -17,10 +17,16 @@
|
|||
<UnoRuntimeIdentifier>Skia</UnoRuntimeIdentifier>
|
||||
<PlatformItemsBasePath>.\</PlatformItemsBasePath>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<DefineConstants>$(DefineConstants);HAS_SKOTTIE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Uno.SourceGenerationTasks" />
|
||||
|
||||
<PackageReference Include="SkiaSharp.Skottie" />
|
||||
<PackageReference Include="SkiaSharp.Views.Uno" Condition="'$(UNO_UWP_BUILD)'=='true'" />
|
||||
<PackageReference Include="SkiaSharp.Views.Uno.WinUI" Condition="'$(UNO_UWP_BUILD)'!='true'" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="..\..\Common.targets" />
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
<ItemGroup>
|
||||
<None Remove="tsconfig.json" />
|
||||
<Compile Include="..\..\Uno.UWP\Storage\Helpers\AssetsPathBuilder.wasm.cs" Link="AssetsPathBuilder.wasm.cs" />
|
||||
<Content Include="tsconfig.json" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -9,12 +9,14 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<NoWarn>$(NoWarn);NU1701</NoWarn>
|
||||
<NoWarn>$(NoWarn);NU1701;Uno0001</NoWarn>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<Deterministic>true</Deterministic>
|
||||
<Nullable>enable</Nullable>
|
||||
<AssemblyName>Uno.UI.Lottie</AssemblyName>
|
||||
<RootNamespace>Uno.UI.Lottie</RootNamespace>
|
||||
|
||||
<DefineConstants Condition="'$(UNO_UWP_BUILD)'!='true'">$(DefineConstants);HAS_SKOTTIE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(UnoTargetFrameworkOverride)'!=''">
|
||||
|
@ -43,24 +45,33 @@
|
|||
<ProjectReference Include="..\..\Uno.UI\Uno.UI.net6.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0-android'">
|
||||
<!--<PackageReference Include="Com.Airbnb.Android.Lottie" Version="4.1.0" PrivateAssets="none" />-->
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
|
||||
|
||||
<PackageReference Include="SkiaSharp.Skottie" />
|
||||
|
||||
<PackageReference Include="SkiaSharp.Views.Uno" Condition="'$(UNO_UWP_BUILD)'=='true'" />
|
||||
<PackageReference Include="SkiaSharp.Views.Uno.WinUI" Condition="'$(UNO_UWP_BUILD)'!='true'" />
|
||||
|
||||
<!-- Explicitly included to remove all assets from Uno dependencies coming from SkiaSharp.Views.* -->
|
||||
<PackageReference Include="Uno.UI" Version="4.3.8" ExcludeAssets="all" IncludeAssets="none" PrivateAssets="all" Condition="'$(UNO_UWP_BUILD)'=='true'"/>
|
||||
<PackageReference Include="Uno.WinUI" Version="4.3.8" ExcludeAssets="all" IncludeAssets="none" PrivateAssets="all" Condition="'$(UNO_UWP_BUILD)'!='true'" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0-android'">
|
||||
<PackageReference Include="SkiaSharp.NativeAssets.Android" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0-ios'">
|
||||
<!--<PackageReference Include="Com.Airbnb.iOS.Lottie" Version="2.5.11" PrivateAssets="none" />-->
|
||||
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
|
||||
<PackageReference Include="SkiaSharp.NativeAssets.iOS" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0-maccatalyst'">
|
||||
<!--<PackageReference Include="Com.Airbnb.iOS.Lottie" Version="2.5.11" PrivateAssets="none" />-->
|
||||
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
|
||||
<PackageReference Include="SkiaSharp.NativeAssets.MacCatalyst" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0-macos'">
|
||||
<!--<PackageReference Include="Com.Airbnb.iOS.Lottie" Version="2.5.11" PrivateAssets="none" />-->
|
||||
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
|
||||
<PackageReference Include="SkiaSharp.NativeAssets.macos" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="..\..\SourceGenerators\Uno.UI.SourceGenerators\Content\Uno.UI.SourceGenerators.props" />
|
||||
|
@ -83,6 +94,4 @@
|
|||
<Copy SourceFiles="@(_OutputFiles)" DestinationFiles="@(_OutputFiles->'$(_TargetNugetFolder)\%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
<Copy SourceFiles="@(_OutputFilesPDB)" DestinationFiles="@(_OutputFilesPDB->'$(_TargetNugetFolder)\%(RecursiveDir)%(Filename).pdb')" />
|
||||
</Target>
|
||||
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -1,9 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<ItemGroup>
|
||||
<UnoRuntimeEnabledPackage Include="Uno.UI.Lottie" PackageBasePath="$(MSBuildThisFileDirectory)" Condition="'$(MSBuildThisFile)'=='uno.ui.lottie.targets'" />
|
||||
<UnoRuntimeEnabledPackage Include="Uno.WinUI.Lottie" PackageBasePath="$(MSBuildThisFileDirectory)" Condition="'$(MSBuildThisFile)'=='uno.winui.lottie.targets'" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<UnoRuntimeEnabledPackage Include="Uno.UI.Lottie" PackageBasePath="$(MSBuildThisFileDirectory)" Condition="'$(MSBuildThisFile)'=='uno.ui.lottie.targets'" />
|
||||
<UnoRuntimeEnabledPackage Include="Uno.WinUI.Lottie" PackageBasePath="$(MSBuildThisFileDirectory)" Condition="'$(MSBuildThisFile)'=='uno.winui.lottie.targets'" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="_ValidateLottieDependencySkia"
|
||||
BeforeTargets="CoreCompile"
|
||||
Condition="'$(IsUnoHead)'=='true' and '$(UnoRuntimeIdentifier)'=='Skia'">
|
||||
|
||||
<!--
|
||||
Nuget does not support dynamic references in packages, and we need Skottie only for the Skia UnoRuntime
|
||||
We do the validation at runtime to determine if the SkiaSharp.Views.Uno and SkiaSharp.Skottie packages
|
||||
are referenced.
|
||||
-->
|
||||
|
||||
<PropertyGroup>
|
||||
<_SkiaSharpPackageName Condition="'$(MSBuildThisFile)'=='uno.ui.lottie.targets'">SkiaSharp.Views.Uno</_SkiaSharpPackageName>
|
||||
<_SkiaSharpPackageName Condition="'$(MSBuildThisFile)'=='uno.winui.lottie.targets'">SkiaSharp.Views.Uno.WinUI</_SkiaSharpPackageName>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<_SkiaSharpViewsRefs Include="@(RuntimeCopyLocalItems)" Condition="'%(RuntimeCopyLocalItems.NuGetPackageId)' == '$(_SkiaSharpPackageName)'" />
|
||||
<_SkottieRefs Include="@(RuntimeCopyLocalItems)" Condition="'%(RuntimeCopyLocalItems.NuGetPackageId)' == 'SkiaSharp.Skottie'" />
|
||||
</ItemGroup>
|
||||
|
||||
<Error Condition="'@(_SkiaSharpViewsRefs)'==''" Text="In order to use Uno Lottie support, the '$(_SkiaSharpPackageName)' NuGet Package (2.88.1-preview.71 or later) must be referenced in the project. You can add <PackageReference Include="$(_SkiaSharpPackageName)" Version="2.88.1-preview.71" /> to your project." />
|
||||
<Error Condition="'@(_SkottieRefs)'==''" Text="The 'SkiaSharp.Skottie' NuGet Package (2.88.1-preview.71 or later) must be referenced in the project. You can add <PackageReference Include="SkiaSharp.Skottie" Version="2.88.1-preview.71" /> to your project." />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
|
@ -45,14 +45,23 @@
|
|||
<PackageReference Update="Xamarin.DuoSdk" Version="0.0.3.4" />
|
||||
<PackageReference Update="Xamarin.UITest" Version="3.2.8" />
|
||||
<PackageReference Update="System.Numerics.Vectors" Version="4.5.0" />
|
||||
<PackageReference Update="SkiaSharp.Views" Version="2.80.3" />
|
||||
<PackageReference Update="SkiaSharp.Views.WPF" Version="2.80.3" />
|
||||
<PackageReference Update="SkiaSharp" Version="2.80.3" />
|
||||
<PackageReference Update="SkiaSharp.NativeAssets.Linux" Version="2.80.3" />
|
||||
<PackageReference Update="SkiaSharp.Harfbuzz" Version="2.80.3" />
|
||||
<PackageReference Update="HarfBuzzSharp.NativeAssets.Linux" Version="2.8.2" />
|
||||
<PackageReference Update="HarfBuzzSharp.NativeAssets.Tizen" Version="2.8.2" />
|
||||
<PackageReference Update="SkiaSharp.HarfBuzz" Version="2.80.3" />
|
||||
|
||||
<PackageReference Update="SkiaSharp.Views" Version="2.88.1-preview.71" />
|
||||
<PackageReference Update="SkiaSharp.Views.Uno" Version="2.88.1-preview.71" />
|
||||
<PackageReference Update="SkiaSharp.Views.Uno.WinUI" Version="2.88.1-preview.71" />
|
||||
<PackageReference Update="SkiaSharp.Views.WPF" Version="2.88.1-preview.71" />
|
||||
<PackageReference Update="SkiaSharp" Version="2.88.1-preview.71" />
|
||||
<PackageReference Update="SkiaSharp.NativeAssets.Linux" Version="2.88.1-preview.71" />
|
||||
<PackageReference Update="SkiaSharp.Harfbuzz" Version="2.88.1-preview.71" />
|
||||
<PackageReference Update="SkiaSharp.Skottie" Version="2.88.1-preview.71" />
|
||||
<PackageReference Update="SkiaSharp.NativeAssets.Android" Version="2.88.1-preview.71" />
|
||||
<PackageReference Update="SkiaSharp.NativeAssets.iOS" Version="2.88.1-preview.71" />
|
||||
<PackageReference Update="SkiaSharp.NativeAssets.MacCatalyst" Version="2.88.1-preview.71" />
|
||||
<PackageReference Update="SkiaSharp.NativeAssets.macos" Version="2.88.1-preview.71" />
|
||||
|
||||
<PackageReference Update="HarfBuzzSharp.NativeAssets.Linux" Version="2.8.2.1-preview.71" />
|
||||
<PackageReference Update="HarfBuzzSharp.NativeAssets.Tizen" Version="2.8.2.1-preview.71" />
|
||||
<PackageReference Update="SkiaSharp.HarfBuzz" Version="2.88.1-preview.71" />
|
||||
<PackageReference Update="GtkSharp" Version="3.24.24.34" />
|
||||
<PackageReference Update="System.Json" Version="4.7.1" />
|
||||
<PackageReference Update="FluentAssertions" Version="5.10.3" />
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
|
||||
<PackageReference Include="SkiaSharp.Views.WPF" Version="2.80.3" />
|
||||
<PackageReference Include="SkiaSharp.Views.WPF" Version="2.88.1-preview.71" />
|
||||
<PackageReference Include="SkiaSharp.Views.Uno" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -79,5 +80,6 @@
|
|||
|
||||
<Import Project="..\..\..\build\*.Skia.Wpf.props" />
|
||||
<Import Project="..\..\..\build\*.Skia.Wpf.targets" />
|
||||
<Import Project="..\..\..\build\uno.winui.runtime-replace.targets" />
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -30,7 +30,11 @@
|
|||
|
||||
<AndroidEnableMultiDex>true</AndroidEnableMultiDex>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<SynthesizeLinkMetadata>true</SynthesizeLinkMetadata>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)'=='net6.0-ios'">
|
||||
<SupportedOSPlatformVersion>10.0</SupportedOSPlatformVersion>
|
||||
</PropertyGroup>
|
||||
|
@ -93,6 +97,22 @@
|
|||
<PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.1" />
|
||||
<PackageReference Include="Uno.Core.Extensions.Logging.Singleton" Version="4.0.0-dev.7" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0-android'">
|
||||
<PackageReference Include="SkiaSharp.NativeAssets.Android" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0-ios'">
|
||||
<PackageReference Include="SkiaSharp.NativeAssets.iOS" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0-maccatalyst'">
|
||||
<PackageReference Include="SkiaSharp.NativeAssets.MacCatalyst" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0-macos'">
|
||||
<PackageReference Include="SkiaSharp.NativeAssets.macos" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)'=='net6.0-android'">
|
||||
<ProjectReference Include="..\..\Uno.UI.BindingHelper.Android\Uno.UI.BindingHelper.Android.net6.csproj" />
|
||||
|
@ -118,7 +138,6 @@
|
|||
|
||||
<ItemGroup>
|
||||
<Folder Include="MacOS\" />
|
||||
<Folder Include="obj\" />
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
|
||||
<PackageReference Include="SkiaSharp.Views" Version="2.80.3" />
|
||||
<PackageReference Include="SkiaSharp.Views" Version="2.88.1-preview.71" />
|
||||
<PackageReference Include="Uno.UI.Skia.Tizen" Version="3.0.0-dev.1447" />
|
||||
<PackageReference Include="Uno.UI.RemoteControl" Version="3.0.0-dev.1447" Condition="'$(Configuration)'=='Debug'" />
|
||||
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="3.0.5" />
|
||||
|
|
|
@ -3966,6 +3966,7 @@ Global
|
|||
{3C272635-C7D1-444C-86C2-CB95E367D13D}.Debug|iPhone.Build.0 = Debug|Any CPU
|
||||
{3C272635-C7D1-444C-86C2-CB95E367D13D}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
|
||||
{3C272635-C7D1-444C-86C2-CB95E367D13D}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
|
||||
{3C272635-C7D1-444C-86C2-CB95E367D13D}.Debug|iPhoneSimulator.Deploy.0 = Debug|Any CPU
|
||||
{3C272635-C7D1-444C-86C2-CB95E367D13D}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{3C272635-C7D1-444C-86C2-CB95E367D13D}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{3C272635-C7D1-444C-86C2-CB95E367D13D}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="$(PlatformItemsBasePath)Microsoft\UI\Xaml\Controls\ProgressRing\ProgressRingIntdeterminate.json" />
|
||||
<EmbeddedResource Include="$(PlatformItemsBasePath)Microsoft\UI\Xaml\Controls\ProgressRing\*.json" />
|
||||
<PRIResource Include="$(PlatformItemsBasePath)**\*.resw" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@
|
|||
<EmbeddedResource Include="LinkerDefinition.$(TargetFramework).xml" Condition="exists('LinkerDefinition.$(TargetFramework).xml')">
|
||||
<LogicalName>$(AssemblyName).xml</LogicalName>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Microsoft\UI\Xaml\Controls\ProgressRing\ProgressRingIntdeterminate.json" />
|
||||
<EmbeddedResource Include="Microsoft\UI\Xaml\Controls\ProgressRing\*.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)'=='net461'">
|
||||
|
|
|
@ -9,6 +9,7 @@ using System.Runtime.InteropServices;
|
|||
[assembly: InternalsVisibleTo("Uno.UI.Tests")]
|
||||
[assembly: InternalsVisibleTo("Uno.UI.Toolkit")]
|
||||
[assembly: InternalsVisibleTo("Uno.UI.Composition")]
|
||||
[assembly: InternalsVisibleTo("Uno.UI.Lottie")]
|
||||
|
||||
[assembly: InternalsVisibleTo("SamplesApp")]
|
||||
[assembly: InternalsVisibleTo("SamplesApp.Droid")]
|
||||
|
|
Загрузка…
Ссылка в новой задаче