Chat stack: hold and drag to reorder the open chats, or onto x to remove
A 300 ms hold lifts a chat in the open column; dragging opens a gap and dropping commits through ChatWorkspaceController.movePane, the pane order the server syncs. An x comes in at the bottom while dragging; dropping on it removes the chat with Undo, which restores its place. Escape, a cancelled pointer or a drop away from the column put it back. Move up, Move down and Remove are semantic actions. Repaint-only motion; reduced motion swaps at once. Also keep floating-layout tracking out of initState, and let the capture kit hold a press before a drag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/theme/app_design_tokens.dart';
|
||||
import 'chat_stack_disc.dart';
|
||||
import 'chat_stack_drag.dart';
|
||||
|
||||
/// Lifts [child] for a drag after a short hold ([chatStackLiftDelay]); a
|
||||
/// quicker tap still reaches [child]'s own tap. Null callbacks leave the
|
||||
/// child alone.
|
||||
class ChatStackDragHandle extends StatelessWidget {
|
||||
const ChatStackDragHandle({
|
||||
super.key,
|
||||
required this.child,
|
||||
this.onStart,
|
||||
this.onMove,
|
||||
this.onEnd,
|
||||
this.onCancel,
|
||||
});
|
||||
|
||||
final Widget child;
|
||||
final VoidCallback? onStart;
|
||||
final ValueChanged<LongPressMoveUpdateDetails>? onMove;
|
||||
final VoidCallback? onEnd;
|
||||
final VoidCallback? onCancel;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (onStart == null) return child;
|
||||
return RawGestureDetector(
|
||||
// The items offer moving and removing as semantic actions instead.
|
||||
excludeFromSemantics: true,
|
||||
gestures: {
|
||||
LongPressGestureRecognizer:
|
||||
GestureRecognizerFactoryWithHandlers<LongPressGestureRecognizer>(
|
||||
() => LongPressGestureRecognizer(
|
||||
duration: chatStackLiftDelay,
|
||||
debugOwner: this,
|
||||
),
|
||||
(recognizer) {
|
||||
recognizer
|
||||
..onLongPressStart = ((_) => onStart?.call())
|
||||
..onLongPressMoveUpdate = onMove
|
||||
..onLongPressEnd = ((_) => onEnd?.call())
|
||||
..onLongPressCancel = onCancel;
|
||||
},
|
||||
),
|
||||
},
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A disc's ink and focus: the splash is drawn over the disc (the disc is
|
||||
/// opaque, so ink under it would never show), in the design's shape.
|
||||
class ChatStackTappable extends StatelessWidget {
|
||||
const ChatStackTappable({
|
||||
super.key,
|
||||
required this.child,
|
||||
required this.onTap,
|
||||
this.autofocus = false,
|
||||
});
|
||||
|
||||
final Widget child;
|
||||
final VoidCallback onTap;
|
||||
final bool autofocus;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final shape = chatStackShape(AppDesignTokens.of(context));
|
||||
return Stack(
|
||||
children: [
|
||||
child,
|
||||
Positioned.fill(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(
|
||||
(kChatStackSlot - kChatStackDisc) / 2,
|
||||
),
|
||||
child: Material(
|
||||
type: MaterialType.transparency,
|
||||
shape: shape,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: InkWell(
|
||||
autofocus: autofocus,
|
||||
excludeFromSemantics: true,
|
||||
customBorder: shape,
|
||||
onTap: onTap,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user