9d8e224995
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
163 lines
5.3 KiB
Dart
163 lines
5.3 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/painting.dart';
|
|
|
|
export 'design_density.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,
|
|
|
|
/// Bordered blocks for the eye that needs them: the operator's turns as
|
|
/// boxes with a thick bar in the chat's colour under a "You" label,
|
|
/// answers as plain text on the page and activity as bordered rows that
|
|
/// name each tool's status in words (High contrast).
|
|
boxed,
|
|
|
|
/// 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 row inverted: the ink as its fill and the page as its text, with a
|
|
/// thick bar (High contrast).
|
|
inverted,
|
|
}
|
|
|
|
/// The ring a design draws around the control with keyboard focus: [width]
|
|
/// thick, [offset] outside the control's bounds, in [color], with a [halo]
|
|
/// of the page between, so it reads over any fill.
|
|
@immutable
|
|
class FocusRingStyle {
|
|
const FocusRingStyle({
|
|
required this.color,
|
|
required this.halo,
|
|
this.width = 3,
|
|
this.offset = 2,
|
|
});
|
|
|
|
final Color color;
|
|
final Color halo;
|
|
final double width;
|
|
final double offset;
|
|
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
other is FocusRingStyle &&
|
|
other.color == color &&
|
|
other.halo == halo &&
|
|
other.width == width &&
|
|
other.offset == offset;
|
|
|
|
@override
|
|
int get hashCode => Object.hash(color, halo, width, offset);
|
|
}
|
|
|
|
/// 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,
|
|
this.paragraphGap = 0.9,
|
|
});
|
|
|
|
/// 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;
|
|
|
|
/// The gap between two paragraphs of an answer, in lines of reading text
|
|
/// (before text scaling): about a line by default, less for a dense design.
|
|
final double paragraphGap;
|
|
|
|
/// [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 &&
|
|
other.paragraphGap == paragraphGap;
|
|
|
|
@override
|
|
int get hashCode =>
|
|
Object.hash(family, height, measure, scale, figureWidth, paragraphGap);
|
|
}
|