beb6c90ebb
# Conflicts: # app/lib/ui/theme/app_design.dart
149 lines
5.0 KiB
Dart
149 lines
5.0 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,
|
|
|
|
/// 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,
|
|
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. It never
|
|
/// animates and never repaints with the content beneath it.
|
|
@immutable
|
|
class ScreenPattern {
|
|
const ScreenPattern({required this.scanline, this.period = 3});
|
|
|
|
/// 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;
|
|
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
other is ScreenPattern &&
|
|
other.scanline == scanline &&
|
|
other.period == period;
|
|
|
|
@override
|
|
int get hashCode => Object.hash(scanline, period);
|
|
}
|