merge: 增加退出清屏浮动按钮

This commit is contained in:
Zhou Weidong committed 2026-10-19 16:53:57 +08:00
commit a2de5e8eb7
10 files changed
+111 -5

No files matched your search

+1
View File
@@ -47,6 +47,7 @@
}
},
"clearScreen": "Clear screen",
"exitClearScreen": "Exit clear screen",
"minutesAgo": "{count} min ago",
"@minutesAgo": {
"placeholders": {
+1
View File
@@ -47,6 +47,7 @@
}
},
"clearScreen": "Bersihkan layar",
"exitClearScreen": "Keluar dari layar bersih",
"minutesAgo": "{count} mnt lalu",
"@minutesAgo": {
"placeholders": {
+6
View File
@@ -346,6 +346,12 @@ abstract class AppLocalizations {
/// **'Clear screen'**
String get clearScreen;
/// No description provided for @exitClearScreen.
///
/// In en, this message translates to:
/// **'Exit clear screen'**
String get exitClearScreen;
/// No description provided for @minutesAgo.
///
/// In en, this message translates to:
+3
View File
@@ -136,6 +136,9 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get clearScreen => 'Clear screen';
@override
String get exitClearScreen => 'Exit clear screen';
@override
String minutesAgo(int count) {
return '$count min ago';
+3
View File
@@ -136,6 +136,9 @@ class AppLocalizationsId extends AppLocalizations {
@override
String get clearScreen => 'Bersihkan layar';
@override
String get exitClearScreen => 'Keluar dari layar bersih';
@override
String minutesAgo(int count) {
return '$count mnt lalu';
+3
View File
@@ -133,6 +133,9 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get clearScreen => '清屏';
@override
String get exitClearScreen => '退出清屏';
@override
String minutesAgo(int count) {
return '$count 分钟前';
+1
View File
@@ -47,6 +47,7 @@
}
},
"clearScreen": "清屏",
"exitClearScreen": "退出清屏",
"minutesAgo": "{count} 分钟前",
"@minutesAgo": {
"placeholders": {
+23 -3
View File
@@ -24,6 +24,7 @@ import '../../l10n/app_localizations.dart';
import 'player_binding.dart';
import 'player_logic.dart';
import 'widgets/home_feed_overlay.dart';
import 'widgets/exit_clear_screen_button.dart';
import 'widgets/player_center_toggle.dart';
import 'widgets/player_featured_comment.dart';
import 'widgets/seek_progress_bar.dart';
@@ -213,9 +214,8 @@ class _PlayerPageState extends State<PlayerPage> with WidgetsBindingObserver {
child: GestureDetector(
key: const Key('home-feed-video-toggle'),
behavior: HitTestBehavior.opaque,
onTap: () => logic.session.setUserWantsPlay(
!logic.session.userWantsPlay,
),
onTap: () =>
logic.session.setUserWantsPlay(!logic.session.userWantsPlay),
),
),
if (widget.homeMode &&
@@ -447,6 +447,16 @@ class _PlayerPageState extends State<PlayerPage> with WidgetsBindingObserver {
onTap: () => setState(() => _feedChromeVisible = true),
),
),
if (widget.homeMode && !_feedChromeVisible)
Positioned(
top: 8,
right: 12,
child: ExitClearScreenButton(
key: const Key('home-feed-exit-clear-screen'),
tooltip: l10n.exitClearScreen,
onPressed: () => setState(() => _feedChromeVisible = true),
),
),
],
);
}
@@ -762,6 +772,16 @@ class _PlaybackOverlayState extends State<_PlaybackOverlay> {
),
],
),
if (!_controlsVisible)
Positioned(
top: 8,
right: 12,
child: ExitClearScreenButton(
key: const Key('player-exit-clear-screen'),
tooltip: widget.l10n.exitClearScreen,
onPressed: () => setState(() => _controlsVisible = true),
),
),
],
),
);
@@ -0,0 +1,34 @@
// Author: fruit.com.cn
import 'package:flutter/material.dart';
/// Shared floating action used to leave clear-screen mode.
class ExitClearScreenButton extends StatelessWidget {
const ExitClearScreenButton({
super.key,
required this.tooltip,
required this.onPressed,
});
final String tooltip;
final VoidCallback onPressed;
@override
Widget build(BuildContext context) {
return SizedBox(
width: 36,
height: 36,
child: IconButton(
tooltip: tooltip,
onPressed: onPressed,
padding: EdgeInsets.zero,
style: IconButton.styleFrom(
backgroundColor: const Color(0x80000000),
foregroundColor: Colors.white,
shape: const CircleBorder(),
),
icon: const Icon(Icons.fullscreen_exit_rounded, size: 18),
),
);
}
}
+36 -2
View File
@@ -131,13 +131,27 @@ void main() {
expect(find.byKey(const Key('player-controls-bottom')), findsNothing);
expect(find.byType(PlayerCenterToggle), findsNothing);
expect(find.byKey(const Key('player-video-tap')), findsOneWidget);
expect(find.byKey(const Key('player-exit-clear-screen')), findsOneWidget);
expect(
tester.getSize(find.byKey(const Key('player-exit-clear-screen'))),
const Size(36, 36),
);
await tester.tap(find.byKey(const Key('player-video-tap')));
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(find.byKey(const Key('player-exit-clear-screen')), findsNothing);
await tester.tap(find.byKey(const Key('player-clear-screen')));
await tester.pump();
expect(find.byKey(const Key('player-exit-clear-screen')), findsOneWidget);
await tester.tap(find.byKey(const Key('player-video-tap')));
await tester.pump();
expect(find.byKey(const Key('player-controls-top')), findsOneWidget);
expect(find.byKey(const Key('player-exit-clear-screen')), findsNothing);
});
testWidgets('should_fit_player_header_on_320_width', (tester) async {
@@ -174,13 +188,33 @@ void main() {
expect(find.byKey(const Key('home-feed-info-card')), findsNothing);
expect(find.byKey(const Key('home-feed-scrim')), findsNothing);
expect(find.byKey(const Key('home-feed-video-tap')), findsOneWidget);
expect(
find.byKey(const Key('home-feed-exit-clear-screen')),
findsOneWidget,
);
expect(
tester.getSize(find.byKey(const Key('home-feed-exit-clear-screen'))),
const Size(36, 36),
);
await tester.tap(find.byKey(const Key('home-feed-video-tap')));
await tester.tap(find.byKey(const Key('home-feed-exit-clear-screen')));
await tester.pump();
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-exit-clear-screen')), findsNothing);
await tester.tap(find.byKey(const Key('home-feed-clear-screen')));
await tester.pump();
expect(
find.byKey(const Key('home-feed-exit-clear-screen')),
findsOneWidget,
);
await tester.tap(find.byKey(const Key('home-feed-video-tap')));
await tester.pump();
expect(find.byKey(const Key('home-feed-title')), findsOneWidget);
expect(find.byKey(const Key('home-feed-exit-clear-screen')), findsNothing);
});
testWidgets('should_show_home_play_toggle_only_when_paused', (tester) async {