ca2f7eee32
AppDesign builds each design's light and dark ThemeData with an AppDesignTokens extension (corner radius, flat surfaces, frame colour, ANSI accents, prompt glyph). Settings gains a Design picker stored per device; the theme hosts rebuild live. Terminal is monospace (bundled RobotoMono), near-black or paper, flat 1px frames with 3px corners, and draws the chat transcript as prompt lines, tool dot/result lines and bracketed follow-up lines. Default keeps its exact themes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
109 lines
3.2 KiB
Dart
109 lines
3.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'app_design.dart';
|
|
|
|
/// The muted ANSI-style accents a design names for status and roles. The
|
|
/// Default design leaves them to its colour scheme; Terminal sets them.
|
|
@immutable
|
|
class AnsiAccents {
|
|
const AnsiAccents({
|
|
required this.green,
|
|
required this.cyan,
|
|
required this.yellow,
|
|
required this.red,
|
|
required this.magenta,
|
|
required this.blue,
|
|
});
|
|
|
|
final Color green;
|
|
final Color cyan;
|
|
final Color yellow;
|
|
final Color red;
|
|
final Color magenta;
|
|
final Color blue;
|
|
}
|
|
|
|
/// The design-specific facts widgets read instead of hard-coding one look:
|
|
/// corner shapes, whether surfaces are flat, frame colour and how the chat
|
|
/// transcript is drawn. Every theme an [AppDesign] builds carries one; a
|
|
/// theme without one (a test's bare `ThemeData`) reads as [standard].
|
|
@immutable
|
|
class AppDesignTokens extends ThemeExtension<AppDesignTokens> {
|
|
const AppDesignTokens({
|
|
required this.design,
|
|
this.radius,
|
|
this.flat = false,
|
|
this.frame,
|
|
this.ansi,
|
|
this.promptGlyph = '>',
|
|
});
|
|
|
|
/// The Default design: every widget keeps its own shapes.
|
|
static const AppDesignTokens standard = AppDesignTokens(
|
|
design: AppDesign.standard,
|
|
);
|
|
|
|
final AppDesign design;
|
|
|
|
/// The corner radius of framed surfaces (cards, pills, the composer,
|
|
/// bubbles); null keeps each widget's own shape.
|
|
final double? radius;
|
|
|
|
/// Whether surfaces are flat: no frosted glass, blur, highlight or shadow.
|
|
final bool flat;
|
|
|
|
/// The 1px frame colour around flat surfaces; null keeps each widget's own.
|
|
final Color? frame;
|
|
|
|
/// The design's ANSI-style accents; null for a design that uses its colour
|
|
/// scheme's roles.
|
|
final AnsiAccents? ansi;
|
|
|
|
/// The glyph before the operator's prompt line and the composer's field.
|
|
final String promptGlyph;
|
|
|
|
/// Whether the transcript draws prompt and tool lines rather than bubbles.
|
|
bool get terminal => design == AppDesign.terminal;
|
|
|
|
/// The tokens of the theme at [context]; [standard] when it has none.
|
|
static AppDesignTokens of(BuildContext context) =>
|
|
Theme.of(context).extension<AppDesignTokens>() ?? standard;
|
|
|
|
/// [designed] as this design draws it: the widget's own shape, or a
|
|
/// rectangle with [radius] corners.
|
|
OutlinedBorder shape(OutlinedBorder designed) {
|
|
final r = radius;
|
|
if (r == null) return designed;
|
|
return RoundedRectangleBorder(borderRadius: BorderRadius.circular(r));
|
|
}
|
|
|
|
/// [designed] corners, or [radius] corners under a design that sets it.
|
|
BorderRadius corners(BorderRadius designed) {
|
|
final r = radius;
|
|
return r == null ? designed : BorderRadius.circular(r);
|
|
}
|
|
|
|
@override
|
|
AppDesignTokens copyWith({
|
|
AppDesign? design,
|
|
double? radius,
|
|
bool? flat,
|
|
Color? frame,
|
|
AnsiAccents? ansi,
|
|
String? promptGlyph,
|
|
}) => AppDesignTokens(
|
|
design: design ?? this.design,
|
|
radius: radius ?? this.radius,
|
|
flat: flat ?? this.flat,
|
|
frame: frame ?? this.frame,
|
|
ansi: ansi ?? this.ansi,
|
|
promptGlyph: promptGlyph ?? this.promptGlyph,
|
|
);
|
|
|
|
/// Designs switch whole: a theme animation snaps halfway rather than
|
|
/// blending two designs' shapes.
|
|
@override
|
|
AppDesignTokens lerp(AppDesignTokens? other, double t) =>
|
|
other == null || t < 0.5 ? this : other;
|
|
}
|