Skip to content

Commit

Permalink
UWP on Release fix (#68)
Browse files Browse the repository at this point in the history
* UWP assemblies to include added on Sample and documentation

* Zero animation duration bug fix on UWP
  • Loading branch information
YZahringer authored Jun 24, 2020
1 parent 1d0b928 commit a227ccc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ With this plugin it is also possible to respond to hover events (if the platform
|Xamarin.Mac|All|
|Xamarin.UWP|10+|

##### Xamarin.UWP - Build on Release with .NET Native tool chain note
````cs
using System.Reflection;
...
var assembliesToInclude = new List<Assembly>
{
typeof(PlatformTouchEff).GetTypeInfo().Assembly,
...
};
Xamarin.Forms.Forms.Init(e, assembliesToInclude);

TouchEffectPreserver.Preserve();
````

## Samples
The samples you can find here https://github.com/AndreiMisiukevich/TouchEffect/tree/master/TouchEffectSample

Expand Down
9 changes: 5 additions & 4 deletions TouchEffect/TouchVisualManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,9 @@ private async Task SetBackgroundColorAsync(TouchEff sender, TouchState touchStat
var pressedBackgroundColor = sender.PressedBackgroundColor;
var hoveredBackgroundColor = sender.HoveredBackgroundColor;

if (regularBackgroundColor == Color.Default &&
pressedBackgroundColor == Color.Default)
if (regularBackgroundColor == Color.Default &&
pressedBackgroundColor == Color.Default &&
hoveredBackgroundColor == Color.Default)
{
return;
}
Expand Down Expand Up @@ -280,7 +281,7 @@ private async Task SetOpacityAsync(TouchEff sender, TouchState touchState, Hover
opacity = hoveredOpacity;
easing = sender.HoveredAnimationEasing;
}

await sender.Control.FadeTo(opacity, (uint)Abs(duration), easing);
}

Expand Down Expand Up @@ -473,7 +474,7 @@ private Task GetAnimationTask(TouchEff sender, TouchState touchState, HoverState
}
duration = duration.AdjustDurationMultiplier(durationMultiplier);

if (duration <= 0 && Device.RuntimePlatform == Device.Android)
if (duration <= 0 && (Device.RuntimePlatform == Device.Android || Device.RuntimePlatform == Device.UWP))
{
duration = 1;
}
Expand Down
6 changes: 5 additions & 1 deletion TouchEffectSample.UWP/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
using TouchEffect.UWP;
using System.Collections.Generic;
using System.Reflection;

namespace TouchEffectSample.UWP
{
Expand Down Expand Up @@ -41,7 +43,9 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)

rootFrame.NavigationFailed += OnNavigationFailed;

Xamarin.Forms.Forms.Init(e);
var assembliesToInclude = new List<Assembly>();
assembliesToInclude.Add(typeof(PlatformTouchEff).GetTypeInfo().Assembly);
Xamarin.Forms.Forms.Init(e, assembliesToInclude);

TouchEffectPreserver.Preserve();

Expand Down

0 comments on commit a227ccc

Please sign in to comment.