Files
pipelines/app/lib/ui/theme/app_design.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

142 lines
4.7 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/material.dart';
import 'app_design_tokens.dart';
import 'app_theme.dart';
import 'paper_theme.dart';
import 'terminal_theme.dart';
/// An app-wide design: how every surface is shaped, typed and coloured, not
/// only a colour. Each design builds a light and a dark [ThemeData] carrying
/// its [AppDesignTokens], so widgets that draw design-specific shapes read the
/// tokens instead of hard-coding one look.
///
/// Adding a design:
/// 1. add a value here with a stable [id], a [label] and a one-line
/// [description] (the Settings picker lists [AppDesign.values]);
/// 2. write its theme builder (`<name>_theme.dart` beside this file, with a
/// palette and, when it needs one, its own typography) and return it from
/// [light] and [dark];
/// 3. give the theme an [AppDesignTokens] extension: set only the tokens it
/// changes (corners, flat surfaces, frame, panel fill, transcript,
/// composer and selected-row styles, reading type); every token defaults
/// to the Default look;
/// 4. give it a [swatch] for the picker and say whether it [usesInterfaceFont].
/// Widgets read the tokens, so most surfaces follow without per-widget code.
enum AppDesign {
/// The app's own Material look.
standard('default', 'Default', 'The app’s Material look.'),
/// A terminal-style look: monospace text, near-black pages, thin frames
/// and a transcript drawn as prompt and tool lines.
terminal(
'terminal',
'Terminal',
'Monospace, flat frames and prompt-style chat, like a CLI agent.',
),
/// A calm reading look: a warm paper page, a serif for reading, ink
/// colours, hairline rules and the chat set as a typeset page.
paper(
'paper',
'Paper',
'Warm paper, serif reading text and ink colours; calm for long reads.',
);
const AppDesign(this.id, this.label, this.description);
/// The stored value; stable across releases and renames.
final String id;
/// The picker's name for the design.
final String label;
/// The picker's one-line summary of the design.
final String description;
/// The design stored as [id], or [standard] for an unknown or missing id.
static AppDesign fromId(String? id) {
for (final design in values) {
if (design.id == id) return design;
}
return standard;
}
/// The design's light theme. [fontFamily] is the device's interface font;
/// a design with its own family (Terminal's monospace) keeps that instead.
ThemeData light({String? fontFamily}) => switch (this) {
standard => appLightTheme(fontFamily: fontFamily),
terminal => terminalTheme(Brightness.light),
paper => paperTheme(Brightness.light, fontFamily: fontFamily),
};
/// The design's dark theme; see [light].
ThemeData dark({String? fontFamily}) => switch (this) {
standard => appDarkTheme(fontFamily: fontFamily),
terminal => terminalTheme(Brightness.dark),
paper => paperTheme(Brightness.dark, fontFamily: fontFamily),
};
/// Whether the device's interface font applies under this design (Paper
/// keeps it for its interface text and sets reading text in its serif).
bool get usesInterfaceFont => this != terminal;
/// The picker's preview: the design's page, ink and accent in [brightness],
/// without building its theme.
DesignSwatch swatch(Brightness brightness) {
final dark = brightness == Brightness.dark;
return switch (this) {
standard =>
dark
? const DesignSwatch(
Color(0xFF141416),
Color(0xFFE6E0E9),
Color(0xFFCFBDFE),
)
: const DesignSwatch(
Color(0xFFFDF7FF),
Color(0xFF1D1B20),
Color(0xFF65558F),
),
terminal =>
dark
? const DesignSwatch(
Color(0xFF0B0B0B),
Color(0xFFD7D7D2),
Color(0xFF8CC38F),
)
: const DesignSwatch(
Color(0xFFF7F6F1),
Color(0xFF1E1E1C),
Color(0xFF2F7434),
),
paper =>
dark
? const DesignSwatch(
Color(0xFF1E1B17),
Color(0xFFE9E1D3),
Color(0xFF9DB4DC),
)
: const DesignSwatch(
Color(0xFFF8F4EB),
Color(0xFF221E19),
Color(0xFF2C4F86),
),
};
}
}
/// A design's three defining colours, for the picker's small preview.
@immutable
class DesignSwatch {
const DesignSwatch(this.page, this.ink, this.accent);
/// The page (scaffold) colour.
final Color page;
/// The main text colour.
final Color ink;
/// The accent (primary) colour.
final Color accent;
}