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

MAUI .NET 8 #395

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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 Lottie.Android/Lottie.Android.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0-android</TargetFrameworks>
<TargetFrameworks>net8.0-android</TargetFrameworks>
<AssemblyName>Lottie.Android</AssemblyName>
<RootNamespace>Lottie.Android</RootNamespace>
<Description>Render After Effects animations natively on Android, iOS, MacOS, TVOs and UWP</Description>
Expand Down
7 changes: 4 additions & 3 deletions Lottie.Maui/Lottie.Maui.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks>net8.0-android;net8.0-ios</TargetFrameworks>
<!--<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>-->
<UseMaui>true</UseMaui>
</PropertyGroup>

Expand Down Expand Up @@ -70,6 +71,6 @@
<None Remove="Platforms\Tizen\**\*.cs" />
<Compile Include="Platforms\Tizen\**\*.cs" />
<PackageReference Include="ElottieSharp" Version="0.9.7-preview2" />
</ItemGroup>
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions Lottie.Maui/Platforms/Ios/AnimationViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ protected override void OnElementChanged(ElementChangedEventArgs<AnimationView>
CompletionBlock = _animationCompletionBlock
};

_animationView.Layer.MasksToBounds = true;

var composition = e.NewElement.GetAnimation();
_animationView.SceneModel = composition;
e.NewElement.InvokeAnimationLoaded(composition);
Expand Down
48 changes: 24 additions & 24 deletions Lottie.iOS/ApiDefinitions.Ios.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using CoreGraphics;
using Foundation;
using ObjCRuntime;
Expand All @@ -7,7 +7,7 @@
namespace Airbnb.Lottie
{
// @interface LOTAnimationTransitionController : NSObject <UIViewControllerAnimatedTransitioning>
[BaseType(typeof(NSObject))]
//[BaseType(typeof(NSObject))]
interface LOTAnimationTransitionController : IUIViewControllerAnimatedTransitioning
{
// -(instancetype _Nonnull)initWithAnimationNamed:(NSString * _Nonnull)animation fromLayerNamed:(NSString * _Nullable)fromLayer toLayerNamed:(NSString * _Nullable)toLayer applyAnimationTransform:(BOOL)applyAnimationTransform;
Expand Down Expand Up @@ -72,7 +72,7 @@ interface LOTAnimatedSwitch
}

// @interface LOTCacheProvider : NSObject
[BaseType(typeof(NSObject))]
//[BaseType(typeof(NSObject))]
interface LOTCacheProvider
{
// +(id<LOTImageCache>)imageCache;
Expand All @@ -84,7 +84,7 @@ interface LOTCacheProvider

// @protocol LOTImageCache <NSObject>
[Protocol, Model]
[BaseType(typeof(NSObject))]
//[BaseType(typeof(NSObject))]
interface LOTImageCache
{
// @required -(UIImage *)imageForKey:(NSString *)key;
Expand Down Expand Up @@ -238,14 +238,14 @@ interface LOTKeypath

// @protocol LOTValueDelegate <NSObject>
[Protocol, Model]
[BaseType(typeof(NSObject))]
////[BaseType(typeof(NSObject))]
interface LOTValueDelegate
{
}

// @protocol LOTColorValueDelegate <LOTValueDelegate>
[Protocol, Model]
[BaseType(typeof(LOTValueDelegate))]
//[BaseType(typeof(LOTValueDelegate))]
interface LOTColorValueDelegate
{
// @required -(CGColorRef)colorForFrame:(CGFloat)currentFrame startKeyframe:(CGFloat)startKeyframe endKeyframe:(CGFloat)endKeyframe interpolatedProgress:(CGFloat)interpolatedProgress startColor:(CGColorRef)startColor endColor:(CGColorRef)endColor currentColor:(CGColorRef)interpolatedColor;
Expand All @@ -256,7 +256,7 @@ interface LOTColorValueDelegate

// @protocol LOTNumberValueDelegate <LOTValueDelegate>
[Protocol, Model]
[BaseType(typeof(LOTValueDelegate))]
//[BaseType(typeof(LOTValueDelegate))]
interface LOTNumberValueDelegate
{
// @required -(CGFloat)floatValueForFrame:(CGFloat)currentFrame startKeyframe:(CGFloat)startKeyframe endKeyframe:(CGFloat)endKeyframe interpolatedProgress:(CGFloat)interpolatedProgress startValue:(CGFloat)startValue endValue:(CGFloat)endValue currentValue:(CGFloat)interpolatedValue;
Expand All @@ -267,7 +267,7 @@ interface LOTNumberValueDelegate

// @protocol LOTPointValueDelegate <LOTValueDelegate>
[Protocol, Model]
[BaseType(typeof(LOTValueDelegate))]
//[BaseType(typeof(LOTValueDelegate))]
interface LOTPointValueDelegate
{
// @required -(CGPoint)pointForFrame:(CGFloat)currentFrame startKeyframe:(CGFloat)startKeyframe endKeyframe:(CGFloat)endKeyframe interpolatedProgress:(CGFloat)interpolatedProgress startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint currentPoint:(CGPoint)interpolatedPoint;
Expand All @@ -278,7 +278,7 @@ interface LOTPointValueDelegate

// @protocol LOTSizeValueDelegate <LOTValueDelegate>
[Protocol, Model]
[BaseType(typeof(LOTValueDelegate))]
//[BaseType(typeof(LOTValueDelegate))]
interface LOTSizeValueDelegate
{
// @required -(CGSize)sizeForFrame:(CGFloat)currentFrame startKeyframe:(CGFloat)startKeyframe endKeyframe:(CGFloat)endKeyframe interpolatedProgress:(CGFloat)interpolatedProgress startSize:(CGSize)startSize endSize:(CGSize)endSize currentSize:(CGSize)interpolatedSize;
Expand All @@ -289,7 +289,7 @@ interface LOTSizeValueDelegate

// @protocol LOTPathValueDelegate <LOTValueDelegate>
[Protocol, Model]
[BaseType(typeof(LOTValueDelegate))]
//[BaseType(typeof(LOTValueDelegate))]
interface LOTPathValueDelegate
{
// @required -(CGPathRef)pathForFrame:(CGFloat)currentFrame startKeyframe:(CGFloat)startKeyframe endKeyframe:(CGFloat)endKeyframe interpolatedProgress:(CGFloat)interpolatedProgress;
Expand Down Expand Up @@ -473,7 +473,7 @@ interface LOTAnimationView
}

// @interface LOTAnimationCache : NSObject
[BaseType(typeof(NSObject))]
//[BaseType(typeof(NSObject))]
interface LOTAnimationCache
{
// +(instancetype _Nonnull)sharedCache;
Expand Down Expand Up @@ -519,7 +519,7 @@ interface LOTAnimationCache
unsafe delegate CGPath LOTPathValueCallbackBlock(nfloat currentFrame, nfloat startKeyFrame, nfloat endKeyFrame, nfloat interpolatedProgress);

// @interface LOTColorBlockCallback : NSObject <LOTColorValueDelegate>
[BaseType(typeof(NSObject))]
//[BaseType(typeof(NSObject))]
interface LOTColorBlockCallback : LOTColorValueDelegate
{
// +(instancetype _Nonnull)withBlock:(LOTColorValueCallbackBlock _Nonnull)block;
Expand All @@ -533,7 +533,7 @@ interface LOTColorBlockCallback : LOTColorValueDelegate
}

// @interface LOTNumberBlockCallback : NSObject <LOTNumberValueDelegate>
[BaseType(typeof(NSObject))]
//[BaseType(typeof(NSObject))]
interface LOTNumberBlockCallback : LOTNumberValueDelegate
{
// +(instancetype _Nonnull)withBlock:(LOTNumberValueCallbackBlock _Nonnull)block;
Expand All @@ -547,7 +547,7 @@ interface LOTNumberBlockCallback : LOTNumberValueDelegate
}

// @interface LOTPointBlockCallback : NSObject <LOTPointValueDelegate>
[BaseType(typeof(NSObject))]
//[BaseType(typeof(NSObject))]
interface LOTPointBlockCallback : LOTPointValueDelegate
{
// +(instancetype _Nonnull)withBlock:(LOTPointValueCallbackBlock _Nonnull)block;
Expand All @@ -561,7 +561,7 @@ interface LOTPointBlockCallback : LOTPointValueDelegate
}

// @interface LOTSizeBlockCallback : NSObject <LOTSizeValueDelegate>
[BaseType(typeof(NSObject))]
//[BaseType(typeof(NSObject))]
interface LOTSizeBlockCallback : LOTSizeValueDelegate
{
// +(instancetype _Nonnull)withBlock:(LOTSizeValueCallbackBlock _Nonnull)block;
Expand All @@ -575,7 +575,7 @@ interface LOTSizeBlockCallback : LOTSizeValueDelegate
}

// @interface LOTPathBlockCallback : NSObject <LOTPathValueDelegate>
[BaseType(typeof(NSObject))]
//[BaseType(typeof(NSObject))]
interface LOTPathBlockCallback : LOTPathValueDelegate
{
// +(instancetype _Nonnull)withBlock:(LOTPathValueCallbackBlock _Nonnull)block;
Expand All @@ -589,7 +589,7 @@ interface LOTPathBlockCallback : LOTPathValueDelegate
}

// @interface LOTPointInterpolatorCallback : NSObject <LOTPointValueDelegate>
[BaseType(typeof(NSObject))]
//[BaseType(typeof(NSObject))]
interface LOTPointInterpolatorCallback : LOTPointValueDelegate
{
// +(instancetype _Nonnull)withFromPoint:(CGPoint)fromPoint toPoint:(CGPoint)toPoint;
Expand All @@ -611,7 +611,7 @@ interface LOTPointInterpolatorCallback : LOTPointValueDelegate
}

// @interface LOTSizeInterpolatorCallback : NSObject <LOTSizeValueDelegate>
[BaseType(typeof(NSObject))]
//[BaseType(typeof(NSObject))]
interface LOTSizeInterpolatorCallback : LOTSizeValueDelegate
{
// +(instancetype _Nonnull)withFromSize:(CGSize)fromSize toSize:(CGSize)toSize;
Expand All @@ -633,7 +633,7 @@ interface LOTSizeInterpolatorCallback : LOTSizeValueDelegate
}

// @interface LOTFloatInterpolatorCallback : NSObject <LOTNumberValueDelegate>
[BaseType(typeof(NSObject))]
//[BaseType(typeof(NSObject))]
interface LOTFloatInterpolatorCallback : LOTNumberValueDelegate
{
// +(instancetype _Nonnull)withFromFloat:(CGFloat)fromFloat toFloat:(CGFloat)toFloat;
Expand All @@ -655,7 +655,7 @@ interface LOTFloatInterpolatorCallback : LOTNumberValueDelegate
}

// @interface LOTColorValueCallback : NSObject <LOTColorValueDelegate>
[BaseType(typeof(NSObject))]
////[BaseType(typeof(NSObject))]
interface LOTColorValueCallback : LOTColorValueDelegate
{
// +(instancetype _Nonnull)withCGColor:(CGColorRef _Nonnull)color;
Expand All @@ -669,7 +669,7 @@ interface LOTColorValueCallback : LOTColorValueDelegate
}

// @interface LOTNumberValueCallback : NSObject <LOTNumberValueDelegate>
[BaseType(typeof(NSObject))]
//[BaseType(typeof(NSObject))]
interface LOTNumberValueCallback : LOTNumberValueDelegate
{
// +(instancetype _Nonnull)withFloatValue:(CGFloat)numberValue;
Expand All @@ -683,7 +683,7 @@ interface LOTNumberValueCallback : LOTNumberValueDelegate
}

// @interface LOTPointValueCallback : NSObject <LOTPointValueDelegate>
[BaseType(typeof(NSObject))]
//[BaseType(typeof(NSObject))]
interface LOTPointValueCallback : LOTPointValueDelegate
{
// +(instancetype _Nonnull)withPointValue:(CGPoint)pointValue;
Expand All @@ -697,7 +697,7 @@ interface LOTPointValueCallback : LOTPointValueDelegate
}

// @interface LOTSizeValueCallback : NSObject <LOTSizeValueDelegate>
[BaseType(typeof(NSObject))]
//[BaseType(typeof(NSObject))]
interface LOTSizeValueCallback : LOTSizeValueDelegate
{
// +(instancetype _Nonnull)withPointValue:(CGSize)sizeValue;
Expand All @@ -711,7 +711,7 @@ interface LOTSizeValueCallback : LOTSizeValueDelegate
}

// @interface LOTPathValueCallback : NSObject <LOTPathValueDelegate>
[BaseType(typeof(NSObject))]
//[BaseType(typeof(NSObject))]
interface LOTPathValueCallback : LOTPathValueDelegate
{
// +(instancetype _Nonnull)withCGPath:(CGPathRef _Nonnull)path;
Expand Down
4 changes: 3 additions & 1 deletion Lottie.iOS/Lottie.iOS.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<!--<TargetFrameworks>net8.0-ios;net8.0-maccatalyst</TargetFrameworks>-->
<TargetFrameworks>net8.0-ios</TargetFrameworks>
<AssemblyName>Lottie.iOS</AssemblyName>
<RootNamespace>Lottie.iOS</RootNamespace>
<Description>Render After Effects animations natively on Android, iOS, MacOS, TVOs and UWP</Description>
<PackageId>Com.Airbnb.iOS.Lottie</PackageId>
<EnableDefaultItems>false</EnableDefaultItems>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<IsBindingProject>true</IsBindingProject>
<Version>2.6.0</Version>
</PropertyGroup>

Expand Down
14 changes: 10 additions & 4 deletions Samples/Maui/Lottie.Sample/Lottie.Sample.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks>net8.0-android;net8.0-ios</TargetFrameworks>
<!--<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>-->
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
Expand All @@ -28,7 +29,7 @@
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>
</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
Expand All @@ -49,7 +50,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.0-preview.7.8842" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Lottie.Maui\Lottie.Maui.csproj" />
</ItemGroup>

</Project>
45 changes: 18 additions & 27 deletions Samples/Maui/Lottie.Sample/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -1,41 +1,32 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:lottie="clr-namespace:Lottie.Forms;assembly=Lottie.Maui"
x:Class="Lottie.Sample.MainPage">

<ScrollView>
<VerticalStackLayout
Spacing="25"
Padding="30,0"
VerticalOptions="Center">
<Grid Margin="20"
RowSpacing="20"
VerticalOptions="FillAndExpand">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>

<Image
Source="dotnet_bot.png"
SemanticProperties.Description="Cute dot net bot waving hi to you!"
HeightRequest="200"
HorizontalOptions="Center" />

<Label
Text="Hello, World!"
SemanticProperties.HeadingLevel="Level1"
FontSize="32"
HorizontalOptions="Center" />
<lottie:AnimationView Grid.Row="0"
Animation="animation_llq1y8ia.json"
AnimationSource="AssetOrBundle"
HeightRequest="200"
WidthRequest="200"
AutoPlay="True"
RepeatMode="Infinite"
RepeatCount="-1"/>

<Label
Text="Welcome to .NET Multi-platform App UI"
SemanticProperties.HeadingLevel="Level2"
SemanticProperties.Description="Welcome to dot net Multi platform App U I"
FontSize="18"
HorizontalOptions="Center" />

<Button
<Button Grid.Row="1"
x:Name="CounterBtn"
Text="Click me"
SemanticProperties.Hint="Counts the number of times you click"
Clicked="OnCounterClicked"
HorizontalOptions="Center" />

</VerticalStackLayout>
</ScrollView>
</Grid>

</ContentPage>
18 changes: 15 additions & 3 deletions Samples/Maui/Lottie.Sample/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using Microsoft.Maui.Controls.Compatibility.Hosting;

namespace Lottie.Sample
{
Expand All @@ -9,10 +10,21 @@ public static MauiApp CreateMauiApp()
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiCompatibility()

.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
fonts.AddFont("OpenSans_Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans_Semibold.ttf", "OpenSansSemibold");
})
.ConfigureMauiHandlers(handlers =>
{
#if ANDROID
handlers.AddCompatibilityRenderer(typeof(Lottie.Forms.AnimationView), typeof(Lottie.Forms.Platforms.Android.AnimationViewRenderer));
#endif
#if IOS
handlers.AddCompatibilityRenderer(typeof(Lottie.Forms.AnimationView), typeof(Lottie.Forms.Platforms.Ios.AnimationViewRenderer));
#endif
});

#if DEBUG
Expand All @@ -22,4 +34,4 @@ public static MauiApp CreateMauiApp()
return builder.Build();
}
}
}
}
Loading