Files
pipelines/app/lib/features/chat/stack/chat_stack_group_pile.dart
T
alan 3089bcd437 Chat stack groups: the dragged chat shrinks onto a drop target; notes
Over another item's middle the lifted item shrinks (as over the close
button), so the target's grown ring stays visible; a group's pile is
0.88 of a chat's disc. Notes for groups and the open-chat group field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 23:07:16 +00:00

80 lines
2.5 KiB
Dart

import 'package:flutter/material.dart';
import '../ui/sessions/chat_awaiting.dart';
import 'chat_stack_disc.dart';
import 'chat_stack_entry.dart';
import 'chat_stack_pose.dart';
/// A group's pile is the collapsed stack's, this much smaller, so it keeps
/// inside its slot.
const double chatStackGroupPileScale = .88;
/// How many of a group's chats its pile draws.
const int chatStackGroupLayers = 3;
/// A group in the open column: its first chats piled as the collapsed stack
/// piles the open ones (smaller, turned), the chat on screen on top when it
/// is in the group, and the waiting bell when any of them waits on the
/// operator. Paint-only poses; nothing animates here.
class ChatStackGroupPile extends StatelessWidget {
const ChatStackGroupPile({
super.key,
required this.entries,
this.glow,
this.ring,
});
final List<ChatStackEntry> entries;
/// The top layer's lifted look (dragged) or drop-target [ring] (0 to 1).
final Animation<double>? glow;
final Color? ring;
@override
Widget build(BuildContext context) {
final current = entries.indexWhere((entry) => entry.current);
final top = current < 0 ? 0 : current;
final shown = [
for (var depth = 0; depth < entries.length; depth++)
entries[(top + depth) % entries.length],
].take(chatStackGroupLayers).toList();
final rtl = Directionality.of(context) == TextDirection.rtl;
final waiting = entries.fold(0, (sum, e) => sum + e.awaitingOperator);
return SizedBox.square(
dimension: kChatStackSlot,
child: Stack(
clipBehavior: Clip.none,
children: [
for (var depth = shown.length - 1; depth >= 0; depth--)
ChatStackPoseTransition(
progress: kAlwaysCompleteAnimation,
from: _pose(depth, rtl),
to: _pose(depth, rtl),
child: ChatStackDisc(
lift: depth == 0 ? glow : null,
liftRing: ring,
child: chatStackAvatar(shown[depth], cues: false),
),
),
if (waiting > 0)
PositionedDirectional(
top: -4,
end: -4,
child: IgnorePointer(child: ChatAwaitingBadge(count: waiting)),
),
],
),
);
}
ChatStackPose _pose(int depth, bool rtl) {
final layer = chatStackLayers[depth];
final pose = ChatStackPose(
offset: layer.offset * chatStackGroupPileScale,
turn: layer.turn,
scale: layer.scale * chatStackGroupPileScale,
);
return rtl ? pose.mirrored() : pose;
}
}