Skip to content

Commit

Permalink
1.0.6: update nugets. New property ReturnAllPointsOnWindows. New beha…
Browse files Browse the repository at this point in the history
…vior: on windows, PanPointCommand is not executed for all intermediate points anymore, only the last point.
  • Loading branch information
softlion committed Aug 23, 2024
1 parent 6f7863b commit 5ac075e
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
#Needs windows to build the windows version
runs-on: windows-latest
env:
NUPKG_MAJOR: 1.0.5
NUPKG_MAJOR: 1.0.6
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
PROJECT: MauiGestures/MauiGestures.csproj
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ riderModule.iml
/_ReSharper.Caches/
.idea/
.vs/
*.user
4 changes: 2 additions & 2 deletions Demo/DemoApp/DemoApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.*" Condition="'$(Configuration)' == 'Debug'" />
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Vapolia.Svg" Version="1.0.4-preH" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.80" />
<PackageReference Include="Vapolia.Svg" Version="1.0.4" />
<PackageReference Include="Vapolia.UserInteraction" Version="4.0.2" />
</ItemGroup>

Expand Down
6 changes: 6 additions & 0 deletions MauiGestures/Gesture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public static class Gesture
public static readonly BindableProperty SwipeThresholdProperty = BindableProperty.CreateAttached("SwipeThreshold", typeof(int), typeof(Gesture), 40, propertyChanged: CommandChanged);
public static readonly BindableProperty CommandParameterProperty = BindableProperty.CreateAttached("CommandParameter", typeof(object), typeof(Gesture), null);

//Windows only
public static readonly BindableProperty ReturnAllPointsOnWindowsProperty = BindableProperty.CreateAttached("ReturnAllPointsOnWindows", typeof(bool), typeof(Gesture), false, propertyChanged: CommandChanged);

public static ICommand GetLongPressCommand(BindableObject view) => (ICommand)view.GetValue(LongPressCommandProperty);
public static ICommand GetTapCommand(BindableObject view) => (ICommand)view.GetValue(TapCommandProperty);
public static ICommand GetDoubleTapCommand(BindableObject view) => (ICommand)view.GetValue(DoubleTapCommandProperty);
Expand Down Expand Up @@ -76,6 +79,9 @@ public static class Gesture
/// Take a (Point,GestureStatus) parameter (it is a tuple)
/// </summary>
public static ICommand GetPanPointCommand(BindableObject view) => (ICommand)view.GetValue(PanPointCommandProperty);


public static bool GetReturnAllPointsOnWindows(BindableObject view) => (bool)view.GetValue(ReturnAllPointsOnWindowsProperty);

public static void SetLongPressCommand(BindableObject view, ICommand value) => view.SetValue(LongPressCommandProperty, value);
public static void SetTapCommand(BindableObject view, ICommand value) => view.SetValue(TapCommandProperty, value);
Expand Down
2 changes: 1 addition & 1 deletion MauiGestures/MauiGestures.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<None Include="../LICENSE" Pack="true" PackagePath="" />
<None Include="../README.md" Pack="true" PackagePath="" />
<None Include="../icon.png" Pack="true" PackagePath="" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.40" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.80" />
</ItemGroup>

<ItemGroup>
Expand Down
44 changes: 27 additions & 17 deletions MauiGestures/Platform/Standard/PlatformGestureEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,43 @@ protected override partial void OnDetached() {}
/// 1 parameter: PinchEventArgs
/// </summary>
private ICommand? pinchCommand;


#if WINDOWS
private bool returnAllPointsOnWindows;
#endif

protected override void OnElementPropertyChanged(PropertyChangedEventArgs args)
{
if (args.PropertyName is not "X" and not "Y" and not "Width" and not "Height")
{
tapCommand = Gesture.GetTapCommand(Element);
panCommand = Gesture.GetPanCommand(Element);
var element = Element;

tapCommand = Gesture.GetTapCommand(element);
panCommand = Gesture.GetPanCommand(element);

pinchCommand = Gesture.GetPinchCommand(element);
doubleTapCommand = Gesture.GetDoubleTapCommand(element);
longPressCommand = Gesture.GetLongPressCommand(element);

pinchCommand = Gesture.GetPinchCommand(Element);
doubleTapCommand = Gesture.GetDoubleTapCommand(Element);
longPressCommand = Gesture.GetLongPressCommand(Element);
swipeLeftCommand = Gesture.GetSwipeLeftCommand(element);
swipeRightCommand = Gesture.GetSwipeRightCommand(element);
swipeTopCommand = Gesture.GetSwipeTopCommand(element);
swipeBottomCommand = Gesture.GetSwipeBottomCommand(element);

swipeLeftCommand = Gesture.GetSwipeLeftCommand(Element);
swipeRightCommand = Gesture.GetSwipeRightCommand(Element);
swipeTopCommand = Gesture.GetSwipeTopCommand(Element);
swipeBottomCommand = Gesture.GetSwipeBottomCommand(Element);
tapPointCommand = Gesture.GetTapPointCommand(element);
panPointCommand = Gesture.GetPanPointCommand(element);
doubleTapPointCommand = Gesture.GetDoubleTapPointCommand(element);
longPressPointCommand = Gesture.GetLongPressPointCommand(element);

tapPointCommand = Gesture.GetTapPointCommand(Element);
panPointCommand = Gesture.GetPanPointCommand(Element);
doubleTapPointCommand = Gesture.GetDoubleTapPointCommand(Element);
longPressPointCommand = Gesture.GetLongPressPointCommand(Element);
commandParameter = Gesture.GetCommandParameter(element);

commandParameter = Gesture.GetCommandParameter(Element);
#if WINDOWS
returnAllPointsOnWindows = Gesture.GetReturnAllPointsOnWindows(element);
#endif

#if IOS || MACCATALYST
panDetector.IsImmediate = Gesture.GetIsPanImmediate(Element);
pinchDetector.IsImmediate = Gesture.GetIsPinchImmediate(Element);
panDetector.IsImmediate = Gesture.GetIsPanImmediate(element);
pinchDetector.IsImmediate = Gesture.GetIsPinchImmediate(element);
#endif
}
}
Expand Down
4 changes: 3 additions & 1 deletion MauiGestures/Platforms/Windows/PlatformGestureEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ private void ControlOnPointerPressed(object sender, PointerRoutedEventArgs point

private void ControlOnPointerMoved(object sender, PointerRoutedEventArgs pointerRoutedEventArgs)
{
detector.ProcessMoveEvents(pointerRoutedEventArgs.GetIntermediatePoints(Control ?? Container));
detector.ProcessMoveEvents(returnAllPointsOnWindows ?
pointerRoutedEventArgs.GetIntermediatePoints(Control ?? Container)
: new List<PointerPoint> { pointerRoutedEventArgs.GetCurrentPoint(Control ?? Container) });
pointerRoutedEventArgs.Handled = true;
}

Expand Down

0 comments on commit 5ac075e

Please sign in to comment.