Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit c1738bd

Browse files
maui-compat-1.3.0
1 parent 27dcf50 commit c1738bd

File tree

404 files changed

+38409
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

404 files changed

+38409
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<Project>
2+
<PropertyGroup>
3+
<Nullable>enable</Nullable>
4+
<PackageId>Xamarin.CommunityToolkit.MauiCompat</PackageId>
5+
<Summary>A .NET MAUI Comapatible version of Xamarin.CommunityToolkit, a community-created toolkit with common Xamarin converters, effects, behaviors etc.</Summary>
6+
<PackageTag>maui,net,xamarin,ios,android,uwp,xamarin.forms,effects,controls,converters,animations,toolkit,kit,communitytoolkit,xamarincommunitytoolkit,watchos,tvos,tizen,Microsoft.Toolkit.Xamarin.Forms</PackageTag>
7+
<Title>Xamarin.CommunityToolkit.MauiCompat</Title>
8+
<Description>Xamarin.CommunityToolkit.MauiCompat is a collection of Animations, Behaviors, Converters, and Effects for mobile development with .NET MAUI. It is the .NET MAUI Compatible version of Xamarin.CommunityToolkit.</Description>
9+
<PackageIcon>icon.png</PackageIcon>
10+
<PackageVersion>$(Version)$(VersionSuffix)</PackageVersion>
11+
<Authors>Microsoft</Authors>
12+
<Owners>microsoft</Owners>
13+
<NeutralLanguage>en</NeutralLanguage>
14+
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
15+
<RepositoryUrl>https://github.com/xamarin/XamarinCommunityToolkit</RepositoryUrl>
16+
<PackageReleaseNotes>See: http://aka.ms/xct-release-notes</PackageReleaseNotes>
17+
<DefineConstants>$(DefineConstants);</DefineConstants>
18+
<UseFullSemVerForNuGet>false</UseFullSemVerForNuGet>
19+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
20+
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
21+
<PackageProjectUrl>https://github.com/xamarin/XamarinCommunityToolkit</PackageProjectUrl>
22+
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
23+
<Version>1.3.0-pre2</Version>
24+
</PropertyGroup>
25+
26+
<ItemGroup>
27+
<Compile Include="**/*.shared.cs" />
28+
<Compile Include="**/*.shared.*.cs" />
29+
<None Include="../../../LICENSE" PackagePath="" Pack="true" />
30+
<None Include="../../../assets/XamarinCommunityToolkit_128x128.png" PackagePath="icon.png" Pack="true" />
31+
</ItemGroup>
32+
33+
<ItemGroup Condition=" $(TargetFramework.Contains(-android)) ">
34+
<Compile Include="**\*.android.cs" />
35+
<Compile Include="**\*.android.*.cs" />
36+
<AndroidResource Include="Resources\**\*.axml" />
37+
<AndroidResource Include="Resources\**\*.xml" />
38+
<AndroidResource Include="Resources\**\*.png" />
39+
</ItemGroup>
40+
41+
<ItemGroup Condition=" $(TargetFramework.Contains(-ios)) ">
42+
<Compile Include="**\*.ios.cs" />
43+
<Compile Include="**\*.ios.*.cs" />
44+
</ItemGroup>
45+
46+
<ItemGroup Condition=" $(TargetFramework.Contains('-windows')) ">
47+
<Compile Include="**\*.uwp.cs" />
48+
<Compile Include="**\*.uwp.*.cs" />
49+
</ItemGroup>
50+
51+
<ItemGroup Condition=" $(TargetFramework.Contains('-maccatalyst')) ">
52+
<Compile Include="**\*.macos.cs" />
53+
<Compile Include="**\*.macos.*.cs" />
54+
</ItemGroup>
55+
</Project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30114.105
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.CommunityToolkit.MauiCompat", "Xamarin.CommunityToolkit.MauiCompat\Xamarin.CommunityToolkit.MauiCompat.csproj", "{DD5F5E42-B509-4631-8522-1398BA2E7CF3}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(SolutionProperties) = preSolution
14+
HideSolutionNode = FALSE
15+
EndGlobalSection
16+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
17+
{DD5F5E42-B509-4631-8522-1398BA2E7CF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18+
{DD5F5E42-B509-4631-8522-1398BA2E7CF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
19+
{DD5F5E42-B509-4631-8522-1398BA2E7CF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
20+
{DD5F5E42-B509-4631-8522-1398BA2E7CF3}.Release|Any CPU.Build.0 = Release|Any CPU
21+
EndGlobalSection
22+
EndGlobal
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using Paint = Android.Graphics.Paint;using Path = Android.Graphics.Path;using Android;
2+
using Xamarin.CommunityToolkit.UI.Views;
3+
using Microsoft.Maui; using Microsoft.Maui.Controls; using Microsoft.Maui.Graphics; using Microsoft.Maui.Controls.Compatibility;
4+
5+
[assembly: LinkerSafe]
6+
7+
[assembly: ExportImageSourceHandler(typeof(GravatarImageSource), typeof(GravatarImageSourceHandler))]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using Foundation;
2+
using Xamarin.CommunityToolkit.UI.Views;
3+
using Microsoft.Maui; using Microsoft.Maui.Controls; using Microsoft.Maui.Graphics; using Microsoft.Maui.Controls.Compatibility;
4+
5+
#pragma warning disable CS0618 // Type or member is obsolete
6+
[assembly: LinkerSafe]
7+
#pragma warning restore CS0618 // Type or member is obsolete
8+
9+
#if XAMARIN_IOS || XAMARIN_MAC
10+
[assembly: ExportImageSourceHandler(typeof(GravatarImageSource), typeof(GravatarImageSourceHandler))]
11+
#endif
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Runtime.CompilerServices;
2+
using Microsoft.Maui; using Microsoft.Maui.Controls; using Microsoft.Maui.Graphics; using Microsoft.Maui.Controls.Compatibility;
3+
4+
[assembly: InternalsVisibleTo("Xamarin.CommunityToolkit.UnitTests")]
5+
6+
#if !NETSTANDARD1_0
7+
[assembly: XmlnsDefinition("http://xamarin.com/schemas/2020/toolkit", "Xamarin.CommunityToolkit.Behaviors")]
8+
[assembly: XmlnsDefinition("http://xamarin.com/schemas/2020/toolkit", "Xamarin.CommunityToolkit.Converters")]
9+
[assembly: XmlnsDefinition("http://xamarin.com/schemas/2020/toolkit", "Xamarin.CommunityToolkit.Effects")]
10+
[assembly: XmlnsDefinition("http://xamarin.com/schemas/2020/toolkit", "Xamarin.CommunityToolkit.Extensions")]
11+
[assembly: XmlnsDefinition("http://xamarin.com/schemas/2020/toolkit", "Xamarin.CommunityToolkit.UI.Views")]
12+
#endif
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
using Xamarin.CommunityToolkit.UI.Views;
2+
using Microsoft.Maui; using Microsoft.Maui.Controls; using Microsoft.Maui.Graphics; using Microsoft.Maui.Controls.Compatibility;
3+
4+
[assembly: ExportImageSourceHandler(typeof(GravatarImageSource), typeof(GravatarImageSourceHandler))]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
using Xamarin.CommunityToolkit.UI.Views;
2+
using Microsoft.Maui.Controls.Compatibility.Platform.UWP;
3+
4+
[assembly: ExportImageSourceHandler(typeof(GravatarImageSource), typeof(GravatarImageSourceHandler))]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
using Xamarin.CommunityToolkit.UI.Views;
2+
using Microsoft.Maui.Controls.Compatibility.Platform.WPF;
3+
4+
[assembly: ExportImageSourceHandler(typeof(GravatarImageSource), typeof(GravatarImageSourceHandler))]
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using System.Threading.Tasks;
2+
using System.Windows.Input;
3+
using Xamarin.CommunityToolkit.ObjectModel;
4+
using Microsoft.Maui; using Microsoft.Maui.Controls; using Microsoft.Maui.Graphics; using Microsoft.Maui.Controls.Compatibility;
5+
6+
namespace Xamarin.CommunityToolkit.Behaviors
7+
{
8+
public class AnimationBehavior : EventToCommandBehavior
9+
{
10+
public static readonly BindableProperty AnimationTypeProperty =
11+
BindableProperty.Create(nameof(AnimationType), typeof(AnimationBase), typeof(AnimationBehavior));
12+
13+
internal static readonly BindablePropertyKey AnimateCommandPropertyKey =
14+
BindableProperty.CreateReadOnly(
15+
nameof(AnimateCommand),
16+
typeof(ICommand),
17+
typeof(AnimationBehavior),
18+
default,
19+
BindingMode.OneWayToSource,
20+
defaultValueCreator: CreateAnimateCommand);
21+
22+
public static readonly BindableProperty AnimateCommandProperty = AnimateCommandPropertyKey.BindableProperty;
23+
24+
public AnimationBase? AnimationType
25+
{
26+
get => (AnimationBase?)GetValue(AnimationTypeProperty);
27+
set => SetValue(AnimationTypeProperty, value);
28+
}
29+
30+
public ICommand AnimateCommand => (ICommand)GetValue(AnimateCommandProperty);
31+
32+
bool isAnimating;
33+
TapGestureRecognizer? tapGestureRecognizer;
34+
35+
protected override void OnAttachedTo(VisualElement bindable)
36+
{
37+
base.OnAttachedTo(bindable);
38+
39+
if (!string.IsNullOrWhiteSpace(EventName) || !(bindable is View view))
40+
return;
41+
42+
tapGestureRecognizer = new TapGestureRecognizer();
43+
tapGestureRecognizer.Tapped += OnTriggerHandled;
44+
view.GestureRecognizers.Clear();
45+
view.GestureRecognizers.Add(tapGestureRecognizer);
46+
}
47+
48+
protected override void OnDetachingFrom(VisualElement bindable)
49+
{
50+
if (tapGestureRecognizer != null)
51+
tapGestureRecognizer.Tapped -= OnTriggerHandled;
52+
53+
base.OnDetachingFrom(bindable);
54+
}
55+
56+
protected override async void OnTriggerHandled(object? sender = null, object? eventArgs = null)
57+
{
58+
await OnAnimate();
59+
60+
base.OnTriggerHandled(sender, eventArgs);
61+
}
62+
63+
static object CreateAnimateCommand(BindableObject bindable)
64+
=> new AsyncCommand(((AnimationBehavior)bindable).OnAnimate);
65+
66+
async Task OnAnimate()
67+
{
68+
if (isAnimating || View is not View typedView)
69+
return;
70+
71+
isAnimating = true;
72+
73+
if (AnimationType != null)
74+
await AnimationType.Animate(typedView);
75+
76+
isAnimating = false;
77+
}
78+
}
79+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using System.Threading.Tasks;
2+
using Microsoft.Maui; using Microsoft.Maui.Controls; using Microsoft.Maui.Graphics; using Microsoft.Maui.Controls.Compatibility;
3+
4+
namespace Xamarin.CommunityToolkit.Behaviors
5+
{
6+
public abstract class AnimationBase<TView> : BindableObject
7+
where TView : View
8+
{
9+
public static readonly BindableProperty DurationProperty =
10+
BindableProperty.Create(nameof(Duration), typeof(uint), typeof(AnimationBase<TView>), default(uint),
11+
BindingMode.TwoWay, defaultValueCreator: GetDefaultDurationProperty);
12+
13+
public uint Duration
14+
{
15+
get => (uint)GetValue(DurationProperty);
16+
set => SetValue(DurationProperty, value);
17+
}
18+
19+
public static readonly BindableProperty EasingTypeProperty =
20+
BindableProperty.Create(nameof(Easing), typeof(Easing), typeof(AnimationBase<TView>), Easing.Linear,
21+
BindingMode.TwoWay);
22+
23+
public Easing Easing
24+
{
25+
get => (Easing)GetValue(EasingTypeProperty);
26+
set => SetValue(EasingTypeProperty, value);
27+
}
28+
29+
static object GetDefaultDurationProperty(BindableObject bindable)
30+
=> ((AnimationBase<TView>)bindable).DefaultDuration;
31+
32+
protected abstract uint DefaultDuration { get; set; }
33+
34+
public abstract Task Animate(TView? view);
35+
}
36+
37+
public abstract class AnimationBase : AnimationBase<View>
38+
{
39+
}
40+
}

0 commit comments

Comments
 (0)