fix: 使用点击序号防止双击误暂停
This commit is contained in:
1 parent
9ddd7fc833
commit
bbc759473c
7 files changed
+113
-61
No files matched your search
@@ -120,8 +120,7 @@ class _PlayerPageState extends State<PlayerPage>
|
||||
bool _scrubbing = false;
|
||||
double? _speedBeforeBoost;
|
||||
bool? _chromeBeforeBoost;
|
||||
bool _doubleTapHandling = false;
|
||||
Timer? _doubleTapGuardTimer;
|
||||
DateTime? _lastDoubleTapAt;
|
||||
|
||||
/// 收藏切换后的本地增量:基准是详情快照,切换成功按服务端状态 ±1。
|
||||
final Map<String, int> _favoriteDelta = {};
|
||||
@@ -263,7 +262,6 @@ class _PlayerPageState extends State<PlayerPage>
|
||||
appRouteObserver.unsubscribe(this);
|
||||
_spriteAxisService.dispose();
|
||||
_thumbnailService.dispose();
|
||||
_doubleTapGuardTimer?.cancel();
|
||||
logic.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
@@ -336,7 +334,7 @@ class _PlayerPageState extends State<PlayerPage>
|
||||
}
|
||||
|
||||
void _handleFeedSurfaceTap() {
|
||||
if (_scrubbing || _doubleTapHandling) return;
|
||||
if (_scrubbing || _doubleTapGuardActive) return;
|
||||
if (!_chromeVisible) {
|
||||
_restoreFeedChrome();
|
||||
return;
|
||||
@@ -345,20 +343,23 @@ class _PlayerPageState extends State<PlayerPage>
|
||||
}
|
||||
|
||||
void _togglePlayback() {
|
||||
if (_doubleTapHandling) return;
|
||||
if (_doubleTapGuardActive) return;
|
||||
logic.session.setUserWantsPlay(!logic.session.userWantsPlay);
|
||||
}
|
||||
|
||||
bool get _doubleTapGuardActive {
|
||||
final lastDoubleTapAt = _lastDoubleTapAt;
|
||||
return lastDoubleTapAt != null &&
|
||||
DateTime.now().difference(lastDoubleTapAt) <
|
||||
const Duration(milliseconds: 350);
|
||||
}
|
||||
|
||||
void _handleDoubleTapLike(
|
||||
BuildContext context,
|
||||
InteractionController interactions,
|
||||
Episode episode,
|
||||
) {
|
||||
_doubleTapHandling = true;
|
||||
_doubleTapGuardTimer?.cancel();
|
||||
_doubleTapGuardTimer = Timer(const Duration(milliseconds: 300), () {
|
||||
_doubleTapHandling = false;
|
||||
});
|
||||
_lastDoubleTapAt = DateTime.now();
|
||||
unawaited(_toggleLike(context, interactions, episode, likeOnly: true));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user