Esc steps out one level: chat, fullscreen, big player to mini, then ask to leave
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
24fc137e4f
commit
9ddd85de90
4 files changed
+24
-4
No files matched your search
@@ -22,7 +22,7 @@ const sessionShortcuts = [
|
||||
('< or Shift+P', 'Put up the previous Jellyfin episode'),
|
||||
('Ctrl+1…6', 'Shaders: Anime4K mode A, B, C, A+A, B+B, C+A'),
|
||||
('Ctrl+0', 'Shaders off'),
|
||||
('Esc', 'Close the panel or fullscreen, else ask to leave'),
|
||||
('Esc', 'Close the panel or fullscreen, shrink the player, then ask to leave'),
|
||||
];
|
||||
|
||||
/// One titled card of the Settings tab (rounded Material, so list tiles
|
||||
|
||||
@@ -164,8 +164,15 @@ class _SessionPlayerState extends State<SessionPlayer> {
|
||||
/// dialog, a card, a text field) is in front of it. Space and Tab are
|
||||
/// app-wide ([AppKeys]).
|
||||
bool _globalKey(KeyEvent event) {
|
||||
if (event is! KeyDownEvent || !mounted || !_full) return false;
|
||||
if (event is! KeyDownEvent || !mounted) return false;
|
||||
if (SessionState.instance.route.peek() != AppRoute.session) return false;
|
||||
// Mini: Esc is the last step out, asking to leave the server.
|
||||
if (!_full) {
|
||||
if (event.logicalKey != LogicalKeyboardKey.escape) return false;
|
||||
if (ModalRoute.of(context)?.isCurrent == false || textInputFocused()) return false;
|
||||
widget.onLeave();
|
||||
return true;
|
||||
}
|
||||
final route = ModalRoute.of(context);
|
||||
if (route != null && !route.isCurrent) {
|
||||
// A menu of ours is open: Esc closes it.
|
||||
@@ -240,7 +247,8 @@ class _SessionPlayerState extends State<SessionPlayer> {
|
||||
} else if (widget.fullscreen) {
|
||||
widget.onToggleFullscreen();
|
||||
} else {
|
||||
widget.onLeave();
|
||||
// One step at a time: big player → mini, then (from mini) leave.
|
||||
widget.onCollapse();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -306,6 +306,17 @@ void main() {
|
||||
await stepThrough();
|
||||
expect(shell().fullscreen, isFalse);
|
||||
expect(find.byType(PartyStrip), findsOneWidget);
|
||||
// Esc again: big → mini, not leave; from mini it asks to leave.
|
||||
await tester.runAsync(() => Future<void>.delayed(const Duration(milliseconds: 400)));
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
||||
await stepThrough();
|
||||
expect(shell().mode, PlayerMode.mini);
|
||||
expect(find.text('Leave server?'), findsNothing);
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Leave server?'), findsOneWidget);
|
||||
await tester.tap(find.text('Cancel'));
|
||||
await tester.pumpAndSettle();
|
||||
// Never rebuilt from scratch on the way.
|
||||
expect(FakeVideo.created, 1);
|
||||
// Offline: no player at all.
|
||||
|
||||
Reference in new issue
Block a user