feat(chat): segmented chat header with back, title and model pills
The open conversation draws its own bar of separate rounded pieces: the platform Back in a circle, a title pill with the folder that opens the chat information, and a pill with the model and mode controls. Detail pages drop only their app bar for it, keeping the body mounted.
This commit is contained in:
@@ -0,0 +1,242 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../ui/sessions/chat_adaptive.dart';
|
||||||
|
|
||||||
|
/// The open conversation's bar: separate rounded pieces on the page's own
|
||||||
|
/// background above the transcript, instead of one solid app bar.
|
||||||
|
///
|
||||||
|
/// From the leading edge: a round Back (only where the page can go back), a
|
||||||
|
/// pill with the conversation's title and folder that opens the chat's
|
||||||
|
/// information, and a pill holding [controls] (model and mode).
|
||||||
|
class ChatThreadHeader extends StatelessWidget {
|
||||||
|
const ChatThreadHeader({
|
||||||
|
super.key,
|
||||||
|
required this.title,
|
||||||
|
required this.folder,
|
||||||
|
required this.onInfo,
|
||||||
|
this.showBack = false,
|
||||||
|
this.onBack,
|
||||||
|
this.controls = const [],
|
||||||
|
});
|
||||||
|
|
||||||
|
final String title;
|
||||||
|
|
||||||
|
/// The working folder's name, shown beneath the title; empty for none.
|
||||||
|
final String folder;
|
||||||
|
final VoidCallback onInfo;
|
||||||
|
|
||||||
|
/// Whether the bar shows Back at all.
|
||||||
|
final bool showBack;
|
||||||
|
|
||||||
|
/// What Back does; null keeps the platform's stock action (pop the route).
|
||||||
|
final VoidCallback? onBack;
|
||||||
|
final List<Widget> controls;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final cupertino =
|
||||||
|
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||||
|
final background = cupertino
|
||||||
|
? CupertinoTheme.of(context).scaffoldBackgroundColor
|
||||||
|
: Theme.of(context).colorScheme.surface;
|
||||||
|
return ColoredBox(
|
||||||
|
color: background,
|
||||||
|
child: SafeArea(
|
||||||
|
bottom: false,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsetsDirectional.fromSTEB(12, 8, 12, 16),
|
||||||
|
child: LayoutBuilder(
|
||||||
|
builder: (context, constraints) => Row(
|
||||||
|
children: [
|
||||||
|
if (showBack) ...[
|
||||||
|
_ChatHeaderPill(
|
||||||
|
circle: true,
|
||||||
|
child: _BackControl(
|
||||||
|
cupertino: cupertino,
|
||||||
|
onPressed: onBack,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
],
|
||||||
|
Expanded(
|
||||||
|
child: Align(
|
||||||
|
alignment: AlignmentDirectional.centerStart,
|
||||||
|
child: _TitlePill(
|
||||||
|
title: title,
|
||||||
|
folder: folder,
|
||||||
|
cupertino: cupertino,
|
||||||
|
onPressed: onInfo,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (controls.isNotEmpty) ...[
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
// The controls keep to the trailing edge and at most about
|
||||||
|
// half the bar, so the title always has room; each control
|
||||||
|
// ellipsises its own label, the model's taking the larger share.
|
||||||
|
ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxWidth: constraints.maxWidth * 0.45,
|
||||||
|
),
|
||||||
|
child: _ChatHeaderPill(
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Flexible(flex: 3, child: controls.first),
|
||||||
|
for (final control in controls.skip(1))
|
||||||
|
Flexible(flex: 2, child: control),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// One rounded, filled piece of the bar in the host's raised surface role.
|
||||||
|
class _ChatHeaderPill extends StatelessWidget {
|
||||||
|
const _ChatHeaderPill({required this.child, this.circle = false});
|
||||||
|
|
||||||
|
final Widget child;
|
||||||
|
final bool circle;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final cupertino =
|
||||||
|
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||||
|
final fill = cupertino
|
||||||
|
? CupertinoColors.systemGrey6.resolveFrom(context)
|
||||||
|
: Theme.of(context).colorScheme.surfaceContainerHigh;
|
||||||
|
final shape = circle
|
||||||
|
? const CircleBorder()
|
||||||
|
: const StadiumBorder() as ShapeBorder;
|
||||||
|
if (cupertino) {
|
||||||
|
return ClipPath(
|
||||||
|
clipper: ShapeBorderClipper(shape: shape),
|
||||||
|
child: ColoredBox(color: fill, child: child),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return Material(
|
||||||
|
color: fill,
|
||||||
|
shape: shape,
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The platform's own Back control, so it reads and behaves as every other
|
||||||
|
/// page's Back; its key and the conversation's destination wording stay.
|
||||||
|
class _BackControl extends StatelessWidget {
|
||||||
|
const _BackControl({required this.cupertino, required this.onPressed});
|
||||||
|
|
||||||
|
final bool cupertino;
|
||||||
|
final VoidCallback? onPressed;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => KeyedSubtree(
|
||||||
|
key: const Key('chat-back'),
|
||||||
|
child: cupertino
|
||||||
|
? CupertinoNavigationBarBackButton(onPressed: onPressed)
|
||||||
|
: BackButton(onPressed: onPressed),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The title and its folder in one pill; pressing it opens the chat's
|
||||||
|
/// information.
|
||||||
|
class _TitlePill extends StatelessWidget {
|
||||||
|
const _TitlePill({
|
||||||
|
required this.title,
|
||||||
|
required this.folder,
|
||||||
|
required this.cupertino,
|
||||||
|
required this.onPressed,
|
||||||
|
});
|
||||||
|
|
||||||
|
final String title;
|
||||||
|
final String folder;
|
||||||
|
final bool cupertino;
|
||||||
|
final VoidCallback onPressed;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final TextStyle? titleStyle;
|
||||||
|
final TextStyle? folderStyle;
|
||||||
|
if (cupertino) {
|
||||||
|
final text = CupertinoTheme.of(context).textTheme;
|
||||||
|
titleStyle = text.textStyle.copyWith(fontWeight: FontWeight.w600);
|
||||||
|
folderStyle = text.tabLabelTextStyle.copyWith(
|
||||||
|
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
titleStyle = theme.textTheme.titleSmall;
|
||||||
|
folderStyle = theme.textTheme.labelSmall?.copyWith(
|
||||||
|
color: theme.colorScheme.onSurfaceVariant,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final content = Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
title.isEmpty ? 'Chat' : title,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: titleStyle,
|
||||||
|
),
|
||||||
|
if (folder.isNotEmpty)
|
||||||
|
Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(
|
||||||
|
cupertino ? CupertinoIcons.folder : Icons.folder_outlined,
|
||||||
|
size: folderStyle?.fontSize,
|
||||||
|
color: folderStyle?.color,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
Flexible(
|
||||||
|
child: Text(
|
||||||
|
folder,
|
||||||
|
maxLines: 1,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: folderStyle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return _ChatHeaderPill(
|
||||||
|
child: Semantics(
|
||||||
|
button: true,
|
||||||
|
label: 'Chat information',
|
||||||
|
child: cupertino
|
||||||
|
? CupertinoButton(
|
||||||
|
key: const Key('chat-info'),
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
minimumSize: Size.zero,
|
||||||
|
onPressed: onPressed,
|
||||||
|
child: DefaultTextStyle.merge(
|
||||||
|
style: titleStyle,
|
||||||
|
child: content,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
: InkWell(
|
||||||
|
key: const Key('chat-info'),
|
||||||
|
onTap: onPressed,
|
||||||
|
child: content,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,6 +28,7 @@ import 'chat_models.dart';
|
|||||||
import 'chat_row_keys.dart';
|
import 'chat_row_keys.dart';
|
||||||
import 'chat_scroll.dart';
|
import 'chat_scroll.dart';
|
||||||
import 'chat_thread_controller.dart';
|
import 'chat_thread_controller.dart';
|
||||||
|
import 'chat_thread_header.dart';
|
||||||
import 'chat_transcript_cache.dart';
|
import 'chat_transcript_cache.dart';
|
||||||
import 'chat_permission_card_model.dart';
|
import 'chat_permission_card_model.dart';
|
||||||
import 'chat_permission_group.dart';
|
import 'chat_permission_group.dart';
|
||||||
@@ -717,78 +718,8 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
|||||||
final inShellBar = ShellBar.available(context);
|
final inShellBar = ShellBar.available(context);
|
||||||
final column = Column(
|
final column = Column(
|
||||||
children: [
|
children: [
|
||||||
// The conversation's own bar first, outside the transcript's scroller,
|
// The conversation's own floating bar, above its transcript.
|
||||||
// as on the web (chat-bar, then background tasks, then transcript).
|
_header(context, inShellBar),
|
||||||
if (!inShellBar)
|
|
||||||
Padding(
|
|
||||||
key: const Key('chat-thread-header'),
|
|
||||||
padding: const EdgeInsetsDirectional.fromSTEB(4, 8, 4, 4),
|
|
||||||
child: LayoutBuilder(
|
|
||||||
builder: (context, constraints) {
|
|
||||||
final title = widget.title.trim();
|
|
||||||
final session = widget.session;
|
|
||||||
final hasModel =
|
|
||||||
session != null &&
|
|
||||||
supportsChatModels('${session['backend'] ?? ''}');
|
|
||||||
// One compact row, as on the web: back, the conversation's
|
|
||||||
// name, its model and the information action. The title
|
|
||||||
// takes the remaining width and ellipsises; the model keeps
|
|
||||||
// a bounded share so neither control is pushed off a narrow
|
|
||||||
// 2x phone and the header never wraps onto a second line.
|
|
||||||
return Row(
|
|
||||||
children: [
|
|
||||||
_backButton(cupertino),
|
|
||||||
Expanded(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsetsDirectional.only(start: 4),
|
|
||||||
child: title.isEmpty
|
|
||||||
? const SizedBox.shrink()
|
|
||||||
: Text(
|
|
||||||
title,
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: cupertino
|
|
||||||
? CupertinoTheme.of(
|
|
||||||
context,
|
|
||||||
).textTheme.navTitleTextStyle
|
|
||||||
: Theme.of(context).textTheme.titleLarge,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (hasModel)
|
|
||||||
ConstrainedBox(
|
|
||||||
constraints: BoxConstraints(
|
|
||||||
maxWidth: constraints.maxWidth * 0.4,
|
|
||||||
),
|
|
||||||
child: ChatModelControl(
|
|
||||||
key: ValueKey<String>(
|
|
||||||
'chat-model-${widget.sessionId}',
|
|
||||||
),
|
|
||||||
gateway: widget.gateway,
|
|
||||||
sessionId: widget.sessionId,
|
|
||||||
session: session,
|
|
||||||
onChanged: widget.onModelChanged,
|
|
||||||
answeredBy: latestReplyModel(_controller.messages),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ConstrainedBox(
|
|
||||||
constraints: BoxConstraints(
|
|
||||||
maxWidth: constraints.maxWidth * 0.3,
|
|
||||||
),
|
|
||||||
child: _modeControl(),
|
|
||||||
),
|
|
||||||
ChatBarAction(
|
|
||||||
key: const Key('chat-info'),
|
|
||||||
label: 'Chat information',
|
|
||||||
onPressed: _openInfo,
|
|
||||||
materialIcon: Icons.info_outline,
|
|
||||||
cupertinoIcon: CupertinoIcons.info,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: NotificationListener<ScrollMetricsNotification>(
|
child: NotificationListener<ScrollMetricsNotification>(
|
||||||
onNotification: _onScrollMetrics,
|
onNotification: _onScrollMetrics,
|
||||||
@@ -922,42 +853,60 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
if (!inShellBar) return column;
|
if (!inShellBar) return column;
|
||||||
final session = widget.session;
|
// The conversation draws its own floating bar; the page shows none.
|
||||||
final hasModel =
|
|
||||||
session != null && supportsChatModels('${session['backend'] ?? ''}');
|
|
||||||
final title = widget.title.trim();
|
final title = widget.title.trim();
|
||||||
return ShellBar(
|
return ShellBar(
|
||||||
|
barless: true,
|
||||||
title: title.isEmpty ? null : title,
|
title: title.isEmpty ? null : title,
|
||||||
actions: [
|
|
||||||
if (hasModel)
|
|
||||||
ConstrainedBox(
|
|
||||||
constraints: const BoxConstraints(maxWidth: 180),
|
|
||||||
child: ChatModelControl(
|
|
||||||
key: ValueKey<String>('chat-model-${widget.sessionId}'),
|
|
||||||
gateway: widget.gateway,
|
|
||||||
sessionId: widget.sessionId,
|
|
||||||
session: session,
|
|
||||||
onChanged: widget.onModelChanged,
|
|
||||||
answeredBy: latestReplyModel(_controller.messages),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
ConstrainedBox(
|
|
||||||
constraints: const BoxConstraints(maxWidth: 160),
|
|
||||||
child: _modeControl(),
|
|
||||||
),
|
|
||||||
ChatBarAction(
|
|
||||||
key: const Key('chat-info'),
|
|
||||||
label: 'Chat information',
|
|
||||||
onPressed: _openInfo,
|
|
||||||
materialIcon: Icons.info_outline,
|
|
||||||
cupertinoIcon: CupertinoIcons.info,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
child: column,
|
child: column,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// The floating bar: Back where this page can go back (a pushed phone page,
|
||||||
|
/// or a standalone screen), the title pill that opens the information, and
|
||||||
|
/// the model and mode controls.
|
||||||
|
Widget _header(BuildContext context, bool inShellBar) {
|
||||||
|
final session = widget.session;
|
||||||
|
final hasModel =
|
||||||
|
session != null && supportsChatModels('${session['backend'] ?? ''}');
|
||||||
|
final canGoBack = inShellBar
|
||||||
|
? ModalRoute.of(context)?.impliesAppBarDismissal ?? false
|
||||||
|
: true;
|
||||||
|
final directory = '${session?['directory'] ?? ''}'.trim();
|
||||||
|
final folder = directory
|
||||||
|
.split(RegExp(r'[/\\]'))
|
||||||
|
.lastWhere((part) => part.isNotEmpty, orElse: () => '');
|
||||||
|
return ChatThreadHeader(
|
||||||
|
key: const Key('chat-thread-header'),
|
||||||
|
title: widget.title.trim(),
|
||||||
|
folder: folder,
|
||||||
|
onInfo: _openInfo,
|
||||||
|
showBack: canGoBack,
|
||||||
|
// A pushed page keeps the platform's stock Back (pop this route); a
|
||||||
|
// standalone conversation calls its owner.
|
||||||
|
onBack: inShellBar ? null : widget.onBack,
|
||||||
|
controls: [
|
||||||
|
if (hasModel)
|
||||||
|
ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(maxWidth: 160),
|
||||||
|
child: ChatModelControl(
|
||||||
|
key: ValueKey<String>('chat-model-${widget.sessionId}'),
|
||||||
|
gateway: widget.gateway,
|
||||||
|
sessionId: widget.sessionId,
|
||||||
|
session: session,
|
||||||
|
onChanged: widget.onModelChanged,
|
||||||
|
answeredBy: latestReplyModel(_controller.messages),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(maxWidth: 140),
|
||||||
|
child: _modeControl(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// The session's permission mode, keyed per session so another chat
|
/// The session's permission mode, keyed per session so another chat
|
||||||
/// re-reads its own modes.
|
/// re-reads its own modes.
|
||||||
Widget _modeControl() => ChatModeControl(
|
Widget _modeControl() => ChatModeControl(
|
||||||
@@ -1037,32 +986,6 @@ class _ChatThreadViewState extends State<ChatThreadView> {
|
|||||||
images: _images,
|
images: _images,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The header's compact Back control, matching the web's icon-only control.
|
|
||||||
/// Its accessible name states the destination; Material keeps a tooltip and
|
|
||||||
/// Cupertino the same label on the wrapping node.
|
|
||||||
Widget _backButton(bool cupertino) {
|
|
||||||
const label = 'Back to chats';
|
|
||||||
final icon = Icon(cupertino ? CupertinoIcons.back : Icons.arrow_back);
|
|
||||||
if (!cupertino) {
|
|
||||||
return IconButton(
|
|
||||||
key: const Key('chat-back'),
|
|
||||||
tooltip: label,
|
|
||||||
onPressed: widget.onBack,
|
|
||||||
icon: icon,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Semantics(
|
|
||||||
label: label,
|
|
||||||
button: true,
|
|
||||||
child: CupertinoButton(
|
|
||||||
key: const Key('chat-back'),
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
onPressed: widget.onBack,
|
|
||||||
child: icon,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The native dismiss control shared by a local notice and a running
|
/// The native dismiss control shared by a local notice and a running
|
||||||
|
|||||||
@@ -129,32 +129,43 @@ class _DetailPaneState extends State<DetailPane> {
|
|||||||
final spec = _bar.specFor(widget.destination);
|
final spec = _bar.specFor(widget.destination);
|
||||||
final title = spec?.title ?? '';
|
final title = spec?.title ?? '';
|
||||||
final actions = spec?.actions ?? const <Widget>[];
|
final actions = spec?.actions ?? const <Widget>[];
|
||||||
|
// Content with its own bar reaches the top edge and owns the
|
||||||
|
// status-bar inset itself. The scaffold and the body's place in it stay
|
||||||
|
// the same either way, so switching never remounts the content.
|
||||||
|
final barless = spec?.barless ?? false;
|
||||||
if (usesCupertinoHost(context)) {
|
if (usesCupertinoHost(context)) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(
|
navigationBar: barless
|
||||||
automaticallyImplyLeading: widget.implyBack,
|
? null
|
||||||
// Inline pane bars are not routes and must not join the shell's
|
: CupertinoNavigationBar(
|
||||||
// navigation-bar hero when resizing into a pushed phone page.
|
automaticallyImplyLeading: widget.implyBack,
|
||||||
transitionBetweenRoutes: widget.implyBack,
|
// Inline pane bars are not routes and must not join the shell's
|
||||||
middle: Text(title),
|
// navigation-bar hero when resizing into a pushed phone page.
|
||||||
trailing: actions.isEmpty
|
transitionBetweenRoutes: widget.implyBack,
|
||||||
? null
|
middle: Text(title),
|
||||||
: Row(
|
trailing: actions.isEmpty
|
||||||
mainAxisSize: MainAxisSize.min,
|
? null
|
||||||
children: [
|
: Row(
|
||||||
for (final action in actions) Flexible(child: action),
|
mainAxisSize: MainAxisSize.min,
|
||||||
],
|
children: [
|
||||||
),
|
for (final action in actions)
|
||||||
),
|
Flexible(child: action),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
child: SafeArea(child: body),
|
child: SafeArea(child: body),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: barless
|
||||||
automaticallyImplyLeading: widget.implyBack,
|
? null
|
||||||
title: Text(title),
|
: AppBar(
|
||||||
actions: [for (final action in actions) Flexible(child: action)],
|
automaticallyImplyLeading: widget.implyBack,
|
||||||
),
|
title: Text(title),
|
||||||
|
actions: [
|
||||||
|
for (final action in actions) Flexible(child: action),
|
||||||
|
],
|
||||||
|
),
|
||||||
body: SafeArea(top: false, child: body),
|
body: SafeArea(top: false, child: body),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,11 +5,20 @@ import 'destination.dart';
|
|||||||
/// What the open screen of a tab puts in the app bar: its title, a Back
|
/// What the open screen of a tab puts in the app bar: its title, a Back
|
||||||
/// control and its actions. Absent, the bar shows the tab's own name.
|
/// control and its actions. Absent, the bar shows the tab's own name.
|
||||||
class ShellBarSpec {
|
class ShellBarSpec {
|
||||||
const ShellBarSpec({this.title, this.onBack, this.actions = const []});
|
const ShellBarSpec({
|
||||||
|
this.title,
|
||||||
|
this.onBack,
|
||||||
|
this.actions = const [],
|
||||||
|
this.barless = false,
|
||||||
|
});
|
||||||
|
|
||||||
final String? title;
|
final String? title;
|
||||||
final VoidCallback? onBack;
|
final VoidCallback? onBack;
|
||||||
final List<Widget> actions;
|
final List<Widget> actions;
|
||||||
|
|
||||||
|
/// The content draws its own floating bar: a detail page shows no bar of
|
||||||
|
/// its own and lets the content reach the top edge.
|
||||||
|
final bool barless;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The bar contents each tab's open screen has published.
|
/// The bar contents each tab's open screen has published.
|
||||||
@@ -86,9 +95,13 @@ class ShellBar extends StatefulWidget {
|
|||||||
this.onBack,
|
this.onBack,
|
||||||
this.actions = const [],
|
this.actions = const [],
|
||||||
this.active = true,
|
this.active = true,
|
||||||
|
this.barless = false,
|
||||||
required this.child,
|
required this.child,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// See [ShellBarSpec.barless].
|
||||||
|
final bool barless;
|
||||||
|
|
||||||
/// False while the screen is kept mounted but hidden (a list under an open
|
/// False while the screen is kept mounted but hidden (a list under an open
|
||||||
/// detail): it then gives the bar up.
|
/// detail): it then gives the bar up.
|
||||||
final bool active;
|
final bool active;
|
||||||
@@ -130,6 +143,7 @@ class _ShellBarState extends State<ShellBar> {
|
|||||||
title: widget.title,
|
title: widget.title,
|
||||||
onBack: widget.onBack,
|
onBack: widget.onBack,
|
||||||
actions: widget.actions,
|
actions: widget.actions,
|
||||||
|
barless: widget.barless,
|
||||||
);
|
);
|
||||||
// The bar is above this screen; update it after this frame's build.
|
// The bar is above this screen; update it after this frame's build.
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Chat: segmented header
|
||||||
|
|
||||||
|
Branch `chat/floating-header`.
|
||||||
|
|
||||||
|
- The open conversation draws its own bar (`ChatThreadHeader`): a round Back
|
||||||
|
pill (the platform's `BackButton` / `CupertinoNavigationBarBackButton`, only
|
||||||
|
where the page can go back; a pushed page keeps the stock pop action), a
|
||||||
|
title pill with the folder beneath it that opens the chat information
|
||||||
|
(`chat-info`), and a trailing pill with the model and mode controls (at most
|
||||||
|
45% of the bar; the model's label ellipsises first).
|
||||||
|
- `ShellBar(barless: true)` tells `DetailPane` to drop only its app bar; the
|
||||||
|
scaffold and body position stay identical so the conversation is never
|
||||||
|
remounted (a remount re-subscribed and re-read history).
|
||||||
|
- The bar sits above the transcript rather than over it: content scrolling
|
||||||
|
underneath put rows under the pills, where taps hit the header.
|
||||||
|
- Checks: `flutter test` 2016 passed, `flutter analyze` only the existing
|
||||||
|
artifacts info; Chrome captures of `tool/chat_composer_probe_entry.dart`
|
||||||
|
(now given a session with model and folder) in Material and Cupertino.
|
||||||
|
Not verified on a device.
|
||||||
@@ -207,20 +207,22 @@ void main() {
|
|||||||
expect(find.byKey(const Key('chat-turn-activity')), findsOneWidget);
|
expect(find.byKey(const Key('chat-turn-activity')), findsOneWidget);
|
||||||
expect(find.text('Kept behind a native disclosure.'), findsNothing);
|
expect(find.text('Kept behind a native disclosure.'), findsNothing);
|
||||||
|
|
||||||
// The shell bar stays over the list and rail; the open chat has its
|
// The shell bar stays over the list and rail; the open chat draws its
|
||||||
// own bar in its pane, with no Back: the list beside it is the way out.
|
// own floating bar in its pane, with no Back: the list beside it is the
|
||||||
|
// way out.
|
||||||
expect(find.byType(ChatSessionsScreen), findsOneWidget);
|
expect(find.byType(ChatSessionsScreen), findsOneWidget);
|
||||||
expect(
|
expect(
|
||||||
find.byType(NavigationRail),
|
find.byType(NavigationRail),
|
||||||
cupertino ? findsNothing : findsOneWidget,
|
cupertino ? findsNothing : findsOneWidget,
|
||||||
);
|
);
|
||||||
if (cupertino) {
|
if (cupertino) {
|
||||||
expect(find.byType(CupertinoNavigationBar), findsNWidgets(2));
|
expect(find.byType(CupertinoNavigationBar), findsOneWidget);
|
||||||
expect(find.byType(AppBar), findsNothing);
|
expect(find.byType(AppBar), findsNothing);
|
||||||
} else {
|
} else {
|
||||||
expect(find.byType(AppBar), findsNWidgets(2));
|
expect(find.byType(AppBar), findsOneWidget);
|
||||||
expect(find.byType(CupertinoNavigationBar), findsNothing);
|
expect(find.byType(CupertinoNavigationBar), findsNothing);
|
||||||
}
|
}
|
||||||
|
expect(find.byKey(const Key('chat-thread-header')), findsOneWidget);
|
||||||
expect(findNativeBack(), findsNothing);
|
expect(findNativeBack(), findsNothing);
|
||||||
|
|
||||||
// A live frame updates the held thread.
|
// A live frame updates the held thread.
|
||||||
@@ -240,8 +242,8 @@ void main() {
|
|||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(find.text('A live line arrived.'), findsOneWidget);
|
expect(find.text('A live line arrived.'), findsOneWidget);
|
||||||
|
|
||||||
// The pane bar carries the thread's controls: no second header row.
|
// The thread's own bar carries its controls once: no second bar.
|
||||||
expect(find.byKey(const Key('chat-thread-header')), findsNothing);
|
expect(find.byKey(const Key('chat-thread-header')), findsOneWidget);
|
||||||
// Browser Back to /chat clears the open pane and keeps the list.
|
// Browser Back to /chat clears the open pane and keeps the list.
|
||||||
await provider.didPushRouteInformation(
|
await provider.didPushRouteInformation(
|
||||||
RouteInformation(uri: Uri.parse('/chat')),
|
RouteInformation(uri: Uri.parse('/chat')),
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
import 'package:pipelines_app/features/chat/conversation/chat_thread_view.dart';
|
||||||
|
|
||||||
|
import '../../../native_back.dart';
|
||||||
import 'chat_thread_fixtures.dart';
|
import 'chat_thread_fixtures.dart';
|
||||||
|
|
||||||
const _title = 'A conversation title long enough to need an ellipsis at 320px';
|
const _title = 'A conversation title long enough to need an ellipsis at 320px';
|
||||||
@@ -36,7 +37,7 @@ void main() {
|
|||||||
for (final cupertino in [false, true]) {
|
for (final cupertino in [false, true]) {
|
||||||
final host = cupertino ? 'Cupertino' : 'Material';
|
final host = cupertino ? 'Cupertino' : 'Material';
|
||||||
|
|
||||||
testWidgets('$host header keeps back, title, model and actions on one row', (
|
testWidgets('$host header keeps back, title pill and model on one row', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
_useNarrowText(tester);
|
_useNarrowText(tester);
|
||||||
@@ -70,23 +71,22 @@ void main() {
|
|||||||
expect(info, findsOneWidget);
|
expect(info, findsOneWidget);
|
||||||
expect(back, findsOneWidget);
|
expect(back, findsOneWidget);
|
||||||
expect(tester.takeException(), isNull);
|
expect(tester.takeException(), isNull);
|
||||||
// The icon-only control still states its destination for assistive use.
|
// Back is the platform's own control, as on every other page.
|
||||||
if (cupertino) {
|
expect(
|
||||||
expect(find.bySemanticsLabel('Back to chats'), findsOneWidget);
|
find.descendant(of: back, matching: findNativeBack()),
|
||||||
} else {
|
findsOneWidget,
|
||||||
expect(find.byTooltip('Back to chats'), findsOneWidget);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
// One row, in the web's order: back, title, model, information. A wrapped
|
// One floating row of separate pieces: the round Back, the title pill
|
||||||
// header would put the controls on a different line from the title.
|
// (which is the information control and holds the title), then the
|
||||||
|
// model in the trailing pill.
|
||||||
double centerY(Finder finder) => tester.getCenter(finder).dy;
|
double centerY(Finder finder) => tester.getCenter(finder).dy;
|
||||||
expect((centerY(back) - centerY(title)).abs(), lessThan(16));
|
expect((centerY(back) - centerY(info)).abs(), lessThan(16));
|
||||||
expect((centerY(model) - centerY(title)).abs(), lessThan(16));
|
expect((centerY(model) - centerY(info)).abs(), lessThan(16));
|
||||||
expect((centerY(info) - centerY(title)).abs(), lessThan(16));
|
expect(find.descendant(of: info, matching: title), findsOneWidget);
|
||||||
double right(Finder finder) => tester.getTopRight(finder).dx;
|
double right(Finder finder) => tester.getTopRight(finder).dx;
|
||||||
expect(right(back), lessThanOrEqualTo(tester.getTopLeft(title).dx));
|
expect(right(back), lessThanOrEqualTo(tester.getTopLeft(info).dx));
|
||||||
expect(right(title), lessThanOrEqualTo(tester.getTopLeft(model).dx));
|
expect(right(info), lessThanOrEqualTo(tester.getTopLeft(model).dx));
|
||||||
expect(right(model), lessThanOrEqualTo(tester.getTopLeft(info).dx));
|
|
||||||
|
|
||||||
await tester.tap(back);
|
await tester.tap(back);
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|||||||
@@ -108,6 +108,12 @@ void main() {
|
|||||||
gateway: gateway,
|
gateway: gateway,
|
||||||
sessionId: 'probe-composer',
|
sessionId: 'probe-composer',
|
||||||
title: 'Composer fixture',
|
title: 'Composer fixture',
|
||||||
|
session: const {
|
||||||
|
'id': 'probe-composer',
|
||||||
|
'backend': 'opencode',
|
||||||
|
'model': 'claude-opus-5-5',
|
||||||
|
'directory': '/Users/ada/repos/tank',
|
||||||
|
},
|
||||||
onBack: () {},
|
onBack: () {},
|
||||||
drafts: MemoryChatDraftStore(),
|
drafts: MemoryChatDraftStore(),
|
||||||
newOperationId: gateway.nextOperation,
|
newOperationId: gateway.nextOperation,
|
||||||
|
|||||||
Reference in New Issue
Block a user