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.05k stars 1.73k forks source link

[iOS] Threshold for SwipeGestureRecognizer doesn't work #20039

Open ptittof57 opened 8 months ago

ptittof57 commented 8 months ago

Description

It's seems threshold for SwipeGestureRecognizer is not working. I didn't see that mention this in documentation but it's seems not implemented for iOS.

For Android there is a swipe gesture handler that call detectSwipe : https://github.com/dotnet/maui/blob/c02195d36fe520758f48afccd221fccbb8a2f7b4/src/Controls/src/Core/Platform/Android/SwipeGestureHandler.cs but I didn't see anything for iOS.

Steps to Reproduce

Run the reproduction project on iOS and swipe down less than the threshold (400), you will see "Swiped" in the console.

<?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" x:Class="SwipeThreshold.MainPage">

<Grid>
    <Grid.GestureRecognizers>
        <SwipeGestureRecognizer Threshold="400"
                                Direction="Down"
                                Swiped="SwipeGestureRecognizer_Swiped" />
    </Grid.GestureRecognizers>
    <Label Text="Swipe down" />
</Grid>

Link to public reproduction project repository

https://github.com/ptittof57/Maui-SwipeThreshold

Version with bug

8.0.3

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 17

Did you find any workaround?

PanGestureRecognizer seems to detect the scroll Y and X positions and could be used to detect the expected threshold

Relevant log output

No response

ghost commented 8 months ago

We've added this issue to our backlog, and we will work to address it as time and resources allow. If you have any additional information or questions about this issue, please leave a comment. For additional info about issue management, please read our Triage Process.

davidschustercof commented 8 months ago

I ran into this issue as well. Has anyone found a workaround? I tried tying into other gestures like pan, drag, and drop to simulate a swipe gesture threshold, but I was unsuccessful.

ptittof57 commented 8 months ago

@davidschustercof maybe you can try to run the project linked to this issue. I just added a sample that work for me in workaround branch.

I used panGestureRecognizer PanUpdated event and checked the totalY value of PanUpdatedEventArgs:

private void PanGestureRecognizer_PanUpdated(object sender, PanUpdatedEventArgs e)
{
    if (e.TotalY > threshold)
    {
        this.scrollPosition.Text = $"Over threshold";
    }
    else
    {
        this.scrollPosition.Text = string.Empty;
    }
}

Direct link is: https://github.com/ptittof57/Maui-SwipeThreshold/tree/workaround

I hope this help.

XamlTest commented 7 months ago

Verified this on VS 17.10.0 Preview 1.0(8.0.6). Repro on iOS 17.2, not repro on Android 14.0-API34 with below Project: SwipeThreshold.zip