From 98655acf5f3eba93d3c14d7a00fd3bead592a1f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Su=C3=A1rez=20Ruiz?= Date: Wed, 8 Nov 2017 21:52:25 +0100 Subject: [PATCH] Added ColorAnimation Updated Animations Sample Added Animations nuspec --- .../Resources/Resource.Designer.cs | 174 +++++++++--------- .../Samples.Android/Samples.Android.csproj | 2 +- .../Samples.Android.csproj.bak | 29 ++- .../Samples/Samples/Views/AnimationsPage.xaml | 36 ++++ nuget/Animations.nuspec | 56 ++++++ src/Animations.sln | 39 ++-- src/Animations/Animations/Animations.csproj | 2 + .../Animations/Animations/ColorAnimation.cs | 38 ++++ .../Animations/Extensions/ColorExtensions.cs | 36 ++++ 9 files changed, 296 insertions(+), 116 deletions(-) create mode 100644 nuget/Animations.nuspec create mode 100644 src/Animations/Animations/Animations/ColorAnimation.cs create mode 100644 src/Animations/Animations/Extensions/ColorExtensions.cs diff --git a/Samples/Samples/Samples.Android/Resources/Resource.Designer.cs b/Samples/Samples/Samples.Android/Resources/Resource.Designer.cs index b827253..843beb3 100644 --- a/Samples/Samples/Samples.Android/Resources/Resource.Designer.cs +++ b/Samples/Samples/Samples.Android/Resources/Resource.Designer.cs @@ -643,7 +643,6 @@ namespace FormsCommunityToolkit.Samples.Droid global::FormsCommunityToolkit.Effects.Droid.Resource.Drawable.abc_textfield_search_material = global::FormsCommunityToolkit.Samples.Droid.Resource.Drawable.abc_textfield_search_material; global::FormsCommunityToolkit.Effects.Droid.Resource.Drawable.design_fab_background = global::FormsCommunityToolkit.Samples.Droid.Resource.Drawable.design_fab_background; global::FormsCommunityToolkit.Effects.Droid.Resource.Drawable.design_snackbar_background = global::FormsCommunityToolkit.Samples.Droid.Resource.Drawable.design_snackbar_background; - global::FormsCommunityToolkit.Effects.Droid.Resource.Drawable.fct_ic_clear_icon = global::FormsCommunityToolkit.Samples.Droid.Resource.Drawable.fct_ic_clear_icon; global::FormsCommunityToolkit.Effects.Droid.Resource.Drawable.ic_audiotrack = global::FormsCommunityToolkit.Samples.Droid.Resource.Drawable.ic_audiotrack; global::FormsCommunityToolkit.Effects.Droid.Resource.Drawable.ic_audiotrack_light = global::FormsCommunityToolkit.Samples.Droid.Resource.Drawable.ic_audiotrack_light; global::FormsCommunityToolkit.Effects.Droid.Resource.Drawable.ic_bluetooth_grey = global::FormsCommunityToolkit.Samples.Droid.Resource.Drawable.ic_bluetooth_grey; @@ -3734,262 +3733,259 @@ namespace FormsCommunityToolkit.Samples.Droid public const int design_snackbar_background = 2130837580; // aapt resource value: 0x7f02004d - public const int fct_ic_clear_icon = 2130837581; + public const int ic_audiotrack = 2130837581; // aapt resource value: 0x7f02004e - public const int ic_audiotrack = 2130837582; + public const int ic_audiotrack_light = 2130837582; // aapt resource value: 0x7f02004f - public const int ic_audiotrack_light = 2130837583; + public const int ic_bluetooth_grey = 2130837583; // aapt resource value: 0x7f020050 - public const int ic_bluetooth_grey = 2130837584; + public const int ic_bluetooth_white = 2130837584; // aapt resource value: 0x7f020051 - public const int ic_bluetooth_white = 2130837585; + public const int ic_cast_dark = 2130837585; // aapt resource value: 0x7f020052 - public const int ic_cast_dark = 2130837586; + public const int ic_cast_disabled_light = 2130837586; // aapt resource value: 0x7f020053 - public const int ic_cast_disabled_light = 2130837587; + public const int ic_cast_grey = 2130837587; // aapt resource value: 0x7f020054 - public const int ic_cast_grey = 2130837588; + public const int ic_cast_light = 2130837588; // aapt resource value: 0x7f020055 - public const int ic_cast_light = 2130837589; + public const int ic_cast_off_light = 2130837589; // aapt resource value: 0x7f020056 - public const int ic_cast_off_light = 2130837590; + public const int ic_cast_on_0_light = 2130837590; // aapt resource value: 0x7f020057 - public const int ic_cast_on_0_light = 2130837591; + public const int ic_cast_on_1_light = 2130837591; // aapt resource value: 0x7f020058 - public const int ic_cast_on_1_light = 2130837592; + public const int ic_cast_on_2_light = 2130837592; // aapt resource value: 0x7f020059 - public const int ic_cast_on_2_light = 2130837593; + public const int ic_cast_on_light = 2130837593; // aapt resource value: 0x7f02005a - public const int ic_cast_on_light = 2130837594; + public const int ic_cast_white = 2130837594; // aapt resource value: 0x7f02005b - public const int ic_cast_white = 2130837595; + public const int ic_close_dark = 2130837595; // aapt resource value: 0x7f02005c - public const int ic_close_dark = 2130837596; + public const int ic_close_light = 2130837596; // aapt resource value: 0x7f02005d - public const int ic_close_light = 2130837597; + public const int ic_collapse = 2130837597; // aapt resource value: 0x7f02005e - public const int ic_collapse = 2130837598; + public const int ic_collapse_00000 = 2130837598; // aapt resource value: 0x7f02005f - public const int ic_collapse_00000 = 2130837599; + public const int ic_collapse_00001 = 2130837599; // aapt resource value: 0x7f020060 - public const int ic_collapse_00001 = 2130837600; + public const int ic_collapse_00002 = 2130837600; // aapt resource value: 0x7f020061 - public const int ic_collapse_00002 = 2130837601; + public const int ic_collapse_00003 = 2130837601; // aapt resource value: 0x7f020062 - public const int ic_collapse_00003 = 2130837602; + public const int ic_collapse_00004 = 2130837602; // aapt resource value: 0x7f020063 - public const int ic_collapse_00004 = 2130837603; + public const int ic_collapse_00005 = 2130837603; // aapt resource value: 0x7f020064 - public const int ic_collapse_00005 = 2130837604; + public const int ic_collapse_00006 = 2130837604; // aapt resource value: 0x7f020065 - public const int ic_collapse_00006 = 2130837605; + public const int ic_collapse_00007 = 2130837605; // aapt resource value: 0x7f020066 - public const int ic_collapse_00007 = 2130837606; + public const int ic_collapse_00008 = 2130837606; // aapt resource value: 0x7f020067 - public const int ic_collapse_00008 = 2130837607; + public const int ic_collapse_00009 = 2130837607; // aapt resource value: 0x7f020068 - public const int ic_collapse_00009 = 2130837608; + public const int ic_collapse_00010 = 2130837608; // aapt resource value: 0x7f020069 - public const int ic_collapse_00010 = 2130837609; + public const int ic_collapse_00011 = 2130837609; // aapt resource value: 0x7f02006a - public const int ic_collapse_00011 = 2130837610; + public const int ic_collapse_00012 = 2130837610; // aapt resource value: 0x7f02006b - public const int ic_collapse_00012 = 2130837611; + public const int ic_collapse_00013 = 2130837611; // aapt resource value: 0x7f02006c - public const int ic_collapse_00013 = 2130837612; + public const int ic_collapse_00014 = 2130837612; // aapt resource value: 0x7f02006d - public const int ic_collapse_00014 = 2130837613; + public const int ic_collapse_00015 = 2130837613; // aapt resource value: 0x7f02006e - public const int ic_collapse_00015 = 2130837614; + public const int ic_expand = 2130837614; // aapt resource value: 0x7f02006f - public const int ic_expand = 2130837615; + public const int ic_expand_00000 = 2130837615; // aapt resource value: 0x7f020070 - public const int ic_expand_00000 = 2130837616; + public const int ic_expand_00001 = 2130837616; // aapt resource value: 0x7f020071 - public const int ic_expand_00001 = 2130837617; + public const int ic_expand_00002 = 2130837617; // aapt resource value: 0x7f020072 - public const int ic_expand_00002 = 2130837618; + public const int ic_expand_00003 = 2130837618; // aapt resource value: 0x7f020073 - public const int ic_expand_00003 = 2130837619; + public const int ic_expand_00004 = 2130837619; // aapt resource value: 0x7f020074 - public const int ic_expand_00004 = 2130837620; + public const int ic_expand_00005 = 2130837620; // aapt resource value: 0x7f020075 - public const int ic_expand_00005 = 2130837621; + public const int ic_expand_00006 = 2130837621; // aapt resource value: 0x7f020076 - public const int ic_expand_00006 = 2130837622; + public const int ic_expand_00007 = 2130837622; // aapt resource value: 0x7f020077 - public const int ic_expand_00007 = 2130837623; + public const int ic_expand_00008 = 2130837623; // aapt resource value: 0x7f020078 - public const int ic_expand_00008 = 2130837624; + public const int ic_expand_00009 = 2130837624; // aapt resource value: 0x7f020079 - public const int ic_expand_00009 = 2130837625; + public const int ic_expand_00010 = 2130837625; // aapt resource value: 0x7f02007a - public const int ic_expand_00010 = 2130837626; + public const int ic_expand_00011 = 2130837626; // aapt resource value: 0x7f02007b - public const int ic_expand_00011 = 2130837627; + public const int ic_expand_00012 = 2130837627; // aapt resource value: 0x7f02007c - public const int ic_expand_00012 = 2130837628; + public const int ic_expand_00013 = 2130837628; // aapt resource value: 0x7f02007d - public const int ic_expand_00013 = 2130837629; + public const int ic_expand_00014 = 2130837629; // aapt resource value: 0x7f02007e - public const int ic_expand_00014 = 2130837630; + public const int ic_expand_00015 = 2130837630; // aapt resource value: 0x7f02007f - public const int ic_expand_00015 = 2130837631; + public const int ic_media_pause = 2130837631; // aapt resource value: 0x7f020080 - public const int ic_media_pause = 2130837632; + public const int ic_media_play = 2130837632; // aapt resource value: 0x7f020081 - public const int ic_media_play = 2130837633; + public const int ic_media_route_disabled_mono_dark = 2130837633; // aapt resource value: 0x7f020082 - public const int ic_media_route_disabled_mono_dark = 2130837634; + public const int ic_media_route_off_mono_dark = 2130837634; // aapt resource value: 0x7f020083 - public const int ic_media_route_off_mono_dark = 2130837635; + public const int ic_media_route_on_0_mono_dark = 2130837635; // aapt resource value: 0x7f020084 - public const int ic_media_route_on_0_mono_dark = 2130837636; + public const int ic_media_route_on_1_mono_dark = 2130837636; // aapt resource value: 0x7f020085 - public const int ic_media_route_on_1_mono_dark = 2130837637; + public const int ic_media_route_on_2_mono_dark = 2130837637; // aapt resource value: 0x7f020086 - public const int ic_media_route_on_2_mono_dark = 2130837638; + public const int ic_media_route_on_mono_dark = 2130837638; // aapt resource value: 0x7f020087 - public const int ic_media_route_on_mono_dark = 2130837639; + public const int ic_pause_dark = 2130837639; // aapt resource value: 0x7f020088 - public const int ic_pause_dark = 2130837640; + public const int ic_pause_light = 2130837640; // aapt resource value: 0x7f020089 - public const int ic_pause_light = 2130837641; + public const int ic_play_dark = 2130837641; // aapt resource value: 0x7f02008a - public const int ic_play_dark = 2130837642; + public const int ic_play_light = 2130837642; // aapt resource value: 0x7f02008b - public const int ic_play_light = 2130837643; + public const int ic_speaker_dark = 2130837643; // aapt resource value: 0x7f02008c - public const int ic_speaker_dark = 2130837644; + public const int ic_speaker_group_dark = 2130837644; // aapt resource value: 0x7f02008d - public const int ic_speaker_group_dark = 2130837645; + public const int ic_speaker_group_light = 2130837645; // aapt resource value: 0x7f02008e - public const int ic_speaker_group_light = 2130837646; + public const int ic_speaker_light = 2130837646; // aapt resource value: 0x7f02008f - public const int ic_speaker_light = 2130837647; + public const int ic_tv_dark = 2130837647; // aapt resource value: 0x7f020090 - public const int ic_tv_dark = 2130837648; + public const int ic_tv_light = 2130837648; // aapt resource value: 0x7f020091 - public const int ic_tv_light = 2130837649; + public const int icon = 2130837649; // aapt resource value: 0x7f020092 - public const int icon = 2130837650; + public const int mr_dialog_material_background_dark = 2130837650; // aapt resource value: 0x7f020093 - public const int mr_dialog_material_background_dark = 2130837651; + public const int mr_dialog_material_background_light = 2130837651; // aapt resource value: 0x7f020094 - public const int mr_dialog_material_background_light = 2130837652; + public const int mr_ic_audiotrack_light = 2130837652; // aapt resource value: 0x7f020095 - public const int mr_ic_audiotrack_light = 2130837653; + public const int mr_ic_cast_dark = 2130837653; // aapt resource value: 0x7f020096 - public const int mr_ic_cast_dark = 2130837654; + public const int mr_ic_cast_light = 2130837654; // aapt resource value: 0x7f020097 - public const int mr_ic_cast_light = 2130837655; + public const int mr_ic_close_dark = 2130837655; // aapt resource value: 0x7f020098 - public const int mr_ic_close_dark = 2130837656; + public const int mr_ic_close_light = 2130837656; // aapt resource value: 0x7f020099 - public const int mr_ic_close_light = 2130837657; + public const int mr_ic_media_route_connecting_mono_dark = 2130837657; // aapt resource value: 0x7f02009a - public const int mr_ic_media_route_connecting_mono_dark = 2130837658; + public const int mr_ic_media_route_connecting_mono_light = 2130837658; // aapt resource value: 0x7f02009b - public const int mr_ic_media_route_connecting_mono_light = 2130837659; + public const int mr_ic_media_route_mono_dark = 2130837659; // aapt resource value: 0x7f02009c - public const int mr_ic_media_route_mono_dark = 2130837660; + public const int mr_ic_media_route_mono_light = 2130837660; // aapt resource value: 0x7f02009d - public const int mr_ic_media_route_mono_light = 2130837661; + public const int mr_ic_pause_dark = 2130837661; // aapt resource value: 0x7f02009e - public const int mr_ic_pause_dark = 2130837662; + public const int mr_ic_pause_light = 2130837662; // aapt resource value: 0x7f02009f - public const int mr_ic_pause_light = 2130837663; + public const int mr_ic_play_dark = 2130837663; // aapt resource value: 0x7f0200a0 - public const int mr_ic_play_dark = 2130837664; + public const int mr_ic_play_light = 2130837664; // aapt resource value: 0x7f0200a1 - public const int mr_ic_play_light = 2130837665; - - // aapt resource value: 0x7f0200a2 - public const int notification_template_icon_bg = 2130837666; + public const int notification_template_icon_bg = 2130837665; static Drawable() { diff --git a/Samples/Samples/Samples.Android/Samples.Android.csproj b/Samples/Samples/Samples.Android/Samples.Android.csproj index 30c0cfc..4c7225e 100644 --- a/Samples/Samples/Samples.Android/Samples.Android.csproj +++ b/Samples/Samples/Samples.Android/Samples.Android.csproj @@ -17,7 +17,7 @@ Off Properties\AndroidManifest.xml true - v7.1 + v8.0 diff --git a/Samples/Samples/Samples.Android/Samples.Android.csproj.bak b/Samples/Samples/Samples.Android/Samples.Android.csproj.bak index 4fffd4c..30c0cfc 100644 --- a/Samples/Samples/Samples.Android/Samples.Android.csproj.bak +++ b/Samples/Samples/Samples.Android/Samples.Android.csproj.bak @@ -17,7 +17,7 @@ Off Properties\AndroidManifest.xml true - v7.0 + v7.1 @@ -49,7 +49,8 @@ - ..\..\packages\Xamarin.Forms.2.3.4.224\lib\MonoAndroid10\FormsViewGroup.dll + ..\..\packages\Xamarin.Forms.2.3.4.247\lib\MonoAndroid10\FormsViewGroup.dll + True @@ -83,16 +84,20 @@ ..\..\packages\Xamarin.Android.Support.Vector.Drawable.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.Vector.Drawable.dll - ..\..\packages\Xamarin.Forms.2.3.4.224\lib\MonoAndroid10\Xamarin.Forms.Core.dll + ..\..\packages\Xamarin.Forms.2.3.4.247\lib\MonoAndroid10\Xamarin.Forms.Core.dll + True - ..\..\packages\Xamarin.Forms.2.3.4.224\lib\MonoAndroid10\Xamarin.Forms.Platform.dll + ..\..\packages\Xamarin.Forms.2.3.4.247\lib\MonoAndroid10\Xamarin.Forms.Platform.dll + True - ..\..\packages\Xamarin.Forms.2.3.4.224\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll + ..\..\packages\Xamarin.Forms.2.3.4.247\lib\MonoAndroid10\Xamarin.Forms.Platform.Android.dll + True - ..\..\packages\Xamarin.Forms.2.3.4.224\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll + ..\..\packages\Xamarin.Forms.2.3.4.247\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll + True @@ -120,6 +125,14 @@ + + {795a04b4-5d20-4744-91fe-33937831ce4b} + Animations.Android + + + {572b958e-cc33-47c1-95fa-1b3a0506f2ed} + Animations + {88dc2010-be3a-4b86-a72f-3df68413858b} Effects.Android @@ -140,7 +153,7 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + - + \ No newline at end of file diff --git a/Samples/Samples/Samples/Views/AnimationsPage.xaml b/Samples/Samples/Samples/Views/AnimationsPage.xaml index c09c20c..c6db2e1 100644 --- a/Samples/Samples/Samples/Views/AnimationsPage.xaml +++ b/Samples/Samples/Samples/Views/AnimationsPage.xaml @@ -68,6 +68,14 @@ Target="{x:Reference JumpBox}" Duration="1500"/> + Red + + + @@ -358,6 +366,34 @@ + + + + + + + + + + diff --git a/nuget/Animations.nuspec b/nuget/Animations.nuspec new file mode 100644 index 0000000..de717da --- /dev/null +++ b/nuget/Animations.nuspec @@ -0,0 +1,56 @@ + + + + FormsCommunityToolkit.Animations + $version$ + Xamarin.Forms Community Toolkit: Animations + FormsCommunityToolkit + FormsCommunityToolkit + https://github.com/FormsCommunityToolkit/FormsCommunityToolkit + https://github.com/FormsCommunityToolkit/FormsCommunityToolkit/blob/master/LICENSE + https://github.com/FormsCommunityToolkit/FormsCommunityToolkit/blob/master/Media/OrganonLogo.64x64.png + false + + Xamarin.Forms Community Toolkit Animations Library + Built against: 2.3.2.127 + + Xamarin.Forms Community Toolkit Animations Library + community, toolkit, xamarin, pcl, android, xamarin.forms, ios, uwp, animations + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Animations.sln b/src/Animations.sln index 1727b09..9e91628 100644 --- a/src/Animations.sln +++ b/src/Animations.sln @@ -1,25 +1,25 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.27004.2006 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Animations", "Animations\Animations\Animations.csproj", "{572B958E-CC33-47C1-95FA-1B3A0506F2ED}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4CF83A7E-B02C-4DEC-A0B7-EFC68623D928}" ProjectSection(SolutionItems) = preProject + ..\..\nuget\Animations.nuspec = ..\..\nuget\Animations.nuspec ..\..\appveyor.yml = ..\..\appveyor.yml ..\..\bootstrapper.ps1 = ..\..\bootstrapper.ps1 ..\..\build.cake = ..\..\build.cake ..\..\CHANGELOG.md = ..\..\CHANGELOG.md - ..\..\nuget\Animations.nuspec = ..\..\nuget\Animations.nuspec ..\..\README.md = ..\..\README.md EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Animations.Android", "Animations\Animations.Android\Animations.Android.csproj", "{88DC2010-BE3A-4B86-A72F-3DF68413858B}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Animations.Android", "Animations\Animations.Android\Animations.Android.csproj", "{795A04B4-5D20-4744-91FE-33937831CE4B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Animations.iOS", "Animations\Animations.iOS\Animations.iOS.csproj", "{F09F8CAF-701A-4673-A880-1580ACCB926B}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Animations.iOS", "Animations\Animations.iOS\Animations.iOS.csproj", "{D8983DBB-12FC-4EA8-8E75-3C5F3A39BBA3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Animations.UWP", "Animations\Animations.UWP\Animations.UWP.csproj", "{98F91808-0410-4362-9B3A-BD5110BEECDE}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Animations.UWP", "Animations\Animations.UWP\Animations.UWP.csproj", "{59804206-D678-42B8-999E-9EEBED9B8064}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -31,20 +31,23 @@ Global {572B958E-CC33-47C1-95FA-1B3A0506F2ED}.Debug|Any CPU.Build.0 = Debug|Any CPU {572B958E-CC33-47C1-95FA-1B3A0506F2ED}.Release|Any CPU.ActiveCfg = Release|Any CPU {572B958E-CC33-47C1-95FA-1B3A0506F2ED}.Release|Any CPU.Build.0 = Release|Any CPU - {88DC2010-BE3A-4B86-A72F-3DF68413858B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {88DC2010-BE3A-4B86-A72F-3DF68413858B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {88DC2010-BE3A-4B86-A72F-3DF68413858B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {88DC2010-BE3A-4B86-A72F-3DF68413858B}.Release|Any CPU.Build.0 = Release|Any CPU - {F09F8CAF-701A-4673-A880-1580ACCB926B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F09F8CAF-701A-4673-A880-1580ACCB926B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F09F8CAF-701A-4673-A880-1580ACCB926B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F09F8CAF-701A-4673-A880-1580ACCB926B}.Release|Any CPU.Build.0 = Release|Any CPU - {98F91808-0410-4362-9B3A-BD5110BEECDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {98F91808-0410-4362-9B3A-BD5110BEECDE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {98F91808-0410-4362-9B3A-BD5110BEECDE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {98F91808-0410-4362-9B3A-BD5110BEECDE}.Release|Any CPU.Build.0 = Release|Any CPU + {795A04B4-5D20-4744-91FE-33937831CE4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {795A04B4-5D20-4744-91FE-33937831CE4B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {795A04B4-5D20-4744-91FE-33937831CE4B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {795A04B4-5D20-4744-91FE-33937831CE4B}.Release|Any CPU.Build.0 = Release|Any CPU + {D8983DBB-12FC-4EA8-8E75-3C5F3A39BBA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D8983DBB-12FC-4EA8-8E75-3C5F3A39BBA3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D8983DBB-12FC-4EA8-8E75-3C5F3A39BBA3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D8983DBB-12FC-4EA8-8E75-3C5F3A39BBA3}.Release|Any CPU.Build.0 = Release|Any CPU + {59804206-D678-42B8-999E-9EEBED9B8064}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {59804206-D678-42B8-999E-9EEBED9B8064}.Debug|Any CPU.Build.0 = Debug|Any CPU + {59804206-D678-42B8-999E-9EEBED9B8064}.Release|Any CPU.ActiveCfg = Release|Any CPU + {59804206-D678-42B8-999E-9EEBED9B8064}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A8C7D1CB-2B2B-4A01-90C6-A15AE6B539F8} + EndGlobalSection EndGlobal diff --git a/src/Animations/Animations/Animations.csproj b/src/Animations/Animations/Animations.csproj index a7d6b89..1a88246 100644 --- a/src/Animations/Animations/Animations.csproj +++ b/src/Animations/Animations/Animations.csproj @@ -39,6 +39,7 @@ + @@ -52,6 +53,7 @@ + diff --git a/src/Animations/Animations/Animations/ColorAnimation.cs b/src/Animations/Animations/Animations/ColorAnimation.cs new file mode 100644 index 0000000..25e0055 --- /dev/null +++ b/src/Animations/Animations/Animations/ColorAnimation.cs @@ -0,0 +1,38 @@ +using FormsCommunityToolkit.Animations.Extensions; +using System; +using System.Threading.Tasks; +using Xamarin.Forms; + +namespace FormsCommunityToolkit.Animations +{ + public class ColorAnimation : AnimationBase + { + public static readonly BindableProperty ToColorProperty = + BindableProperty.Create(nameof(ToColor), typeof(Color), typeof(ColorAnimation), Color.Default, + BindingMode.TwoWay, null); + + public Color ToColor + { + get { return (Color)GetValue(ToColorProperty); } + set { SetValue(ToColorProperty, value); } + } + + protected override Task BeginAnimation() + { + if (Target == null) + { + throw new NullReferenceException("Null Target property."); + } + + var fromColor = Target.BackgroundColor; + + return Task.Run(() => + { + Device.BeginInvokeOnMainThread(async () => + { + await Target.ColorTo(fromColor, ToColor, c => Target.BackgroundColor = c, Convert.ToUInt32(Duration)); + }); + }); + } + } +} diff --git a/src/Animations/Animations/Extensions/ColorExtensions.cs b/src/Animations/Animations/Extensions/ColorExtensions.cs new file mode 100644 index 0000000..03af5a4 --- /dev/null +++ b/src/Animations/Animations/Extensions/ColorExtensions.cs @@ -0,0 +1,36 @@ +using System; +using System.Threading.Tasks; +using Xamarin.Forms; + +// https://developer.xamarin.com/samples/xamarin-forms/userinterface/animation/custom/ +namespace FormsCommunityToolkit.Animations.Extensions +{ + public static class ColorExtensions + { + public static Task ColorTo(this VisualElement self, Color fromColor, Color toColor, Action callback, uint length = 250, Easing easing = null) + { + Func transform = (t) => + Color.FromRgba(fromColor.R + t * (toColor.R - fromColor.R), + fromColor.G + t * (toColor.G - fromColor.G), + fromColor.B + t * (toColor.B - fromColor.B), + fromColor.A + t * (toColor.A - fromColor.A)); + + return ColorAnimation(self, "ColorTo", transform, callback, length, easing); + } + + public static void CancelAnimation(this VisualElement self) + { + self.AbortAnimation("ColorTo"); + } + + static Task ColorAnimation(VisualElement element, string name, Func transform, Action callback, uint length, Easing easing) + { + easing = easing ?? Easing.Linear; + var taskCompletionSource = new TaskCompletionSource(); + + element.Animate(name, transform, callback, 16, length, easing, (v, c) => taskCompletionSource.SetResult(c)); + + return taskCompletionSource.Task; + } + } +} \ No newline at end of file