App: add a selectable app design with a Terminal look
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>
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import 'dart:ui' show SemanticsRole;
|
||||
|
||||
import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
|
||||
import '../theme/app_design_tokens.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../motion/motion.dart';
|
||||
@@ -109,18 +111,22 @@ class FloatingTabButton extends StatelessWidget {
|
||||
({Color tint, Color selectedIcon, Color icon}) colors,
|
||||
double t,
|
||||
) {
|
||||
// A flat design (Terminal) squares the button and its fill.
|
||||
final shape = AppDesignTokens.of(context).shape(const CircleBorder());
|
||||
final decoration = ShapeDecoration(
|
||||
color: colors.tint.withValues(alpha: colors.tint.a * t),
|
||||
shape: const CircleBorder(),
|
||||
shape: shape,
|
||||
);
|
||||
final Widget fill = Ink(
|
||||
key: fillKey,
|
||||
decoration: decoration,
|
||||
child: InkResponse(
|
||||
onTap: enabled ? onTap : null,
|
||||
customBorder: const CircleBorder(),
|
||||
customBorder: shape,
|
||||
containedInkWell: true,
|
||||
highlightShape: BoxShape.circle,
|
||||
highlightShape: shape is CircleBorder
|
||||
? BoxShape.circle
|
||||
: BoxShape.rectangle,
|
||||
),
|
||||
);
|
||||
Widget glyph = IconTheme.merge(
|
||||
@@ -147,7 +153,7 @@ class FloatingTabButton extends StatelessWidget {
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: GlassPill(shape: const CircleBorder(), child: fill),
|
||||
child: GlassPill(shape: shape, child: fill),
|
||||
),
|
||||
IgnorePointer(child: glyph),
|
||||
],
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../theme/app_design_tokens.dart';
|
||||
import 'glass_surface.dart';
|
||||
|
||||
/// A frosted-glass piece floating over content: the content behind is
|
||||
@@ -60,20 +61,28 @@ class GlassPill extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _build(BuildContext context, double reveal, Widget child) {
|
||||
final solid = MediaQuery.maybeHighContrastOf(context) ?? false;
|
||||
// A flat design (Terminal) draws a solid piece in its own corners with
|
||||
// its 1px frame: no blur, highlight, rim or shadow.
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
final flat = tokens.flat;
|
||||
final solid = flat || (MediaQuery.maybeHighContrastOf(context) ?? false);
|
||||
final shape = tokens.shape(this.shape);
|
||||
final textDirection = Directionality.maybeOf(context);
|
||||
final Color base;
|
||||
final Color edge;
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
base = scheme.surfaceContainerHigh;
|
||||
edge = scheme.outlineVariant;
|
||||
base = flat ? scheme.surfaceContainerLow : scheme.surfaceContainerHigh;
|
||||
edge = flat ? tokens.frame ?? scheme.outline : scheme.outlineVariant;
|
||||
final opaque = fill ?? (solid ? base : base.withValues(alpha: fillOpacity));
|
||||
final color = opaque.withValues(alpha: opaque.a * reveal);
|
||||
final look = GlassLook.forFill(opaque);
|
||||
Color faded(Color c, [double by = 1]) =>
|
||||
c.withValues(alpha: c.a * by * reveal);
|
||||
final border = shape.copyWith(
|
||||
side: BorderSide(color: faded(edge, solid ? 1 : 0.6), width: 0.5),
|
||||
side: BorderSide(
|
||||
color: faded(edge, solid ? 1 : 0.6),
|
||||
width: flat ? 1 : 0.5,
|
||||
),
|
||||
);
|
||||
Widget content = Material(type: MaterialType.transparency, child: child);
|
||||
if (!solid) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../theme/app_design_tokens.dart';
|
||||
import 'package:flutter/physics.dart';
|
||||
|
||||
import '../motion/motion.dart';
|
||||
@@ -122,7 +123,7 @@ class _SegmentedPressState extends State<SegmentedPress>
|
||||
child: DecoratedBox(
|
||||
position: DecorationPosition.foreground,
|
||||
decoration: ShapeDecoration(
|
||||
shape: const StadiumBorder(),
|
||||
shape: AppDesignTokens.of(context).shape(const StadiumBorder()),
|
||||
color: tint.withValues(
|
||||
alpha:
|
||||
tint.a *
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../theme/app_design_tokens.dart';
|
||||
|
||||
/// The leading circle every list row uses, as large as a native contact
|
||||
/// avatar ([CircleAvatar]'s default).
|
||||
@@ -58,10 +59,19 @@ class AppListAvatar extends StatelessWidget {
|
||||
fontWeight: FontWeight.w700,
|
||||
height: 1,
|
||||
);
|
||||
// A flat design (Terminal) frames the mark in a square box instead of a
|
||||
// tinted circle.
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
final decoration = tokens.flat
|
||||
? BoxDecoration(
|
||||
border: Border.all(color: mark.withValues(alpha: 0.55)),
|
||||
borderRadius: tokens.corners(BorderRadius.zero),
|
||||
)
|
||||
: BoxDecoration(color: fill, shape: BoxShape.circle);
|
||||
final circle = SizedBox.square(
|
||||
dimension: kAppListAvatarSize,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(color: fill, shape: BoxShape.circle),
|
||||
decoration: decoration,
|
||||
child: Center(
|
||||
// The glyph is identity, not reading text: it scales down to stay
|
||||
// inside the circle under large text instead of overflowing it.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../theme/app_design_tokens.dart';
|
||||
|
||||
/// The shared status glyph whose tooltip and accessible name say the state.
|
||||
///
|
||||
/// [state] is the normalised run state (`succeeded`, `failed`, `running`,
|
||||
@@ -20,7 +22,7 @@ class RunStatusIcon extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final color = runStatusColor(state, Theme.of(context).colorScheme);
|
||||
final color = runStatusColorOf(context, state);
|
||||
// The label is the glyph's accessible name; the tooltip must not repeat it.
|
||||
return Tooltip(
|
||||
message: label,
|
||||
@@ -35,6 +37,23 @@ class RunStatusIcon extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// [runStatusColor] as the design at [context] draws it: a design with ANSI
|
||||
/// accents (Terminal) names its own muted hues; the Default design keeps the
|
||||
/// system colours.
|
||||
Color runStatusColorOf(BuildContext context, String state) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final ansi = AppDesignTokens.of(context).ansi;
|
||||
if (ansi == null) return runStatusColor(state, scheme);
|
||||
return switch (state) {
|
||||
'succeeded' => ansi.green,
|
||||
'failed' => ansi.red,
|
||||
'running' || 'active' => ansi.blue,
|
||||
'waiting' || 'waiting_quota' => ansi.yellow,
|
||||
'interrupted' => ansi.magenta,
|
||||
_ => scheme.onSurfaceVariant,
|
||||
};
|
||||
}
|
||||
|
||||
/// The colour for a run state, shared by every status glyph: green
|
||||
/// succeeded, red failed, blue running, yellow waiting, orange interrupted,
|
||||
/// grey otherwise, each with a brighter dark-mode shade.
|
||||
@@ -75,7 +94,7 @@ class RunStatusKicker extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final color = runStatusColor(state, Theme.of(context).colorScheme);
|
||||
final color = runStatusColorOf(context, state);
|
||||
return Row(
|
||||
key: const Key('run-status-kicker'),
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'app_design_tokens.dart';
|
||||
import 'app_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 means one more value here and its theme builder; the
|
||||
/// Settings picker lists [AppDesign.values].
|
||||
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.',
|
||||
);
|
||||
|
||||
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),
|
||||
};
|
||||
|
||||
/// The design's dark theme; see [light].
|
||||
ThemeData dark({String? fontFamily}) => switch (this) {
|
||||
standard => appDarkTheme(fontFamily: fontFamily),
|
||||
terminal => terminalTheme(Brightness.dark),
|
||||
};
|
||||
|
||||
/// Whether the device's interface font applies under this design.
|
||||
bool get usesInterfaceFont => this == standard;
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'app_design.dart';
|
||||
|
||||
/// The device's design choice. It lives in this device's (or browser's) own
|
||||
/// preferences and is never sent to a server.
|
||||
const String appDesignKey = 'pipelines.design.v1';
|
||||
|
||||
/// The persistence seam for the design choice: an [AppDesign.id].
|
||||
abstract interface class AppDesignStore {
|
||||
/// The stored id; null when nothing is stored or it cannot be read.
|
||||
Future<String?> load();
|
||||
|
||||
/// Whether the choice is actually stored.
|
||||
Future<bool> save(String id);
|
||||
}
|
||||
|
||||
/// `shared_preferences` storage. An unreadable store means the default; a
|
||||
/// failed save returns false rather than throwing.
|
||||
class SharedPreferencesAppDesignStore implements AppDesignStore {
|
||||
const SharedPreferencesAppDesignStore();
|
||||
|
||||
@override
|
||||
Future<String?> load() async {
|
||||
try {
|
||||
return (await SharedPreferences.getInstance()).getString(appDesignKey);
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> save(String id) async {
|
||||
try {
|
||||
return await (await SharedPreferences.getInstance()).setString(
|
||||
appDesignKey,
|
||||
id,
|
||||
);
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An in-memory store for tests and fixtures.
|
||||
class MemoryAppDesignStore implements AppDesignStore {
|
||||
MemoryAppDesignStore([this.id]);
|
||||
|
||||
String? id;
|
||||
bool failSaves = false;
|
||||
|
||||
@override
|
||||
Future<String?> load() async => id;
|
||||
|
||||
@override
|
||||
Future<bool> save(String id) async {
|
||||
if (failSaves) return false;
|
||||
this.id = id;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// The device's app-wide design. The theme hosts listen to it, so a choice
|
||||
/// rebuilds every theme in place without a restart.
|
||||
class AppDesignController extends ChangeNotifier {
|
||||
AppDesignController({AppDesignStore? store})
|
||||
: _store = store ?? const SharedPreferencesAppDesignStore();
|
||||
|
||||
/// The app's own controller, shared by the theme hosts and Settings.
|
||||
static final AppDesignController instance = AppDesignController();
|
||||
|
||||
final AppDesignStore _store;
|
||||
AppDesign _design = AppDesign.standard;
|
||||
int _revision = 0;
|
||||
bool _saveFailed = false;
|
||||
|
||||
AppDesign get design => _design;
|
||||
|
||||
/// The last choice could not be stored on this device.
|
||||
bool get saveFailed => _saveFailed;
|
||||
|
||||
/// Reads the stored choice. A choice made while reading wins.
|
||||
Future<void> restore() async {
|
||||
final revision = _revision;
|
||||
final id = await _store.load();
|
||||
if (revision != _revision || id == null) return;
|
||||
final design = AppDesign.fromId(id);
|
||||
if (design == _design) return;
|
||||
_design = design;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// Applies [design] now and stores it.
|
||||
Future<void> select(AppDesign design) async {
|
||||
_revision++;
|
||||
final revision = _revision;
|
||||
if (design != _design) {
|
||||
_design = design;
|
||||
notifyListeners();
|
||||
}
|
||||
final saved = await _store.save(design.id);
|
||||
if (revision != _revision || saved != _saveFailed) return;
|
||||
_saveFailed = !saved;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'app_design_tokens.dart';
|
||||
|
||||
/// Terminal's muted ANSI accents on its near-black page.
|
||||
const AnsiAccents terminalDarkAnsi = AnsiAccents(
|
||||
green: Color(0xFF8CC38F),
|
||||
cyan: Color(0xFF6FB8C4),
|
||||
yellow: Color(0xFFD6BC7A),
|
||||
red: Color(0xFFE07A80),
|
||||
magenta: Color(0xFFC08BC4),
|
||||
blue: Color(0xFF7FA6D9),
|
||||
);
|
||||
|
||||
/// Terminal's accents darkened to read on its light paper page.
|
||||
const AnsiAccents terminalLightAnsi = AnsiAccents(
|
||||
green: Color(0xFF2F7434),
|
||||
cyan: Color(0xFF1C6E7C),
|
||||
yellow: Color(0xFF7D6316),
|
||||
red: Color(0xFFB3332E),
|
||||
magenta: Color(0xFF8E3F8A),
|
||||
blue: Color(0xFF2E5F9E),
|
||||
);
|
||||
|
||||
/// Terminal's colour scheme: a near-black (or paper) page whose surfaces
|
||||
/// step up only slightly, light grey text with dim grey secondary text, and
|
||||
/// the ANSI accents as the scheme's roles (green primary, cyan secondary,
|
||||
/// yellow tertiary, red error).
|
||||
ColorScheme terminalColorScheme(Brightness brightness) {
|
||||
if (brightness == Brightness.dark) {
|
||||
return const ColorScheme(
|
||||
brightness: Brightness.dark,
|
||||
primary: Color(0xFF8CC38F),
|
||||
onPrimary: Color(0xFF0B0B0B),
|
||||
primaryContainer: Color(0xFF1B2A1C),
|
||||
onPrimaryContainer: Color(0xFFB4DDB5),
|
||||
secondary: Color(0xFF6FB8C4),
|
||||
onSecondary: Color(0xFF0B0B0B),
|
||||
secondaryContainer: Color(0xFF16282B),
|
||||
onSecondaryContainer: Color(0xFFA8D8E0),
|
||||
tertiary: Color(0xFFD6BC7A),
|
||||
onTertiary: Color(0xFF0B0B0B),
|
||||
tertiaryContainer: Color(0xFF2B2516),
|
||||
onTertiaryContainer: Color(0xFFEBD9A9),
|
||||
error: Color(0xFFE07A80),
|
||||
onError: Color(0xFF0B0B0B),
|
||||
errorContainer: Color(0xFF3A1B1E),
|
||||
onErrorContainer: Color(0xFFF3B9BD),
|
||||
surface: Color(0xFF0B0B0B),
|
||||
onSurface: Color(0xFFD7D7D2),
|
||||
onSurfaceVariant: Color(0xFF8D8D88),
|
||||
surfaceDim: Color(0xFF0B0B0B),
|
||||
surfaceBright: Color(0xFF2A2A28),
|
||||
surfaceContainerLowest: Color(0xFF070707),
|
||||
surfaceContainerLow: Color(0xFF111111),
|
||||
surfaceContainer: Color(0xFF151514),
|
||||
surfaceContainerHigh: Color(0xFF1A1A19),
|
||||
surfaceContainerHighest: Color(0xFF21211F),
|
||||
outline: Color(0xFF4A4A46),
|
||||
outlineVariant: Color(0xFF2B2B29),
|
||||
shadow: Color(0xFF000000),
|
||||
scrim: Color(0xFF000000),
|
||||
inverseSurface: Color(0xFFD7D7D2),
|
||||
onInverseSurface: Color(0xFF0B0B0B),
|
||||
inversePrimary: Color(0xFF2F7434),
|
||||
surfaceTint: Color(0x00000000),
|
||||
);
|
||||
}
|
||||
return const ColorScheme(
|
||||
brightness: Brightness.light,
|
||||
primary: Color(0xFF2F7434),
|
||||
onPrimary: Color(0xFFFFFFFF),
|
||||
primaryContainer: Color(0xFFDCEBD9),
|
||||
onPrimaryContainer: Color(0xFF14351A),
|
||||
secondary: Color(0xFF1C6E7C),
|
||||
onSecondary: Color(0xFFFFFFFF),
|
||||
secondaryContainer: Color(0xFFD5E8EB),
|
||||
onSecondaryContainer: Color(0xFF0D3239),
|
||||
tertiary: Color(0xFF7D6316),
|
||||
onTertiary: Color(0xFFFFFFFF),
|
||||
tertiaryContainer: Color(0xFFF0E6C8),
|
||||
onTertiaryContainer: Color(0xFF3A2D05),
|
||||
error: Color(0xFFB3332E),
|
||||
onError: Color(0xFFFFFFFF),
|
||||
errorContainer: Color(0xFFF6D9D7),
|
||||
onErrorContainer: Color(0xFF4A0D0B),
|
||||
surface: Color(0xFFF7F6F1),
|
||||
onSurface: Color(0xFF1E1E1C),
|
||||
onSurfaceVariant: Color(0xFF64645F),
|
||||
surfaceDim: Color(0xFFE6E5DF),
|
||||
surfaceBright: Color(0xFFFCFBF7),
|
||||
surfaceContainerLowest: Color(0xFFFCFBF7),
|
||||
surfaceContainerLow: Color(0xFFF1F0EA),
|
||||
surfaceContainer: Color(0xFFECEBE5),
|
||||
surfaceContainerHigh: Color(0xFFE6E5DF),
|
||||
surfaceContainerHighest: Color(0xFFDFDED7),
|
||||
outline: Color(0xFF9C9C95),
|
||||
outlineVariant: Color(0xFFD2D1CA),
|
||||
shadow: Color(0xFF000000),
|
||||
scrim: Color(0xFF000000),
|
||||
inverseSurface: Color(0xFF1E1E1C),
|
||||
onInverseSurface: Color(0xFFF7F6F1),
|
||||
inversePrimary: Color(0xFF8CC38F),
|
||||
surfaceTint: Color(0x00000000),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../text/monospace.dart';
|
||||
import 'app_design.dart';
|
||||
import 'app_design_tokens.dart';
|
||||
import 'app_theme.dart';
|
||||
import 'terminal_palette.dart';
|
||||
|
||||
/// Terminal's corner radius: square enough to read as a terminal frame, soft
|
||||
/// enough not to alias.
|
||||
const double terminalRadius = 3;
|
||||
|
||||
const BorderRadius _corners = BorderRadius.all(Radius.circular(terminalRadius));
|
||||
|
||||
/// The Terminal design's theme: the bundled monospace family everywhere,
|
||||
/// compact text, flat surfaces with 1px dim frames and no elevation, and
|
||||
/// the ANSI accents as the colour roles. Every Material component the app
|
||||
/// uses takes the same shapes, so lists, dialogs, menus and buttons follow
|
||||
/// without per-widget code.
|
||||
ThemeData terminalTheme(Brightness brightness) {
|
||||
final scheme = terminalColorScheme(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);
|
||||
final base = ThemeData(
|
||||
platform: kIsWeb ? TargetPlatform.android : null,
|
||||
colorScheme: scheme,
|
||||
fontFamily: appMonospaceFamily,
|
||||
scaffoldBackgroundColor: scheme.surface,
|
||||
canvasColor: scheme.surface,
|
||||
pageTransitionsTheme: appPageTransitions,
|
||||
visualDensity: const VisualDensity(horizontal: -1, vertical: -1),
|
||||
splashFactory: NoSplash.splashFactory,
|
||||
shadowColor: const Color(0x00000000),
|
||||
dividerColor: scheme.outlineVariant,
|
||||
extensions: [
|
||||
AppDesignTokens(
|
||||
design: AppDesign.terminal,
|
||||
radius: terminalRadius,
|
||||
flat: true,
|
||||
frame: scheme.outlineVariant,
|
||||
ansi: ansi,
|
||||
),
|
||||
],
|
||||
);
|
||||
ButtonStyle buttons(ButtonStyle? style) =>
|
||||
(style ?? const ButtonStyle()).copyWith(
|
||||
shape: const WidgetStatePropertyAll(square),
|
||||
elevation: const WidgetStatePropertyAll(0),
|
||||
shadowColor: const WidgetStatePropertyAll(Color(0x00000000)),
|
||||
);
|
||||
final menu = MenuStyle(
|
||||
backgroundColor: WidgetStatePropertyAll(scheme.surfaceContainerLow),
|
||||
elevation: const WidgetStatePropertyAll(0),
|
||||
shadowColor: const WidgetStatePropertyAll(Color(0x00000000)),
|
||||
surfaceTintColor: const WidgetStatePropertyAll(Color(0x00000000)),
|
||||
shape: WidgetStatePropertyAll(
|
||||
RoundedRectangleBorder(
|
||||
borderRadius: _corners,
|
||||
side: BorderSide(color: scheme.outline),
|
||||
),
|
||||
),
|
||||
);
|
||||
return base.copyWith(
|
||||
textTheme: terminalTextTheme(base.textTheme),
|
||||
primaryTextTheme: terminalTextTheme(base.primaryTextTheme),
|
||||
appBarTheme: AppBarTheme(
|
||||
backgroundColor: scheme.surface,
|
||||
surfaceTintColor: const Color(0x00000000),
|
||||
elevation: 0,
|
||||
scrolledUnderElevation: 0,
|
||||
shape: Border(bottom: frame),
|
||||
),
|
||||
// Only the frame: each card variant (filled, outlined) keeps its own
|
||||
// fill, so a selected graph node still reads apart.
|
||||
cardTheme: CardThemeData(
|
||||
elevation: 0,
|
||||
shadowColor: const Color(0x00000000),
|
||||
surfaceTintColor: const Color(0x00000000),
|
||||
shape: framed,
|
||||
),
|
||||
dialogTheme: DialogThemeData(
|
||||
backgroundColor: scheme.surfaceContainerLow,
|
||||
surfaceTintColor: const Color(0x00000000),
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: _corners,
|
||||
side: BorderSide(color: scheme.outline),
|
||||
),
|
||||
),
|
||||
bottomSheetTheme: BottomSheetThemeData(
|
||||
backgroundColor: scheme.surfaceContainerLow,
|
||||
modalBackgroundColor: scheme.surfaceContainerLow,
|
||||
surfaceTintColor: const Color(0x00000000),
|
||||
elevation: 0,
|
||||
modalElevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: _corners,
|
||||
side: BorderSide(color: scheme.outline),
|
||||
),
|
||||
),
|
||||
popupMenuTheme: PopupMenuThemeData(
|
||||
color: scheme.surfaceContainerLow,
|
||||
surfaceTintColor: const Color(0x00000000),
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: _corners,
|
||||
side: BorderSide(color: scheme.outline),
|
||||
),
|
||||
),
|
||||
menuTheme: MenuThemeData(style: menu),
|
||||
dropdownMenuTheme: DropdownMenuThemeData(menuStyle: menu),
|
||||
menuButtonTheme: MenuButtonThemeData(
|
||||
style: MenuItemButton.styleFrom(shape: square),
|
||||
),
|
||||
filledButtonTheme: FilledButtonThemeData(
|
||||
style: buttons(base.filledButtonTheme.style),
|
||||
),
|
||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||
style: buttons(base.elevatedButtonTheme.style),
|
||||
),
|
||||
outlinedButtonTheme: OutlinedButtonThemeData(
|
||||
style: buttons(base.outlinedButtonTheme.style).copyWith(
|
||||
side: WidgetStatePropertyAll(BorderSide(color: scheme.outline)),
|
||||
),
|
||||
),
|
||||
textButtonTheme: TextButtonThemeData(
|
||||
style: buttons(base.textButtonTheme.style),
|
||||
),
|
||||
iconButtonTheme: IconButtonThemeData(
|
||||
style: buttons(base.iconButtonTheme.style),
|
||||
),
|
||||
segmentedButtonTheme: SegmentedButtonThemeData(
|
||||
style: buttons(base.segmentedButtonTheme.style),
|
||||
),
|
||||
floatingActionButtonTheme: FloatingActionButtonThemeData(
|
||||
elevation: 0,
|
||||
focusElevation: 0,
|
||||
hoverElevation: 0,
|
||||
highlightElevation: 0,
|
||||
backgroundColor: scheme.surfaceContainerHigh,
|
||||
foregroundColor: scheme.primary,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: _corners,
|
||||
side: BorderSide(color: scheme.outline),
|
||||
),
|
||||
),
|
||||
chipTheme: ChipThemeData(
|
||||
backgroundColor: const Color(0x00000000),
|
||||
shape: framed,
|
||||
side: frame,
|
||||
elevation: 0,
|
||||
pressElevation: 0,
|
||||
),
|
||||
// Only the base border: a field that sets `InputBorder.none` (the
|
||||
// composer, whose frame is its pill) keeps none in every state.
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
isDense: true,
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: _corners,
|
||||
borderSide: BorderSide(color: scheme.outline),
|
||||
),
|
||||
),
|
||||
searchBarTheme: SearchBarThemeData(
|
||||
elevation: const WidgetStatePropertyAll(0),
|
||||
shape: const WidgetStatePropertyAll(square),
|
||||
side: WidgetStatePropertyAll(BorderSide(color: scheme.outline)),
|
||||
backgroundColor: WidgetStatePropertyAll(scheme.surfaceContainerLow),
|
||||
),
|
||||
navigationRailTheme: NavigationRailThemeData(
|
||||
backgroundColor: scheme.surface,
|
||||
elevation: 0,
|
||||
indicatorColor: scheme.primaryContainer,
|
||||
indicatorShape: square,
|
||||
),
|
||||
navigationBarTheme: NavigationBarThemeData(
|
||||
backgroundColor: scheme.surface,
|
||||
elevation: 0,
|
||||
indicatorColor: scheme.primaryContainer,
|
||||
indicatorShape: square,
|
||||
surfaceTintColor: const Color(0x00000000),
|
||||
),
|
||||
listTileTheme: const ListTileThemeData(shape: square),
|
||||
dividerTheme: DividerThemeData(
|
||||
color: scheme.outlineVariant,
|
||||
thickness: 1,
|
||||
space: 1,
|
||||
),
|
||||
tabBarTheme: TabBarThemeData(
|
||||
dividerColor: scheme.outlineVariant,
|
||||
indicatorSize: TabBarIndicatorSize.tab,
|
||||
indicator: UnderlineTabIndicator(
|
||||
borderSide: BorderSide(color: scheme.primary, width: 2),
|
||||
),
|
||||
),
|
||||
snackBarTheme: SnackBarThemeData(
|
||||
backgroundColor: scheme.surfaceContainerHigh,
|
||||
contentTextStyle: TextStyle(
|
||||
color: scheme.onSurface,
|
||||
fontFamily: appMonospaceFamily,
|
||||
),
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: _corners,
|
||||
side: BorderSide(color: scheme.outline),
|
||||
),
|
||||
),
|
||||
tooltipTheme: TooltipThemeData(
|
||||
decoration: BoxDecoration(
|
||||
color: scheme.surfaceContainerHighest,
|
||||
borderRadius: _corners,
|
||||
border: Border.all(color: scheme.outline),
|
||||
),
|
||||
textStyle: TextStyle(
|
||||
color: scheme.onSurface,
|
||||
fontFamily: appMonospaceFamily,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
scrollbarTheme: const ScrollbarThemeData(radius: Radius.zero),
|
||||
progressIndicatorTheme: ProgressIndicatorThemeData(
|
||||
color: scheme.primary,
|
||||
linearTrackColor: scheme.outlineVariant,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// [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) {
|
||||
TextStyle? mono(TextStyle? style) {
|
||||
if (style == null) return null;
|
||||
final size = style.fontSize;
|
||||
return style.copyWith(
|
||||
fontFamily: appMonospaceFamily,
|
||||
fontSize: size == null ? null : (size * 0.875).roundToDouble(),
|
||||
letterSpacing: 0,
|
||||
);
|
||||
}
|
||||
|
||||
return base.copyWith(
|
||||
displayLarge: mono(base.displayLarge),
|
||||
displayMedium: mono(base.displayMedium),
|
||||
displaySmall: mono(base.displaySmall),
|
||||
headlineLarge: mono(base.headlineLarge),
|
||||
headlineMedium: mono(base.headlineMedium),
|
||||
headlineSmall: mono(base.headlineSmall),
|
||||
titleLarge: mono(base.titleLarge),
|
||||
titleMedium: mono(base.titleMedium),
|
||||
titleSmall: mono(base.titleSmall),
|
||||
bodyLarge: mono(base.bodyLarge),
|
||||
bodyMedium: mono(base.bodyMedium),
|
||||
bodySmall: mono(base.bodySmall),
|
||||
labelLarge: mono(base.labelLarge),
|
||||
labelMedium: mono(base.labelMedium),
|
||||
labelSmall: mono(base.labelSmall),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user