fix(flutter): 收窄清屏范围并保留底栏

This commit is contained in:
Zhou Weidong committed 2026-10-20 11:33:23 +08:00
1 parent a26b0071e4
commit 3068eb99da
2 files changed
+63 -61

No files matched your search

+25 -24
View File
@@ -5,7 +5,6 @@ import '../../../core/formatting/localized_content.dart';
import '../../../core/theme/app_colors.dart';
import '../../../core/theme/app_dimens.dart';
import '../../../l10n/app_localizations.dart';
import 'exit_clear_screen_button.dart';
import 'player_center_toggle.dart';
import 'player_overlay_models.dart';
import 'seek_progress_bar.dart';
@@ -51,21 +50,9 @@ class PlayerPlaybackOverlay extends StatelessWidget {
onTap: actions.onTogglePlay,
),
),
if (controlsVisible) ...[
_top(context),
_bottom(context),
_rail(context),
],
if (!controlsVisible)
Positioned(
top: AppDimens.spaceSm,
right: AppDimens.spaceMd,
child: ExitClearScreenButton(
key: const Key('player-exit-clear-screen'),
tooltip: data.l10n.exitClearScreen,
onPressed: actions.onExitClear,
),
),
if (controlsVisible) _rail(context),
if (!data.playing)
Center(
child: PlayerCenterToggle(
@@ -153,15 +140,23 @@ class PlayerPlaybackOverlay extends StatelessWidget {
}
Widget _bottom(BuildContext context) {
final series = localizedDramaTitle(data.l10n, data.drama);
final synopsis = localizedDramaSynopsis(data.l10n, data.drama);
return Positioned(
left: 0,
right: 0,
bottom: 0,
child: Padding(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [if (controlsVisible) _bottomInfo(context), _bottomActions()],
),
);
}
Widget _bottomInfo(BuildContext context) {
final series = localizedDramaTitle(data.l10n, data.drama);
final synopsis = localizedDramaSynopsis(data.l10n, data.drama);
return Padding(
key: const Key('player-controls-bottom'),
padding: const EdgeInsets.fromLTRB(14, 8, 14, 6),
padding: const EdgeInsets.fromLTRB(14, 8, 14, 0),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
@@ -187,10 +182,8 @@ class PlayerPlaybackOverlay extends StatelessWidget {
onScrubStart: actions.onScrubStart,
onSeek: actions.onSeek,
),
_bottomActions(),
],
),
),
);
}
@@ -234,7 +227,10 @@ class PlayerPlaybackOverlay extends StatelessWidget {
}
Widget _bottomActions() {
return Row(
return Padding(
key: const Key('player-bottom-actions'),
padding: const EdgeInsets.fromLTRB(14, 6, 14, 6),
child: Row(
children: [
Expanded(
child: Material(
@@ -284,11 +280,16 @@ class PlayerPlaybackOverlay extends StatelessWidget {
const SizedBox(width: 8),
_BottomIconButton(
key: const Key('player-bottom-clear-screen'),
tooltip: data.l10n.clearScreen,
icon: Icons.fullscreen_rounded,
onPressed: actions.onClear,
tooltip: controlsVisible
? data.l10n.clearScreen
: data.l10n.exitClearScreen,
icon: controlsVisible
? Icons.fullscreen_rounded
: Icons.fullscreen_exit_rounded,
onPressed: controlsVisible ? actions.onClear : actions.onExitClear,
),
],
),
);
}
}
+38 -37
View File
@@ -110,8 +110,10 @@ void main() {
await _clearFromMore(tester);
await tester.pump();
expect(find.byKey(const Key('player-controls-top')), findsNothing);
expect(find.byKey(const Key('player-controls-top')), findsOneWidget);
expect(find.byKey(const Key('player-controls-bottom')), findsNothing);
expect(find.byKey(const Key('player-bottom-actions')), findsOneWidget);
expect(find.byKey(const Key('player-interaction-rail')), findsNothing);
expect(find.byType(PlayerCenterToggle), findsOneWidget);
expect(
tester
@@ -122,45 +124,30 @@ void main() {
isFalse,
);
expect(find.byKey(const Key('player-video-tap')), findsOneWidget);
expect(find.byKey(const Key('player-exit-clear-screen')), findsOneWidget);
expect(find.byKey(const Key('player-bottom-clear-screen')), findsOneWidget);
expect(find.byTooltip('Exit clear screen'), findsOneWidget);
expect(
tester.getSize(find.byKey(const Key('player-exit-clear-screen'))),
const Size(36, 36),
tester.getSize(find.byKey(const Key('player-bottom-clear-screen'))),
const Size(30, 30),
);
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(find.byKey(const Key('player-controls-top')), findsOneWidget);
expect(find.byKey(const Key('player-bottom-actions')), findsOneWidget);
expect(find.byType(PlayerCenterToggle), findsNothing);
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,
);
expect(find.byType(PlayerCenterToggle), findsOneWidget);
await tester.tap(find.byKey(const Key('player-exit-clear-screen')));
await tester.tap(find.byKey(const Key('player-bottom-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.byKey(const Key('player-interaction-rail')), 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);
expect(find.byTooltip('Clear screen'), findsOneWidget);
});
testWidgets('should_fit_player_header_on_320_width', (tester) async {
@@ -251,20 +238,22 @@ void main() {
await _clearFromMore(tester);
await tester.pump();
expect(find.byKey(const Key('player-controls-top')), findsNothing);
expect(find.byKey(const Key('player-controls-top')), findsOneWidget);
await tester.drag(find.byType(PageView), const Offset(0, -550));
await tester.pumpAndSettle();
expect(find.byKey(const Key('player-controls-top')), findsNothing);
expect(find.byKey(const Key('player-controls-top')), findsOneWidget);
expect(find.byKey(const Key('player-controls-bottom')), findsNothing);
expect(find.byKey(const Key('player-exit-clear-screen')), findsOneWidget);
expect(find.byKey(const Key('player-bottom-actions')), findsOneWidget);
expect(find.byKey(const Key('player-interaction-rail')), findsNothing);
expect(find.byKey(const Key('player-bottom-clear-screen')), findsOneWidget);
await tester.tap(find.byKey(const Key('player-exit-clear-screen')));
await tester.tap(find.byKey(const Key('player-bottom-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.byKey(const Key('player-exit-clear-screen')), findsNothing);
expect(find.byKey(const Key('player-interaction-rail')), findsOneWidget);
});
testWidgets('should_open_speed_sheet_and_apply_selected_speed', (
@@ -309,9 +298,9 @@ void main() {
await _clearFromMore(tester);
await tester.pump();
expect(find.byKey(const Key('player-more')), findsNothing);
expect(find.byKey(const Key('player-more')), findsOneWidget);
await tester.tap(find.byKey(const Key('player-exit-clear-screen')));
await tester.tap(find.byKey(const Key('player-bottom-clear-screen')));
await tester.pump();
await tester.drag(find.byType(PageView), const Offset(0, -550));
await tester.pumpAndSettle();
@@ -448,9 +437,11 @@ void main() {
await tester.tap(find.byKey(const Key('player-more-clear')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('player-controls-top')), findsNothing);
expect(find.byKey(const Key('player-controls-top')), findsOneWidget);
expect(find.byKey(const Key('player-controls-bottom')), findsNothing);
expect(find.byKey(const Key('player-exit-clear-screen')), findsOneWidget);
expect(find.byKey(const Key('player-bottom-actions')), findsOneWidget);
expect(find.byKey(const Key('player-interaction-rail')), findsNothing);
expect(find.byTooltip('Exit clear screen'), findsOneWidget);
});
testWidgets('should_enter_clear_screen_from_bottom_button', (tester) async {
@@ -462,9 +453,19 @@ void main() {
await tester.tap(find.byKey(const Key('player-bottom-clear-screen')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('player-controls-top')), findsNothing);
expect(find.byKey(const Key('player-controls-top')), findsOneWidget);
expect(find.byKey(const Key('player-controls-bottom')), findsNothing);
expect(find.byKey(const Key('player-exit-clear-screen')), findsOneWidget);
expect(find.byKey(const Key('player-bottom-actions')), findsOneWidget);
expect(find.byKey(const Key('player-interaction-rail')), findsNothing);
expect(find.byType(PlayerCenterToggle), findsNothing);
expect(find.byTooltip('Exit clear screen'), findsOneWidget);
await tester.tap(find.byKey(const Key('player-bottom-clear-screen')));
await tester.pumpAndSettle();
expect(find.byKey(const Key('player-controls-bottom')), findsOneWidget);
expect(find.byKey(const Key('player-interaction-rail')), findsOneWidget);
expect(find.byType(PlayerCenterToggle), findsNothing);
expect(find.byTooltip('Clear screen'), findsOneWidget);
});
testWidgets('should_open_unlock_panel_with_honest_method_states', (