mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-07-30 23:40:13 +08:00
46
lib/common/widgets/tap_region_surface.dart
Normal file
46
lib/common/widgets/tap_region_surface.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter/rendering.dart' show BoxHitTestResult, HitTestEntry;
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
class SelectionTapRegionSurface extends TapRegionSurface {
|
||||
const SelectionTapRegionSurface({
|
||||
super.key,
|
||||
required super.child,
|
||||
required this.isScrolling,
|
||||
});
|
||||
|
||||
final ValueGetter<bool> isScrolling;
|
||||
|
||||
@override
|
||||
RenderObject createRenderObject(BuildContext context) {
|
||||
return RenderSelectionTapRegionSurface(isScrolling);
|
||||
}
|
||||
|
||||
@override
|
||||
void updateRenderObject(
|
||||
BuildContext context,
|
||||
RenderSelectionTapRegionSurface renderObject,
|
||||
) {
|
||||
renderObject.isScrolling = isScrolling;
|
||||
}
|
||||
}
|
||||
|
||||
class RenderSelectionTapRegionSurface extends RenderTapRegionSurface {
|
||||
RenderSelectionTapRegionSurface(this.isScrolling);
|
||||
|
||||
ValueGetter<bool> isScrolling;
|
||||
bool _isScrolling = false;
|
||||
|
||||
@override
|
||||
bool hitTest(BoxHitTestResult result, {required Offset position}) {
|
||||
_isScrolling = isScrolling();
|
||||
return super.hitTest(result, position: position);
|
||||
}
|
||||
|
||||
@override
|
||||
void handleEvent(PointerEvent event, HitTestEntry entry) {
|
||||
if (_isScrolling) {
|
||||
return;
|
||||
}
|
||||
super.handleEvent(event, entry);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user