Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi!: rewrite gesture handling #1733

Closed
wants to merge 113 commits into from
Closed
Show file tree
Hide file tree
Changes from 101 commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
c8f3961
tap, longPress, secondaryTap, drag, scroll gestures
josxha Nov 19, 2023
c409de6
doubleClick, rename multiFingerGestureStart
josxha Nov 19, 2023
76b2e8f
remove PositionedTapDetector2
josxha Nov 21, 2023
2358885
create gesture classes
josxha Nov 21, 2023
184951b
fix double tap and co
josxha Nov 21, 2023
ebef123
check if gesture is enabled, add tertiary and secondaryLongPress call…
josxha Nov 21, 2023
ec57c70
remove prefix from class, match file names
josxha Nov 21, 2023
c863202
fix new gestures
josxha Nov 21, 2023
499f77a
fix enable scroll wheel gesture check
josxha Nov 21, 2023
1f87645
use dedicated event classes for new map events
josxha Nov 21, 2023
6c9ea3f
add DoubleTapDragZoomGesture
josxha Nov 21, 2023
d9088b3
remove `MultiFingerGesture`
josxha Nov 22, 2023
95a25b4
fix rebase
josxha Nov 23, 2023
beaeb44
add `CtrlDragRotateGesture`
josxha Nov 25, 2023
451ceac
remove `TapPosition`
josxha Nov 25, 2023
fdd0788
pass full gesture event alongside the callback
josxha Nov 26, 2023
41348c2
add twoFingerRotate, twoFingerZoom, twoFingerMove
josxha Nov 26, 2023
7c744de
add pointer event callbacks
josxha Nov 26, 2023
a2b2148
add thresholds for two finger gestures
josxha Nov 26, 2023
158dfb1
add gesture, remove zoom and rotate threshold
josxha Nov 26, 2023
09be7e7
change default scroll wheel velocity
josxha Nov 26, 2023
30fded1
Delete internal_map_controller.dart
josxha Dec 8, 2023
9b005c8
Merge branch 'master' into gesture-handling
josxha Dec 8, 2023
e278e3e
Merge branch 'master' into gesture-handling
josxha Dec 10, 2023
e75b187
Merge branch 'master' into gesture-handling
josxha Dec 10, 2023
c908173
Merge branch 'master' into gesture-handling
josxha Dec 12, 2023
f25abcc
fix imports
josxha Dec 12, 2023
26f24e6
fix merge
josxha Dec 12, 2023
7166dcd
add doubleTapZoomIn
josxha Dec 12, 2023
7db3361
fix `DragGesture` end callback
josxha Dec 12, 2023
0c6e859
stop animation on gesture input
josxha Dec 12, 2023
2ea24e0
add flingAnimation
josxha Dec 13, 2023
ec0cef7
Update flutter_map_test.dart
josxha Dec 13, 2023
e3738a1
Update full_coverage_test.dart
josxha Dec 13, 2023
92e360b
use bool fields for interactiveFlags, keep support for bitfield
josxha Dec 13, 2023
f3c5e21
small improvements
josxha Dec 13, 2023
9202645
disable double clicks
josxha Dec 13, 2023
e59f4da
optional double click and scale callbacks
josxha Dec 13, 2023
cefacc3
remove null checks
josxha Dec 13, 2023
f32cca2
add docs
josxha Dec 14, 2023
794e9ba
refactor, turn MoveAndRotateResult to a class
josxha Dec 14, 2023
91f77dc
fix imports
josxha Dec 14, 2023
1ec5152
move map events to the controller
josxha Dec 14, 2023
94b687d
move gestures to map directory
josxha Dec 14, 2023
7d61515
move things around
josxha Dec 14, 2023
3b7b08d
clean up typedefs
josxha Dec 14, 2023
1fce148
clean up
josxha Dec 14, 2023
a1084fc
revert rename of `TapCallback`
josxha Dec 15, 2023
121da5e
remove `pinchZoomWinGestures` option
josxha Dec 15, 2023
0f10eb9
remove `IsKeyCursorRotationTrigger` typdef
josxha Dec 15, 2023
cb45f99
dart format
josxha Dec 15, 2023
e2a2e40
remove `CursorKeyboardRotationOptions`
josxha Dec 15, 2023
9f1d4a1
add docs, add ctrlRotateKeys to the hashKey and == function
josxha Dec 15, 2023
b0c0b5f
update docs
josxha Dec 15, 2023
dcc07b8
rename `InteractiveFlag` fields
josxha Dec 15, 2023
b93e02a
clean up
josxha Dec 15, 2023
134efa1
consistent naming
josxha Dec 15, 2023
ee7bf4a
refactor
josxha Dec 15, 2023
950fdd1
use threshhold options for two finger gestures
josxha Dec 15, 2023
4ac22eb
adjust threshholds
josxha Dec 15, 2023
c221060
clean up
josxha Dec 15, 2023
5dfe784
refactor
josxha Dec 16, 2023
ed0556d
Merge branch 'master' into gesture-handling
josxha Dec 16, 2023
7bef3eb
split gesture service into more files
josxha Dec 16, 2023
15d8658
use delta to start value for threshold
josxha Dec 16, 2023
876c098
fix: two finger gestures don't comply with options
josxha Dec 16, 2023
2c22a95
adjust thresholds one last time
josxha Dec 16, 2023
f9bcdc7
fix map events
josxha Dec 16, 2023
2309026
`TertiaryLongPressGestureService` is no delayed gesture
josxha Dec 17, 2023
f0904ea
fix refactoring
josxha Dec 17, 2023
48e1a3b
rename wither
josxha Dec 17, 2023
be56976
small fix in docs
josxha Dec 17, 2023
5aa3aff
fix disable double tap in example pages with clicks
josxha Dec 18, 2023
e2c7827
rename `groups` constructor to `byGroup`
josxha Dec 18, 2023
9c117cb
update label "Two finger drag"
josxha Dec 18, 2023
15697d7
remove `MoveAndRotateResult`
josxha Dec 18, 2023
5df6045
public default constructor for `EnabledGestures`
josxha Dec 18, 2023
39faadc
use `byGroup` constructor for `noRotation` constructor
josxha Dec 19, 2023
00a0dc4
use static field for default keyboard keys
josxha Dec 19, 2023
3be89b7
Merge branch 'master' into gesture-handling
josxha Jan 13, 2024
a49ad6c
Merge branch 'master' into gesture-handling
josxha Jan 15, 2024
905abbd
rename CtrlDragRotate to KeyTriggerDrag gesture
josxha Jan 15, 2024
6809dad
rename `DelayedGestureService` to `BaseDetailsGestureService`
josxha Jan 15, 2024
6d90dd3
add docs
josxha Jan 16, 2024
9916541
Merge branch 'master' into gesture-handling
josxha Jan 16, 2024
8a4995b
rename BaseDetailsGestureService to SingleShotGestureService
josxha Jan 17, 2024
ca81357
introduce SetTapDownDetailsMixin
josxha Jan 17, 2024
64d6892
add ProgressableGestureService , BaseLongPressGestureService, remove …
josxha Jan 17, 2024
c102197
stop gesture animation by any onPointerDown event
josxha Jan 17, 2024
cd4b7eb
Merge branch 'master' into gesture-handling
josxha Jan 18, 2024
9a39009
create getter for MapControllerImpl
josxha Jan 19, 2024
9956ada
remove obsolete `controller.stopAnimationRaw()` from services
josxha Jan 19, 2024
a19e580
Merge branch 'gesture-handling' into gesture-service-setDetails-as-mixin
josxha Jan 19, 2024
3fae4e2
clean up methods
josxha Jan 19, 2024
0b17c54
change abtract classes that have no method bodies or fields to interf…
josxha Jan 19, 2024
ae3ac26
Merge pull request #2 add polymorthism to gesture services
josxha Jan 19, 2024
777e432
Merge branch 'master' into gesture-handling
josxha Jan 19, 2024
57d94db
fix spelling
josxha Jan 20, 2024
be6cefb
feat: add support for trackpad zoom gesture (#3)
josxha Jan 20, 2024
d8c2f12
Merge branch 'master' into gesture-handling
josxha Jan 20, 2024
874b3a9
match trackpad velocity on new and legacy service
josxha Jan 20, 2024
e49bc02
rename `EnabledGestures` to `MapGestures`
josxha Jan 21, 2024
e175fcf
remove hasMultiFinger() method
josxha Jan 21, 2024
7d7b539
update docs
josxha Jan 21, 2024
53af338
rename `multiFinger` to `twoFinger` to match the gesture services
josxha Jan 21, 2024
8265953
MapGestures: remove `noRotation()`, add `.noGroups` and `.allGroups()`
josxha Jan 21, 2024
51fa616
change to noneByGroup, allByGroup
josxha Jan 21, 2024
133d5b8
Merge branch 'master' into gesture-handling
josxha Jan 21, 2024
c18170b
Merge branch 'master' into gesture-handling
josxha Jan 21, 2024
bacd10d
additional changes to merge upstream
josxha Jan 21, 2024
bcf30c5
add documentation
josxha Jan 21, 2024
6155f3a
add `trackpadZoom` to example app
josxha Jan 21, 2024
e8d4577
fix overflow in example app
josxha Jan 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'package:flutter_map_example/pages/custom_crs/custom_crs.dart';
import 'package:flutter_map_example/pages/epsg3413_crs.dart';
import 'package:flutter_map_example/pages/epsg4326_crs.dart';
import 'package:flutter_map_example/pages/fallback_url_page.dart';
import 'package:flutter_map_example/pages/gestures_page.dart';
import 'package:flutter_map_example/pages/home.dart';
import 'package:flutter_map_example/pages/interactive_test_page.dart';
import 'package:flutter_map_example/pages/latlng_to_screen_point.dart';
import 'package:flutter_map_example/pages/many_circles.dart';
import 'package:flutter_map_example/pages/many_markers.dart';
Expand Down Expand Up @@ -76,7 +76,7 @@ class MyApp extends StatelessWidget {
TileLoadingErrorHandle.route: (context) =>
const TileLoadingErrorHandle(),
TileBuilderPage.route: (context) => const TileBuilderPage(),
InteractiveFlagsPage.route: (context) => const InteractiveFlagsPage(),
GesturesPage.route: (context) => const GesturesPage(),
ManyMarkersPage.route: (context) => const ManyMarkersPage(),
StatefulMarkersPage.route: (context) => const StatefulMarkersPage(),
MapInsideListViewPage.route: (context) => const MapInsideListViewPage(),
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/custom_crs/custom_crs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class CustomCrsPageState extends State<CustomCrsPage> {
// Set maxZoom usually scales.length - 1 OR resolutions.length - 1
// but not greater
maxZoom: maxZoom,
onTap: (tapPosition, p) => setState(() {
onTap: (_, p) => setState(() {
initText = 'You clicked at';
point = proj4.Point(x: p.latitude, y: p.longitude);
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,50 @@ import 'package:flutter_map_example/misc/tile_providers.dart';
import 'package:flutter_map_example/widgets/drawer/menu_drawer.dart';
import 'package:latlong2/latlong.dart';

class InteractiveFlagsPage extends StatefulWidget {
static const String route = '/interactive_flags_page';
class GesturesPage extends StatefulWidget {
static const String route = '/enabled_gestures_page';

const InteractiveFlagsPage({super.key});
const GesturesPage({super.key});

@override
State createState() => _InteractiveFlagsPageState();
State createState() => _GesturesPageState();
}

class _InteractiveFlagsPageState extends State<InteractiveFlagsPage> {
class _GesturesPageState extends State<GesturesPage> {
static const availableFlags = {
'Movement': {
InteractiveFlag.drag: 'Drag',
InteractiveFlag.flingAnimation: 'Fling',
InteractiveFlag.pinchMove: 'Pinch',
InteractiveFlag.twoFingerMove: 'Two finger drag',
},
'Zooming': {
InteractiveFlag.pinchZoom: 'Pinch',
InteractiveFlag.twoFingerZoom: 'Pinch',
InteractiveFlag.scrollWheelZoom: 'Scroll',
InteractiveFlag.doubleTapZoom: 'Double tap',
InteractiveFlag.doubleTapDragZoom: '+ drag',
InteractiveFlag.doubleTapZoomIn: 'Double tap',
InteractiveFlag.doubleTapDragZoom: 'Double tap+drag',
},
'Rotation': {
InteractiveFlag.rotate: 'Twist',
InteractiveFlag.twoFingerRotate: 'Twist',
InteractiveFlag.keyTriggerDragRotate: 'CTRL+Drag',
},
};

int flags = InteractiveFlag.drag | InteractiveFlag.pinchZoom;
bool keyboardCursorRotate = false;
int flags = InteractiveFlag.drag | InteractiveFlag.twoFingerZoom;

MapEvent? _latestEvent;

@override
Widget build(BuildContext context) {
final screenWidth = MediaQuery.sizeOf(context).width;
return Scaffold(
appBar: AppBar(title: const Text('Interactive Flags')),
drawer: const MenuDrawer(InteractiveFlagsPage.route),
appBar: AppBar(title: const Text('Input gestures')),
drawer: const MenuDrawer(GesturesPage.route),
body: Padding(
padding: const EdgeInsets.all(8),
child: Column(
children: [
Flex(
direction: screenWidth >= 600 ? Axis.horizontal : Axis.vertical,
direction: screenWidth >= 650 ? Axis.horizontal : Axis.vertical,
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: availableFlags.entries
Expand Down Expand Up @@ -75,22 +75,10 @@ class _InteractiveFlagsPageState extends State<InteractiveFlagsPage> {
setState(() => flags |= e.key);
},
),
Text(e.value),
Text(e.value, textAlign: TextAlign.center),
],
),
),
if (category.key == 'Rotation') ...[
Column(
children: [
Checkbox.adaptive(
value: keyboardCursorRotate,
onChanged: (enabled) => setState(
() => keyboardCursorRotate = enabled!),
),
const Text('Cursor & CTRL'),
],
),
]
].interleave(const SizedBox(width: 12)).toList()
..removeLast(),
)
Expand Down Expand Up @@ -121,14 +109,7 @@ class _InteractiveFlagsPageState extends State<InteractiveFlagsPage> {
initialCenter: const LatLng(51.5, -0.09),
initialZoom: 11,
interactionOptions: InteractionOptions(
flags: flags,
cursorKeyboardRotationOptions:
CursorKeyboardRotationOptions(
isKeyTrigger: (key) =>
keyboardCursorRotate &&
CursorKeyboardRotationOptions.defaultTriggerKeys
.contains(key),
),
enabledGestures: EnabledGestures.bitfield(flags),
),
),
children: [openStreetMapTileLayer],
Expand Down Expand Up @@ -178,6 +159,12 @@ class _InteractiveFlagsPageState extends State<InteractiveFlagsPage> {
return 'MapEventRotateEnd';
case MapEventNonRotatedSizeChange():
return 'MapEventNonRotatedSizeChange';
case MapEventSecondaryLongPress():
return 'MapEventSecondaryLongPress';
case MapEventTertiaryTap():
return 'MapEventTertiaryTap';
case MapEventTertiaryLongPress():
return 'MapEventTertiaryLongPress';
case null:
return 'null';
default:
Expand Down
5 changes: 4 additions & 1 deletion example/lib/pages/latlng_to_screen_point.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ class _LatLngToScreenPointPageState extends State<LatLngToScreenPointPage> {
initialCenter: const LatLng(51.5, -0.09),
initialZoom: 11,
interactionOptions: const InteractionOptions(
flags: ~InteractiveFlag.doubleTapZoom,
enabledGestures: EnabledGestures.all(
doubleTapZoomIn: false,
doubleTapDragZoom: false,
),
),
onTap: (_, latLng) {
final point = mapController.camera
Expand Down
10 changes: 7 additions & 3 deletions example/lib/pages/markers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,14 @@ class _MarkerPageState extends State<MarkerPage> {
options: MapOptions(
initialCenter: const LatLng(51.5, -0.09),
initialZoom: 5,
onTap: (_, p) => setState(() => customMarkers.add(buildPin(p))),
onTap: (_, p) {
setState(() => customMarkers.add(buildPin(p)));
},
interactionOptions: const InteractionOptions(
flags: ~InteractiveFlag.doubleTapZoom,
),
enabledGestures: EnabledGestures.all(
doubleTapDragZoom: false,
doubleTapZoomIn: false,
)),
),
children: [
openStreetMapTileLayer,
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/secondary_tap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SecondaryTapPage extends StatelessWidget {
Flexible(
child: FlutterMap(
options: MapOptions(
onSecondaryTap: (tapPos, latLng) {
onSecondaryTap: (_, latLng) {
ScaffoldMessenger.maybeOf(context)?.showSnackBar(
SnackBar(content: Text('Secondary tap at $latLng')),
);
Expand Down
6 changes: 3 additions & 3 deletions example/lib/widgets/drawer/menu_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'package:flutter_map_example/pages/custom_crs/custom_crs.dart';
import 'package:flutter_map_example/pages/epsg3413_crs.dart';
import 'package:flutter_map_example/pages/epsg4326_crs.dart';
import 'package:flutter_map_example/pages/fallback_url_page.dart';
import 'package:flutter_map_example/pages/gestures_page.dart';
import 'package:flutter_map_example/pages/home.dart';
import 'package:flutter_map_example/pages/interactive_test_page.dart';
import 'package:flutter_map_example/pages/latlng_to_screen_point.dart';
import 'package:flutter_map_example/pages/many_circles.dart';
import 'package:flutter_map_example/pages/many_markers.dart';
Expand Down Expand Up @@ -109,8 +109,8 @@ class MenuDrawer extends StatelessWidget {
currentRoute: currentRoute,
),
MenuItemWidget(
caption: 'Interactive Flags',
routeName: InteractiveFlagsPage.route,
caption: 'Map Gestures',
routeName: GesturesPage.route,
currentRoute: currentRoute,
),
const Divider(),
Expand Down
14 changes: 6 additions & 8 deletions lib/flutter_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ library flutter_map;

export 'package:flutter_map/src/geo/crs.dart';
export 'package:flutter_map/src/geo/latlng_bounds.dart';
export 'package:flutter_map/src/gestures/interactive_flag.dart';
export 'package:flutter_map/src/gestures/latlng_tween.dart';
export 'package:flutter_map/src/gestures/map_events.dart';
export 'package:flutter_map/src/gestures/multi_finger_gesture.dart';
export 'package:flutter_map/src/gestures/positioned_tap_detector_2.dart';
export 'package:flutter_map/src/layer/attribution_layer/rich/animation.dart';
export 'package:flutter_map/src/layer/attribution_layer/rich/source.dart';
export 'package:flutter_map/src/layer/attribution_layer/rich/widget.dart';
Expand Down Expand Up @@ -50,11 +45,14 @@ export 'package:flutter_map/src/layer/tile_layer/tile_update_transformer.dart';
export 'package:flutter_map/src/map/camera/camera.dart';
export 'package:flutter_map/src/map/camera/camera_constraint.dart';
export 'package:flutter_map/src/map/camera/camera_fit.dart';
export 'package:flutter_map/src/map/controller/events/map_event_source.dart';
export 'package:flutter_map/src/map/controller/events/map_events.dart';
export 'package:flutter_map/src/map/controller/map_controller.dart';
export 'package:flutter_map/src/map/controller/map_controller_impl.dart';
export 'package:flutter_map/src/map/options/cursor_keyboard_rotation.dart';
export 'package:flutter_map/src/map/options/interaction.dart';
export 'package:flutter_map/src/map/options/options.dart';
export 'package:flutter_map/src/map/gestures/latlng_tween.dart';
export 'package:flutter_map/src/map/options/enabled_gestures.dart';
export 'package:flutter_map/src/map/options/interaction_options.dart';
export 'package:flutter_map/src/map/options/map_options.dart';
export 'package:flutter_map/src/map/widget.dart';
export 'package:flutter_map/src/misc/bounds.dart';
export 'package:flutter_map/src/misc/extensions.dart';
96 changes: 0 additions & 96 deletions lib/src/gestures/interactive_flag.dart

This file was deleted.

Loading
Loading