Drag chats at once with a mouse and mark only the receiving zone

The list rows used a long-press drag, which a mouse rarely triggers; they
now drag immediately with the chip at the pointer. The drop indicator
outlines just the area that will receive the chat (the pane, or the
right or bottom half) with a label saying what happens.
This commit is contained in:
2026-11-13 13:00:57 +00:00
parent ad05909b75
commit f7f2504a30
4 changed files with 152 additions and 29 deletions
@@ -126,7 +126,10 @@ class ChatCompactSidebar extends StatelessWidget {
? Duration.zero
: const Duration(milliseconds: 200),
color: selected ? Colors.transparent : color.withValues(alpha: .07),
child: LongPressDraggable<JsonMap>(
child: Draggable<JsonMap>(
// A mouse drags at once (a click still opens the chat); the chip
// follows the pointer.
dragAnchorStrategy: pointerDragAnchorStrategy,
data: row,
feedback: Material(
elevation: 4,
@@ -81,7 +81,10 @@ class ChatSessionRow extends StatelessWidget {
marker: marker,
markerWidth: visible ? (selected ? 10 : 3) : 0,
child: draggable
? LongPressDraggable<JsonMap>(
? Draggable<JsonMap>(
// A mouse drags at once (a click still opens the chat); the chip
// follows the pointer.
dragAnchorStrategy: pointerDragAnchorStrategy,
data: session,
feedback: Material(
elevation: 4,
@@ -57,38 +57,77 @@ class _ChatWorkspaceDropTargetState extends State<ChatWorkspaceDropTarget> {
builder: (context, candidates, rejected) {
final zone = _zone;
if (zone == null) return const SizedBox.expand();
final color = Theme.of(context).colorScheme.primary;
final indicator = switch (zone) {
ChatWorkspaceDropZone.replace => const SizedBox.expand(),
ChatWorkspaceDropZone.right => const Align(
alignment: Alignment.centerRight,
child: FractionallySizedBox(widthFactor: .5, heightFactor: 1),
final scheme = Theme.of(context).colorScheme;
final (alignment, width, height, icon, label) = switch (zone) {
ChatWorkspaceDropZone.replace => (
Alignment.center,
1.0,
1.0,
Icons.swap_horiz,
'Show here',
),
ChatWorkspaceDropZone.bottom => const Align(
alignment: Alignment.bottomCenter,
child: FractionallySizedBox(widthFactor: 1, heightFactor: .5),
ChatWorkspaceDropZone.right => (
Alignment.centerRight,
.5,
1.0,
Icons.vertical_split_outlined,
'Open to the right',
),
ChatWorkspaceDropZone.bottom => (
Alignment.bottomCenter,
1.0,
.5,
Icons.horizontal_split_outlined,
'Open below',
),
};
return Stack(
fit: StackFit.expand,
children: [
DecoratedBox(
decoration: BoxDecoration(color: color.withValues(alpha: .18)),
child: indicator,
),
if (zone != ChatWorkspaceDropZone.replace)
Align(
alignment: zone == ChatWorkspaceDropZone.right
? Alignment.centerRight
: Alignment.bottomCenter,
child: Icon(
zone == ChatWorkspaceDropZone.right
? Icons.vertical_split
: Icons.horizontal_split,
color: color,
// Only the area that will receive the chat is marked: the whole pane
// to replace its chat, or the half a new split will take.
return IgnorePointer(
child: Align(
alignment: alignment,
child: FractionallySizedBox(
widthFactor: width,
heightFactor: height,
child: Padding(
padding: const EdgeInsets.all(8),
child: DecoratedBox(
key: ValueKey('chat-drop-zone-${zone.name}'),
decoration: BoxDecoration(
color: scheme.primary.withValues(alpha: .14),
border: Border.all(color: scheme.primary, width: 2),
borderRadius: BorderRadius.circular(16),
),
child: Center(
child: DecoratedBox(
decoration: BoxDecoration(
color: scheme.primaryContainer,
borderRadius: BorderRadius.circular(24),
),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16,
vertical: 10,
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(icon, color: scheme.onPrimaryContainer),
const SizedBox(width: 8),
Text(
label,
style: Theme.of(context).textTheme.labelLarge
?.copyWith(color: scheme.onPrimaryContainer),
),
],
),
),
),
),
),
),
],
),
),
);
},
);