merge: 仅在暂停时显示播放按钮
This commit is contained in:
commit
3fcfd68660
2 files changed
+53
-10
No files matched your search
@@ -208,6 +208,28 @@ class _PlayerPageState extends State<PlayerPage> with WidgetsBindingObserver {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (widget.homeMode && _feedChromeVisible && !logic.chromeHidden)
|
||||||
|
Positioned.fill(
|
||||||
|
child: GestureDetector(
|
||||||
|
key: const Key('home-feed-video-toggle'),
|
||||||
|
behavior: HitTestBehavior.opaque,
|
||||||
|
onTap: () => logic.session.setUserWantsPlay(
|
||||||
|
!logic.session.userWantsPlay,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (widget.homeMode &&
|
||||||
|
_feedChromeVisible &&
|
||||||
|
!logic.chromeHidden &&
|
||||||
|
selected &&
|
||||||
|
!logic.session.userWantsPlay)
|
||||||
|
Center(
|
||||||
|
child: PlayerCenterToggle(
|
||||||
|
key: const Key('home-feed-center-play'),
|
||||||
|
playing: false,
|
||||||
|
onTap: () => logic.session.setUserWantsPlay(true),
|
||||||
|
),
|
||||||
|
),
|
||||||
// 票据三态之一:起播前正在向后端要签名地址
|
// 票据三态之一:起播前正在向后端要签名地址
|
||||||
if (selected && logic.ticketLoading)
|
if (selected && logic.ticketLoading)
|
||||||
const Center(
|
const Center(
|
||||||
@@ -605,7 +627,7 @@ class _PlaybackOverlayState extends State<_PlaybackOverlay> {
|
|||||||
void _onVideoTap() {
|
void _onVideoTap() {
|
||||||
if (!_controlsVisible) {
|
if (!_controlsVisible) {
|
||||||
setState(() => _controlsVisible = true);
|
setState(() => _controlsVisible = true);
|
||||||
} else if (!widget.playing) {
|
} else {
|
||||||
widget.onTogglePlay();
|
widget.onTogglePlay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -632,11 +654,11 @@ class _PlaybackOverlayState extends State<_PlaybackOverlay> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
if (widget.playing)
|
if (!widget.playing)
|
||||||
Center(
|
Center(
|
||||||
child: PlayerCenterToggle(
|
child: PlayerCenterToggle(
|
||||||
key: const Key('player-play-toggle'),
|
key: const Key('player-play-toggle'),
|
||||||
playing: true,
|
playing: false,
|
||||||
onTap: widget.onTogglePlay,
|
onTap: widget.onTogglePlay,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ void main() {
|
|||||||
expect(tester.takeException(), isNull);
|
expect(tester.takeException(), isNull);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('should_hide_pause_toggle_when_playback_is_paused', (
|
testWidgets('should_show_play_toggle_only_when_playback_is_paused', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
await _pumpApp(tester);
|
await _pumpApp(tester);
|
||||||
@@ -82,16 +82,18 @@ void main() {
|
|||||||
await tester.tap(find.byKey(const Key('detail-cta')));
|
await tester.tap(find.byKey(const Key('detail-cta')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
await tester.tap(find.byKey(const Key('player-play-toggle')));
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
|
|
||||||
expect(find.byKey(const Key('player-play-toggle')), findsNothing);
|
expect(find.byKey(const Key('player-play-toggle')), findsNothing);
|
||||||
expect(find.byKey(const Key('player-controls-top')), findsOneWidget);
|
|
||||||
expect(find.byKey(const Key('player-controls-bottom')), findsOneWidget);
|
|
||||||
|
|
||||||
await tester.tap(find.byKey(const Key('player-video-tap')));
|
await tester.tap(find.byKey(const Key('player-video-tap')));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
expect(find.byKey(const Key('player-play-toggle')), findsOneWidget);
|
expect(find.byKey(const Key('player-play-toggle')), findsOneWidget);
|
||||||
|
expect(find.byKey(const Key('player-controls-top')), findsOneWidget);
|
||||||
|
expect(find.byKey(const Key('player-controls-bottom')), findsOneWidget);
|
||||||
|
|
||||||
|
await tester.tap(find.byKey(const Key('player-play-toggle')));
|
||||||
|
await tester.pump();
|
||||||
|
expect(find.byKey(const Key('player-play-toggle')), findsNothing);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('should_keep_controls_visible_until_clear_screen_is_tapped', (
|
testWidgets('should_keep_controls_visible_until_clear_screen_is_tapped', (
|
||||||
@@ -109,6 +111,10 @@ void main() {
|
|||||||
|
|
||||||
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), findsNothing);
|
||||||
|
|
||||||
|
await tester.tap(find.byKey(const Key('player-video-tap')));
|
||||||
|
await tester.pump();
|
||||||
expect(find.byType(PlayerCenterToggle), findsOneWidget);
|
expect(find.byType(PlayerCenterToggle), findsOneWidget);
|
||||||
|
|
||||||
await tester.pump(const Duration(seconds: 5));
|
await tester.pump(const Duration(seconds: 5));
|
||||||
@@ -176,6 +182,21 @@ 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);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('should_show_home_play_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')), findsNothing);
|
||||||
|
await tester.tap(find.byKey(const Key('home-feed-video-toggle')));
|
||||||
|
await tester.pump();
|
||||||
|
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
|
||||||
|
|
||||||
|
await tester.tap(find.byKey(const Key('home-feed-center-play')));
|
||||||
|
await tester.pump();
|
||||||
|
expect(find.byKey(const Key('home-feed-center-play')), findsNothing);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _expectFullscreenOverlay(WidgetTester tester) {
|
void _expectFullscreenOverlay(WidgetTester tester) {
|
||||||
@@ -185,7 +206,7 @@ void _expectFullscreenOverlay(WidgetTester tester) {
|
|||||||
for (final key in const [Key('player-back'), Key('player-more')]) {
|
for (final key in const [Key('player-back'), Key('player-more')]) {
|
||||||
expect(tester.getSize(find.byKey(key)), const Size(36, 36));
|
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-episodes')), findsOneWidget);
|
||||||
expect(find.byKey(const Key('player-comments')), findsOneWidget);
|
expect(find.byKey(const Key('player-comments')), findsOneWidget);
|
||||||
expect(find.byKey(const Key('player-next')), findsOneWidget);
|
expect(find.byKey(const Key('player-next')), findsOneWidget);
|
||||||
|
|||||||
Reference in new issue
Block a user