Float one chat pane over the app and toggle it with Ctrl+Y / Cmd+Y
This commit is contained in:
@@ -20,6 +20,9 @@ import 'package:flutter/services.dart';
|
||||
|
||||
import '../../core/api_gateway.dart';
|
||||
import '../../core/servers/server_scope.dart';
|
||||
import 'workspace/chat_float_binding.dart';
|
||||
import 'workspace/chat_float_shortcut.dart';
|
||||
import 'workspace/chat_float_store.dart';
|
||||
import 'workspace/chat_workspace_binding.dart';
|
||||
import 'workspace/chat_workspace_snapshot.dart';
|
||||
import 'workspace/chat_workspace_store.dart';
|
||||
@@ -50,6 +53,7 @@ import 'ui/sessions/chat_sessions_controller.dart';
|
||||
import 'ui/sessions/chat_sessions_screen.dart';
|
||||
import '../../ui/input/keyboard_owner.dart';
|
||||
|
||||
part 'chat_screen_float.dart';
|
||||
part 'chat_screen_keys.dart';
|
||||
part 'chat_screen_workspace.dart';
|
||||
|
||||
@@ -94,7 +98,7 @@ class ChatScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ChatScreenState extends State<ChatScreen>
|
||||
with _ChatScreenWorkspace, _ChatScreenKeys {
|
||||
with _ChatScreenWorkspace, _ChatScreenKeys, _ChatScreenFloat {
|
||||
/// The list's controller, shared with the mounted list screen. The list
|
||||
/// screen refreshes it on mount and swaps its repository when the socket is
|
||||
/// replaced; this destination lists created rows and re-reads after a
|
||||
@@ -273,10 +277,7 @@ class _ChatScreenState extends State<ChatScreen>
|
||||
/// Another device started a new session in a chat: only an open chat
|
||||
/// follows it; the list already swapped the row.
|
||||
void _replacedElsewhere(String previousId, JsonMap session) {
|
||||
if (!mounted ||
|
||||
!_workspace.panes.any((pane) => pane.sessionId == previousId)) {
|
||||
return;
|
||||
}
|
||||
if (!mounted || !_workspace.holdsSession(previousId)) return;
|
||||
_followNewSession(previousId, session, chatNewSessionElsewhereNotice);
|
||||
}
|
||||
|
||||
@@ -314,6 +315,8 @@ class _ChatScreenState extends State<ChatScreen>
|
||||
.toList()) {
|
||||
_closePane(pane.id);
|
||||
}
|
||||
final floating = _workspace.floatingPane;
|
||||
if (floating?.sessionId == sessionId) _closePane(floating!.id);
|
||||
unawaited(_sessions.refresh());
|
||||
}
|
||||
|
||||
@@ -452,6 +455,7 @@ class _ChatScreenState extends State<ChatScreen>
|
||||
HardwareKeyboard.instance.removeHandler(_slashFocusKey);
|
||||
_page.dispose();
|
||||
_workspaceBinding?.dispose();
|
||||
_disposeFloat();
|
||||
_workspace.removeListener(_workspaceChanged);
|
||||
_workspace.dispose();
|
||||
_sessions.removeListener(_nextChanged);
|
||||
@@ -505,6 +509,8 @@ class _ChatScreenState extends State<ChatScreen>
|
||||
: _page.open || !showsListBesideDetail(context),
|
||||
paneControls: pane == null
|
||||
? const []
|
||||
: _workspace.floatingPane?.id == pane.id
|
||||
? _floatControls(pane)
|
||||
: [
|
||||
ChatBarAction(
|
||||
label: 'Add chat pane',
|
||||
@@ -526,6 +532,7 @@ class _ChatScreenState extends State<ChatScreen>
|
||||
materialIcon: Icons.close,
|
||||
cupertinoIcon: CupertinoIcons.xmark,
|
||||
),
|
||||
..._floatControls(pane),
|
||||
],
|
||||
);
|
||||
return ChatComposerFocusScope(
|
||||
|
||||
Reference in New Issue
Block a user