Float several chats and keep them working on every tab
Floating chats were stuck on other destinations: the hidden Chat tab muted the window's hide animation, so the window stayed painted but took no input. The reveal now uses its own ticker, each floating pane's focus scope hangs from a FloatingFocusRoot above the destination stack, and the windows show over every destination like the terminal. Any number of chats can float; the shortcut, a window's X and the menu show or hide them together. Each pane keeps its own frame (also while docked), saved in record version 2; version 1 records still load. Drags read the live frame so fast pointer events no longer lose movement.
This commit is contained in:
@@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/window_margins.dart';
|
||||
import '../../terminal/terminal_float_frame.dart' show terminalFloatChrome;
|
||||
import 'chat_float_binding.dart';
|
||||
import 'chat_float_store.dart';
|
||||
|
||||
/// [rect] moved and shrunk to fit inside [bounds], at least the smallest
|
||||
@@ -24,13 +23,16 @@ Rect fitChatFloat(Rect rect, Size bounds) {
|
||||
);
|
||||
}
|
||||
|
||||
/// The floating chat's window: moved by its title bar, resized from its
|
||||
/// A floating chat's window: moved by its title bar, resized from its
|
||||
/// lower right corner, kept inside [bounds]. It grows and fades in from its
|
||||
/// place as [reveal] runs forward and leaves the same way in reverse.
|
||||
class ChatFloatWindow extends StatelessWidget {
|
||||
const ChatFloatWindow({
|
||||
super.key,
|
||||
required this.frame,
|
||||
required this.rect,
|
||||
required this.currentRect,
|
||||
required this.onMove,
|
||||
required this.onCommit,
|
||||
required this.bounds,
|
||||
required this.title,
|
||||
required this.cupertino,
|
||||
@@ -43,7 +45,15 @@ class ChatFloatWindow extends StatelessWidget {
|
||||
required this.child,
|
||||
});
|
||||
|
||||
final ChatFloatFrame frame;
|
||||
/// The saved frame; it is drawn fitted inside [bounds].
|
||||
final Rect rect;
|
||||
|
||||
/// The frame now: several drag events can arrive before a rebuild.
|
||||
final Rect Function() currentRect;
|
||||
final ValueChanged<Rect> onMove;
|
||||
|
||||
/// A move or resize ended.
|
||||
final VoidCallback onCommit;
|
||||
final Size bounds;
|
||||
final String title;
|
||||
final bool cupertino;
|
||||
@@ -62,8 +72,8 @@ class ChatFloatWindow extends StatelessWidget {
|
||||
static const double revealScale = 0.92;
|
||||
|
||||
void _resize(Offset delta) {
|
||||
final rect = fitChatFloat(frame.rect, bounds);
|
||||
frame.move(
|
||||
final rect = fitChatFloat(currentRect(), bounds);
|
||||
onMove(
|
||||
fitChatFloat(
|
||||
Rect.fromLTWH(
|
||||
rect.left,
|
||||
@@ -78,7 +88,7 @@ class ChatFloatWindow extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final rect = fitChatFloat(frame.rect, bounds);
|
||||
final rect = fitChatFloat(this.rect, bounds);
|
||||
final window = SizedBox.fromSize(
|
||||
size: rect.size,
|
||||
child: Stack(
|
||||
@@ -122,7 +132,7 @@ class ChatFloatWindow extends StatelessWidget {
|
||||
).animate(reveal),
|
||||
child: Semantics(
|
||||
container: true,
|
||||
label: 'Floating chat',
|
||||
label: 'Floating chat: $title',
|
||||
identifier: 'chat-float-window',
|
||||
child: terminalFloatChrome(context, cupertino, window),
|
||||
),
|
||||
@@ -149,13 +159,13 @@ class ChatFloatWindow extends StatelessWidget {
|
||||
key: const ValueKey('chat-float-title'),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
onPanUpdate: (details) => frame.move(
|
||||
onPanUpdate: (details) => onMove(
|
||||
fitChatFloat(
|
||||
fitChatFloat(frame.rect, bounds).shift(details.delta),
|
||||
fitChatFloat(currentRect(), bounds).shift(details.delta),
|
||||
bounds,
|
||||
),
|
||||
),
|
||||
onPanEnd: (_) => frame.commit(),
|
||||
onPanEnd: (_) => onCommit(),
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(start: 12),
|
||||
child: Align(
|
||||
@@ -175,7 +185,7 @@ class ChatFloatWindow extends StatelessWidget {
|
||||
onDock,
|
||||
),
|
||||
_button(
|
||||
'Hide floating chat ($shortcut)',
|
||||
'Hide floating chats ($shortcut)',
|
||||
Icons.close,
|
||||
CupertinoIcons.xmark,
|
||||
onHide,
|
||||
@@ -206,7 +216,7 @@ class ChatFloatWindow extends StatelessWidget {
|
||||
behavior: HitTestBehavior.opaque,
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
onPanUpdate: (details) => _resize(details.delta),
|
||||
onPanEnd: (_) => frame.commit(),
|
||||
onPanEnd: (_) => onCommit(),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: Icon(
|
||||
|
||||
Reference in New Issue
Block a user