From be69ab4b80ef7c85a394bdd30f85a1d3defcfbe2 Mon Sep 17 00:00:00 2001 From: zarzet <42882290+zarzet@users.noreply.github.com> Date: Sun, 27 Sep 2026 01:03:31 +0700 Subject: [PATCH] fix(player): separate adjacent titles during track swipes --- lib/widgets/player_track_swipe.dart | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/widgets/player_track_swipe.dart b/lib/widgets/player_track_swipe.dart index fb644da7..edc5eb26 100644 --- a/lib/widgets/player_track_swipe.dart +++ b/lib/widgets/player_track_swipe.dart @@ -24,8 +24,11 @@ class PlayerTrackSwipe extends StatefulWidget { class _PlayerTrackSwipeState extends State with SingleTickerProviderStateMixin { + static const _titleGap = 32.0; + late final _offset = AnimationController.unbounded(vsync: this); double _width = 240; + double get _pageExtent => _width + _titleGap; double _drag = 0; bool _settling = false; int _generation = 0; @@ -63,7 +66,7 @@ class _PlayerTrackSwipeState extends State _drag += details.primaryDelta ?? 0; _offset.value = _neighbor(_drag) == null ? _drag * 0.18 / (1 + _drag.abs() / _width) - : _drag.clamp(-_width, _width); + : _drag.clamp(-_pageExtent, _pageExtent); } Future _finish([DragEndDetails? details]) async { @@ -81,7 +84,7 @@ class _PlayerTrackSwipeState extends State try { await _offset .animateTo( - commit ? _width * offset.sign : 0, + commit ? _pageExtent * offset.sign : 0, duration: MediaQuery.disableAnimationsOf(context) ? Duration.zero : const Duration(milliseconds: 280), @@ -165,7 +168,7 @@ class PlayerTrackSwipeTitles extends StatelessWidget { return ClipRect( child: AnimatedBuilder( animation: state._offset, - child: builder(current), + child: ClipRect(child: builder(current)), builder: (context, child) { final offset = state._offset.value; final next = state._neighbor(offset); @@ -178,11 +181,13 @@ class PlayerTrackSwipeTitles extends StatelessWidget { ), if (offset != 0 && next != null) Positioned( - left: offset - width * offset.sign, + left: offset - state._pageExtent * offset.sign, top: 0, width: width, child: ExcludeSemantics( - child: IgnorePointer(child: builder(next)), + child: IgnorePointer( + child: ClipRect(child: builder(next)), + ), ), ), ],