fix(player): 保持清屏并常驻中心按钮
This commit is contained in:
1 parent
bc5feebf39
commit
0d977da75b
2 files changed
+171
-51
No files matched your search
@@ -128,9 +128,6 @@ class _PlayerPageState extends State<PlayerPage> with WidgetsBindingObserver {
|
||||
itemCount: indices.length,
|
||||
onPageChanged: (position) {
|
||||
final index = indices[position];
|
||||
if (widget.homeMode && !_feedChromeVisible) {
|
||||
setState(() => _feedChromeVisible = true);
|
||||
}
|
||||
widget.onDramaChanged?.call(logic.queue.entryAt(index).drama);
|
||||
unawaited(logic.selectEpisode(index));
|
||||
},
|
||||
@@ -221,18 +218,6 @@ class _PlayerPageState extends State<PlayerPage> with WidgetsBindingObserver {
|
||||
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)
|
||||
const Center(
|
||||
@@ -466,6 +451,15 @@ class _PlayerPageState extends State<PlayerPage> with WidgetsBindingObserver {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (widget.homeMode && !logic.chromeHidden && selected)
|
||||
Center(
|
||||
child: PlayerCenterToggle(
|
||||
key: const Key('home-feed-center-play'),
|
||||
playing: logic.session.userWantsPlay,
|
||||
onTap: () =>
|
||||
logic.session.setUserWantsPlay(!logic.session.userWantsPlay),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -669,14 +663,6 @@ class _PlaybackOverlayState extends State<_PlaybackOverlay> {
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
if (!widget.playing)
|
||||
Center(
|
||||
child: PlayerCenterToggle(
|
||||
key: const Key('player-play-toggle'),
|
||||
playing: false,
|
||||
onTap: widget.onTogglePlay,
|
||||
),
|
||||
),
|
||||
const Positioned(
|
||||
right: 10,
|
||||
bottom: 14,
|
||||
@@ -787,6 +773,13 @@ class _PlaybackOverlayState extends State<_PlaybackOverlay> {
|
||||
onPressed: () => setState(() => _controlsVisible = true),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: PlayerCenterToggle(
|
||||
key: const Key('player-play-toggle'),
|
||||
playing: widget.playing,
|
||||
onTap: widget.onTogglePlay,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -69,9 +69,7 @@ void main() {
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('should_show_play_toggle_only_when_playback_is_paused', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('should_keep_center_toggle_in_both_play_states', (tester) async {
|
||||
await _pumpApp(tester);
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
@@ -82,18 +80,51 @@ void main() {
|
||||
await tester.tap(find.byKey(const Key('detail-cta')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(const Key('player-play-toggle')), findsNothing);
|
||||
|
||||
await tester.tap(find.byKey(const Key('player-video-tap')));
|
||||
await tester.pump();
|
||||
|
||||
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);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('player-play-toggle')),
|
||||
)
|
||||
.playing,
|
||||
isTrue,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('player-play-toggle')));
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('player-play-toggle')), findsNothing);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('player-play-toggle')),
|
||||
)
|
||||
.playing,
|
||||
isFalse,
|
||||
);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('player-play-toggle')),
|
||||
matching: find.byIcon(Icons.play_arrow_rounded),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
|
||||
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,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_keep_controls_visible_until_clear_screen_is_tapped', (
|
||||
@@ -111,11 +142,19 @@ void main() {
|
||||
|
||||
expect(find.byKey(const Key('player-controls-top')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-controls-bottom')), findsOneWidget);
|
||||
expect(find.byType(PlayerCenterToggle), findsNothing);
|
||||
expect(find.byType(PlayerCenterToggle), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(const Key('player-video-tap')));
|
||||
await tester.tapAt(const Offset(80, 300));
|
||||
await tester.pump();
|
||||
expect(find.byType(PlayerCenterToggle), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('player-play-toggle')),
|
||||
)
|
||||
.playing,
|
||||
isFalse,
|
||||
);
|
||||
|
||||
await tester.pump(const Duration(seconds: 5));
|
||||
await tester.pump();
|
||||
@@ -129,7 +168,15 @@ void main() {
|
||||
|
||||
expect(find.byKey(const Key('player-controls-top')), findsNothing);
|
||||
expect(find.byKey(const Key('player-controls-bottom')), findsNothing);
|
||||
expect(find.byType(PlayerCenterToggle), findsNothing);
|
||||
expect(find.byType(PlayerCenterToggle), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('player-play-toggle')),
|
||||
)
|
||||
.playing,
|
||||
isFalse,
|
||||
);
|
||||
expect(find.byKey(const Key('player-video-tap')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-exit-clear-screen')), findsOneWidget);
|
||||
expect(
|
||||
@@ -137,21 +184,45 @@ void main() {
|
||||
const Size(36, 36),
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('player-video-tap')));
|
||||
await tester.tapAt(const Offset(80, 300));
|
||||
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,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('player-video-tap')));
|
||||
await tester.tapAt(const Offset(80, 300));
|
||||
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,
|
||||
isFalse,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('player-exit-clear-screen')));
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('player-controls-top')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-controls-bottom')), findsOneWidget);
|
||||
expect(find.byType(PlayerCenterToggle), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('player-play-toggle')),
|
||||
)
|
||||
.playing,
|
||||
isFalse,
|
||||
);
|
||||
expect(find.byKey(const Key('player-exit-clear-screen')), findsNothing);
|
||||
});
|
||||
|
||||
@@ -181,6 +252,15 @@ 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,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-clear-screen')));
|
||||
await tester.pump();
|
||||
@@ -197,6 +277,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.ancestor(
|
||||
of: find.byKey(const Key('home-feed-exit-clear-screen')),
|
||||
@@ -211,21 +292,37 @@ void main() {
|
||||
greaterThanOrEqualTo(8),
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-video-tap')));
|
||||
await tester.tapAt(const Offset(80, 300));
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('home-feed-title')), findsNothing);
|
||||
expect(
|
||||
find.byKey(const Key('home-feed-exit-clear-screen')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('home-feed-center-play')),
|
||||
)
|
||||
.playing,
|
||||
isFalse,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-video-tap')));
|
||||
await tester.tapAt(const Offset(80, 300));
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('home-feed-title')), findsNothing);
|
||||
expect(
|
||||
find.byKey(const Key('home-feed-exit-clear-screen')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('home-feed-center-play')),
|
||||
)
|
||||
.playing,
|
||||
isTrue,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-exit-clear-screen')));
|
||||
await tester.pump();
|
||||
@@ -234,25 +331,51 @@ 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')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_show_home_play_toggle_only_when_paused', (tester) async {
|
||||
testWidgets('should_keep_home_center_toggle_in_both_play_states', (
|
||||
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')));
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('home-feed-center-play')),
|
||||
)
|
||||
.playing,
|
||||
isTrue,
|
||||
);
|
||||
await tester.tapAt(const Offset(80, 300));
|
||||
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,
|
||||
isFalse,
|
||||
);
|
||||
|
||||
await tester.tap(find.byKey(const Key('home-feed-center-play')));
|
||||
await tester.pump();
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
|
||||
expect(
|
||||
tester
|
||||
.widget<PlayerCenterToggle>(
|
||||
find.byKey(const Key('home-feed-center-play')),
|
||||
)
|
||||
.playing,
|
||||
isTrue,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('should_reset_home_chrome_when_swiping_to_next_page', (
|
||||
testWidgets('should_keep_home_clear_state_when_swiping_to_next_page', (
|
||||
tester,
|
||||
) async {
|
||||
await _pumpApp(tester);
|
||||
@@ -265,9 +388,13 @@ void main() {
|
||||
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);
|
||||
expect(find.byKey(const Key('home-feed-title')), findsNothing);
|
||||
expect(find.byKey(const Key('home-feed-info-card')), findsNothing);
|
||||
expect(
|
||||
find.byKey(const Key('home-feed-exit-clear-screen')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byKey(const Key('home-feed-center-play')), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -278,7 +405,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')), findsNothing);
|
||||
expect(find.byKey(const Key('player-play-toggle')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-episodes')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-comments')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-next')), findsOneWidget);
|
||||
|
||||
Reference in new issue
Block a user