dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.21k stars 1.75k forks source link

Swipe gestures attached to rotated controls are rotated on Android #15280

Open bat-kin opened 1 year ago

bat-kin commented 1 year ago

Description

If you have a SwipeGestureRecognizer attached to an object with a rotation set to anything other than 0, the gesture registers relative to the object's rotation on Android. For example, you might have to swipe down to trigger a swipe left. The swipe gesture behaves as expected on Windows.

Steps to Reproduce

Using the below sample, watch as the gesture direction rotates every time the image itself rotates.

XAML

<Image
     x:Name="BotImage"
     Source="dotnet_bot.png"
     SemanticProperties.Description="Cute dot net bot waving hi to you!"
     HeightRequest="400"
     HorizontalOptions="Center" >
     <Image.GestureRecognizers>
          <SwipeGestureRecognizer Direction="Up" Swiped="SwipeGestureRecognizer_Swiped" Threshold="20"/>
          <SwipeGestureRecognizer Direction="Down" Swiped="SwipeGestureRecognizer_Swiped" Threshold="20"/>
          <SwipeGestureRecognizer Direction="Left" Swiped="SwipeGestureRecognizer_Swiped" Threshold="20"/>
          <SwipeGestureRecognizer Direction="Right" Swiped="SwipeGestureRecognizer_Swiped" Threshold="20"/>
     </Image.GestureRecognizers>
</Image>

<Label x:Name="MessageBack" Text="Try a swipe" FontSize="32" HorizontalOptions="Center" />

C#

private void SwipeGestureRecognizer_Swiped(object sender, SwipedEventArgs e)
{
     MessageBack.Text = $"Swiped {e.Direction.ToString().ToUpper()}. Try again.";
     BotImage.Rotation += 90;
}

Link to public reproduction project repository

https://github.com/bat-kin/MauiBug

Version with bug

7.0.86

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 13

Did you find any workaround?

No

Relevant log output

No response

XamlTest commented 1 year ago

Verified this on Visual Studio Enterprise 17.8.0 Preview 2.0(8.0.0-rc.1.23419.4). Repro on Android 13.0-API33 and iOS 16.4, not repro on Windows 11 with below Project:

15280.zip Android