Host floating chats on the shell window system
Phase 2.3 and 2.4 of docs/plans/floating-windows.md. A floating chat is a window of the chat kind over the app's WindowManager, built from the app-lifetime ChatRuntime, so it shows over every destination and at start without the Chat destination being built. Float and Dock move the same keyed view between the tiling and the window host. The pipelines app keeps one runtime and one ChatWindows; saved chatFloat records (v1 and v2) are brought over once. ChatFloatHost, ChatFloatWindow, the float frames and binding, the controller's float list and FloatingFocusRoot are gone; the workspace only asks whether a chat is out in a window. Every MenuAnchor targets the root overlay (guarded by a test), and menus and tooltips name the Alt chords.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import '../ui/floating/floating_layer.dart';
|
||||
import '../ui/motion/fade_through_stack.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -423,15 +422,12 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
|
||||
);
|
||||
}
|
||||
|
||||
// Floating windows (chats) keep the keyboard over every destination.
|
||||
Widget _destinationStack(List<Widget> contents) => ListPaneWidthsScope(
|
||||
widths: _paneWidths,
|
||||
child: FloatingFocusRoot(
|
||||
child: FadeThroughStack(
|
||||
key: _destinationStackKey,
|
||||
index: AppDestination.values.indexOf(_selected),
|
||||
children: contents,
|
||||
),
|
||||
child: FadeThroughStack(
|
||||
key: _destinationStackKey,
|
||||
index: AppDestination.values.indexOf(_selected),
|
||||
children: contents,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -68,41 +68,55 @@ class _WindowHostState extends State<WindowHost> {
|
||||
if (_visible.isEmpty && visible.isNotEmpty) _focus.remember();
|
||||
if (active == null) {
|
||||
if (_visible.isNotEmpty) _focus.release();
|
||||
} else if (active != _active || !_visible.contains(active)) {
|
||||
_focus.focusSoon(active);
|
||||
} else if (focused != null && !visible.contains(focused)) {
|
||||
_focus.focusSoon(active);
|
||||
} else if (active != _active ||
|
||||
!_visible.contains(active) ||
|
||||
(focused != null && !visible.contains(focused))) {
|
||||
_focusWindow(active);
|
||||
}
|
||||
_visible = visible;
|
||||
_active = active;
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
/// The window takes the keyboard, then its content places it.
|
||||
void _focusWindow(String id) {
|
||||
_focus.focusSoon(id);
|
||||
final entry = widget.manager.byId(id);
|
||||
if (entry != null) widget.manager.kinds[entry.kind]?.focusContent(entry);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final manager = widget.manager;
|
||||
final windows = manager.windows;
|
||||
_focus.retain({for (final w in windows) w.id});
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final bounds = constraints.biggest;
|
||||
return Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
for (final entry in windows)
|
||||
if (manager.kinds[entry.kind] case final kind?)
|
||||
WindowLayer(
|
||||
key: ValueKey(entry.id),
|
||||
manager: manager,
|
||||
kind: kind,
|
||||
entry: entry,
|
||||
visible: manager.isVisible(entry),
|
||||
bounds: bounds,
|
||||
focus: _focus,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
return ListenableBuilder(
|
||||
listenable: Listenable.merge([
|
||||
for (final kind in manager.kinds.all) ?kind.changes,
|
||||
]),
|
||||
builder: (context, _) => LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final bounds = constraints.biggest;
|
||||
return Stack(
|
||||
fit: StackFit.expand,
|
||||
children: [
|
||||
for (final entry in windows)
|
||||
if (manager.kinds[entry.kind] case final kind?)
|
||||
WindowLayer(
|
||||
key: ValueKey(entry.id),
|
||||
manager: manager,
|
||||
kind: kind,
|
||||
entry: entry,
|
||||
visible:
|
||||
manager.isVisible(entry) &&
|
||||
bounds.width >= kind.minHostWidth,
|
||||
bounds: bounds,
|
||||
focus: _focus,
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,17 @@ abstract class WindowKind {
|
||||
List<WindowAction> actions(BuildContext context, WindowEntry entry) =>
|
||||
const [];
|
||||
|
||||
/// Notifies when a title or the actions of this kind's windows change.
|
||||
Listenable? get changes => null;
|
||||
|
||||
/// The narrowest app this kind's windows show in; below it they hide (and
|
||||
/// come back when the app widens).
|
||||
double get minHostWidth => 0;
|
||||
|
||||
/// Puts the keyboard where [entry]'s content wants it (a chat's composer)
|
||||
/// as its window takes focus. The default leaves it on the window.
|
||||
void focusContent(WindowEntry entry) {}
|
||||
|
||||
/// Called after the user closes the window (the X).
|
||||
void closed(WindowEntry entry) {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user