From b2c219d6bdeaae37b629ed79315c6cc8315a6692 Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Tue, 20 Oct 2026 14:38:09 +0800 Subject: [PATCH] =?UTF-8?q?fix(flutter):=20=E6=B8=85=E5=B1=8F=E6=80=81?= =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E5=8F=AF=E6=8B=96=E5=8A=A8=E5=B9=B6=E9=95=BF?= =?UTF-8?q?=E6=8C=89=E6=81=A2=E5=A4=8D=E6=92=AD=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/player/player_view.dart | 11 +--- test/home/home_preview_layout_test.dart | 79 +++++++++++++++++++++++++ test/home/k28_a_navigation_test.dart | 22 +++++++ 3 files changed, 103 insertions(+), 9 deletions(-) diff --git a/lib/pages/player/player_view.dart b/lib/pages/player/player_view.dart index 70a69a4..6ee2abb 100644 --- a/lib/pages/player/player_view.dart +++ b/lib/pages/player/player_view.dart @@ -142,6 +142,8 @@ class _PlayerPageState extends State with WidgetsBindingObserver { /// 长按两侧:切 2 倍速并清屏,记下进入前的状态用于松手恢复。 void _startBoost() { if (_boosting) return; + // 暂停时长按两侧先恢复播放,再进入 2 倍速。 + if (!logic.session.userWantsPlay) logic.session.setUserWantsPlay(true); setState(() { _boosting = true; _speedBeforeBoost = _playbackSpeed; @@ -499,15 +501,6 @@ class _PlayerPageState extends State with WidgetsBindingObserver { ? null : () => _openUnlockSheet(context, index, episode), ), - if (widget.homeMode && !_chromeVisible) - Positioned.fill( - child: GestureDetector( - key: const Key('home-feed-video-tap'), - behavior: HitTestBehavior.opaque, - onTap: () => - logic.session.setUserWantsPlay(!logic.session.userWantsPlay), - ), - ), if (widget.homeMode && !_chromeVisible) Positioned( right: 12, diff --git a/test/home/home_preview_layout_test.dart b/test/home/home_preview_layout_test.dart index a79629e..b281dfc 100644 --- a/test/home/home_preview_layout_test.dart +++ b/test/home/home_preview_layout_test.dart @@ -379,4 +379,83 @@ void main() { expect(find.byKey(const Key('home-feed-refreshing')), findsNothing); expect(find.byIcon(Icons.refresh_rounded), findsOneWidget); }); + + testWidgets('should_seek_from_series_bar_when_overlay_is_cleared', ( + tester, + ) async { + Duration? seeked; + final controller = ValueNotifier( + VideoPlayerValue( + duration: const Duration(seconds: 100), + position: const Duration(seconds: 10), + isInitialized: true, + ), + ); + addTearDown(controller.dispose); + await tester.pumpWidget( + MaterialApp( + theme: AppTheme.light(), + locale: const Locale('en'), + supportedLocales: AppLocalizations.supportedLocales, + localizationsDelegates: AppLocalizations.localizationsDelegates, + home: Builder( + builder: (context) => Scaffold( + body: HomeFeedOverlay( + l10n: AppLocalizations.of(context)!, + drama: const Drama( + id: 'clear-drama', + title: 'Clear Drama', + synopsis: 'synopsis', + posterUrl: '', + totalEpisodes: 8, + ), + episode: const Episode( + id: 'clear-episode', + number: 1, + title: 'Episode 1', + isFree: true, + ), + controller: controller, + liked: false, + saved: false, + visible: false, + boosting: false, + onTogglePlay: () {}, + onBoostStart: () {}, + onBoostEnd: () {}, + onLike: () {}, + onSave: () {}, + onComments: () {}, + onShare: () {}, + onEpisodes: () {}, + onDetail: () {}, + onOpenFullPlayer: () {}, + onRefreshFeed: () async => true, + onDownload: () {}, + onClear: () {}, + onSearch: () {}, + onMore: () {}, + onScrubStart: () {}, + onSeek: (value) => seeked = value, + ), + ), + ), + ), + ); + await tester.pumpAndSettle(); + + expect(find.byKey(const Key('home-feed-refresh')), findsOneWidget); + expect(find.byKey(const Key('home-feed-full-series')), findsOneWidget); + expect(find.byKey(const Key('home-feed-progress')), findsOneWidget); + + final gesture = await tester.startGesture( + tester.getCenter(find.byKey(const Key('home-feed-progress'))), + ); + await gesture.moveBy(const Offset(80, 0)); + await gesture.up(); + await tester.pumpAndSettle(); + + expect(seeked, isNotNull); + expect(seeked!.inSeconds, greaterThan(0)); + }); } diff --git a/test/home/k28_a_navigation_test.dart b/test/home/k28_a_navigation_test.dart index bda1d33..bff3ca7 100644 --- a/test/home/k28_a_navigation_test.dart +++ b/test/home/k28_a_navigation_test.dart @@ -178,6 +178,28 @@ void main() { expect(find.byKey(const Key('rail-save')), findsOneWidget); }); + testWidgets('should_resume_playback_when_boosting_while_paused', ( + tester, + ) async { + await _pumpApp(tester); + await tester.tap(find.byKey(const Key('home-feed-video-toggle'))); + await tester.pump(); + expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget); + + final gesture = await tester.startGesture(const Offset(60, 300)); + await tester.pump(const Duration(milliseconds: 700)); + await tester.pump(); + + expect(find.byKey(const Key('home-feed-speed-boost-hint')), findsOneWidget); + expect(find.textContaining('2.0'), findsWidgets); + expect(find.byKey(const Key('home-feed-center-play')), findsNothing); + + await gesture.up(); + await tester.pumpAndSettle(); + expect(find.byKey(const Key('home-feed-speed-boost-hint')), findsNothing); + expect(find.byKey(const Key('home-feed-center-play')), findsNothing); + }); + testWidgets('should_open_more_sheet_on_center_long_press', (tester) async { await _pumpApp(tester);