Skip to content

Commit

Permalink
feat: Add support for Lottie on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinZikmund committed Mar 25, 2020
1 parent 17df575 commit 1b8c6e5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/AddIns/Uno.UI.Lottie/LottieVisualSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public async Task SetSourceAsync(Uri sourceUri)
}


#if !(__WASM__ || __ANDROID__ || __IOS__)
#if !(__WASM__ || __ANDROID__ || __IOS__ || __MACOS__)

private void Update()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
using Windows.UI.Xaml.Controls;
using Airbnb.Lottie;

#if __IOS__
using _ViewContentMode = UIKit.UIViewContentMode;
#else
using _ViewContentMode = Airbnb.Lottie.LOTViewContentMode;
#endif

namespace Microsoft.Toolkit.Uwp.UI.Lottie
{
partial class LottieVisualSource
Expand All @@ -29,8 +35,11 @@ public void Update(AnimatedVisualPlayer player)
_animation = new LOTAnimationView();
//_animation.Scale = (float)Scale;
SetProperties();

#if __IOS__
player.Add(_animation);
#else
player.AddSubview(_animation);
#endif
}
else
{
Expand All @@ -44,18 +53,17 @@ void SetProperties()
switch (player.Stretch)
{
case Windows.UI.Xaml.Media.Stretch.None:
_animation.ContentMode = UIKit.UIViewContentMode.Center;
_animation.ContentMode = _ViewContentMode.Center;
break;
case Windows.UI.Xaml.Media.Stretch.Uniform:
_animation.ContentMode = UIKit.UIViewContentMode.ScaleAspectFit;
_animation.ContentMode = _ViewContentMode.ScaleAspectFit;
break;
case Windows.UI.Xaml.Media.Stretch.Fill:
_animation.ContentMode = UIKit.UIViewContentMode.ScaleToFill;
_animation.ContentMode = _ViewContentMode.ScaleToFill;
break;
case Windows.UI.Xaml.Media.Stretch.UniformToFill:
_animation.ContentMode = UIKit.UIViewContentMode.ScaleAspectFill;
_animation.ContentMode = _ViewContentMode.ScaleAspectFill;
break;

}


Expand Down Expand Up @@ -116,7 +124,7 @@ public void Unload()

Size IAnimatedVisualSource.Measure(Size availableSize)
{
throw new NotImplementedException();
return availableSize;
}
}
}
2 changes: 1 addition & 1 deletion src/AddIns/Uno.UI.Lottie/Uno.UI.Lottie.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<PackageReference Include="Com.Airbnb.Android.Lottie" Version="2.5.2.1" PrivateAssets="none" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'xamarinios10'">
<ItemGroup Condition="'$(TargetFramework)' == 'xamarinios10' or '$(TargetFramework)' == 'xamarinmac20'">
<PackageReference Include="Com.Airbnb.iOS.Lottie" Version="2.5.10" PrivateAssets="none" />
</ItemGroup>

Expand Down

0 comments on commit 1b8c6e5

Please sign in to comment.