merge: 中心按钮仅暂停时显示

This commit is contained in:
Zhou Weidong committed 2026-10-19 17:20:56 +08:00
commit 99a57ec502
2 files changed
+29 -83

No files matched your search

+12 -8
View File
@@ -451,11 +451,14 @@ class _PlayerPageState extends State<PlayerPage> with WidgetsBindingObserver {
),
),
),
if (widget.homeMode && !logic.chromeHidden && selected)
if (widget.homeMode &&
!logic.chromeHidden &&
selected &&
!logic.session.userWantsPlay)
Center(
child: PlayerCenterToggle(
key: const Key('home-feed-center-play'),
playing: logic.session.userWantsPlay,
playing: false,
onTap: () =>
logic.session.setUserWantsPlay(!logic.session.userWantsPlay),
),
@@ -773,13 +776,14 @@ class _PlaybackOverlayState extends State<_PlaybackOverlay> {
onPressed: () => setState(() => _controlsVisible = true),
),
),
Center(
child: PlayerCenterToggle(
key: const Key('player-play-toggle'),
playing: widget.playing,
onTap: widget.onTogglePlay,
if (!widget.playing)
Center(
child: PlayerCenterToggle(
key: const Key('player-play-toggle'),
playing: false,
onTap: widget.onTogglePlay,
),
),
),
],
),
);
+17 -75
View File
@@ -69,7 +69,7 @@ void main() {
expect(tester.takeException(), isNull);
});
testWidgets('should_keep_center_toggle_in_both_play_states', (tester) async {
testWidgets('should_show_center_toggle_only_when_paused', (tester) async {
await _pumpApp(tester);
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
@@ -80,18 +80,11 @@ void main() {
await tester.tap(find.byKey(const Key('detail-cta')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('player-play-toggle')), findsOneWidget);
expect(
tester
.widget<PlayerCenterToggle>(
find.byKey(const Key('player-play-toggle')),
)
.playing,
isTrue,
);
expect(find.byKey(const Key('player-play-toggle')), findsNothing);
await tester.tap(find.byKey(const Key('player-play-toggle')));
await tester.tapAt(const Offset(80, 300));
await tester.pump();
expect(find.byKey(const Key('player-play-toggle')), findsOneWidget);
expect(
tester
.widget<PlayerCenterToggle>(
@@ -110,21 +103,7 @@ void main() {
await tester.tap(find.byKey(const Key('player-play-toggle')));
await tester.pump();
expect(
tester
.widget<PlayerCenterToggle>(
find.byKey(const Key('player-play-toggle')),
)
.playing,
isTrue,
);
expect(
find.descendant(
of: find.byKey(const Key('player-play-toggle')),
matching: find.byIcon(Icons.pause_rounded),
),
findsOneWidget,
);
expect(find.byKey(const Key('player-play-toggle')), findsNothing);
});
testWidgets('should_keep_controls_visible_until_clear_screen_is_tapped', (
@@ -142,7 +121,7 @@ void main() {
expect(find.byKey(const Key('player-controls-top')), findsOneWidget);
expect(find.byKey(const Key('player-controls-bottom')), findsOneWidget);
expect(find.byType(PlayerCenterToggle), findsOneWidget);
expect(find.byType(PlayerCenterToggle), findsNothing);
await tester.tapAt(const Offset(80, 300));
await tester.pump();
@@ -188,14 +167,7 @@ void main() {
await tester.pump();
expect(find.byKey(const Key('player-controls-top')), findsNothing);
expect(find.byKey(const Key('player-exit-clear-screen')), findsOneWidget);
expect(
tester
.widget<PlayerCenterToggle>(
find.byKey(const Key('player-play-toggle')),
)
.playing,
isTrue,
);
expect(find.byType(PlayerCenterToggle), findsNothing);
await tester.tapAt(const Offset(80, 300));
await tester.pump();
@@ -252,15 +224,7 @@ void main() {
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-scrim')), findsOneWidget);
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
expect(
tester
.widget<PlayerCenterToggle>(
find.byKey(const Key('home-feed-center-play')),
)
.playing,
isTrue,
);
expect(find.byKey(const Key('home-feed-center-play')), findsNothing);
await tester.tap(find.byKey(const Key('home-feed-clear-screen')));
await tester.pump();
@@ -277,7 +241,7 @@ void main() {
tester.getSize(find.byKey(const Key('home-feed-exit-clear-screen'))),
const Size(36, 36),
);
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
expect(find.byKey(const Key('home-feed-center-play')), findsNothing);
expect(
find.ancestor(
of: find.byKey(const Key('home-feed-exit-clear-screen')),
@@ -299,6 +263,7 @@ void main() {
find.byKey(const Key('home-feed-exit-clear-screen')),
findsOneWidget,
);
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
expect(
tester
.widget<PlayerCenterToggle>(
@@ -315,14 +280,7 @@ void main() {
find.byKey(const Key('home-feed-exit-clear-screen')),
findsOneWidget,
);
expect(
tester
.widget<PlayerCenterToggle>(
find.byKey(const Key('home-feed-center-play')),
)
.playing,
isTrue,
);
expect(find.byKey(const Key('home-feed-center-play')), findsNothing);
await tester.tap(find.byKey(const Key('home-feed-exit-clear-screen')));
await tester.pump();
@@ -331,25 +289,17 @@ void main() {
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-exit-clear-screen')), findsNothing);
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
expect(find.byKey(const Key('home-feed-center-play')), findsNothing);
});
testWidgets('should_keep_home_center_toggle_in_both_play_states', (
testWidgets('should_show_home_center_toggle_only_when_paused', (
tester,
) async {
await _pumpApp(tester);
await tester.tap(find.byKey(const Key('tab-home')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
expect(
tester
.widget<PlayerCenterToggle>(
find.byKey(const Key('home-feed-center-play')),
)
.playing,
isTrue,
);
expect(find.byKey(const Key('home-feed-center-play')), findsNothing);
await tester.tapAt(const Offset(80, 300));
await tester.pump();
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
@@ -364,15 +314,7 @@ void main() {
await tester.tap(find.byKey(const Key('home-feed-center-play')));
await tester.pump();
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
expect(
tester
.widget<PlayerCenterToggle>(
find.byKey(const Key('home-feed-center-play')),
)
.playing,
isTrue,
);
expect(find.byKey(const Key('home-feed-center-play')), findsNothing);
});
testWidgets('should_keep_home_clear_state_when_swiping_to_next_page', (
@@ -394,7 +336,7 @@ void main() {
find.byKey(const Key('home-feed-exit-clear-screen')),
findsOneWidget,
);
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
expect(find.byKey(const Key('home-feed-center-play')), findsNothing);
});
}
@@ -405,7 +347,7 @@ void _expectFullscreenOverlay(WidgetTester tester) {
for (final key in const [Key('player-back'), Key('player-more')]) {
expect(tester.getSize(find.byKey(key)), const Size(36, 36));
}
expect(find.byKey(const Key('player-play-toggle')), findsOneWidget);
expect(find.byKey(const Key('player-play-toggle')), findsNothing);
expect(find.byKey(const Key('player-episodes')), findsOneWidget);
expect(find.byKey(const Key('player-comments')), findsOneWidget);
expect(find.byKey(const Key('player-next')), findsOneWidget);