Keep chat controls readable and expose labeled app navigation

This commit is contained in:
2026-11-07 20:46:02 +00:00
parent 68c0ad3caa
commit 4bbbe01633
20 changed files with 582 additions and 159 deletions
@@ -48,55 +48,86 @@ class ChatThreadHeader extends StatelessWidget {
Widget build(BuildContext context) {
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
return SegmentedBar(
cupertino: cupertino,
automaticallyImplyLeading: false,
// The platform's own Back, so it reads and behaves as every other
// page's Back; its key stays for finders.
leading: showBack
? SegmentedBackButton(
key: const Key('chat-back'),
cupertino: cupertino,
onPressed: onBack,
)
: null,
title: title.isEmpty ? 'Chat' : title,
subtitle: folder,
subtitleIcon: cupertino ? CupertinoIcons.folder : Icons.folder_outlined,
onTitlePressed: onInfo,
titleSemanticLabel: 'Chat information',
titleKey: const Key('chat-info'),
separateActionIslands: true,
actions: [
if (controls.isNotEmpty)
_ControlIsland(
key: const Key('chat-model-permission-island'),
children: controls,
),
if (actions.isNotEmpty || moreActions.isNotEmpty)
Row(
key: const Key('chat-actions-island'),
return LayoutBuilder(
builder: (context, constraints) {
final narrow = constraints.maxWidth < 800;
final bar = SegmentedBar(
cupertino: cupertino,
automaticallyImplyLeading: false,
// The platform's own Back, so it reads and behaves as every other
// page's Back; its key stays for finders.
leading: showBack
? SegmentedBackButton(
key: const Key('chat-back'),
cupertino: cupertino,
onPressed: onBack,
)
: null,
title: title.isEmpty ? 'Chat' : title,
subtitle: folder,
subtitleIcon: cupertino
? CupertinoIcons.folder
: Icons.folder_outlined,
onTitlePressed: onInfo,
titleSemanticLabel: 'Chat information',
titleKey: const Key('chat-info'),
separateActionIslands: true,
actions: [
if (!narrow && controls.isNotEmpty)
_ControlIsland(
key: const Key('chat-model-permission-island'),
children: controls,
),
if (actions.isNotEmpty || moreActions.isNotEmpty)
Row(
key: const Key('chat-actions-island'),
mainAxisSize: MainAxisSize.min,
children: [
...actions,
// Unknown action widgets retain their original behavior and stay
// visible; only the explicit overflow contract becomes a menu.
for (final action in moreActions)
if (action is! SegmentedOverflowable) action,
if (moreActions.whereType<SegmentedOverflowable>().isNotEmpty)
SegmentedMoreButton(
cupertino: cupertino,
entries: [
for (final action
in moreActions.whereType<SegmentedOverflowable>())
action.overflowEntry,
],
),
],
),
],
bottomPadding: narrow ? 8 : 16,
backdrop: backdrop,
);
return ColoredBox(
color: cupertino
? CupertinoTheme.of(context).scaffoldBackgroundColor
: Theme.of(context).colorScheme.surface,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
...actions,
// Unknown action widgets retain their original behavior and stay
// visible; only the explicit overflow contract becomes a menu.
for (final action in moreActions)
if (action is! SegmentedOverflowable) action,
if (moreActions.whereType<SegmentedOverflowable>().isNotEmpty)
SegmentedMoreButton(
cupertino: cupertino,
entries: [
for (final action
in moreActions.whereType<SegmentedOverflowable>())
action.overflowEntry,
],
bar,
if (narrow && controls.isNotEmpty)
Padding(
padding: const EdgeInsets.fromLTRB(12, 0, 12, 8),
child: SegmentedPill(
cupertino: cupertino,
child: _ControlIsland(
key: const Key('chat-model-permission-island'),
fill: true,
vertical: constraints.maxWidth < 340,
children: controls,
),
),
),
],
),
],
bottomPadding: 16,
backdrop: backdrop,
);
},
);
}
}
@@ -104,11 +135,27 @@ class ChatThreadHeader extends StatelessWidget {
/// Related selectors share the available width. Each remains a real control;
/// they never migrate into the unrelated actions menu.
class _ControlIsland extends StatelessWidget {
const _ControlIsland({super.key, required this.children});
const _ControlIsland({
super.key,
required this.children,
this.fill = false,
this.vertical = false,
});
final List<Widget> children;
final bool fill;
final bool vertical;
@override
Widget build(BuildContext context) => Row(
mainAxisSize: MainAxisSize.min,
children: [for (final child in children) Flexible(child: child)],
);
Widget build(BuildContext context) => vertical
? Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: children,
)
: Row(
mainAxisSize: fill ? MainAxisSize.max : MainAxisSize.min,
children: [
for (final child in children)
if (fill) Expanded(child: child) else Flexible(child: child),
],
);
}