Files
pipelines/app/lib/ui/theme/app_design_styles.dart
T
alan 113063b040 Notebook design: numbered In/Out cells, tool sub-cells and an input-cell composer
Adds the Notebook design (TranscriptStyle.cells, ComposerStyle.cell), a
white/charcoal IDE theme with light grey cells, hairlines and 5px corners.

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

115 lines
3.9 KiB
Dart

import 'package:flutter/foundation.dart';
import 'package:flutter/painting.dart';
/// How the chat transcript draws a conversation. Each design picks one; the
/// transcript widgets branch on it, never on the design itself.
enum TranscriptStyle {
/// The operator's turns as bubbles on the trailing side, the agent's
/// answers on the page and its activity as a one-line button (Classic).
bubbles,
/// A CLI's prompt line, glyph-led tool lines and bracketed injected
/// prompts, every turn starting at the same edge (Terminal).
prompt,
/// A typeset page: the operator's turns as indented block quotes under a
/// small-caps label, answers as prose, activity as a muted marginal note
/// and injected prompts as italic editorial notes (Paper).
manuscript,
/// A notebook: each operator prompt an "In [n]:" input cell and each
/// answer its "Out [n]:" cell, numbered per turn in a fixed-width gutter,
/// with tool calls as collapsible sub-cells (Notebook).
cells,
}
/// How the chat composer frames its writing area.
enum ComposerStyle {
/// A floating pill (frosted, or flat and framed under a flat design) in
/// the design's corners, with a focus ring along its edge.
pill,
/// An open writing area on the page with a rule beneath it that takes
/// the accent while the field has focus.
underline,
/// A notebook's empty input cell, "In [ ]:" in the gutter beside a light
/// grey cell whose frame takes the accent while the field has focus.
cell,
}
/// How a list (AppListRow) marks the row that is open. Every style keeps
/// the leading bar in the row's accent; they differ in the fill and frame.
enum SelectedRowStyle {
/// Material's tonal `secondaryContainer` fill (Classic).
tonal,
/// The accent washed over the page, stronger than a tinted row, inside a
/// hairline frame in the accent (Terminal).
framed,
/// The accent washed over the page, without a frame (Paper).
washed,
}
/// The typography of reading text: chat messages, markdown answers and
/// documents. Interface text (navigation, buttons, chips, labels, metadata)
/// keeps the theme's own text roles.
@immutable
class ReadingType {
const ReadingType({
this.family,
this.height,
this.measure,
this.scale = 1,
this.figureWidth = 0.5,
});
/// The reading face; null keeps the theme's body face.
final String? family;
/// The line height as a multiple of the font size; null keeps the role's.
final double? height;
/// The widest reading column in `ch` (widths of the digit zero in the
/// reading face); null keeps the app's fixed reading width.
final double? measure;
/// The reading size relative to the theme's `bodyLarge`.
final double scale;
/// The width of the reading face's digit zero, in ems: what one `ch` of
/// [measure] is worth (half an em for Source Serif's figures).
final double figureWidth;
/// [base] in the reading face, size and line height.
TextStyle? apply(TextStyle? base) {
if (base == null) return null;
if (family == null && height == null && scale == 1) return base;
final size = base.fontSize;
return base.copyWith(
fontFamily: family,
// The interface face stays as the fallback, so a glyph the reading
// face lacks still draws from a bundled family.
fontFamilyFallback: family == null || base.fontFamily == null
? null
: <String>[base.fontFamily!, ...?base.fontFamilyFallback],
fontSize: size == null ? null : size * scale,
height: height,
letterSpacing: family == null ? null : 0,
);
}
@override
bool operator ==(Object other) =>
other is ReadingType &&
other.family == family &&
other.height == height &&
other.measure == measure &&
other.scale == scale &&
other.figureWidth == figureWidth;
@override
int get hashCode => Object.hash(family, height, measure, scale, figureWidth);
}