diff --git a/src/libs/Mapbox.Maui/IMapboxView.cs b/src/libs/Mapbox.Maui/IMapboxView.cs index 3cf595d..c4ec801 100644 --- a/src/libs/Mapbox.Maui/IMapboxView.cs +++ b/src/libs/Mapbox.Maui/IMapboxView.cs @@ -8,6 +8,7 @@ public partial interface IMapboxView : IView { CameraOptions CameraOptions { get; set; } + GestureSettings GestureSettings { get; set; } MapboxStyle MapboxStyle { get; set; } IPosition MapCenter { get; set; } float? MapZoom { get; set; } diff --git a/src/libs/Mapbox.Maui/Mapbox.Maui.csproj b/src/libs/Mapbox.Maui/Mapbox.Maui.csproj index 11bf076..907eee3 100644 --- a/src/libs/Mapbox.Maui/Mapbox.Maui.csproj +++ b/src/libs/Mapbox.Maui/Mapbox.Maui.csproj @@ -53,7 +53,7 @@ https://github.com/tuyen-vuduc/mapbox-maui https://mapbox.tuyen-vuduc.tech false - 11.4.0-alpha01 + 11.4.0-alpha02 README.md LICENSE tv-mapbox.png @@ -80,8 +80,8 @@ - - + + diff --git a/src/libs/Mapbox.Maui/MapboxView.cs b/src/libs/Mapbox.Maui/MapboxView.cs index 1b3901b..d9fe7ca 100644 --- a/src/libs/Mapbox.Maui/MapboxView.cs +++ b/src/libs/Mapbox.Maui/MapboxView.cs @@ -5,6 +5,17 @@ public partial class MapboxView : View, IMapboxView { + public static readonly BindableProperty GestureSettingsProperty = BindableProperty.Create( + nameof(GestureSettings), + typeof(GestureSettings), + typeof(MapboxView) + ); + public GestureSettings GestureSettings + { + get => (GestureSettings)GetValue(GestureSettingsProperty); + set => SetValue(GestureSettingsProperty, value); + } + public static readonly BindableProperty ViewAnnotationsProperty = BindableProperty.Create( nameof(ViewAnnotations), typeof(IEnumerable), diff --git a/src/libs/Mapbox.Maui/MapboxViewHandler.cs b/src/libs/Mapbox.Maui/MapboxViewHandler.cs index 141b3fe..4b954d1 100644 --- a/src/libs/Mapbox.Maui/MapboxViewHandler.cs +++ b/src/libs/Mapbox.Maui/MapboxViewHandler.cs @@ -18,6 +18,7 @@ public static IPropertyMapper PropertyMapper = new PropertyMapper(ViewHandler.ViewMapper) { [nameof(MapboxView.CameraOptions)] = HandleCameraOptionsChanged, + [nameof(MapboxView.GestureSettings)] = HandleGestureSettingsChanged, [nameof(MapboxView.MapboxStyle)] = HandleMapboxStyleChanged, [nameof(MapboxView.ScaleBarVisibility)] = HandleScaleBarVisibilityChanged, [nameof(MapboxView.DebugOptions)] = HandleDebugOptionsChanged, diff --git a/src/libs/Mapbox.Maui/Models/GestureSettings.cs b/src/libs/Mapbox.Maui/Models/GestureSettings.cs new file mode 100644 index 0000000..c847975 --- /dev/null +++ b/src/libs/Mapbox.Maui/Models/GestureSettings.cs @@ -0,0 +1,106 @@ +namespace MapboxMaui; + +public record struct GestureSettings +{ + public GestureSettings() + { + } + + /// + /// Whether the rotate gesture is enabled. + /// + public bool RotateEnabled { get; set; } = true; + /// + /// Whether the pinch to zoom gesture is enabled. + /// + /// iOS: PinchZoomEnabled + /// + public bool PinchToZoomEnabled { get; set; } = true; + /// + /// Whether the single-touch scroll gesture is enabled. + /// + public bool ScrollEnabled { get; set; } = true; + /// + /// Whether rotation is enabled for the pinch to zoom gesture. + /// + /// iOS: SimultaneousRotateAndPinchZoomEnabled + /// + public bool SimultaneousRotateAndPinchToZoomEnabled { get; set; } = true; + /// + /// Whether the pitch gesture is enabled. + /// + public bool PitchEnabled { get; set; } = true; + /// + /// Configures the directions in which the map is allowed to move during a scroll gesture. + /// + /// iOS: PanMode + /// + public PanMode ScrollMode { get; set; } = PanMode.Both; + /// + /// Whether double tapping the map with one touch results in a zoom-in animation. + /// + public bool DoubleTapToZoomInEnabled { get; set; } = true; + /// + /// Whether single tapping the map with two touches results in a zoom-out animation. + /// + public bool DoubleTouchToZoomOutEnabled { get; set; } = true; + /// + /// Whether the quick zoom gesture is enabled. + /// + public bool QuickZoomEnabled { get; set; } = true; + /// + /// By default, gestures rotate and zoom around the center of the gesture. Set this property to + /// rotate and zoom around a fixed point instead. + /// + public ScreenPosition? FocalPoint { get; set; } + /// + /// Android only. + /// Whether a deceleration animation following a pinch-to-zoom gesture is enabled. True by default. + /// + public bool PinchToZoomDecelerationEnabled { get; set; } = true; + /// + /// Android only. + /// Whether a deceleration animation following a rotate gesture is enabled. True by default. + /// + public bool RotateDecelerationEnabled { get; set; } = true; + /// + /// Android only. + /// Whether a deceleration animation following a scroll gesture is enabled. True by default. + /// + public bool ScrollDecelerationEnabled { get; set; } = true; + /// + /// Android only. + /// + /// Whether rotate threshold increases when pinching to zoom. true by default. + /// + public bool IncreaseRotateThresholdWhenPinchingToZoom { get; set; } = true; + /// + /// Android only. + /// Whether pinch to zoom threshold increases when rotating. true by default. + /// + public bool IncreasePinchToZoomThresholdWhenRotating { get; set; } = true; + /// + /// Android only. + /// The amount by which the zoom level increases or decreases during a double-tap-to-zoom-in or + /// double-touch-to-zoom-out gesture. 1.0 by default. Must be positive. + /// + public float ZoomAnimationAmount { get; set; } = 1.0f; + /// + /// iOS only. + /// A constant factor that determines how quickly pan deceleration animations happen. + /// Multiplied with the velocity vector once per millisecond during deceleration animations. + /// + public float PanDecelerationFactor { get; set; } = 1.0f; + /// + /// Whether pan is enabled for the pinch gesture. + /// + /// iOS: PanEnabled + /// + public bool PinchScrollEnabled { get; set; } = true; +} +public enum PanMode +{ + Horizontal = 0x0001, + Vertical = 0x0010, + Both = 0x0011, +} \ No newline at end of file diff --git a/src/libs/Mapbox.Maui/Platforms/Android/AdditionalExtensions.cs b/src/libs/Mapbox.Maui/Platforms/Android/AdditionalExtensions.cs index b711623..c456614 100644 --- a/src/libs/Mapbox.Maui/Platforms/Android/AdditionalExtensions.cs +++ b/src/libs/Mapbox.Maui/Platforms/Android/AdditionalExtensions.cs @@ -15,10 +15,20 @@ using AndroidX.Fragment.App; using Com.Mapbox.Maps.Plugins.Animation; using Com.Mapbox.Functions; +using Com.Mapbox.Maps.Plugins; static class AdditionalExtensions { internal static DisplayMetrics Metrics; + + public static ScrollMode ToNative(this PanMode scrollDirection) + { + return scrollDirection switch { + PanMode.Horizontal => ScrollMode.Horizontal, + PanMode.Vertical => ScrollMode.Vertical, + _ => ScrollMode.HorizontalAndVertical, + }; + } public static MapAnimationOptions ToNative(this AnimationOptions animationOptions) { diff --git a/src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.cs b/src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.cs index 048b8bc..e98fc0e 100644 --- a/src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.cs +++ b/src/libs/Mapbox.Maui/Platforms/Android/MapboxViewHandler.cs @@ -7,12 +7,40 @@ using Android.Content; using Android.Graphics; using GeoJSON.Text; - +using Com.Mapbox.Maps.Plugins.Gestures; +using Com.Mapbox.Maps.Plugins.Gestures.Generated; + namespace MapboxMaui; public partial class MapboxViewHandler { MapboxFragment mapboxFragment; + private static void HandleGestureSettingsChanged(MapboxViewHandler handler, IMapboxView view) + { + var mapView = handler.GetMapView(); + if (mapView == null) return; + + var gestures = mapView.GetGestures(); + + gestures.DoubleTapToZoomInEnabled = view.GestureSettings.DoubleTapToZoomInEnabled; + gestures.DoubleTouchToZoomOutEnabled = view.GestureSettings.DoubleTouchToZoomOutEnabled; + gestures.FocalPoint = view.GestureSettings.FocalPoint?.ToScreenCoordinate(); + gestures.IncreasePinchToZoomThresholdWhenRotating = view.GestureSettings.IncreasePinchToZoomThresholdWhenRotating; + gestures.IncreaseRotateThresholdWhenPinchingToZoom = view.GestureSettings.IncreaseRotateThresholdWhenPinchingToZoom; + gestures.PinchScrollEnabled = view.GestureSettings.PinchScrollEnabled; + gestures.PinchToZoomDecelerationEnabled = view.GestureSettings.PinchToZoomDecelerationEnabled; + gestures.PinchToZoomEnabled = view.GestureSettings.PinchToZoomEnabled; + gestures.PitchEnabled = view.GestureSettings.PitchEnabled; + gestures.QuickZoomEnabled = view.GestureSettings.QuickZoomEnabled; + gestures.RotateDecelerationEnabled = view.GestureSettings.RotateDecelerationEnabled; + gestures.RotateEnabled = view.GestureSettings.RotateEnabled; + gestures.ScrollDecelerationEnabled = view.GestureSettings.ScrollDecelerationEnabled; + gestures.ScrollEnabled = view.GestureSettings.ScrollEnabled; + gestures.ScrollMode = view.GestureSettings.ScrollMode.ToNative(); + gestures.SimultaneousRotateAndPinchToZoomEnabled = view.GestureSettings.SimultaneousRotateAndPinchToZoomEnabled; + gestures.ZoomAnimationAmount = view.GestureSettings.ZoomAnimationAmount; + } + private static void HandleLightChanged(MapboxViewHandler handler, IMapboxView view) { var mapView = handler.GetMapView(); @@ -197,7 +225,7 @@ private static void HandleMapboxStyleChanged(MapboxViewHandler handler, IMapboxV styleUri = MapboxMapsStyle.MapboxStreets; } - handler.GetMapView()?.MapboxMap.LoadStyleUri(styleUri); + handler.GetMapView()?.MapboxMap.LoadStyle(styleUri); } protected override PlatformView CreatePlatformView() diff --git a/src/libs/Mapbox.Maui/Platforms/iOS/AdditionalExtensions.cs b/src/libs/Mapbox.Maui/Platforms/iOS/AdditionalExtensions.cs index 28ca899..020fe9c 100644 --- a/src/libs/Mapbox.Maui/Platforms/iOS/AdditionalExtensions.cs +++ b/src/libs/Mapbox.Maui/Platforms/iOS/AdditionalExtensions.cs @@ -11,10 +11,20 @@ namespace MapboxMaui; using MapboxMapsObjC; using Microsoft.Maui.Controls.Compatibility.Platform.iOS; using Microsoft.Maui.Platform; -using System.Runtime.InteropServices; +using CoreGraphics; public static partial class AdditionalExtensions { + internal static TMBPanMode ToNative(this PanMode panMode) + { + return panMode switch + { + PanMode.Horizontal => TMBPanMode.Horizontal, + PanMode.Vertical => TMBPanMode.Vertical, + _ => TMBPanMode.HorizontalAndVertical, + }; + } + internal static NSDictionary ToNative(this IDictionary dictionary) { var list = new NSMutableDictionary(); @@ -278,12 +288,8 @@ public static TMBCameraOptions ToNative(this CameraOptions cameraOptions) (float)cameraOptions.Padding.Value.Bottom, (float)cameraOptions.Padding.Value.Right) : UIKit.UIEdgeInsets.Zero; - var anchor = cameraOptions.Anchor is not null - ? new CoreGraphics.CGPoint( - cameraOptions.Anchor.Value.X, - cameraOptions.Anchor.Value.Y - ) - : CoreGraphics.CGPoint.Empty; + var anchor = cameraOptions.Anchor?.ToNative() + ?? CGPoint.Empty; var zoom = cameraOptions.Zoom.HasValue ? cameraOptions.Zoom.Value : 14f; @@ -303,5 +309,15 @@ public static TMBCameraOptions ToNative(this CameraOptions cameraOptions) pitch ); } + + internal static CGPoint ToNative(this ScreenPosition screenPosition) + { + return new CGPoint(screenPosition.X, screenPosition.Y); + } + + internal static NSValue ToNSValue(this ScreenPosition screenPosition) + { + return NSValue.FromCGPoint(screenPosition.ToNative()); + } } diff --git a/src/libs/Mapbox.Maui/Platforms/iOS/GeometryExtensions.cs b/src/libs/Mapbox.Maui/Platforms/iOS/GeometryExtensions.cs index 7d64a4a..69be0c8 100644 --- a/src/libs/Mapbox.Maui/Platforms/iOS/GeometryExtensions.cs +++ b/src/libs/Mapbox.Maui/Platforms/iOS/GeometryExtensions.cs @@ -93,14 +93,6 @@ internal static CGPoint ToCGPoint(this IPosition xobj) ); } - internal static CGPoint ToCGPoint(this ScreenPosition xobj) - { - return new CGPoint( - xobj.X, - xobj.Y - ); - } - public static IPosition ToMapPosition(this CLLocationCoordinate2D point) { return new MapPosition( diff --git a/src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.Controller.cs b/src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.Controller.cs index 1a73146..872c247 100644 --- a/src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.Controller.cs +++ b/src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.Controller.cs @@ -26,7 +26,7 @@ public IPosition GetMapPosition(ScreenPosition position) if (mapView == null) return null; var coords = mapView.MapboxMap().CoordinateFor( - position.ToCGPoint() + position.ToNative() ); return coords.ToMapPosition(); diff --git a/src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.cs b/src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.cs index a6a039b..751c9b1 100644 --- a/src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.cs +++ b/src/libs/Mapbox.Maui/Platforms/iOS/MapboxViewHandler.cs @@ -14,6 +14,29 @@ public partial class MapboxViewHandler UITapGestureRecognizer mapTapGestureRecognizer; UILongPressGestureRecognizer mapLongPressGestureRecognizer; + private static void HandleGestureSettingsChanged(MapboxViewHandler handler, IMapboxView view) + { + var mapView = handler.PlatformView.MapView; + if (mapView == null) return; + + var gestureOptions = new TMBGestureOptions( + panEnabled: view.GestureSettings.PinchScrollEnabled, + pinchEnabled: false, + rotateEnabled: view.GestureSettings.RotateEnabled, + simultaneousRotateAndPinchZoomEnabled: view.GestureSettings.SimultaneousRotateAndPinchToZoomEnabled, + pinchZoomEnabled: view.GestureSettings.PinchToZoomEnabled, + pinchPanEnabled: false, + pitchEnabled: view.GestureSettings.PitchEnabled, + doubleTapToZoomInEnabled: view.GestureSettings.DoubleTapToZoomInEnabled, + doubleTouchToZoomOutEnabled: view.GestureSettings.DoubleTouchToZoomOutEnabled, + quickZoomEnabled: view.GestureSettings.QuickZoomEnabled, + panDecelerationFactor: UIScrollView.DecelerationRateNormal, + panMode: view.GestureSettings.ScrollMode.ToNative(), + focalPoint: view.GestureSettings.FocalPoint?.ToNSValue() + ); + mapView.Gestures().GestureOptions = gestureOptions; + } + private static void HandleLightChanged(MapboxViewHandler handler, IMapboxView view) { var mapView = handler.PlatformView.MapView; diff --git a/src/qs/MapboxMauiQs/AppShell.xaml.cs b/src/qs/MapboxMauiQs/AppShell.xaml.cs index ec63949..c76c482 100644 --- a/src/qs/MapboxMauiQs/AppShell.xaml.cs +++ b/src/qs/MapboxMauiQs/AppShell.xaml.cs @@ -5,6 +5,8 @@ public partial class AppShell : Shell public AppShell() { InitializeComponent(); + + Routing.RegisterRoute(nameof(GestureSettingsExample.GestureSettingsExampleSettingsPage), typeof(GestureSettingsExample.GestureSettingsExampleSettingsPage)); } } diff --git a/src/qs/MapboxMauiQs/Examples/Lab/66.GestureSettings/GestureSettingsExample.cs b/src/qs/MapboxMauiQs/Examples/Lab/66.GestureSettings/GestureSettingsExample.cs new file mode 100644 index 0000000..5d75ee6 --- /dev/null +++ b/src/qs/MapboxMauiQs/Examples/Lab/66.GestureSettings/GestureSettingsExample.cs @@ -0,0 +1,481 @@ +namespace MapboxMauiQs; + +public class GestureSettingsExample : ContentPage, IExamplePage, IQueryAttributable +{ + MapboxView map; + IExampleInfo info; + + public GestureSettingsExample() + { + iOSPage.SetUseSafeArea(this, false); + Content = map = new MapboxView(); + + var toolbarItem = new ToolbarItem() + { + Text = "Config", + Command = new Command(ShowPopup) + }; + ToolbarItems.Add(toolbarItem); + + map.MapReady += Map_MapReady; + map.MapLoaded += Map_MapLoaded; + } + + private async void ShowPopup() + { + await Shell.Current.GoToAsync(nameof(GestureSettingsExampleSettingsPage), true, new Dictionary() + { + { "data", map.GestureSettings } + }); + } + + public void ApplyQueryAttributes(IDictionary query) + { + if (query.TryGetValue("example", out var example) && example is IExampleInfo exampleInfo) + { + info = exampleInfo; + Title = info?.Title; + } + + if (query.TryGetValue("data", out var data) && data is GestureSettings gestureSettings) + { + map.GestureSettings = gestureSettings; + } + } + + private void Map_MapReady(object sender, EventArgs e) + { + var centerLocation = new MapPosition(21.028511, 105.804817); + var cameraOptions = new CameraOptions + { + Center = centerLocation, + Zoom = 14, + }; + + map.CameraOptions = cameraOptions; + } + + private void Map_MapLoaded(object sender, EventArgs e) + { + // Setup Styles, Annotations, etc here + } + + public class GestureSettingsExampleSettingsPage : ContentPage, IQueryAttributable + { + private GestureSettings gestureSettings; + private StackLayout mainContent; + + public GestureSettingsExampleSettingsPage() + { + Shell.SetPresentationMode(this, PresentationMode.ModalAnimated); + + Padding = new Thickness(0, 64, 0, 0); + + mainContent = new StackLayout + { + Spacing = 0, + }; + Content = new StackLayout + { + Spacing = 0, + Children = { + new Grid + { + Children = + { + new Label + { + Text = "Gesture Configs", + FontSize = 26, + Margin = 16, + HorizontalTextAlignment = TextAlignment.Center, + }, + new Label + { + Text = "Apply", + Margin = 16, + VerticalOptions = LayoutOptions.Center, + HorizontalOptions = LayoutOptions.End, + GestureRecognizers = + { + new TapGestureRecognizer + { + Command = new Command(Apply), + }, + } + } + } + }, + new BoxView + { + Margin = 16, + }, + new ScrollView + { + HorizontalScrollBarVisibility = ScrollBarVisibility.Never, + Content = new Grid + { + Children = + { + mainContent, + }, + }, + } + }, + }; + } + + private View CreateSwitchRow(string title, bool defaultValue) + { + var @switch = new Switch + { + IsToggled = defaultValue, + VerticalOptions = LayoutOptions.Center, + HorizontalOptions = LayoutOptions.End, + }; + + @switch.Toggled += (s, e) => + { + ToggleEnabled((s as Switch).Parent, e); + }; + return new Grid + { + Padding = new Thickness(16, 8), + Children = { + new Label + { + Text = title, + FontSize = 16, + VerticalOptions = LayoutOptions.Center, + }, + @switch, + } + }; + } + + private void ToggleEnabled(object sender, ToggledEventArgs e) + { + var grid = (Grid)sender; + var label = (Label)grid.Children[0]; + + switch (label.Text) { + case nameof(DoubleTapToZoomInEnabled): + DoubleTapToZoomInEnabled = e.Value; + break; + case nameof(DoubleTouchToZoomOutEnabled): + DoubleTouchToZoomOutEnabled = e.Value; + break; + case nameof(PinchScrollEnabled): + PinchScrollEnabled = e.Value; + break; + case nameof(PinchToZoomDecelerationEnabled): + PinchToZoomDecelerationEnabled = e.Value; + break; + case nameof(PinchToZoomEnabled): + PinchToZoomEnabled = e.Value; + break; + case nameof(PitchEnabled): + PitchEnabled = e.Value; + break; + case nameof(QuickZoomEnabled): + QuickZoomEnabled = e.Value; + break; + case nameof(RotateDecelerationEnabled): + RotateDecelerationEnabled = e.Value; + break; + case nameof(RotateEnabled): + RotateEnabled = e.Value; + break; + case nameof(ScrollDecelerationEnabled): + ScrollDecelerationEnabled = e.Value; + break; + case nameof(ScrollEnabled): + ScrollEnabled = e.Value; + break; + case nameof(SimultaneousRotateAndPinchToZoomEnabled): + SimultaneousRotateAndPinchToZoomEnabled = e.Value; + break; + } + } + + private async void Apply() + { + await Shell.Current.GoToAsync("..", new Dictionary() + { + { "data", gestureSettings }, + }); + } + + public void ApplyQueryAttributes(IDictionary query) + { + gestureSettings = (GestureSettings)query["data"]; + + mainContent.Children.Add(CreateSwitchRow(nameof(DoubleTapToZoomInEnabled), DoubleTapToZoomInEnabled)); + mainContent.Children.Add(CreateSwitchRow(nameof(DoubleTouchToZoomOutEnabled), DoubleTouchToZoomOutEnabled)); + mainContent.Children.Add(CreateSwitchRow(nameof(IncreasePinchToZoomThresholdWhenRotating), IncreasePinchToZoomThresholdWhenRotating)); + mainContent.Children.Add(CreateSwitchRow(nameof(IncreaseRotateThresholdWhenPinchingToZoom), IncreaseRotateThresholdWhenPinchingToZoom)); + mainContent.Children.Add(CreateSwitchRow(nameof(PinchScrollEnabled), PinchScrollEnabled)); + mainContent.Children.Add(CreateSwitchRow(nameof(PinchToZoomDecelerationEnabled), PinchToZoomDecelerationEnabled)); + mainContent.Children.Add(CreateSwitchRow(nameof(PinchToZoomEnabled), PinchToZoomEnabled)); + mainContent.Children.Add(CreateSwitchRow(nameof(PitchEnabled), PitchEnabled)); + mainContent.Children.Add(CreateSwitchRow(nameof(QuickZoomEnabled), QuickZoomEnabled)); + mainContent.Children.Add(CreateSwitchRow(nameof(RotateDecelerationEnabled), RotateDecelerationEnabled)); + mainContent.Children.Add(CreateSwitchRow(nameof(RotateEnabled), RotateEnabled)); + mainContent.Children.Add(CreateSwitchRow(nameof(ScrollDecelerationEnabled), ScrollDecelerationEnabled)); + mainContent.Children.Add(CreateSwitchRow(nameof(ScrollEnabled), ScrollEnabled)); + mainContent.Children.Add(CreateSwitchRow(nameof(SimultaneousRotateAndPinchToZoomEnabled), SimultaneousRotateAndPinchToZoomEnabled)); + + mainContent.Children.Add(CreateFocalPointView()); + } + + private IView CreateFocalPointView() + { + var row = new StackLayout + { + + }; + row.Add(new Label + { + Text = "FocalPoint", + }); + row.Add(new StackLayout + { + Orientation = StackOrientation.Horizontal, + Children = + { + new Label + { + Text = "X=" + }, + new Slider + { + Minimum = 0, + Maximum = DeviceDisplay.Current.MainDisplayInfo.Width, + }, + } + }); + row.Add(new StackLayout + { + Orientation = StackOrientation.Horizontal, + Children = + { + new Label + { + Text = "Y=" + }, + new Slider + { + Minimum = 0, + Maximum = DeviceDisplay.Current.MainDisplayInfo.Height, + }, + } + }); + + return row; + } + + /// + /// Whether the rotate gesture is enabled. + /// + public bool RotateEnabled + { + get => gestureSettings.RotateEnabled; + set => gestureSettings = gestureSettings with + { + RotateEnabled = value, + }; + } + /// + /// Whether the pinch to zoom gesture is enabled. + /// + /// iOS: PinchZoomEnabled + /// + public bool PinchToZoomEnabled + { + get => gestureSettings.PinchToZoomEnabled; + set => gestureSettings = gestureSettings with + { + PinchToZoomEnabled = value, + }; + } + /// + /// Whether the single-touch scroll gesture is enabled. + /// + public bool ScrollEnabled + { + get => gestureSettings.ScrollEnabled; + set => gestureSettings = gestureSettings with + { + ScrollEnabled = value, + }; + } + /// + /// Whether rotation is enabled for the pinch to zoom gesture. + /// + /// iOS: SimultaneousRotateAndPinchZoomEnabled + /// + public bool SimultaneousRotateAndPinchToZoomEnabled + { + get => gestureSettings.SimultaneousRotateAndPinchToZoomEnabled; + set => gestureSettings = gestureSettings with + { + SimultaneousRotateAndPinchToZoomEnabled = value, + }; + } + /// + /// Whether the pitch gesture is enabled. + /// + public bool PitchEnabled + { + get => gestureSettings.PitchEnabled; + set => gestureSettings = gestureSettings with + { + PitchEnabled = value, + }; + } + /// + /// Configures the directions in which the map is allowed to move during a scroll gesture. + /// + /// iOS: PanMode + /// + public PanMode ScrollMode + { + get => gestureSettings.ScrollMode; + set => gestureSettings = gestureSettings with + { + ScrollMode = value, + }; + } + /// + /// Whether double tapping the map with one touch results in a zoom-in animation. + /// + public bool DoubleTapToZoomInEnabled + { + get => gestureSettings.DoubleTapToZoomInEnabled; + set => gestureSettings = gestureSettings with + { + DoubleTapToZoomInEnabled = value, + }; + } + /// + /// Whether single tapping the map with two touches results in a zoom-out animation. + /// + public bool DoubleTouchToZoomOutEnabled + { + get => gestureSettings.DoubleTouchToZoomOutEnabled; + set => gestureSettings = gestureSettings with + { + DoubleTouchToZoomOutEnabled = value, + }; + } + /// + /// Whether the quick zoom gesture is enabled. + /// + public bool QuickZoomEnabled + { + get => gestureSettings.QuickZoomEnabled; + set => gestureSettings = gestureSettings with + { + QuickZoomEnabled = value, + }; + } + /// + /// By default, gestures rotate and zoom around the center of the gesture. Set this property to + /// rotate and zoom around a fixed point instead. + /// + public ScreenPosition? FocalPoint + { + get => gestureSettings.FocalPoint; + set => gestureSettings = gestureSettings with + { + FocalPoint = value, + }; + } + /// + /// Android only. + /// Whether a deceleration animation following a pinch-to-zoom gesture is enabled. True by default. + /// + public bool PinchToZoomDecelerationEnabled + { + get => gestureSettings.PinchToZoomDecelerationEnabled; + set => gestureSettings = gestureSettings with + { + PinchToZoomDecelerationEnabled = value, + }; + } + /// + /// Android only. + /// Whether a deceleration animation following a rotate gesture is enabled. True by default. + /// + public bool RotateDecelerationEnabled + { + get => gestureSettings.RotateDecelerationEnabled; + set => gestureSettings = gestureSettings with + { + RotateDecelerationEnabled = value, + }; + } + /// + /// Android only. + /// Whether a deceleration animation following a scroll gesture is enabled. True by default. + /// + public bool ScrollDecelerationEnabled + { + get => gestureSettings.ScrollDecelerationEnabled; + set => gestureSettings = gestureSettings with + { + ScrollDecelerationEnabled = value, + }; + } + /// + /// Android only. + /// + /// Whether rotate threshold increases when pinching to zoom. true by default. + /// + public bool IncreaseRotateThresholdWhenPinchingToZoom + { + get => gestureSettings.IncreaseRotateThresholdWhenPinchingToZoom; + set => gestureSettings = gestureSettings with + { + IncreaseRotateThresholdWhenPinchingToZoom = value, + }; + } + /// + /// Android only. + /// Whether pinch to zoom threshold increases when rotating. true by default. + /// + public bool IncreasePinchToZoomThresholdWhenRotating + { + get => gestureSettings.IncreasePinchToZoomThresholdWhenRotating; + set => gestureSettings = gestureSettings with + { + IncreasePinchToZoomThresholdWhenRotating = value, + }; + } + /// + /// The amount by which the zoom level increases or decreases during a double-tap-to-zoom-in or + /// double-touch-to-zoom-out gesture. 1.0 by default. Must be positive. + /// + public float ZoomAnimationAmount + { + get => gestureSettings.ZoomAnimationAmount; + set => gestureSettings = gestureSettings with + { + ZoomAnimationAmount = value, + }; + } + /// + /// Whether pan is enabled for the pinch gesture. + /// + /// iOS: PanEnabled + /// + public bool PinchScrollEnabled + { + get => gestureSettings.PinchScrollEnabled; + set => gestureSettings = gestureSettings with + { + PinchScrollEnabled = value, + }; + } + } +} \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/Examples/Lab/66.GestureSettings/GestureSettingsExampleInfo.cs b/src/qs/MapboxMauiQs/Examples/Lab/66.GestureSettings/GestureSettingsExampleInfo.cs new file mode 100644 index 0000000..432aba7 --- /dev/null +++ b/src/qs/MapboxMauiQs/Examples/Lab/66.GestureSettings/GestureSettingsExampleInfo.cs @@ -0,0 +1,11 @@ +namespace MapboxMauiQs; + +class GestureSettingsExampleInfo : IExampleInfo +{ + public string Group => "Lab"; + public string Title => "Gesture Settings"; + public string Subtitle => "Enable and disable default gestures."; + public string PageRoute => typeof(GestureSettingsExample).FullName; + public int GroupIndex => 0; + public int Index => 66; +} \ No newline at end of file diff --git a/src/qs/MapboxMauiQs/MapboxMauiQs.csproj b/src/qs/MapboxMauiQs/MapboxMauiQs.csproj index fdbb110..4692bf6 100644 --- a/src/qs/MapboxMauiQs/MapboxMauiQs.csproj +++ b/src/qs/MapboxMauiQs/MapboxMauiQs.csproj @@ -105,8 +105,8 @@ - - + + Platforms\iOS\Shared\%(RecursiveDir)%(Filename)%(Extension)