9eaa8d18c0
One hue per variant (brightness steps for roles, statuses and chat colours, with cross/ring glyphs where hue alone told status), square corners, 1px phosphor frames, a faint text glow and a static scanline and vignette pattern painted once in its own repaint boundary. Light mode is a paper-white phosphor. Terminal's theme builder is shared, not forked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
256 lines
8.9 KiB
Dart
256 lines
8.9 KiB
Dart
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';
|
|
import 'terminal_typography.dart';
|
|
|
|
/// Terminal's corner radius: square enough to read as a terminal frame, soft
|
|
/// enough not to alias.
|
|
const double terminalRadius = 3;
|
|
|
|
/// One tab indicator per accent: [UnderlineTabIndicator] compares by
|
|
/// identity, so a fresh one would make a rebuilt theme unequal to the last.
|
|
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
|
|
/// 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;
|
|
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,
|
|
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: [tokens],
|
|
);
|
|
ButtonStyle buttons(ButtonStyle? style) =>
|
|
(style ?? const ButtonStyle()).copyWith(
|
|
shape: 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, glow: glow),
|
|
primaryTextTheme: terminalTextTheme(base.primaryTextTheme, glow: glow),
|
|
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: 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: ListTileThemeData(shape: square),
|
|
dividerTheme: DividerThemeData(
|
|
color: scheme.outlineVariant,
|
|
thickness: 1,
|
|
space: 1,
|
|
),
|
|
tabBarTheme: TabBarThemeData(
|
|
dividerColor: scheme.outlineVariant,
|
|
indicatorSize: TabBarIndicatorSize.tab,
|
|
indicator: _tabIndicators[scheme.primary] ??= UnderlineTabIndicator(
|
|
borderSide: BorderSide(color: scheme.primary, width: 2),
|
|
),
|
|
),
|
|
snackBarTheme: SnackBarThemeData(
|
|
backgroundColor: scheme.surfaceContainerHigh,
|
|
contentTextStyle: TextStyle(
|
|
color: scheme.onSurface,
|
|
fontFamily: appMonospaceFamily,
|
|
shadows: glow,
|
|
),
|
|
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,
|
|
shadows: glow,
|
|
),
|
|
),
|
|
scrollbarTheme: const ScrollbarThemeData(radius: Radius.zero),
|
|
progressIndicatorTheme: ProgressIndicatorThemeData(
|
|
color: scheme.primary,
|
|
linearTrackColor: scheme.outlineVariant,
|
|
),
|
|
);
|
|
}
|