From 6074779224f26fe785131c0d9ba3055448f56a75 Mon Sep 17 00:00:00 2001 From: Yijing Huang Date: Thu, 3 Aug 2023 15:56:10 -0500 Subject: [PATCH] refactor: separate mobile and desktop selection gesture detector --- .../service/selection/desktop_selection_service.dart | 4 ++-- .../service/selection/mobile_selection_service.dart | 2 +- ...e.dart => desktop_selection_gesture_detector.dart} | 11 ++++++----- ...re.dart => mobile_selection_gesture_detector.dart} | 0 4 files changed, 9 insertions(+), 8 deletions(-) rename lib/src/service/selection/{selection_gesture.dart => desktop_selection_gesture_detector.dart} (91%) rename lib/src/service/selection/{mobile_selection_gesture.dart => mobile_selection_gesture_detector.dart} (100%) diff --git a/lib/src/editor/editor_component/service/selection/desktop_selection_service.dart b/lib/src/editor/editor_component/service/selection/desktop_selection_service.dart index 37332818c..a61b047a4 100644 --- a/lib/src/editor/editor_component/service/selection/desktop_selection_service.dart +++ b/lib/src/editor/editor_component/service/selection/desktop_selection_service.dart @@ -6,7 +6,7 @@ import 'package:flutter/material.dart' hide Overlay, OverlayEntry; import 'package:appflowy_editor/src/render/selection/cursor_widget.dart'; import 'package:appflowy_editor/src/render/selection/selection_widget.dart'; -import 'package:appflowy_editor/src/service/selection/selection_gesture.dart'; +import 'package:appflowy_editor/src/service/selection/desktop_selection_gesture_detector.dart'; import 'package:provider/provider.dart'; class DesktopSelectionServiceWidget extends StatefulWidget { @@ -88,7 +88,7 @@ class _DesktopSelectionServiceWidgetState @override Widget build(BuildContext context) { - return SelectionGestureDetector( + return DesktopSelectionGestureDetector( onPanStart: _onPanStart, onPanUpdate: _onPanUpdate, onPanEnd: _onPanEnd, diff --git a/lib/src/editor/editor_component/service/selection/mobile_selection_service.dart b/lib/src/editor/editor_component/service/selection/mobile_selection_service.dart index d2d22397c..1502db6f9 100644 --- a/lib/src/editor/editor_component/service/selection/mobile_selection_service.dart +++ b/lib/src/editor/editor_component/service/selection/mobile_selection_service.dart @@ -1,7 +1,7 @@ import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:appflowy_editor/src/flutter/overlay.dart'; import 'package:appflowy_editor/src/render/selection/mobile_selection_widget.dart'; -import 'package:appflowy_editor/src/service/selection/mobile_selection_gesture.dart'; +import 'package:appflowy_editor/src/service/selection/mobile_selection_gesture_detector.dart'; import 'package:flutter/material.dart' hide Overlay, OverlayEntry; import 'package:appflowy_editor/src/render/selection/cursor_widget.dart'; diff --git a/lib/src/service/selection/selection_gesture.dart b/lib/src/service/selection/desktop_selection_gesture_detector.dart similarity index 91% rename from lib/src/service/selection/selection_gesture.dart rename to lib/src/service/selection/desktop_selection_gesture_detector.dart index 50c36ca99..a7da3840d 100644 --- a/lib/src/service/selection/selection_gesture.dart +++ b/lib/src/service/selection/desktop_selection_gesture_detector.dart @@ -6,8 +6,8 @@ import 'package:flutter/material.dart'; /// Because the flutter's [DoubleTapGestureRecognizer] will block the [TapGestureRecognizer] /// for a while. So we need to implement our own GestureDetector. @immutable -class SelectionGestureDetector extends StatefulWidget { - const SelectionGestureDetector({ +class DesktopSelectionGestureDetector extends StatefulWidget { + const DesktopSelectionGestureDetector({ Key? key, this.child, this.onTapDown, @@ -20,8 +20,8 @@ class SelectionGestureDetector extends StatefulWidget { }) : super(key: key); @override - State createState() => - SelectionGestureDetectorState(); + State createState() => + DesktopSelectionGestureDetectorState(); final Widget? child; @@ -34,7 +34,8 @@ class SelectionGestureDetector extends StatefulWidget { final GestureDragEndCallback? onPanEnd; } -class SelectionGestureDetectorState extends State { +class DesktopSelectionGestureDetectorState + extends State { bool _isDoubleTap = false; Timer? _doubleTapTimer; int _tripleTabCount = 0; diff --git a/lib/src/service/selection/mobile_selection_gesture.dart b/lib/src/service/selection/mobile_selection_gesture_detector.dart similarity index 100% rename from lib/src/service/selection/mobile_selection_gesture.dart rename to lib/src/service/selection/mobile_selection_gesture_detector.dart