fix: addGlobalRoute вместо addRoute (на iOS видимо адресная подписка не доставляла события)

This commit is contained in:
klockky
2026-05-23 06:20:36 +00:00
parent 3e3ff6d07b
commit 561cea38cb
2 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -1738,7 +1738,7 @@ class _LongPressBubbleState extends State<_LongPressBubble> {
Haptics.medium();
final controller = MessageActionsController();
controller.attach(pointerId, details.globalPosition);
controller.attach(details.globalPosition, pointerId: pointerId);
_controller = controller;
Navigator.of(ctx)
@@ -15,18 +15,20 @@ class MessageActionsController extends ChangeNotifier {
Offset? initialPointer;
bool committed = false;
bool movedSignificantly = false;
bool _attached = false;
void attach(int pointerId, Offset initial) {
if (_pointerId != null) return;
void attach(Offset initial, {int? pointerId}) {
if (_attached) return;
_attached = true;
_pointerId = pointerId;
initialPointer = initial;
pointer = initial;
GestureBinding.instance.pointerRouter
.addRoute(pointerId, _onPointerEvent);
GestureBinding.instance.pointerRouter.addGlobalRoute(_onPointerEvent);
}
void _onPointerEvent(PointerEvent event) {
if (committed) return;
if (_pointerId != null && event.pointer != _pointerId) return;
if (event is PointerMoveEvent) {
pointer = event.position;
if (initialPointer != null &&
@@ -48,11 +50,9 @@ class MessageActionsController extends ChangeNotifier {
@override
void dispose() {
final id = _pointerId;
if (id != null) {
GestureBinding.instance.pointerRouter
.removeRoute(id, _onPointerEvent);
_pointerId = null;
if (_attached) {
GestureBinding.instance.pointerRouter.removeGlobalRoute(_onPointerEvent);
_attached = false;
}
super.dispose();
}