WIP compact
This commit is contained in:
@@ -69,7 +69,9 @@ class ChatAutomatedPromptCard extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
);
|
||||
final transcript = AppDesignTokens.of(context).transcript;
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
final density = tokens.density;
|
||||
final transcript = tokens.transcript;
|
||||
final card = transcript == TranscriptStyle.manuscript
|
||||
? PaperEditorialNote(
|
||||
label: label,
|
||||
@@ -84,11 +86,18 @@ class ChatAutomatedPromptCard extends StatelessWidget {
|
||||
color: scheme.surfaceContainerLow,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||
borderRadius: tokens.corners(
|
||||
const BorderRadius.all(Radius.circular(16)),
|
||||
),
|
||||
side: BorderSide(color: scheme.outlineVariant),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(14, 8, 14, 10),
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
density.inset(14),
|
||||
density.space(8),
|
||||
density.inset(14),
|
||||
density.space(10),
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
||||
@@ -166,7 +166,11 @@ class ChatCodeCopyRegion extends StatelessWidget {
|
||||
key: const Key('chat-code-header'),
|
||||
color: headerFill(context),
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(start: 12, end: 4),
|
||||
// Its label starts at the code's own inset (tighter when dense).
|
||||
padding: EdgeInsetsDirectional.only(
|
||||
start: AppDesignTokens.of(context).density.space(12),
|
||||
end: 4,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(child: label),
|
||||
|
||||
@@ -272,7 +272,9 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
||||
code: code,
|
||||
label: Text(markdownCodeLabel(language), style: labelStyle),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
padding: EdgeInsets.all(
|
||||
AppDesignTokens.of(context).density.space(12),
|
||||
),
|
||||
child: ChatTranscriptHorizontalScrollView(
|
||||
label: 'code block',
|
||||
child: Text.rich(
|
||||
@@ -570,9 +572,15 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
||||
/// a tighter line, as a technical book does.
|
||||
TextStyle _codeStyle(BuildContext context) {
|
||||
const mono = TextStyle(fontFamily: appMonospaceFamily);
|
||||
final reading = AppDesignTokens.of(context).reading;
|
||||
if (reading.family == null) return mono;
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
final reading = tokens.reading;
|
||||
final size = DefaultTextStyle.of(context).style.fontSize ?? 16;
|
||||
// A dense design sets code at its body size (13 beside 14px prose): the
|
||||
// monospace runs wider than the prose face.
|
||||
if (reading.family == null && tokens.density.dense) {
|
||||
return mono.copyWith(fontSize: size * 13 / 14, height: 1.4);
|
||||
}
|
||||
if (reading.family == null) return mono;
|
||||
return mono.copyWith(
|
||||
fontSize: size * 0.82,
|
||||
height: 1.45,
|
||||
|
||||
@@ -55,15 +55,26 @@ class ChatUserBubble extends StatelessWidget {
|
||||
break;
|
||||
}
|
||||
// A Material surface (not a bare DecoratedBox) so a disclosure ListTile
|
||||
// inside the bubble keeps its ink and background.
|
||||
// inside the bubble keeps its ink and background. A dense design draws
|
||||
// a tighter bubble in its own corners.
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
final density = tokens.density;
|
||||
return Material(
|
||||
color: chatBubbleFill(
|
||||
context,
|
||||
Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
shape: const RoundedRectangleBorder(borderRadius: _radius),
|
||||
child: Padding(padding: _padding, child: child),
|
||||
shape: RoundedRectangleBorder(borderRadius: tokens.corners(_radius)),
|
||||
child: Padding(
|
||||
padding: density.dense
|
||||
? EdgeInsets.symmetric(
|
||||
horizontal: density.inset(_padding.left),
|
||||
vertical: density.space(_padding.top),
|
||||
)
|
||||
: _padding,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -89,8 +100,10 @@ TextStyle? chatMessageTextStyle(BuildContext context) => AppDesignTokens.of(
|
||||
|
||||
/// The empty-line gap between two paragraphs of a reply: about one line of
|
||||
/// body text at [fontSize] (else the ambient text size), scaled by the
|
||||
/// operator's text scaling, so chunks read as separate paragraphs.
|
||||
/// operator's text scaling, so chunks read as separate paragraphs. A design
|
||||
/// may set a tighter gap ([ReadingType.paragraphGap]).
|
||||
double chatParagraphGap(BuildContext context, [double? fontSize]) {
|
||||
final size = fontSize ?? DefaultTextStyle.of(context).style.fontSize ?? 14;
|
||||
return MediaQuery.textScalerOf(context).scale(size) * 0.9;
|
||||
return MediaQuery.textScalerOf(context).scale(size) *
|
||||
AppDesignTokens.of(context).reading.paragraphGap;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,8 @@ class ChatMessageView extends StatelessWidget {
|
||||
// A terminal or manuscript transcript reads top to bottom: the
|
||||
// operator's prompt line or block quote starts at the same edge as the
|
||||
// answer and spans its column.
|
||||
final transcript = AppDesignTokens.of(context).transcript;
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
final transcript = tokens.transcript;
|
||||
final trailingUser =
|
||||
user && !automated && transcript == TranscriptStyle.bubbles;
|
||||
// No visible role label: side and surface say who spoke and the row's
|
||||
@@ -104,9 +105,12 @@ class ChatMessageView extends StatelessWidget {
|
||||
label: '$role message',
|
||||
child: Padding(
|
||||
// A manuscript leaves a little more air between turns, as a page
|
||||
// spaces its paragraphs, since no bubble sets them apart.
|
||||
// spaces its paragraphs, since no bubble sets them apart; a dense
|
||||
// design a little less.
|
||||
padding: EdgeInsets.symmetric(
|
||||
vertical: transcript == TranscriptStyle.manuscript ? 12 : 6,
|
||||
vertical: transcript == TranscriptStyle.manuscript
|
||||
? 12
|
||||
: tokens.density.space(6),
|
||||
),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) => Align(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -123,7 +124,8 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
|
||||
: DateTime.now().difference(started);
|
||||
final seconds = duration.inSeconds.clamp(0, 2147483647);
|
||||
final label = '${data.label}${widget.streaming ? ' ${seconds}s' : ''}';
|
||||
switch (AppDesignTokens.of(context).transcript) {
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
switch (tokens.transcript) {
|
||||
case TranscriptStyle.prompt:
|
||||
return TerminalActivityRows(
|
||||
data: data,
|
||||
@@ -145,8 +147,12 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
|
||||
}
|
||||
// Desktop hover hugs the label; phones keep the full-width touch row.
|
||||
final compact = prefersCompactHitTargets(context);
|
||||
// A dense design draws the line slimmer on a pointer device; a touch
|
||||
// device keeps a 40px target.
|
||||
final density = tokens.density;
|
||||
final dense = density.dense;
|
||||
final content = ConstrainedBox(
|
||||
constraints: const BoxConstraints(minHeight: 32),
|
||||
constraints: BoxConstraints(minHeight: dense ? 20 : 32),
|
||||
child: Row(
|
||||
mainAxisSize: compact ? MainAxisSize.min : MainAxisSize.max,
|
||||
children: [
|
||||
@@ -157,7 +163,7 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
|
||||
child: const ChatResponsePending(),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
SizedBox(width: density.space(8)),
|
||||
],
|
||||
Flexible(
|
||||
child: Text(
|
||||
@@ -179,8 +185,13 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
|
||||
final button = TextButton(
|
||||
key: const Key('chat-turn-activity'),
|
||||
style: TextButton.styleFrom(
|
||||
minimumSize: const Size(0, 48),
|
||||
padding: const EdgeInsets.all(chatAgentContentInset),
|
||||
minimumSize: Size(0, dense ? math.max(28, density.minTouchRow) : 48),
|
||||
padding: dense
|
||||
? const EdgeInsets.symmetric(
|
||||
horizontal: chatAgentContentInset,
|
||||
vertical: 4,
|
||||
)
|
||||
: const EdgeInsets.all(chatAgentContentInset),
|
||||
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
),
|
||||
|
||||
@@ -109,9 +109,9 @@ class _ChatTurnChipState extends State<ChatTurnChip> {
|
||||
).corners(BorderRadius.circular(8)),
|
||||
onTap: _show,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: chatAgentContentInset,
|
||||
vertical: 6,
|
||||
vertical: AppDesignTokens.of(context).density.space(6),
|
||||
),
|
||||
child: content,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user