Grow the tapped chat row into the chat page on phones

Replace the identity-avatar Hero with a container transform: the row's
surface, tint and edge marker morph into the full page while the content
cross-fades, and Back, the Cupertino edge swipe or Android predictive back
shrink the page into the open chat's row. Reduced motion or a row off
screen fades instead; wide layouts are unchanged.
This commit is contained in:
2026-11-10 03:11:05 +00:00
parent 60b4c495f1
commit eea1361980
16 changed files with 1392 additions and 124 deletions
@@ -34,7 +34,6 @@ class ChatThreadHeader extends StatelessWidget {
this.moreActions = const [],
this.chatColor,
this.identity,
this.identityHeroTag,
});
final String title;
@@ -55,9 +54,8 @@ class ChatThreadHeader extends StatelessWidget {
/// The chat's colour name, or null for none.
final String? chatColor;
/// The chat identity carried from the mobile session row into this header.
/// The chat's identity avatar, shown in the title on a phone.
final Widget? identity;
final String? identityHeroTag;
@override
Widget build(BuildContext context) {
@@ -68,12 +66,6 @@ class ChatThreadHeader extends StatelessWidget {
builder: (context, constraints) {
final textScale = MediaQuery.textScalerOf(context).scale(14) / 14;
final compact = constraints.maxWidth / textScale < 800;
final heroIdentity =
identity == null ||
identityHeroTag == null ||
(MediaQuery.maybeDisableAnimationsOf(context) ?? false)
? identity
: Hero(tag: identityHeroTag!, child: identity!);
final Widget bar = SegmentedBar(
cupertino: cupertino,
pillColor: tint?.fill,
@@ -89,7 +81,7 @@ class ChatThreadHeader extends StatelessWidget {
)
: null,
title: title.isEmpty ? 'Chat' : title,
titleLeading: heroIdentity,
titleLeading: identity,
subtitle: ServerContext.metadata(context, folder),
subtitleIcon: cupertino
? CupertinoIcons.folder
@@ -1393,13 +1393,6 @@ class _ChatThreadViewState extends State<ChatThreadView> {
MediaQuery.sizeOf(context).width >= kListDetailMinWidth
? null
: ChatSessionAvatar(session: session, selected: true),
identityHeroTag:
widget.useNativeBack &&
session != null &&
MediaQuery.sizeOf(context).width < kListDetailMinWidth &&
!(MediaQuery.maybeDisableAnimationsOf(context) ?? false)
? 'chat-identity-${widget.sessionId}'
: null,
onInfo: _openInfo,
showBack: canGoBack,
// A pushed page keeps the platform's stock Back (pop this route); a
+14 -1
View File
@@ -10,6 +10,7 @@ import '../../shell/empty_detail_pane.dart';
import '../../shell/list_detail.dart';
import 'dart:async';
import '../../ui/motion/motion.dart';
import '../../ui/motion/container_transform_source.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart' show setEquals;
@@ -415,6 +416,13 @@ class _ChatScreenState extends State<ChatScreen>
/// On a phone the open chat is a real page above the main screen.
final DetailPageHost _page = DetailPageHost();
/// The list rows the phone's chat page grows from and shrinks back into:
/// the open chat's row, also after the page switched to another chat.
final ContainerTransformSources _rowSources = ContainerTransformSources();
late final ContainerTransformLink _growFromRow = _rowSources.link(
() => _selected,
);
@override
bool get _pageOpen => _page.open;
@@ -550,13 +558,14 @@ class _ChatScreenState extends State<ChatScreen>
selected: selected != null && !beside && !_usedWorkspace,
destination: AppDestination.chat,
onClosed: _back,
growFrom: _growFromRow,
builder: (context) => selected == null
? const SizedBox.shrink()
: ShellBar(barless: true, child: _workspaceView()),
);
// The session list pads its first row by the bar's height itself, so it
// scrolls behind the shell's floating bar like the other lists.
final fullList = ChatSessionsScreen(
final sessions = ChatSessionsScreen(
gateway: widget.gateway,
embedded: true,
syncToken: widget.syncToken,
@@ -575,6 +584,10 @@ class _ChatScreenState extends State<ChatScreen>
_sidebarMode == ChatSidebarMode.expanded) &&
(beside || !_usedWorkspace || selected == null),
);
final fullList = ContainerTransformScope(
sources: _rowSources,
child: sessions,
);
final list = _sidebarList(fullList, selected, beside);
if (!beside) {
if (!_usedWorkspace) return list;
@@ -6,7 +6,7 @@ import '../../../../core/api_gateway.dart';
import '../../../../ui/layout/app_list_avatar.dart';
import '../../../../ui/layout/app_list_row.dart';
import '../../../../ui/text/relative_time_label.dart';
import '../../../../shell/list_detail_policy.dart';
import '../../../../ui/motion/container_transform_source.dart';
import '../../domain/chat_colors.dart';
import '../../domain/chat_list_activity.dart';
import '../../domain/chat_sessions.dart';
@@ -65,11 +65,34 @@ class ChatSessionRow extends StatelessWidget {
final id = '${session['id'] ?? ''}';
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
final closed = chatSessionRowStatus(session, unseen: false) == 'Closed';
final unread = unseen && !closed;
final accent = cupertino
? CupertinoTheme.of(context).primaryColor
: Theme.of(context).colorScheme.primary;
final shade = chatColorShade(context, chatSessionColor(session));
final marker = shade ?? accent;
final tint = AppListRow.tintFor(context, shade, cupertino: cupertino);
final background = cupertino
? CupertinoDynamicColor.resolve(
CupertinoTheme.of(context).scaffoldBackgroundColor,
context,
)
: Theme.of(context).scaffoldBackgroundColor;
// On a phone the chat's page grows out of this row and shrinks back
// into it; the surface it starts from is the row's tint over the list.
return ContainerTransformSource(
id: id,
color: tint == null ? background : Color.alphaBlend(tint, background),
marker: marker,
markerWidth: visible ? (selected ? 10 : 3) : 0,
child: _marked(context, id, marker, accent),
);
}
Widget _marked(BuildContext context, String id, Color marker, Color accent) {
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
final closed = chatSessionRowStatus(session, unseen: false) == 'Closed';
final unread = unseen && !closed;
final text = chatSessionSubtitle(session);
final updatedAt = _chatSessionInstant(session['updated_at']);
final avatar = ChatSessionAvatar(
@@ -80,15 +103,9 @@ class ChatSessionRow extends StatelessWidget {
: chatSessionBackgroundTasks(session),
selected: selected,
);
final mobileHero =
!showsListBesideDetail(context) &&
!(MediaQuery.maybeDisableAnimationsOf(context) ?? false);
final identity = mobileHero
? Hero(tag: 'chat-identity-$id', child: avatar)
: avatar;
return ChatVisibilityMarker(
sessionId: id,
color: chatColorShade(context, chatSessionColor(session)) ?? accent,
color: marker,
visible: visible,
active: selected,
child: AppListRow(
@@ -102,7 +119,7 @@ class ChatSessionRow extends StatelessWidget {
onLongPress: selectionOnly ? null : onLongPress,
accent: chatColorShade(context, chatSessionColor(session)),
showAccentBorder: false,
leading: identity,
leading: avatar,
// The star rides in the title's own text, so a narrow row ellipsises
// them together.
title: Text.rich(
@@ -65,8 +65,8 @@ class _ChatWorkspaceEntranceState extends State<ChatWorkspaceEntrance>
@override
Widget build(BuildContext context) {
final content = HeroMode(
// The initial pushed page has a native Hero. Here both surfaces share
// one route; only the workspace entrance animates, never duplicate tags.
// Both surfaces share one route here; only the workspace entrance
// animates, so no Hero inside the chat flies or duplicates a tag.
enabled: false,
child: TickerMode(enabled: widget.visible, child: widget.child),
);