Files
pipelines/app/lib/features/chat/ui/transcript/paper/paper_quote.dart
T
alan 7d2c3412a1 Paper design: warm paper, serif reading text and a typeset transcript
Adds the Paper design and generalises design tokens (transcript, composer,
selected-row styles, reading type, panel fill, chat colour saturation).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 18:00:07 +00:00

101 lines
3.4 KiB
Dart

import 'package:flutter/material.dart';
import '../../sessions/chat_color_palette.dart';
import '../chat_message_bubble.dart';
/// How far a manuscript's block quote (the operator's turn) sits in from the
/// answer's text edge, so the reader sees whose words they are by indent.
const double paperQuoteIndent = 16;
/// The width of the quote's rule.
const double paperQuoteRule = 2;
/// The gap between the rule and the quoted text.
const double paperQuoteGap = 12;
/// Where the quoted text starts, from the row's edge: the footer under the
/// quote (its delivery line and time) starts here too.
const double paperQuoteTextInset =
paperQuoteIndent + paperQuoteRule + paperQuoteGap;
/// The words of the small-caps label above the operator's turn.
const String paperQuoteLabel = 'You';
/// The style of a manuscript's small editorial labels: italic capitals set
/// small and spaced, the way a book sets small caps (the serif's italic has
/// no small-caps feature, so they are spaced capitals), in the muted ink.
TextStyle? paperSmallCapsStyle(BuildContext context) {
final theme = Theme.of(context);
final reading = chatMessageTextStyle(context);
final size = (reading?.fontSize ?? 16) * 0.72;
return reading?.copyWith(
fontSize: size,
fontStyle: FontStyle.italic,
letterSpacing: size * 0.12,
height: 1.2,
color: theme.colorScheme.onSurfaceVariant,
);
}
/// The operator's turn under a manuscript transcript: an indented block
/// quote with a thin rule in the chat's colour (the outline for a chat with
/// none) and a small-caps "You" above it, instead of a bubble. It spans the
/// reading column, like the answer below it.
class PaperQuote extends StatelessWidget {
const PaperQuote({super.key, required this.child});
final Widget child;
@override
Widget build(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
final shade = chatColorShade(context, ChatBubbleColor.of(context));
return Material(
key: const Key('chat-paper-quote'),
type: MaterialType.transparency,
child: Padding(
padding: const EdgeInsetsDirectional.only(start: paperQuoteIndent),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ExcludeSemantics(
child: SelectionContainer.disabled(
child: Padding(
padding: const EdgeInsetsDirectional.only(
start: paperQuoteRule + paperQuoteGap,
bottom: 4,
),
child: Text(
paperQuoteLabel.toUpperCase(),
key: const Key('chat-paper-quote-label'),
style: paperSmallCapsStyle(context),
),
),
),
),
DecoratedBox(
decoration: BoxDecoration(
border: BorderDirectional(
start: BorderSide(
color: shade ?? scheme.outline,
width: paperQuoteRule,
),
),
),
child: Padding(
padding: const EdgeInsetsDirectional.only(
start: paperQuoteGap,
top: 2,
bottom: 2,
),
child: child,
),
),
],
),
),
);
}
}