feat(player): add mobile edge adjustments

This commit is contained in:
edde746
2026-06-14 13:40:16 +02:00
parent e7809b3160
commit a861a4110f
13 changed files with 1184 additions and 5 deletions
@@ -82,6 +82,9 @@ class MobileVideoControls extends StatefulWidget {
/// Called when the content strip visibility changes
final ValueChanged<bool>? onStripVisibilityChanged;
/// Returns true when a global touch position belongs to the parent edge-adjustment zone.
final bool Function(Offset globalPosition)? isInEdgeAdjustmentZone;
const MobileVideoControls({
super.key,
required this.player,
@@ -115,6 +118,7 @@ class MobileVideoControls extends StatefulWidget {
this.onQueueItemSelected,
this.chromeController,
this.onStripVisibilityChanged,
this.isInEdgeAdjustmentZone,
});
@override
@@ -125,6 +129,7 @@ class _MobileVideoControlsState extends State<MobileVideoControls> with SingleTi
late final AnimationController _stripAnim;
bool _stripVisible = false;
late bool _lastControlsVisible;
bool _stripDragEnabled = true;
/// Drag distance (in pixels) required to fully reveal the strip.
static const _dragExtent = 150.0;
@@ -183,12 +188,21 @@ class _MobileVideoControlsState extends State<MobileVideoControls> with SingleTi
}
}
void _onVerticalDragStart(DragStartDetails details) {
_stripDragEnabled = widget.isInEdgeAdjustmentZone?.call(details.globalPosition) != true;
}
void _onVerticalDragUpdate(DragUpdateDetails details) {
if (!_stripDragEnabled) return;
// Negative primaryDelta = swipe up = reveal strip (increase value)
_stripAnim.value -= (details.primaryDelta ?? 0) / _dragExtent;
}
void _onVerticalDragEnd(DragEndDetails details) {
if (!_stripDragEnabled) {
_stripDragEnabled = true;
return;
}
final velocity = details.primaryVelocity ?? 0;
// Fast swipe up or past halfway without fast swipe down → show strip
if (velocity < -200 || (_stripAnim.value > 0.5 && velocity < 200)) {
@@ -219,6 +233,7 @@ class _MobileVideoControlsState extends State<MobileVideoControls> with SingleTi
_buildTopBar(context),
Expanded(
child: GestureDetector(
onVerticalDragStart: _onVerticalDragStart,
onVerticalDragUpdate: _onVerticalDragUpdate,
onVerticalDragEnd: _onVerticalDragEnd,
behavior: HitTestBehavior.translucent,