Merge branch 'worktree-agent-abb9404cc062f4b30'
This commit is contained in:
@@ -3,6 +3,7 @@ import '../ui/adaptive/window_margins.dart';
|
||||
import '../ui/theme/app_design_controller.dart';
|
||||
import '../ui/theme/glass_backdrop.dart';
|
||||
import '../ui/theme/app_font_controller.dart';
|
||||
import '../ui/theme/design_screen_overlay.dart';
|
||||
import '../ui/scale/ui_scale.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -91,11 +92,14 @@ class MyApp extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
static Widget _scaled(BuildContext context, Widget? child) => DesignFocusRing(
|
||||
child: UiScaleHost(
|
||||
child: WindowMargins(
|
||||
child: GlassBackdrop(child: child ?? const SizedBox.shrink()),
|
||||
),
|
||||
),
|
||||
);
|
||||
static Widget _scaled(BuildContext context, Widget? child) =>
|
||||
DesignScreenOverlay(
|
||||
child: DesignFocusRing(
|
||||
child: UiScaleHost(
|
||||
child: WindowMargins(
|
||||
child: GlassBackdrop(child: child ?? const SizedBox.shrink()),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import '../../ui/adaptive/window_margins.dart';
|
||||
import '../../ui/scale/ui_scale.dart';
|
||||
import '../../ui/theme/app_font_controller.dart';
|
||||
import '../../ui/theme/app_design_controller.dart';
|
||||
import '../../ui/theme/design_screen_overlay.dart';
|
||||
import '../../ui/theme/glass_backdrop.dart';
|
||||
import '../app_route.dart';
|
||||
import '../app_session.dart';
|
||||
@@ -224,10 +225,12 @@ class _DetachedWindowAppState extends State<DetachedWindowApp> {
|
||||
: '${_title.value} · Pipelines',
|
||||
scaffoldMessengerKey: appScaffoldMessengerKey,
|
||||
debugShowCheckedModeBanner: false,
|
||||
builder: (context, child) => DesignFocusRing(
|
||||
child: UiScaleHost(
|
||||
child: WindowMargins(
|
||||
child: GlassBackdrop(child: child ?? const SizedBox.shrink()),
|
||||
builder: (context, child) => DesignScreenOverlay(
|
||||
child: DesignFocusRing(
|
||||
child: UiScaleHost(
|
||||
child: WindowMargins(
|
||||
child: GlassBackdrop(child: child ?? const SizedBox.shrink()),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -20,6 +20,7 @@ import '../ui/scale/ui_scale.dart';
|
||||
import '../ui/theme/app_design_controller.dart';
|
||||
import '../ui/theme/glass_backdrop.dart';
|
||||
import '../ui/theme/app_font_controller.dart';
|
||||
import '../ui/theme/design_screen_overlay.dart';
|
||||
import 'detached/detached_app.dart';
|
||||
import 'detached/detached_route.dart';
|
||||
import 'pipelines_app.dart';
|
||||
@@ -386,10 +387,12 @@ class _PipelinesRootState extends State<PipelinesRoot> {
|
||||
listenable: Listenable.merge([fonts, designs]),
|
||||
builder: (context, _) => MaterialApp(
|
||||
title: 'Pipelines',
|
||||
builder: (context, child) => DesignFocusRing(
|
||||
child: UiScaleHost(
|
||||
child: WindowMargins(
|
||||
child: GlassBackdrop(child: child ?? const SizedBox.shrink()),
|
||||
builder: (context, child) => DesignScreenOverlay(
|
||||
child: DesignFocusRing(
|
||||
child: UiScaleHost(
|
||||
child: WindowMargins(
|
||||
child: GlassBackdrop(child: child ?? const SizedBox.shrink()),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../domain/artifact_groups.dart';
|
||||
@@ -59,7 +61,7 @@ class _ArtifactTileState extends State<ArtifactTile> {
|
||||
// Just inside the tile's frame: its corners less the line.
|
||||
borderRadius: BorderRadius.vertical(
|
||||
top: Radius.circular(
|
||||
(AppDesignTokens.of(context).radius ?? 12) - 1,
|
||||
math.max(0, (AppDesignTokens.of(context).radius ?? 12) - 1),
|
||||
),
|
||||
),
|
||||
child: ColoredBox(color: surface, child: preview),
|
||||
|
||||
@@ -227,7 +227,11 @@ class ChatUsageRingPainter extends CustomPainter {
|
||||
width: half * 2,
|
||||
height: half * 2,
|
||||
);
|
||||
final r = Radius.circular(corner + gap + stroke / 2);
|
||||
// A square button (no corner radius) keeps a square ring; a rounded one
|
||||
// a ring with its corners offset by the gap.
|
||||
final r = corner <= 0
|
||||
? Radius.zero
|
||||
: Radius.circular(corner + gap + stroke / 2);
|
||||
final c = rect.center;
|
||||
// Built clockwise from the top centre, so the used length starts there.
|
||||
final path = Path()
|
||||
|
||||
@@ -14,9 +14,17 @@ import '../../domain/chat_colors.dart';
|
||||
/// the shade lightened or darkened until it reaches that contrast against
|
||||
/// its page, so a chat's bar reads as plainly as text.
|
||||
Color? chatColorShade(BuildContext context, String? name) {
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
final mono = tokens.monochrome;
|
||||
if (mono != null) {
|
||||
return chatMonochromeShade(
|
||||
mono,
|
||||
name,
|
||||
Theme.of(context).brightness == Brightness.dark,
|
||||
);
|
||||
}
|
||||
final shade = _materialShade(context, name);
|
||||
if (shade == null) return null;
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
final contrast = tokens.minContrast;
|
||||
if (contrast != null) {
|
||||
final page = Theme.of(context).scaffoldBackgroundColor;
|
||||
@@ -58,6 +66,20 @@ Color? _materialShade(BuildContext context, String? name) {
|
||||
};
|
||||
}
|
||||
|
||||
/// A chat colour under a monochrome design ([AppDesignTokens.monochrome]):
|
||||
/// hue is gone, so each name is its own brightness step of [phosphor], in
|
||||
/// picker order from dimmest to brightest on a dark page (deepest to palest
|
||||
/// ink on a light one), every step legible on the page. Null for no (or an
|
||||
/// unknown) colour.
|
||||
Color? chatMonochromeShade(Color phosphor, String? name, bool dark) {
|
||||
final index = name == null ? -1 : chatColorNames.indexOf(name);
|
||||
if (index < 0) return null;
|
||||
final t = index / (chatColorNames.length - 1);
|
||||
final hsl = HSLColor.fromColor(phosphor);
|
||||
final lightness = dark ? 0.30 + t * 0.58 : 0.08 + t * 0.22;
|
||||
return hsl.withLightness(lightness).withSaturation(1).toColor();
|
||||
}
|
||||
|
||||
/// Whether the surrounding theme is dark.
|
||||
bool chatColorDarkSurface(BuildContext context) =>
|
||||
Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
@@ -133,8 +133,17 @@ class TerminalActivityRows extends StatelessWidget {
|
||||
if (duration != null) formatChatToolDuration(duration),
|
||||
].join(' · ');
|
||||
}
|
||||
// Without hue, a failed or running call also takes its own glyph.
|
||||
final mono = AppDesignTokens.of(context).monochrome != null;
|
||||
final glyph = !mono
|
||||
? TerminalGlyphKind.dot
|
||||
: failed
|
||||
? TerminalGlyphKind.cross
|
||||
: running
|
||||
? TerminalGlyphKind.ring
|
||||
: TerminalGlyphKind.dot;
|
||||
return [
|
||||
_line(context, TerminalGlyphKind.dot, color, head),
|
||||
_line(context, glyph, color, head),
|
||||
if (result.isNotEmpty)
|
||||
_line(context, TerminalGlyphKind.elbow, scheme.outline, [
|
||||
TextSpan(
|
||||
|
||||
@@ -26,6 +26,13 @@ enum TerminalGlyphKind {
|
||||
|
||||
/// A bracket corner under a call: its result line.
|
||||
elbow,
|
||||
|
||||
/// A cross: a failed tool call under a monochrome design, where the dot's
|
||||
/// colour cannot say so.
|
||||
cross,
|
||||
|
||||
/// A hollow ring: a running tool call under a monochrome design.
|
||||
ring,
|
||||
}
|
||||
|
||||
/// One painted terminal glyph, a glyph column wide and one text line tall,
|
||||
@@ -74,6 +81,21 @@ class _GlyphPainter extends CustomPainter {
|
||||
..lineTo(x, h * 0.55)
|
||||
..lineTo(size.width * 0.95, h * 0.55);
|
||||
canvas.drawPath(path, paint);
|
||||
case TerminalGlyphKind.cross:
|
||||
paint
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 1.5
|
||||
..strokeCap = StrokeCap.square;
|
||||
final c = Offset(h * 0.3, h / 2);
|
||||
final r = h * 0.15;
|
||||
canvas
|
||||
..drawLine(c - Offset(r, r), c + Offset(r, r), paint)
|
||||
..drawLine(c + Offset(-r, r), c + Offset(r, -r), paint);
|
||||
case TerminalGlyphKind.ring:
|
||||
paint
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 1.25;
|
||||
canvas.drawCircle(Offset(h * 0.3, h / 2), h * 0.15, paint);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -221,8 +221,10 @@ Widget graphEdgeHighlight({
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
strokeWidth: edgeWidth * 2.5,
|
||||
// A design's own corners (the stage cards take them) plus the
|
||||
// glow's 5px spread; the Default keeps its rounder glow.
|
||||
// glow's 5px spread; the Default keeps its rounder glow, and a
|
||||
// square design (no corner radius) a square one.
|
||||
glowRadius: switch (AppDesignTokens.of(context).radius) {
|
||||
final radius? when radius <= 0 => 0,
|
||||
final radius? => radius + 5,
|
||||
null => 14,
|
||||
},
|
||||
|
||||
@@ -3,6 +3,8 @@ import 'package:flutter/material.dart';
|
||||
import 'app_design_tokens.dart';
|
||||
import 'app_theme.dart';
|
||||
import 'compact_theme.dart';
|
||||
import 'crt_palette.dart';
|
||||
import 'crt_theme.dart';
|
||||
import 'glass_theme.dart';
|
||||
import 'high_contrast_theme.dart';
|
||||
import 'notebook_theme.dart';
|
||||
@@ -85,6 +87,22 @@ enum AppDesign {
|
||||
'glass',
|
||||
'Glass',
|
||||
'Frosted panes over a soft gradient, rounded cards and gentle depth.',
|
||||
),
|
||||
|
||||
/// Terminal's structure on a monochrome tube: green phosphor shades, square
|
||||
/// frames, a faint glow and static scanlines; [retroCrtAmber] is the same
|
||||
/// design in amber.
|
||||
retroCrt(
|
||||
'retro-crt',
|
||||
'Retro CRT',
|
||||
'Terminal on a green phosphor tube: one hue, glow and scanlines.',
|
||||
),
|
||||
|
||||
/// [retroCrt] in amber phosphor.
|
||||
retroCrtAmber(
|
||||
'retro-crt-amber',
|
||||
'Retro CRT (amber)',
|
||||
'Terminal on an amber phosphor tube: one hue, glow and scanlines.',
|
||||
);
|
||||
|
||||
const AppDesign(this.id, this.label, this.description);
|
||||
@@ -142,6 +160,14 @@ enum AppDesign {
|
||||
(notebook, _) => notebookTheme(brightness, fontFamily: fontFamily),
|
||||
(highContrast, _) => highContrastTheme(brightness, fontFamily: fontFamily),
|
||||
(glass, _) => glassTheme(brightness, fontFamily: fontFamily),
|
||||
(retroCrt || retroCrtAmber, _) => crtTheme(crtPhosphor!, this, brightness),
|
||||
};
|
||||
|
||||
/// The phosphor of a Retro CRT design; null for every other design.
|
||||
CrtPhosphor? get crtPhosphor => switch (this) {
|
||||
retroCrt => CrtPhosphor.green,
|
||||
retroCrtAmber => CrtPhosphor.amber,
|
||||
_ => null,
|
||||
};
|
||||
|
||||
/// Whether this design packs the interface densely
|
||||
@@ -152,7 +178,7 @@ enum AppDesign {
|
||||
|
||||
/// 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;
|
||||
bool get usesInterfaceFont => this != terminal && crtPhosphor == null;
|
||||
|
||||
/// The picker's preview: the design's page, ink and accent in [brightness],
|
||||
/// without building its theme.
|
||||
@@ -231,6 +257,10 @@ enum AppDesign {
|
||||
Color(0xFF1A1A2B),
|
||||
Color(0xFF5546C7),
|
||||
),
|
||||
retroCrt || retroCrtAmber => () {
|
||||
final ramp = CrtRamp(crtPhosphor!, brightness);
|
||||
return DesignSwatch(ramp.page, ramp.text, ramp.accent);
|
||||
}(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -165,3 +165,28 @@ class ReadingType {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -68,6 +68,8 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
||||
this.selectedRow = SelectedRowStyle.tonal,
|
||||
this.reading = const ReadingType(),
|
||||
this.chatColorSaturation = 1,
|
||||
this.monochrome,
|
||||
this.screen,
|
||||
this.stroke = 1,
|
||||
this.ringStroke = 2,
|
||||
this.focusRing,
|
||||
@@ -123,6 +125,16 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
||||
/// palette as is, lower to quieten it towards ink.
|
||||
final double chatColorSaturation;
|
||||
|
||||
/// The one hue of a monochrome design (Retro CRT's phosphor); null for a
|
||||
/// design with colour. Under it chat colours become brightness steps of
|
||||
/// this hue, and a status that only colour told apart (a failed or running
|
||||
/// tool line) gets its own glyph too.
|
||||
final Color? monochrome;
|
||||
|
||||
/// A static pattern painted once over the whole app (Retro CRT's
|
||||
/// scanlines); null paints nothing.
|
||||
final ScreenPattern? screen;
|
||||
|
||||
/// The width of the design's frames: [frameSide], flat panels, the
|
||||
/// composer pill and the floating bar pieces (High contrast's 2px).
|
||||
final double stroke;
|
||||
@@ -249,6 +261,8 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
||||
SelectedRowStyle? selectedRow,
|
||||
ReadingType? reading,
|
||||
double? chatColorSaturation,
|
||||
Color? monochrome,
|
||||
ScreenPattern? screen,
|
||||
double? stroke,
|
||||
double? ringStroke,
|
||||
FocusRingStyle? focusRing,
|
||||
@@ -271,6 +285,8 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
||||
selectedRow: selectedRow ?? this.selectedRow,
|
||||
reading: reading ?? this.reading,
|
||||
chatColorSaturation: chatColorSaturation ?? this.chatColorSaturation,
|
||||
monochrome: monochrome ?? this.monochrome,
|
||||
screen: screen ?? this.screen,
|
||||
stroke: stroke ?? this.stroke,
|
||||
ringStroke: ringStroke ?? this.ringStroke,
|
||||
focusRing: focusRing ?? this.focusRing,
|
||||
@@ -300,6 +316,8 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
||||
other.selectedRow == selectedRow &&
|
||||
other.reading == reading &&
|
||||
other.chatColorSaturation == chatColorSaturation &&
|
||||
other.monochrome == monochrome &&
|
||||
other.screen == screen &&
|
||||
other.stroke == stroke &&
|
||||
other.ringStroke == ringStroke &&
|
||||
other.focusRing == focusRing &&
|
||||
@@ -324,6 +342,8 @@ class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
||||
selectedRow,
|
||||
reading,
|
||||
chatColorSaturation,
|
||||
monochrome,
|
||||
screen,
|
||||
stroke,
|
||||
ringStroke,
|
||||
focusRing,
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'app_design_tokens.dart';
|
||||
|
||||
/// A CRT phosphor: the one hue Retro CRT draws everything in, and how light
|
||||
/// its normal text glows on the dark tube ([text] lightness), since equal
|
||||
/// lightness looks brighter in amber than in green.
|
||||
enum CrtPhosphor {
|
||||
/// P1 green, `#33FF66` text on a green-black tube.
|
||||
green(135, 0.60),
|
||||
|
||||
/// P3 amber, `#FFAA00` text on a brown-black tube.
|
||||
amber(40, 0.50);
|
||||
|
||||
const CrtPhosphor(this.hue, this.text);
|
||||
|
||||
/// The phosphor's hue in degrees.
|
||||
final double hue;
|
||||
|
||||
/// The HSL lightness of normal text on the dark tube.
|
||||
final double text;
|
||||
|
||||
/// The phosphor at [lightness] and [saturation].
|
||||
Color at(double lightness, [double saturation = 1]) =>
|
||||
HSLColor.fromAHSL(1, hue, saturation, lightness).toColor();
|
||||
}
|
||||
|
||||
/// The lightness steps of one phosphor, darkest page to brightest glow (dark
|
||||
/// tube) or palest page to deepest ink (paper-white phosphor in light).
|
||||
/// Brightness, never hue, tells roles apart: dim secondary text, normal text,
|
||||
/// a brighter accent, a brighter warning and the brightest error (each of
|
||||
/// those statuses also has its own glyph or icon).
|
||||
class CrtRamp {
|
||||
CrtRamp(this.phosphor, this.brightness);
|
||||
|
||||
final CrtPhosphor phosphor;
|
||||
final Brightness brightness;
|
||||
|
||||
bool get _dark => brightness == Brightness.dark;
|
||||
|
||||
/// A surface step: pages and containers, barely tinted.
|
||||
Color surface(double darkL, double lightL) =>
|
||||
phosphor.at(_dark ? darkL : lightL, _dark ? 0.45 : 0.40);
|
||||
|
||||
Color get page => surface(0.03, 0.93);
|
||||
Color get frame => phosphor.at(_dark ? 0.20 : 0.70, _dark ? 0.75 : 0.32);
|
||||
Color get outline => phosphor.at(_dark ? 0.32 : 0.48, _dark ? 0.75 : 0.40);
|
||||
Color get dim => phosphor.at(_dark ? 0.42 : 0.28, 0.70);
|
||||
Color get text => phosphor.at(_dark ? phosphor.text : 0.17);
|
||||
Color get accent => phosphor.at(_dark ? phosphor.text + 0.15 : 0.22);
|
||||
Color get warning => phosphor.at(_dark ? phosphor.text + 0.20 : 0.12);
|
||||
|
||||
/// Success sits below normal text: a finished call is the calm case, so
|
||||
/// the brighter steps are left for what needs a look.
|
||||
Color get success => phosphor.at(_dark ? phosphor.text - 0.16 : 0.28);
|
||||
Color get error => phosphor.at(_dark ? 0.93 : 0.07);
|
||||
|
||||
/// A container tone under [ink]: dark tube containers glow a little, the
|
||||
/// light page's sit a step deeper than the page.
|
||||
Color container(double darkL, double lightL) =>
|
||||
phosphor.at(_dark ? darkL : lightL, _dark ? 0.6 : 0.45);
|
||||
|
||||
/// The status accents, as brightness steps: success a step below normal
|
||||
/// text, running a step above it, waiting and warnings brighter, errors
|
||||
/// brightest.
|
||||
AnsiAccents get ansi => AnsiAccents(
|
||||
green: success,
|
||||
cyan: phosphor.at(_dark ? phosphor.text - 0.08 : 0.24),
|
||||
yellow: warning,
|
||||
red: error,
|
||||
magenta: dim,
|
||||
blue: accent,
|
||||
);
|
||||
}
|
||||
|
||||
/// Retro CRT's colour scheme for [phosphor] in [brightness]: every colour a
|
||||
/// shade of the one hue.
|
||||
ColorScheme crtColorScheme(CrtPhosphor phosphor, Brightness brightness) {
|
||||
final r = CrtRamp(phosphor, brightness);
|
||||
final page = r.page;
|
||||
return ColorScheme(
|
||||
brightness: brightness,
|
||||
primary: r.accent,
|
||||
onPrimary: page,
|
||||
primaryContainer: r.container(0.14, 0.82),
|
||||
onPrimaryContainer: r.accent,
|
||||
secondary: r.text,
|
||||
onSecondary: page,
|
||||
secondaryContainer: r.container(0.11, 0.86),
|
||||
onSecondaryContainer: r.text,
|
||||
tertiary: r.warning,
|
||||
onTertiary: page,
|
||||
tertiaryContainer: r.container(0.17, 0.78),
|
||||
onTertiaryContainer: r.warning,
|
||||
error: r.error,
|
||||
onError: page,
|
||||
errorContainer: r.container(0.20, 0.74),
|
||||
onErrorContainer: r.error,
|
||||
surface: page,
|
||||
onSurface: r.text,
|
||||
onSurfaceVariant: r.dim,
|
||||
surfaceDim: page,
|
||||
surfaceBright: r.surface(0.14, 0.97),
|
||||
surfaceContainerLowest: r.surface(0.02, 0.97),
|
||||
surfaceContainerLow: r.surface(0.05, 0.90),
|
||||
surfaceContainer: r.surface(0.065, 0.87),
|
||||
surfaceContainerHigh: r.surface(0.08, 0.84),
|
||||
surfaceContainerHighest: r.surface(0.10, 0.80),
|
||||
outline: r.outline,
|
||||
outlineVariant: r.frame,
|
||||
shadow: const Color(0xFF000000),
|
||||
scrim: const Color(0xFF000000),
|
||||
inverseSurface: r.text,
|
||||
onInverseSurface: page,
|
||||
inversePrimary: r.dim,
|
||||
surfaceTint: const Color(0x00000000),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'app_design.dart';
|
||||
import 'app_design_tokens.dart';
|
||||
import 'crt_palette.dart';
|
||||
import 'terminal_theme.dart';
|
||||
|
||||
/// Retro CRT's corner radius: square, like a character cell.
|
||||
const double crtRadius = 0;
|
||||
|
||||
/// The Retro CRT design's theme: Terminal's structure (monospace, prompt
|
||||
/// transcript, flat framed surfaces) in one [phosphor]'s shades, square
|
||||
/// corners, 1px phosphor frames, a faint glow under every text role and a
|
||||
/// static scanline pattern over the app ([AppDesignTokens.screen]).
|
||||
///
|
||||
/// Dark is the tube: the phosphor glowing on near-black. Light is a
|
||||
/// "paper-white phosphor": deep phosphor ink on a pale tinted page, without
|
||||
/// glow (a halo round dark ink reads as smudge) and with scanlines faint
|
||||
/// enough to read as texture only.
|
||||
ThemeData crtTheme(
|
||||
CrtPhosphor phosphor,
|
||||
AppDesign design,
|
||||
Brightness brightness,
|
||||
) {
|
||||
final scheme = crtColorScheme(phosphor, brightness);
|
||||
final ramp = CrtRamp(phosphor, brightness);
|
||||
final dark = brightness == Brightness.dark;
|
||||
final tokens = AppDesignTokens(
|
||||
design: design,
|
||||
radius: crtRadius,
|
||||
flat: true,
|
||||
frame: scheme.outlineVariant,
|
||||
panel: scheme.surfaceContainerLow,
|
||||
ansi: ramp.ansi,
|
||||
transcript: TranscriptStyle.prompt,
|
||||
selectedRow: SelectedRowStyle.framed,
|
||||
monochrome: ramp.text,
|
||||
screen: dark
|
||||
? const ScreenPattern(scanline: Color(0x29000000))
|
||||
: ScreenPattern(scanline: ramp.text.withValues(alpha: 0.035)),
|
||||
// A blend into or out of the glow passes every text shadow through a
|
||||
// near-zero blur; in the browser (skwasm) that corrupted paragraph
|
||||
// layout and hung the page within a few live switches.
|
||||
snapSwitch: true,
|
||||
);
|
||||
final theme = terminalStructureTheme(
|
||||
scheme,
|
||||
tokens,
|
||||
glow: dark
|
||||
? [Shadow(color: ramp.text.withValues(alpha: 0.38), blurRadius: 3)]
|
||||
: null,
|
||||
);
|
||||
return theme.copyWith(
|
||||
textSelectionTheme: TextSelectionThemeData(
|
||||
cursorColor: scheme.primary,
|
||||
selectionColor: ramp.text.withValues(alpha: dark ? 0.28 : 0.22),
|
||||
selectionHandleColor: scheme.primary,
|
||||
),
|
||||
iconTheme: theme.iconTheme.copyWith(color: scheme.onSurface),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'app_design_tokens.dart';
|
||||
|
||||
/// [child] under the design's [AppDesignTokens.screen] pattern (Retro CRT's
|
||||
/// scanlines), or [child] alone under a design without one.
|
||||
///
|
||||
/// The pattern is one [CustomPaint] in its own [RepaintBoundary]: it paints
|
||||
/// once (again only on a resize, a pixel-ratio change or a design switch)
|
||||
/// and the compositor reuses its picture every frame. It adds no saveLayer,
|
||||
/// no filter and no animation, ignores the pointer and has no semantics.
|
||||
/// [child] stays the Stack's first child either way, so switching to or
|
||||
/// from a patterned design never remounts the app beneath.
|
||||
class DesignScreenOverlay extends StatelessWidget {
|
||||
const DesignScreenOverlay({super.key, required this.child});
|
||||
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final pattern = AppDesignTokens.of(context).screen;
|
||||
return Stack(
|
||||
fit: StackFit.passthrough,
|
||||
children: [
|
||||
child,
|
||||
if (pattern != null)
|
||||
Positioned.fill(
|
||||
child: IgnorePointer(
|
||||
child: RepaintBoundary(
|
||||
key: const Key('design-screen-overlay'),
|
||||
child: CustomPaint(
|
||||
painter: ScreenPatternPainter(
|
||||
pattern,
|
||||
MediaQuery.devicePixelRatioOf(context),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Paints a [ScreenPattern]: its scanlines as one path of thin rectangles,
|
||||
/// snapped to device pixels and filled solid without anti-aliasing. One draw
|
||||
/// with no shader: a full-screen gradient (and a vignette tried with it)
|
||||
/// doubled the CPU raster time per frame in the browser bench, while solid
|
||||
/// bands touch only a third of the pixels and blend at memory speed.
|
||||
class ScreenPatternPainter extends CustomPainter {
|
||||
const ScreenPatternPainter(this.pattern, this.pixelRatio);
|
||||
|
||||
final ScreenPattern pattern;
|
||||
final double pixelRatio;
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final period = pattern.period.clamp(2, 12);
|
||||
final band = (period / 3).round().clamp(1, period - 1);
|
||||
// In logical pixels, on device-pixel boundaries.
|
||||
final step = period / pixelRatio;
|
||||
final height = band / pixelRatio;
|
||||
final lines = Path();
|
||||
for (var y = step - height; y < size.height; y += step) {
|
||||
lines.addRect(Rect.fromLTWH(0, y, size.width, height));
|
||||
}
|
||||
canvas.drawPath(
|
||||
lines,
|
||||
Paint()
|
||||
..color = pattern.scanline
|
||||
..isAntiAlias = false,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(ScreenPatternPainter old) =>
|
||||
old.pattern != pattern || old.pixelRatio != pixelRatio;
|
||||
}
|
||||
@@ -12,11 +12,9 @@ import 'terminal_typography.dart';
|
||||
/// enough not to alias.
|
||||
const double terminalRadius = 3;
|
||||
|
||||
/// One tab indicator per brightness: [UnderlineTabIndicator] compares by
|
||||
/// One tab indicator per accent: [UnderlineTabIndicator] compares by
|
||||
/// identity, so a fresh one would make a rebuilt theme unequal to the last.
|
||||
final Map<Brightness, Decoration> _tabIndicators = {};
|
||||
|
||||
const BorderRadius _corners = BorderRadius.all(Radius.circular(terminalRadius));
|
||||
final Map<Color, Decoration> _tabIndicators = {};
|
||||
|
||||
/// The Terminal design's theme: the bundled monospace family everywhere,
|
||||
/// compact text, flat surfaces with 1px dim frames and no elevation, and
|
||||
@@ -28,9 +26,37 @@ ThemeData terminalTheme(Brightness brightness) {
|
||||
final ansi = brightness == Brightness.dark
|
||||
? terminalDarkAnsi
|
||||
: terminalLightAnsi;
|
||||
final frame = BorderSide(color: scheme.outlineVariant);
|
||||
final framed = RoundedRectangleBorder(borderRadius: _corners, side: frame);
|
||||
const square = RoundedRectangleBorder(borderRadius: _corners);
|
||||
return terminalStructureTheme(
|
||||
scheme,
|
||||
AppDesignTokens(
|
||||
design: AppDesign.terminal,
|
||||
radius: terminalRadius,
|
||||
flat: true,
|
||||
frame: scheme.outlineVariant,
|
||||
ansi: ansi,
|
||||
transcript: TranscriptStyle.prompt,
|
||||
selectedRow: SelectedRowStyle.framed,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Terminal's structure over [scheme]: monospace text, flat framed surfaces,
|
||||
/// no elevation and the same corners on every Material component. [tokens]
|
||||
/// is the design's extension; its [AppDesignTokens.radius] shapes every
|
||||
/// corner and its [AppDesignTokens.frame] every hairline. A design built on
|
||||
/// Terminal (Retro CRT) passes its own scheme and tokens, and [glow] for a
|
||||
/// shadow under every text role.
|
||||
ThemeData terminalStructureTheme(
|
||||
ColorScheme scheme,
|
||||
AppDesignTokens tokens, {
|
||||
List<Shadow>? glow,
|
||||
}) {
|
||||
final corners = BorderRadius.all(
|
||||
Radius.circular(tokens.radius ?? terminalRadius),
|
||||
);
|
||||
final frame = BorderSide(color: tokens.frame ?? scheme.outlineVariant);
|
||||
final framed = RoundedRectangleBorder(borderRadius: corners, side: frame);
|
||||
final square = RoundedRectangleBorder(borderRadius: corners);
|
||||
final base = ThemeData(
|
||||
platform: kIsWeb ? TargetPlatform.android : null,
|
||||
colorScheme: scheme,
|
||||
@@ -42,21 +68,11 @@ ThemeData terminalTheme(Brightness brightness) {
|
||||
splashFactory: NoSplash.splashFactory,
|
||||
shadowColor: const Color(0x00000000),
|
||||
dividerColor: scheme.outlineVariant,
|
||||
extensions: [
|
||||
AppDesignTokens(
|
||||
design: AppDesign.terminal,
|
||||
radius: terminalRadius,
|
||||
flat: true,
|
||||
frame: scheme.outlineVariant,
|
||||
ansi: ansi,
|
||||
transcript: TranscriptStyle.prompt,
|
||||
selectedRow: SelectedRowStyle.framed,
|
||||
),
|
||||
],
|
||||
extensions: [tokens],
|
||||
);
|
||||
ButtonStyle buttons(ButtonStyle? style) =>
|
||||
(style ?? const ButtonStyle()).copyWith(
|
||||
shape: const WidgetStatePropertyAll(square),
|
||||
shape: WidgetStatePropertyAll(square),
|
||||
elevation: const WidgetStatePropertyAll(0),
|
||||
shadowColor: const WidgetStatePropertyAll(Color(0x00000000)),
|
||||
);
|
||||
@@ -67,14 +83,14 @@ ThemeData terminalTheme(Brightness brightness) {
|
||||
surfaceTintColor: const WidgetStatePropertyAll(Color(0x00000000)),
|
||||
shape: WidgetStatePropertyAll(
|
||||
RoundedRectangleBorder(
|
||||
borderRadius: _corners,
|
||||
borderRadius: corners,
|
||||
side: BorderSide(color: scheme.outline),
|
||||
),
|
||||
),
|
||||
);
|
||||
return base.copyWith(
|
||||
textTheme: terminalTextTheme(base.textTheme),
|
||||
primaryTextTheme: terminalTextTheme(base.primaryTextTheme),
|
||||
textTheme: terminalTextTheme(base.textTheme, glow: glow),
|
||||
primaryTextTheme: terminalTextTheme(base.primaryTextTheme, glow: glow),
|
||||
appBarTheme: AppBarTheme(
|
||||
backgroundColor: scheme.surface,
|
||||
surfaceTintColor: const Color(0x00000000),
|
||||
@@ -95,7 +111,7 @@ ThemeData terminalTheme(Brightness brightness) {
|
||||
surfaceTintColor: const Color(0x00000000),
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: _corners,
|
||||
borderRadius: corners,
|
||||
side: BorderSide(color: scheme.outline),
|
||||
),
|
||||
),
|
||||
@@ -106,7 +122,7 @@ ThemeData terminalTheme(Brightness brightness) {
|
||||
elevation: 0,
|
||||
modalElevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: _corners,
|
||||
borderRadius: corners,
|
||||
side: BorderSide(color: scheme.outline),
|
||||
),
|
||||
),
|
||||
@@ -115,7 +131,7 @@ ThemeData terminalTheme(Brightness brightness) {
|
||||
surfaceTintColor: const Color(0x00000000),
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: _corners,
|
||||
borderRadius: corners,
|
||||
side: BorderSide(color: scheme.outline),
|
||||
),
|
||||
),
|
||||
@@ -152,7 +168,7 @@ ThemeData terminalTheme(Brightness brightness) {
|
||||
backgroundColor: scheme.surfaceContainerHigh,
|
||||
foregroundColor: scheme.primary,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: _corners,
|
||||
borderRadius: corners,
|
||||
side: BorderSide(color: scheme.outline),
|
||||
),
|
||||
),
|
||||
@@ -168,13 +184,13 @@ ThemeData terminalTheme(Brightness brightness) {
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
isDense: true,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: _corners,
|
||||
borderRadius: corners,
|
||||
borderSide: BorderSide(color: scheme.outline),
|
||||
),
|
||||
),
|
||||
searchBarTheme: SearchBarThemeData(
|
||||
elevation: const WidgetStatePropertyAll(0),
|
||||
shape: const WidgetStatePropertyAll(square),
|
||||
shape: WidgetStatePropertyAll(square),
|
||||
side: WidgetStatePropertyAll(BorderSide(color: scheme.outline)),
|
||||
backgroundColor: WidgetStatePropertyAll(scheme.surfaceContainerLow),
|
||||
),
|
||||
@@ -191,7 +207,7 @@ ThemeData terminalTheme(Brightness brightness) {
|
||||
indicatorShape: square,
|
||||
surfaceTintColor: const Color(0x00000000),
|
||||
),
|
||||
listTileTheme: const ListTileThemeData(shape: square),
|
||||
listTileTheme: ListTileThemeData(shape: square),
|
||||
dividerTheme: DividerThemeData(
|
||||
color: scheme.outlineVariant,
|
||||
thickness: 1,
|
||||
@@ -200,7 +216,7 @@ ThemeData terminalTheme(Brightness brightness) {
|
||||
tabBarTheme: TabBarThemeData(
|
||||
dividerColor: scheme.outlineVariant,
|
||||
indicatorSize: TabBarIndicatorSize.tab,
|
||||
indicator: _tabIndicators[brightness] ??= UnderlineTabIndicator(
|
||||
indicator: _tabIndicators[scheme.primary] ??= UnderlineTabIndicator(
|
||||
borderSide: BorderSide(color: scheme.primary, width: 2),
|
||||
),
|
||||
),
|
||||
@@ -209,23 +225,25 @@ ThemeData terminalTheme(Brightness brightness) {
|
||||
contentTextStyle: TextStyle(
|
||||
color: scheme.onSurface,
|
||||
fontFamily: appMonospaceFamily,
|
||||
shadows: glow,
|
||||
),
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: _corners,
|
||||
borderRadius: corners,
|
||||
side: BorderSide(color: scheme.outline),
|
||||
),
|
||||
),
|
||||
tooltipTheme: TooltipThemeData(
|
||||
decoration: BoxDecoration(
|
||||
color: scheme.surfaceContainerHighest,
|
||||
borderRadius: _corners,
|
||||
borderRadius: corners,
|
||||
border: Border.all(color: scheme.outline),
|
||||
),
|
||||
textStyle: TextStyle(
|
||||
color: scheme.onSurface,
|
||||
fontFamily: appMonospaceFamily,
|
||||
fontSize: 12,
|
||||
shadows: glow,
|
||||
),
|
||||
),
|
||||
scrollbarTheme: const ScrollbarThemeData(radius: Radius.zero),
|
||||
|
||||
@@ -3,8 +3,9 @@ import 'package:flutter/material.dart';
|
||||
import '../text/monospace.dart';
|
||||
|
||||
/// [base] in the monospace family at a terminal's compact size: Material's
|
||||
/// roles a step smaller (monospace runs wide), with no added letter spacing.
|
||||
TextTheme terminalTextTheme(TextTheme base) {
|
||||
/// roles a step smaller (monospace runs wide), with no added letter spacing,
|
||||
/// and [glow] (Retro CRT's phosphor halo) as every role's shadow.
|
||||
TextTheme terminalTextTheme(TextTheme base, {List<Shadow>? glow}) {
|
||||
TextStyle? mono(TextStyle? style) {
|
||||
if (style == null) return null;
|
||||
final size = style.fontSize;
|
||||
@@ -12,6 +13,7 @@ TextTheme terminalTextTheme(TextTheme base) {
|
||||
fontFamily: appMonospaceFamily,
|
||||
fontSize: size == null ? null : (size * 0.875).roundToDouble(),
|
||||
letterSpacing: 0,
|
||||
shadows: glow,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user