Chat stack: the default, also on a wide phone or tablet; a close button where the pile was
Chat stack is now the default phone chat navigation (a stored choice is kept), and on Android or iOS it stays on a wide layout (an unfolded foldable) above the active pane, where floating is ignored too. When expanded, the pile turns into a close button at its own spot and the column rises above it; while a chat is dragged that button is the remove target, replacing the separate x at the bottom. Chat widget tests start on Quick switch (they run as Android); the stack's tests choose it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -9,13 +7,14 @@ import 'chat_stack_disc.dart';
|
||||
import 'chat_stack_drag.dart';
|
||||
import 'chat_stack_entry.dart';
|
||||
import 'chat_stack_motion.dart';
|
||||
import 'chat_stack_remove_target.dart';
|
||||
import 'chat_stack_close_target.dart';
|
||||
|
||||
/// The chat stack fanned out: a scrim over the screen and the open chats in
|
||||
/// a column rising from the stack's own slot, each avatar with its name in a
|
||||
/// small pill beside it, and Add chat at the top.
|
||||
///
|
||||
/// Item 0 sits exactly on the collapsed stack, nearest the thumb. The chats
|
||||
/// The stack's own slot turns into a close button ([ChatStackCloseTarget]);
|
||||
/// item 0 sits a pitch above it, nearest the thumb. The chats
|
||||
/// keep the open-chat order (the order the server syncs), so a chat keeps
|
||||
/// its place in the column from one visit to the next; the chat on screen
|
||||
/// wears a ring in its colour. Add chat is last, at the top: the reachable
|
||||
@@ -24,7 +23,8 @@ import 'chat_stack_remove_target.dart';
|
||||
///
|
||||
/// A short hold lifts a chat ([ChatStackDrag]): dragged up or down it
|
||||
/// reorders the open chats, the others sliding aside to open its slot;
|
||||
/// dropped on the "×" that comes in at the bottom it leaves them. Add chat
|
||||
/// dropped on the close button (armed as a remove target while dragging)
|
||||
/// it leaves them. Add chat
|
||||
/// stays put. The same moves are semantic actions on each chat.
|
||||
///
|
||||
/// Nothing here rebuilds per frame: every item moves through
|
||||
@@ -168,7 +168,8 @@ class _ChatStackColumnState extends State<ChatStackColumn>
|
||||
builder: (context, constraints) {
|
||||
final size = constraints.biggest;
|
||||
final count = widget.motion.count;
|
||||
final height = (count - 1) * kChatStackPitch + kChatStackSlot;
|
||||
// The stack's own slot (the close button) and the items above it.
|
||||
final height = count * kChatStackPitch + kChatStackSlot;
|
||||
final top = media.padding.top + 8;
|
||||
final available = anchor.bottom - top;
|
||||
final fits = height <= available;
|
||||
@@ -184,18 +185,23 @@ class _ChatStackColumnState extends State<ChatStackColumn>
|
||||
..sort((a, b) => (depths[b] ?? 99).compareTo(depths[a] ?? 99));
|
||||
final lifted = _entries.indexWhere((e) => e.paneId == _drag.lifted);
|
||||
if (lifted >= 0) order.add(order.removeAt(order.indexOf(lifted)));
|
||||
// The remove target: centred in the band below the stack's slot
|
||||
// (over the composer), clear of the safe area.
|
||||
const r = kChatStackRemoveSize / 2;
|
||||
final floor = size.height - media.padding.bottom;
|
||||
final removeCenter = Offset(
|
||||
size.width / 2,
|
||||
math.max(
|
||||
anchor.bottom + 4,
|
||||
math.min((anchor.bottom + floor) / 2, floor - r - 8),
|
||||
// The close button takes the pile's place; while a chat is dragged
|
||||
// it is the remove target.
|
||||
_removeCenter = anchor.center;
|
||||
final close = Positioned.fromRect(
|
||||
key: const ValueKey('chat-stack-close'),
|
||||
rect: anchor,
|
||||
child: IgnorePointer(
|
||||
ignoring: _drag.lifted != null,
|
||||
child: ChatStackCloseTarget(
|
||||
open: widget.motion.close,
|
||||
armed: _drag.removeShown,
|
||||
hover: _drag.hover,
|
||||
reduced: _drag.reduced,
|
||||
onClose: widget.onDismiss,
|
||||
),
|
||||
),
|
||||
);
|
||||
_removeCenter = removeCenter;
|
||||
final items = ChatStackColumnItems(
|
||||
motion: widget.motion,
|
||||
entries: _entries,
|
||||
@@ -226,24 +232,15 @@ class _ChatStackColumnState extends State<ChatStackColumn>
|
||||
color: scheme.scrim.withValues(alpha: dark ? .5 : .32),
|
||||
dismissible: true,
|
||||
onDismiss: widget.onDismiss,
|
||||
semanticsLabel: 'Close chats',
|
||||
semanticsLabel: 'Dismiss',
|
||||
),
|
||||
),
|
||||
),
|
||||
// Under the column: a chat dragged onto it is drawn over it.
|
||||
if (widget.onRemove != null)
|
||||
Positioned(
|
||||
left: removeCenter.dx - r,
|
||||
top: removeCenter.dy - r,
|
||||
width: kChatStackRemoveSize,
|
||||
height: kChatStackRemoveSize,
|
||||
child: ChatStackRemoveTarget(
|
||||
shown: _drag.removeShown,
|
||||
hover: _drag.hover,
|
||||
reduced: _drag.reduced,
|
||||
),
|
||||
),
|
||||
// A dragged chat is drawn over the button (it shrinks into
|
||||
// it); otherwise the button is on top, to take its tap.
|
||||
if (_drag.lifted != null) close,
|
||||
PositionedDirectional(
|
||||
key: const ValueKey('chat-stack-column'),
|
||||
end: endInset,
|
||||
bottom: size.height - anchor.bottom,
|
||||
top: top,
|
||||
@@ -266,6 +263,7 @@ class _ChatStackColumnState extends State<ChatStackColumn>
|
||||
),
|
||||
),
|
||||
),
|
||||
if (_drag.lifted == null) close,
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user