Skip to content

Commit

Permalink
chore: faster video tap detecting
Browse files Browse the repository at this point in the history
now will only delay if pressed at seek areas
  • Loading branch information
MSOB7YY committed Feb 5, 2024
1 parent 5c832b0 commit 59a920c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 182 deletions.
177 changes: 0 additions & 177 deletions lib/packages/tap_detector.dart

This file was deleted.

33 changes: 28 additions & 5 deletions lib/ui/widgets/video_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,10 @@ class NamidaVideoControlsState extends State<NamidaVideoControls> with TickerPro
final borr = BorderRadius.circular(10.0.multipliedRadius);

bool _pointerDownedOnRight = true;

bool _doubleTapFirstPress = false;
Timer? _doubleTapTimer;

@override
Widget build(BuildContext context) {
final fallbackChild = widget.isLocal && !widget.isFullScreen
Expand Down Expand Up @@ -592,11 +596,30 @@ class NamidaVideoControlsState extends State<NamidaVideoControls> with TickerPro
}
}
},
child: TapDetector(
enableTaps: widget.showControls,
onTap: (d) => _onTap(),
onDoubleTap: (details) => _onDoubleTap(details.localPosition),
doubleTapTime: const Duration(milliseconds: 200),
child: Listener(
onPointerDown: widget.showControls
? (event) {
if (_doubleTapFirstPress) {
_onDoubleTap(event.localPosition);
_doubleTapFirstPress = false;
return;
}
final screenPart = context.width / 3;
final dx = event.position.dx;
if (dx >= screenPart && dx <= screenPart * 2) {
// pressed in middle
_onTap();
_doubleTapFirstPress = false;
} else {
_doubleTapFirstPress = true;
_doubleTapTimer?.cancel();
_doubleTapTimer = Timer(const Duration(milliseconds: 200), () {
_onTap();
_doubleTapFirstPress = false;
});
}
}
: null,
child: Stack(
fit: StackFit.passthrough,
alignment: Alignment.center,
Expand Down

0 comments on commit 59a920c

Please sign in to comment.