Files
pipelines/app/lib/ui/theme/app_design_styles.dart
T
alan 6fc6f1c001 Merge branch 'main' into worktree-agent-abb9404cc062f4b30
# Conflicts:
#	app/lib/ui/theme/app_design.dart
#	app/lib/ui/theme/app_design_tokens.dart
2026-12-03 23:21:54 +00:00

146 lines
4.8 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,
}
/// 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,
}
/// 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,
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);
}
/// A static pattern a design lays over the whole app, painted once into its
/// own layer (see `DesignScreenOverlay`): horizontal scanlines and a soft
/// vignette darkening the corners. It never animates and never repaints with
/// the content beneath it.
@immutable
class ScreenPattern {
const ScreenPattern({required this.scanline, this.period = 3, this.vignette});
/// The colour of each scanline's dark band (a translucent shade).
final Color scanline;
/// The distance between scanlines in device pixels; each dark band is a
/// third of it (at least one device pixel), so lines stay crisp at any
/// pixel ratio.
final int period;
/// The colour the corners fade to, transparent at the centre; null for
/// no vignette.
final Color? vignette;
@override
bool operator ==(Object other) =>
other is ScreenPattern &&
other.scanline == scanline &&
other.period == period &&
other.vignette == vignette;
@override
int get hashCode => Object.hash(scanline, period, vignette);
}