Float one chat pane over the app and toggle it with Ctrl+Y / Cmd+Y
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
part of 'screen.dart';
|
||||
|
||||
/// The floating chat for one Chat destination visit: its menu choices, its
|
||||
/// window frame and its persistence (see `notes/chat-floating-pane.md`).
|
||||
mixin _ChatScreenFloat on State<ChatScreen>, _ChatScreenWorkspace {
|
||||
@override
|
||||
final ChatFloatFrame _floatFrame = ChatFloatFrame();
|
||||
ChatFloatBinding? _floatBinding;
|
||||
|
||||
/// Restores and saves the floating chat in [store] once [restored] (the
|
||||
/// workspace layout's own restore) completes.
|
||||
@override
|
||||
void _bindFloat(ChatFloatStore store, Future<void> restored) {
|
||||
_floatBinding?.dispose();
|
||||
final binding = _floatBinding = ChatFloatBinding(
|
||||
controller: _workspace,
|
||||
frame: _floatFrame,
|
||||
store: store,
|
||||
);
|
||||
unawaited(
|
||||
restored.then((_) {
|
||||
if (mounted && identical(_floatBinding, binding)) {
|
||||
return binding.start();
|
||||
}
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void _unbindFloat() {
|
||||
_floatBinding?.dispose();
|
||||
_floatBinding = null;
|
||||
}
|
||||
|
||||
void _disposeFloat() {
|
||||
_unbindFloat();
|
||||
_floatFrame.dispose();
|
||||
}
|
||||
|
||||
/// Panes float only on a wide layout, beside the chat list.
|
||||
bool get _floatsHere => !_pageOpen && showsListBesideDetail(context);
|
||||
|
||||
void _dockFloat() {
|
||||
final pane = _workspace.floatingPane;
|
||||
_workspace.dock();
|
||||
if (pane != null) _composerFocus.request(pane.sessionId);
|
||||
}
|
||||
|
||||
/// The pane menu's floating choices: Float on a tiled pane that can, and
|
||||
/// Dock, Hide and Close on the floating chat.
|
||||
List<Widget> _floatControls(ChatWorkspacePane pane) {
|
||||
final shortcut = chatFloatShortcutLabel();
|
||||
if (_workspace.floatingPane?.id == pane.id) {
|
||||
return [
|
||||
ChatBarAction(
|
||||
label: 'Dock',
|
||||
onPressed: _dockFloat,
|
||||
materialIcon: Icons.vertical_split_outlined,
|
||||
cupertinoIcon: CupertinoIcons.rectangle_split_3x1,
|
||||
),
|
||||
ChatBarAction(
|
||||
label: 'Hide floating chat ($shortcut)',
|
||||
onPressed: () => _workspace.setFloatShown(false),
|
||||
materialIcon: Icons.visibility_off_outlined,
|
||||
cupertinoIcon: CupertinoIcons.eye_slash,
|
||||
),
|
||||
ChatBarAction(
|
||||
label: 'Close pane',
|
||||
onPressed: () => _closePane(pane.id),
|
||||
materialIcon: Icons.close,
|
||||
cupertinoIcon: CupertinoIcons.xmark,
|
||||
),
|
||||
];
|
||||
}
|
||||
if (!_floatsHere || !_workspace.canFloat(pane.id)) return const [];
|
||||
return [
|
||||
ChatBarAction(
|
||||
label: 'Float ($shortcut)',
|
||||
onPressed: () => _workspace.float(pane.id),
|
||||
materialIcon: Icons.picture_in_picture_alt_outlined,
|
||||
cupertinoIcon: CupertinoIcons.rectangle_on_rectangle,
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user