0599d6dc23
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
232 lines
7.9 KiB
Dart
232 lines
7.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;
|
|
|
|
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,
|
|
),
|
|
);
|
|
}
|