merge: 修正清屏态点击与滑动复位

This commit is contained in:
Zhou Weidong committed 2026-10-19 17:06:32 +08:00
commit bc5feebf39
2 files changed
+75 -32

No files matched your search

+17 -12
View File
@@ -128,6 +128,9 @@ class _PlayerPageState extends State<PlayerPage> with WidgetsBindingObserver {
itemCount: indices.length, itemCount: indices.length,
onPageChanged: (position) { onPageChanged: (position) {
final index = indices[position]; final index = indices[position];
if (widget.homeMode && !_feedChromeVisible) {
setState(() => _feedChromeVisible = true);
}
widget.onDramaChanged?.call(logic.queue.entryAt(index).drama); widget.onDramaChanged?.call(logic.queue.entryAt(index).drama);
unawaited(logic.selectEpisode(index)); unawaited(logic.selectEpisode(index));
}, },
@@ -444,17 +447,23 @@ class _PlayerPageState extends State<PlayerPage> with WidgetsBindingObserver {
child: GestureDetector( child: GestureDetector(
key: const Key('home-feed-video-tap'), key: const Key('home-feed-video-tap'),
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
onTap: () => setState(() => _feedChromeVisible = true), onTap: () =>
logic.session.setUserWantsPlay(!logic.session.userWantsPlay),
), ),
), ),
if (widget.homeMode && !_feedChromeVisible) if (widget.homeMode && !_feedChromeVisible)
Positioned( Positioned(
top: 8, top: 0,
right: 12, right: 0,
child: ExitClearScreenButton( child: SafeArea(
key: const Key('home-feed-exit-clear-screen'), left: false,
tooltip: l10n.exitClearScreen, bottom: false,
onPressed: () => setState(() => _feedChromeVisible = true), minimum: const EdgeInsets.only(top: 8, right: 12),
child: ExitClearScreenButton(
key: const Key('home-feed-exit-clear-screen'),
tooltip: l10n.exitClearScreen,
onPressed: () => setState(() => _feedChromeVisible = true),
),
), ),
), ),
], ],
@@ -635,11 +644,7 @@ class _PlaybackOverlayState extends State<_PlaybackOverlay> {
bool _controlsVisible = true; bool _controlsVisible = true;
void _onVideoTap() { void _onVideoTap() {
if (!_controlsVisible) { widget.onTogglePlay();
setState(() => _controlsVisible = true);
} else {
widget.onTogglePlay();
}
} }
void _clearScreen() => setState(() => _controlsVisible = false); void _clearScreen() => setState(() => _controlsVisible = false);
+58 -20
View File
@@ -137,21 +137,22 @@ void main() {
const Size(36, 36), const Size(36, 36),
); );
await tester.tap(find.byKey(const Key('player-video-tap')));
await tester.pump();
expect(find.byKey(const Key('player-controls-top')), findsNothing);
expect(find.byKey(const Key('player-exit-clear-screen')), findsOneWidget);
await tester.tap(find.byKey(const Key('player-video-tap')));
await tester.pump();
expect(find.byKey(const Key('player-controls-top')), findsNothing);
expect(find.byKey(const Key('player-exit-clear-screen')), findsOneWidget);
await tester.tap(find.byKey(const Key('player-exit-clear-screen'))); await tester.tap(find.byKey(const Key('player-exit-clear-screen')));
await tester.pump(); await tester.pump();
expect(find.byKey(const Key('player-controls-top')), findsOneWidget); expect(find.byKey(const Key('player-controls-top')), findsOneWidget);
expect(find.byKey(const Key('player-controls-bottom')), findsOneWidget); expect(find.byKey(const Key('player-controls-bottom')), findsOneWidget);
expect(find.byType(PlayerCenterToggle), findsOneWidget); expect(find.byType(PlayerCenterToggle), findsOneWidget);
expect(find.byKey(const Key('player-exit-clear-screen')), findsNothing); expect(find.byKey(const Key('player-exit-clear-screen')), findsNothing);
await tester.tap(find.byKey(const Key('player-clear-screen')));
await tester.pump();
expect(find.byKey(const Key('player-exit-clear-screen')), findsOneWidget);
await tester.tap(find.byKey(const Key('player-video-tap')));
await tester.pump();
expect(find.byKey(const Key('player-controls-top')), findsOneWidget);
expect(find.byKey(const Key('player-exit-clear-screen')), findsNothing);
}); });
testWidgets('should_fit_player_header_on_320_width', (tester) async { testWidgets('should_fit_player_header_on_320_width', (tester) async {
@@ -196,6 +197,35 @@ void main() {
tester.getSize(find.byKey(const Key('home-feed-exit-clear-screen'))), tester.getSize(find.byKey(const Key('home-feed-exit-clear-screen'))),
const Size(36, 36), const Size(36, 36),
); );
expect(
find.ancestor(
of: find.byKey(const Key('home-feed-exit-clear-screen')),
matching: find.byType(SafeArea),
),
findsWidgets,
);
expect(
tester
.getTopLeft(find.byKey(const Key('home-feed-exit-clear-screen')))
.dy,
greaterThanOrEqualTo(8),
);
await tester.tap(find.byKey(const Key('home-feed-video-tap')));
await tester.pump();
expect(find.byKey(const Key('home-feed-title')), findsNothing);
expect(
find.byKey(const Key('home-feed-exit-clear-screen')),
findsOneWidget,
);
await tester.tap(find.byKey(const Key('home-feed-video-tap')));
await tester.pump();
expect(find.byKey(const Key('home-feed-title')), findsNothing);
expect(
find.byKey(const Key('home-feed-exit-clear-screen')),
findsOneWidget,
);
await tester.tap(find.byKey(const Key('home-feed-exit-clear-screen'))); await tester.tap(find.byKey(const Key('home-feed-exit-clear-screen')));
await tester.pump(); await tester.pump();
@@ -204,17 +234,7 @@ void main() {
expect(find.byKey(const Key('home-feed-info-card')), findsOneWidget); expect(find.byKey(const Key('home-feed-info-card')), findsOneWidget);
expect(find.byKey(const Key('home-feed-scrim')), findsOneWidget); expect(find.byKey(const Key('home-feed-scrim')), findsOneWidget);
expect(find.byKey(const Key('home-feed-exit-clear-screen')), findsNothing); expect(find.byKey(const Key('home-feed-exit-clear-screen')), findsNothing);
expect(find.byKey(const Key('home-feed-center-play')), findsNothing);
await tester.tap(find.byKey(const Key('home-feed-clear-screen')));
await tester.pump();
expect(
find.byKey(const Key('home-feed-exit-clear-screen')),
findsOneWidget,
);
await tester.tap(find.byKey(const Key('home-feed-video-tap')));
await tester.pump();
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
expect(find.byKey(const Key('home-feed-exit-clear-screen')), findsNothing);
}); });
testWidgets('should_show_home_play_toggle_only_when_paused', (tester) async { testWidgets('should_show_home_play_toggle_only_when_paused', (tester) async {
@@ -231,6 +251,24 @@ void main() {
await tester.pump(); await tester.pump();
expect(find.byKey(const Key('home-feed-center-play')), findsNothing); expect(find.byKey(const Key('home-feed-center-play')), findsNothing);
}); });
testWidgets('should_reset_home_chrome_when_swiping_to_next_page', (
tester,
) async {
await _pumpApp(tester);
await tester.tap(find.byKey(const Key('tab-home')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('home-feed-clear-screen')));
await tester.pump();
expect(find.byKey(const Key('home-feed-title')), findsNothing);
await tester.drag(find.byType(PageView), const Offset(0, -550));
await tester.pumpAndSettle();
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
expect(find.byKey(const Key('home-feed-info-card')), findsOneWidget);
expect(find.byKey(const Key('home-feed-exit-clear-screen')), findsNothing);
});
} }
void _expectFullscreenOverlay(WidgetTester tester) { void _expectFullscreenOverlay(WidgetTester tester) {