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