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,7 @@
|
||||
import '../ui/adaptive/window_margins.dart';
|
||||
import '../ui/theme/app_design.dart';
|
||||
import '../ui/theme/app_design_controller.dart';
|
||||
import '../ui/theme/app_font_controller.dart';
|
||||
import '../ui/theme/app_theme.dart';
|
||||
import '../ui/scale/ui_scale.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -19,6 +20,7 @@ class MyApp extends StatelessWidget {
|
||||
this.destination,
|
||||
this.onDestinationSelected,
|
||||
this.fonts,
|
||||
this.designs,
|
||||
}) : routerConfig = null;
|
||||
|
||||
/// A host for a [Router]-owned location, so browser Back/Forward and deep
|
||||
@@ -28,6 +30,7 @@ class MyApp extends StatelessWidget {
|
||||
super.key,
|
||||
required RouterConfig<Object> this.routerConfig,
|
||||
this.fonts,
|
||||
this.designs,
|
||||
}) : destinationBodies = const {},
|
||||
destination = null,
|
||||
onDestinationSelected = null;
|
||||
@@ -42,24 +45,29 @@ class MyApp extends StatelessWidget {
|
||||
/// A change rebuilds the themes in place, without a restart.
|
||||
final AppFontController? fonts;
|
||||
|
||||
/// The device's design; defaults to the app's shared controller. A change
|
||||
/// rebuilds the themes in place, like a font change.
|
||||
final AppDesignController? designs;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final fonts = this.fonts ?? AppFontController.instance;
|
||||
final designs = this.designs ?? AppDesignController.instance;
|
||||
return ListenableBuilder(
|
||||
listenable: fonts,
|
||||
builder: (context, _) => _host(fonts.family),
|
||||
listenable: Listenable.merge([fonts, designs]),
|
||||
builder: (context, _) => _host(designs.design, fonts.family),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _host(String? fontFamily) {
|
||||
Widget _host(AppDesign design, String? fontFamily) {
|
||||
final router = routerConfig;
|
||||
if (router != null) {
|
||||
return MaterialApp.router(
|
||||
title: 'Pipelines',
|
||||
scaffoldMessengerKey: appScaffoldMessengerKey,
|
||||
builder: _scaled,
|
||||
theme: appLightTheme(fontFamily: fontFamily),
|
||||
darkTheme: appDarkTheme(fontFamily: fontFamily),
|
||||
theme: design.light(fontFamily: fontFamily),
|
||||
darkTheme: design.dark(fontFamily: fontFamily),
|
||||
themeMode: ThemeMode.system,
|
||||
routerConfig: router,
|
||||
);
|
||||
@@ -68,8 +76,8 @@ class MyApp extends StatelessWidget {
|
||||
title: 'Pipelines',
|
||||
scaffoldMessengerKey: appScaffoldMessengerKey,
|
||||
builder: _scaled,
|
||||
theme: appLightTheme(fontFamily: fontFamily),
|
||||
darkTheme: appDarkTheme(fontFamily: fontFamily),
|
||||
theme: design.light(fontFamily: fontFamily),
|
||||
darkTheme: design.dark(fontFamily: fontFamily),
|
||||
themeMode: ThemeMode.system,
|
||||
home: AdaptiveShell(
|
||||
destinationBodies: destinationBodies,
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'pipelines_binding.dart';
|
||||
import 'pipelines_root.dart';
|
||||
import 'server_endpoint.dart';
|
||||
import '../features/settings/settings_store.dart';
|
||||
import '../ui/theme/app_design_controller.dart';
|
||||
import '../ui/theme/app_font_controller.dart';
|
||||
import '../ui/theme/app_font_licenses.dart';
|
||||
import '../ui/motion/animation_speed.dart';
|
||||
@@ -73,9 +74,11 @@ Future<void> runPipelinesApp({
|
||||
final quickSwitchAnimation = QuickSwitchAnimationController.instance
|
||||
.restore();
|
||||
final font = AppFontController.instance.restore(wait: appFontStartupWait);
|
||||
final design = AppDesignController.instance.restore();
|
||||
// A phone behind the web login reconnects with its kept session.
|
||||
await ServerSession.load();
|
||||
await font;
|
||||
await design;
|
||||
await animationSpeed;
|
||||
await uiScale;
|
||||
await terminalLayout;
|
||||
|
||||
@@ -13,7 +13,7 @@ import '../../features/terminal/terminal_layout.dart';
|
||||
import '../../ui/adaptive/window_margins.dart';
|
||||
import '../../ui/scale/ui_scale.dart';
|
||||
import '../../ui/theme/app_font_controller.dart';
|
||||
import '../../ui/theme/app_theme.dart';
|
||||
import '../../ui/theme/app_design_controller.dart';
|
||||
import '../app_route.dart';
|
||||
import '../app_session.dart';
|
||||
import '../app_terminals.dart';
|
||||
@@ -202,8 +202,9 @@ class _DetachedWindowAppState extends State<DetachedWindowApp> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final fonts = AppFontController.instance;
|
||||
final designs = AppDesignController.instance;
|
||||
final app = ListenableBuilder(
|
||||
listenable: Listenable.merge([fonts, _title]),
|
||||
listenable: Listenable.merge([fonts, designs, _title]),
|
||||
builder: (context, _) => MaterialApp(
|
||||
title: _title.value.isEmpty
|
||||
? 'Pipelines'
|
||||
@@ -213,8 +214,8 @@ class _DetachedWindowAppState extends State<DetachedWindowApp> {
|
||||
builder: (context, child) => UiScaleHost(
|
||||
child: WindowMargins(child: child ?? const SizedBox.shrink()),
|
||||
),
|
||||
theme: appLightTheme(fontFamily: fonts.family),
|
||||
darkTheme: appDarkTheme(fontFamily: fonts.family),
|
||||
theme: designs.design.light(fontFamily: fonts.family),
|
||||
darkTheme: designs.design.dark(fontFamily: fonts.family),
|
||||
themeMode: ThemeMode.system,
|
||||
// The window's one page is named by its route, so the address bar
|
||||
// (and a reload) keeps the detached location instead of `/`.
|
||||
|
||||
@@ -16,6 +16,7 @@ import '../features/settings/server_connections.dart';
|
||||
import '../features/settings/saved_servers_section.dart';
|
||||
import '../features/settings/settings_store.dart';
|
||||
import '../ui/scale/ui_scale.dart';
|
||||
import '../ui/theme/app_design_controller.dart';
|
||||
import '../ui/theme/app_font_controller.dart';
|
||||
import '../ui/theme/app_theme.dart';
|
||||
import 'detached/detached_app.dart';
|
||||
@@ -377,15 +378,16 @@ class _PipelinesRootState extends State<PipelinesRoot> {
|
||||
const [],
|
||||
);
|
||||
final fonts = AppFontController.instance;
|
||||
final designs = AppDesignController.instance;
|
||||
return ListenableBuilder(
|
||||
listenable: fonts,
|
||||
listenable: Listenable.merge([fonts, designs]),
|
||||
builder: (context, _) => MaterialApp(
|
||||
title: 'Pipelines',
|
||||
builder: (context, child) => UiScaleHost(
|
||||
child: WindowMargins(child: child ?? const SizedBox.shrink()),
|
||||
),
|
||||
theme: appLightTheme(fontFamily: fonts.family),
|
||||
darkTheme: appDarkTheme(fontFamily: fonts.family),
|
||||
theme: designs.design.light(fontFamily: fonts.family),
|
||||
darkTheme: designs.design.dark(fontFamily: fonts.family),
|
||||
debugShowCheckedModeBanner: false,
|
||||
home: flow,
|
||||
),
|
||||
|
||||
@@ -34,6 +34,7 @@ import 'composer_focus_request.dart';
|
||||
import 'composer_focus_restore.dart';
|
||||
import 'chat_bar_tint.dart';
|
||||
import 'composer_focus_ring.dart';
|
||||
import '../../../ui/theme/app_design_tokens.dart';
|
||||
import 'composer_running_border.dart';
|
||||
import '../shell/chat_shell_command.dart';
|
||||
import '../shell/chat_shell_mode_indicator.dart';
|
||||
@@ -1107,15 +1108,16 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
/// ([ComposerRunningBorder]); it is mounted only for that time.
|
||||
Widget _pill(BuildContext context, Widget child) {
|
||||
final accent = chatFocusRingColor(context, widget.chatColor);
|
||||
final shape = AppDesignTokens.of(context).shape(_pillShape);
|
||||
return Stack(
|
||||
children: [
|
||||
ComposerFocusRing(
|
||||
focus: _focus,
|
||||
accent: accent,
|
||||
shape: _pillShape,
|
||||
shape: shape,
|
||||
child: GlassPill(
|
||||
key: const Key('chat-composer-pill'),
|
||||
shape: _pillShape,
|
||||
shape: shape,
|
||||
// The end controls keep the same gap from the pill's sides as from
|
||||
// its bottom (and its top while the field is one line).
|
||||
child: Padding(
|
||||
@@ -1130,7 +1132,7 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
child: ListenableBuilder(
|
||||
listenable: _focus,
|
||||
builder: (context, _) => ComposerRunningBorder(
|
||||
shape: _pillShape,
|
||||
shape: shape,
|
||||
primary: accent,
|
||||
tertiary: Theme.of(context).colorScheme.tertiary,
|
||||
focused: _focus.hasFocus,
|
||||
@@ -1312,6 +1314,10 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
// Let a long folder name wrap when the attach and primary controls
|
||||
// leave little horizontal room.
|
||||
hintMaxLines: 2,
|
||||
// A terminal design's prompt glyph leads the field, as a CLI's
|
||||
// input line does.
|
||||
prefixIcon: _promptGlyph(context),
|
||||
prefixIconConstraints: const BoxConstraints(),
|
||||
// The pill draws the field's surface; the field adds no border.
|
||||
border: InputBorder.none,
|
||||
isDense: true,
|
||||
@@ -1320,6 +1326,26 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
);
|
||||
}
|
||||
|
||||
/// The prompt glyph before the field under a terminal design; null under
|
||||
/// the Default design.
|
||||
Widget? _promptGlyph(BuildContext context) {
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
if (!tokens.terminal) return null;
|
||||
return ExcludeSemantics(
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(start: 4, end: 10),
|
||||
child: Text(
|
||||
tokens.promptGlyph,
|
||||
key: const Key('chat-composer-prompt-glyph'),
|
||||
style: TextStyle(
|
||||
color: chatFocusRingColor(context, widget.chatColor),
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// The single primary control: Send (or Run command for a `!` draft). A
|
||||
/// prompt sent while a turn runs takes the server's queued-prompt path; the
|
||||
/// running turn is stopped by Escape twice, `/stop`, or the More menu.
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../ui/theme/app_design_tokens.dart';
|
||||
|
||||
import '../../conversation/chat_schedule_time.dart';
|
||||
import '../../domain/chat_prompt_origin.dart';
|
||||
import 'chat_copy_button.dart';
|
||||
import 'chat_hover_actions.dart';
|
||||
import 'terminal/terminal_glyphs.dart';
|
||||
|
||||
/// The header words of an automated prompt.
|
||||
String chatAutomatedPromptLabel(ChatPromptOrigin origin) => switch (origin) {
|
||||
@@ -64,35 +67,40 @@ class ChatAutomatedPromptCard extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
);
|
||||
final card = Material(
|
||||
key: const Key('chat-automated-prompt'),
|
||||
color: scheme.surfaceContainerLow,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||
side: BorderSide(color: scheme.outlineVariant),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(14, 8, 14, 10),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
header,
|
||||
if (prompt.body.trim().isNotEmpty) ...[
|
||||
const SizedBox(height: 4),
|
||||
DefaultTextStyle.merge(
|
||||
style: theme.textTheme.bodyMedium,
|
||||
child: body,
|
||||
final card = AppDesignTokens.of(context).terminal
|
||||
? _terminalLine(context, label, detail)
|
||||
: Material(
|
||||
key: const Key('chat-automated-prompt'),
|
||||
color: scheme.surfaceContainerLow,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(16)),
|
||||
side: BorderSide(color: scheme.outlineVariant),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(14, 8, 14, 10),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
header,
|
||||
if (prompt.body.trim().isNotEmpty) ...[
|
||||
const SizedBox(height: 4),
|
||||
DefaultTextStyle.merge(
|
||||
style: theme.textTheme.bodyMedium,
|
||||
child: body,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
),
|
||||
);
|
||||
final copy = prompt.body.trim().isEmpty
|
||||
? null
|
||||
: ChatHoverReveal(child: ChatCopyButton(text: prompt.body.trim()));
|
||||
final footerInset = AppDesignTokens.of(context).terminal
|
||||
? 8 + terminalGlyphColumn(context)
|
||||
: 14.0;
|
||||
return ChatHoverRegion(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
@@ -101,7 +109,7 @@ class ChatAutomatedPromptCard extends StatelessWidget {
|
||||
card,
|
||||
if (footer.isNotEmpty || timestamp != null || copy != null)
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.only(start: 14, top: 2),
|
||||
padding: EdgeInsetsDirectional.only(start: footerInset, top: 2),
|
||||
child: Wrap(
|
||||
key: const Key('chat-message-footer'),
|
||||
spacing: 8,
|
||||
@@ -115,6 +123,90 @@ class ChatAutomatedPromptCard extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
extension on ChatAutomatedPromptCard {
|
||||
/// Under a terminal design the prompt is not a card but dim bracketed
|
||||
/// lines, as a CLI prints a message it injected: `[Follow-up from agent ·
|
||||
/// scheduled …]`, then the prompt behind a dim rule.
|
||||
Widget _terminalLine(BuildContext context, String label, String? detail) {
|
||||
final theme = Theme.of(context);
|
||||
final dim = theme.textTheme.bodyMedium?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
);
|
||||
final header = SelectionContainer.disabled(
|
||||
child: Text.rich(
|
||||
key: const Key('chat-automated-prompt-header'),
|
||||
TextSpan(
|
||||
style: dim,
|
||||
children: [
|
||||
const TextSpan(text: '['),
|
||||
TextSpan(
|
||||
text: label,
|
||||
style: const TextStyle(fontWeight: FontWeight.w700),
|
||||
),
|
||||
if (detail != null) TextSpan(text: ' · $detail'),
|
||||
const TextSpan(text: ']'),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
// Inset like the answer's text, so the bracket starts in the same
|
||||
// column as the agent's dots.
|
||||
return Material(
|
||||
key: const Key('chat-automated-prompt'),
|
||||
type: MaterialType.transparency,
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(start: 8),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
header,
|
||||
if (prompt.body.trim().isNotEmpty)
|
||||
IntrinsicHeight(
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: terminalGlyphColumn(context),
|
||||
child: CustomPaint(
|
||||
painter: _RulePainter(theme.colorScheme.outline),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: DefaultTextStyle.merge(style: dim, child: body),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The dim vertical rule beside an injected prompt's text.
|
||||
class _RulePainter extends CustomPainter {
|
||||
const _RulePainter(this.color);
|
||||
|
||||
final Color color;
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final x = size.width * 0.25;
|
||||
canvas.drawLine(
|
||||
Offset(x, 2),
|
||||
Offset(x, size.height - 2),
|
||||
Paint()
|
||||
..color = color
|
||||
..strokeWidth = 1,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(_RulePainter old) => old.color != color;
|
||||
}
|
||||
|
||||
/// The small "Scheduled" mark under the operator's own message they had
|
||||
/// scheduled to send later, once it is no longer waiting.
|
||||
class ChatScheduledMark extends StatelessWidget {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../ui/theme/app_design_tokens.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'chat_copy_button.dart';
|
||||
|
||||
@@ -151,6 +152,9 @@ class ChatCodeCopyRegion extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final corners = AppDesignTokens.of(
|
||||
context,
|
||||
).corners(BorderRadius.circular(radius));
|
||||
final header = ColoredBox(
|
||||
key: const Key('chat-code-header'),
|
||||
color: headerFill(context),
|
||||
@@ -170,10 +174,10 @@ class ChatCodeCopyRegion extends StatelessWidget {
|
||||
position: DecorationPosition.foreground,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: scheme.outlineVariant),
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
borderRadius: corners,
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(radius),
|
||||
borderRadius: corners,
|
||||
child: ColoredBox(
|
||||
key: const Key('chat-code-body'),
|
||||
color: fill(context),
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../ui/theme/app_design_tokens.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
import 'chat_transcript_selection.dart';
|
||||
@@ -521,6 +523,17 @@ class _ChatMarkdownViewState extends State<ChatMarkdownView> {
|
||||
/// heading never reads like a paragraph.
|
||||
TextStyle? _headingStyle(BuildContext context, int level) {
|
||||
final text = Theme.of(context).textTheme;
|
||||
// A terminal prints headings at the text's own size, in bold; the top
|
||||
// level takes the accent colour.
|
||||
if (AppDesignTokens.of(context).terminal) {
|
||||
return _roleStyle(
|
||||
context,
|
||||
text.bodyLarge?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
color: level == 1 ? Theme.of(context).colorScheme.primary : null,
|
||||
),
|
||||
);
|
||||
}
|
||||
final role = switch (level) {
|
||||
1 => text.headlineSmall,
|
||||
2 => text.titleLarge,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../ui/theme/app_design_tokens.dart';
|
||||
import '../sessions/chat_color_palette.dart';
|
||||
import 'terminal/terminal_prompt_line.dart';
|
||||
|
||||
/// How strongly a coloured chat's shade washes the operator's bubbles over
|
||||
/// the host's neutral bubble fill. Text keeps the host's colours.
|
||||
@@ -43,6 +45,9 @@ class ChatUserBubble extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (AppDesignTokens.of(context).terminal) {
|
||||
return TerminalPromptLine(child: child);
|
||||
}
|
||||
// A Material surface (not a bare DecoratedBox) so a disclosure ListTile
|
||||
// inside the bubble keeps its ink and background.
|
||||
return Material(
|
||||
|
||||
@@ -2,6 +2,8 @@ import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../ui/theme/app_design_tokens.dart';
|
||||
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../data/chat_attachment_images.dart';
|
||||
import 'chat_attachment_gallery.dart';
|
||||
@@ -16,6 +18,7 @@ import 'chat_link_text.dart';
|
||||
import 'chat_message_bubble.dart';
|
||||
import 'chat_turn_activity_view.dart';
|
||||
import 'native_disclosure.dart';
|
||||
import 'terminal/terminal_glyphs.dart';
|
||||
import 'chat_message_timestamp.dart';
|
||||
import 'chat_read_aloud_button.dart';
|
||||
import '../../speech/speech_controller.dart';
|
||||
@@ -76,6 +79,11 @@ class ChatMessageView extends StatelessWidget {
|
||||
// A wide window draws an answer's Copy in the gutter left of the reading
|
||||
// column; without room it trails the time in the answer's footer.
|
||||
final gutter = user ? 0.0 : ChatCopyGutter.of(context);
|
||||
// A terminal design reads top to bottom like a CLI: the operator's
|
||||
// prompt line starts at the same edge as the answer and spans its
|
||||
// column.
|
||||
final terminal = AppDesignTokens.of(context).terminal;
|
||||
final trailingUser = user && !automated && !terminal;
|
||||
// No visible role label: side and surface say who spoke and the row's
|
||||
// semantics label names the role. The operator's turn is a neutral bubble
|
||||
// that shrinks to its content; the agent's answer sits on the page with no
|
||||
@@ -96,7 +104,7 @@ class ChatMessageView extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) => Align(
|
||||
alignment: user && !automated
|
||||
alignment: trailingUser
|
||||
? AlignmentDirectional.centerEnd
|
||||
: AlignmentDirectional.centerStart,
|
||||
child: ConstrainedBox(
|
||||
@@ -104,14 +112,14 @@ class ChatMessageView extends StatelessWidget {
|
||||
// sides read as a conversation; the answer keeps a readable
|
||||
// measure on a wide pane.
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: user
|
||||
maxWidth: trailingUser
|
||||
? (constraints.maxWidth * 0.85).clamp(0, 560).toDouble()
|
||||
: 720 + gutter,
|
||||
),
|
||||
child: automated
|
||||
? _automatedTurn(origin, content)
|
||||
: user
|
||||
? _userTurn(content, body, origin)
|
||||
? _userTurn(content, body, origin, terminal: terminal)
|
||||
: _agentRow(
|
||||
context,
|
||||
content,
|
||||
@@ -135,7 +143,12 @@ class ChatMessageView extends StatelessWidget {
|
||||
/// Attached images sit above the operator's bubble, as their own thumbnails;
|
||||
/// an images-only turn draws no empty bubble. The footer (the delivery line)
|
||||
/// sits under the bubble's trailing corner.
|
||||
Widget _userTurn(List<Widget> content, Widget body, ChatPromptOrigin origin) {
|
||||
Widget _userTurn(
|
||||
List<Widget> content,
|
||||
Widget body,
|
||||
ChatPromptOrigin origin, {
|
||||
required bool terminal,
|
||||
}) {
|
||||
final thumbnails = [
|
||||
for (final part in _partsOf(_userMessage))
|
||||
if (_isFile(part) && chatPartIsThumbnail(part)) part,
|
||||
@@ -150,7 +163,9 @@ class ChatMessageView extends StatelessWidget {
|
||||
}
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
crossAxisAlignment: terminal
|
||||
? CrossAxisAlignment.stretch
|
||||
: CrossAxisAlignment.end,
|
||||
children: [
|
||||
if (thumbnails.isNotEmpty)
|
||||
ChatAttachmentGallery(
|
||||
@@ -167,7 +182,7 @@ class ChatMessageView extends StatelessWidget {
|
||||
Wrap(
|
||||
key: const Key('chat-message-footer'),
|
||||
spacing: 8,
|
||||
alignment: WrapAlignment.end,
|
||||
alignment: terminal ? WrapAlignment.start : WrapAlignment.end,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
...footer,
|
||||
@@ -307,6 +322,7 @@ class ChatMessageView extends StatelessWidget {
|
||||
for (final part in parts)
|
||||
if (isChatToolPart(part)) part,
|
||||
];
|
||||
final terminal = AppDesignTokens.of(context).terminal;
|
||||
final model = '${row['model'] ?? ''}'.trim();
|
||||
// The metadata line: the model that answered and the time, muted; the
|
||||
// actions (when not in the gutter) trail it.
|
||||
@@ -345,7 +361,7 @@ class ChatMessageView extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: chatAgentContentInset,
|
||||
),
|
||||
child: answer,
|
||||
child: terminal ? _terminalAnswer(context, answer) : answer,
|
||||
),
|
||||
// Settled permissions, questions and changes: meta rows that, like
|
||||
// the activity line, sit at the row edge with their content inset to
|
||||
@@ -363,7 +379,10 @@ class ChatMessageView extends StatelessWidget {
|
||||
// trail it, so hidden actions leave no gap before it. Without
|
||||
// metadata the buttons' own inset aligns their icons instead.
|
||||
padding: EdgeInsetsDirectional.only(
|
||||
start: meta.isEmpty ? 0 : chatAgentContentInset,
|
||||
start: meta.isEmpty
|
||||
? 0
|
||||
: chatAgentContentInset +
|
||||
(terminal ? terminalGlyphColumn(context) : 0),
|
||||
end: chatAgentContentInset,
|
||||
),
|
||||
child: Wrap(
|
||||
@@ -377,6 +396,18 @@ class ChatMessageView extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// The answer under a terminal design: a dot in the glyph column, as a
|
||||
/// CLI agent marks its reply, then the text.
|
||||
Widget _terminalAnswer(BuildContext context, Widget answer) =>
|
||||
TerminalGlyphRow(
|
||||
glyph: TerminalGlyph(
|
||||
TerminalGlyphKind.dot,
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
style: chatMessageTextStyle(context),
|
||||
),
|
||||
child: answer,
|
||||
);
|
||||
|
||||
/// The answer as the operator reads it: the turn's text parts in order,
|
||||
/// without reasoning, tools or attachments.
|
||||
List<String> _answerParts(List<JsonMap> parts) => [
|
||||
|
||||
@@ -5,9 +5,11 @@ import 'package:flutter/material.dart';
|
||||
import '../../../../core/api_gateway.dart';
|
||||
import '../../domain/chat_turn_activity.dart';
|
||||
import '../../../../ui/adaptive/platform.dart';
|
||||
import '../../../../ui/theme/app_design_tokens.dart';
|
||||
import 'chat_response_pending.dart';
|
||||
import 'chat_turn_activity_details.dart';
|
||||
import 'chat_turn_chip.dart';
|
||||
import 'terminal/terminal_activity_rows.dart';
|
||||
|
||||
/// The activity control's content inset is shared with the rest of the reply.
|
||||
const chatAgentContentInset = 8.0;
|
||||
@@ -120,6 +122,15 @@ class _ChatTurnActivityViewState extends State<ChatTurnActivityView> {
|
||||
: DateTime.now().difference(started);
|
||||
final seconds = duration.inSeconds.clamp(0, 2147483647);
|
||||
final label = '${data.label}${widget.streaming ? ' ${seconds}s' : ''}';
|
||||
if (AppDesignTokens.of(context).terminal) {
|
||||
return TerminalActivityRows(
|
||||
data: data,
|
||||
status: label,
|
||||
streaming: widget.streaming,
|
||||
seconds: seconds,
|
||||
onOpen: _open,
|
||||
);
|
||||
}
|
||||
// Desktop hover hugs the label; phones keep the full-width touch row.
|
||||
final compact = prefersCompactHitTargets(context);
|
||||
final content = ConstrainedBox(
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../core/api_gateway.dart';
|
||||
import '../../../../../ui/theme/app_design_tokens.dart';
|
||||
import '../../../domain/chat_tool_calls.dart';
|
||||
import '../../../domain/chat_turn_activity.dart';
|
||||
import '../chat_response_pending.dart';
|
||||
import 'terminal_glyphs.dart';
|
||||
|
||||
/// How many of a turn's calls the transcript lists; earlier ones fold into
|
||||
/// one "earlier" line (every call stays in the details dialog).
|
||||
const int terminalActivityMaxCalls = 6;
|
||||
|
||||
/// A turn's activity under a terminal design, as a CLI agent prints it: one
|
||||
/// `● Tool(detail)` line per call, its status in the dot's colour, with a
|
||||
/// `⎿ result` line beneath, and while the turn runs a live status line.
|
||||
/// The block is one button that opens the activity details, like the
|
||||
/// Default design's one-line status.
|
||||
class TerminalActivityRows extends StatelessWidget {
|
||||
const TerminalActivityRows({
|
||||
super.key,
|
||||
required this.data,
|
||||
required this.status,
|
||||
required this.streaming,
|
||||
required this.onOpen,
|
||||
this.seconds = 0,
|
||||
});
|
||||
|
||||
final ChatTurnActivityData data;
|
||||
|
||||
/// The turn's one-line status (with its running seconds while streaming).
|
||||
final String status;
|
||||
final bool streaming;
|
||||
final VoidCallback onOpen;
|
||||
|
||||
/// How long the running turn has been doing what it does now.
|
||||
final int seconds;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
final scheme = theme.colorScheme;
|
||||
final ansi = AppDesignTokens.of(context).ansi;
|
||||
final style = theme.textTheme.bodyMedium!;
|
||||
final dim = style.copyWith(color: scheme.onSurfaceVariant);
|
||||
final calls = data.tools;
|
||||
final shown = calls.length > terminalActivityMaxCalls
|
||||
? calls.sublist(calls.length - terminalActivityMaxCalls)
|
||||
: calls;
|
||||
final hidden = calls.length - shown.length;
|
||||
final lines = <Widget>[
|
||||
if (data.reasoning.isNotEmpty && calls.isEmpty && !streaming)
|
||||
_line(context, TerminalGlyphKind.dot, scheme.onSurfaceVariant, [
|
||||
TextSpan(text: 'Thought', style: dim),
|
||||
]),
|
||||
if (hidden > 0)
|
||||
_line(context, null, scheme.onSurfaceVariant, [
|
||||
TextSpan(
|
||||
text: '… +$hidden earlier tool ${hidden == 1 ? 'use' : 'uses'}',
|
||||
style: dim,
|
||||
),
|
||||
]),
|
||||
for (final call in shown) ..._call(context, call, style, dim, ansi),
|
||||
if (calls.isEmpty && data.reasoning.isEmpty && !streaming)
|
||||
_line(context, TerminalGlyphKind.dot, scheme.onSurfaceVariant, [
|
||||
TextSpan(text: status, style: dim),
|
||||
]),
|
||||
if (streaming) _live(context, style),
|
||||
];
|
||||
return Semantics(
|
||||
button: true,
|
||||
label: '$status, expand for details',
|
||||
excludeSemantics: true,
|
||||
onTap: onOpen,
|
||||
child: InkWell(
|
||||
key: const Key('chat-turn-activity'),
|
||||
onTap: onOpen,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(minHeight: 40),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
child: DefaultTextStyle.merge(
|
||||
style: style,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: lines,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _call(
|
||||
BuildContext context,
|
||||
JsonMap call,
|
||||
TextStyle style,
|
||||
TextStyle dim,
|
||||
AnsiAccents? ansi,
|
||||
) {
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final failed = chatToolFailed(call);
|
||||
final running = chatToolRunning(call);
|
||||
final color = failed
|
||||
? ansi?.red ?? scheme.error
|
||||
: running
|
||||
? ansi?.yellow ?? scheme.tertiary
|
||||
: ansi?.green ?? scheme.primary;
|
||||
final detail = chatToolDetail(call);
|
||||
final head = [
|
||||
TextSpan(
|
||||
text: chatToolLabel(call),
|
||||
style: style.copyWith(fontWeight: FontWeight.w700),
|
||||
),
|
||||
if (detail != null) TextSpan(text: '($detail)', style: dim),
|
||||
];
|
||||
final duration = chatToolDurationMillis(call);
|
||||
final String result;
|
||||
if (running) {
|
||||
result = 'running…';
|
||||
} else {
|
||||
final text = failed ? chatToolErrorText(call) : chatToolOutputText(call);
|
||||
final first = text
|
||||
.split('\n')
|
||||
.map((line) => line.trim())
|
||||
.firstWhere((line) => line.isNotEmpty, orElse: () => '');
|
||||
final more = text.trim().split('\n').length - 1;
|
||||
result = [
|
||||
if (first.isNotEmpty) first,
|
||||
if (more > 0) '+$more lines',
|
||||
if (duration != null) formatChatToolDuration(duration),
|
||||
].join(' · ');
|
||||
}
|
||||
return [
|
||||
_line(context, TerminalGlyphKind.dot, color, head),
|
||||
if (result.isNotEmpty)
|
||||
_line(context, TerminalGlyphKind.elbow, scheme.outline, [
|
||||
TextSpan(
|
||||
text: result,
|
||||
style: failed ? dim.copyWith(color: color) : dim,
|
||||
),
|
||||
], indent: true),
|
||||
];
|
||||
}
|
||||
|
||||
/// The running status: the pending dots, then what the turn is doing and
|
||||
/// for how long, in the accent colour.
|
||||
Widget _live(BuildContext context, TextStyle style) {
|
||||
final accent =
|
||||
AppDesignTokens.of(context).ansi?.yellow ??
|
||||
Theme.of(context).colorScheme.primary;
|
||||
return Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: terminalGlyphColumn(context),
|
||||
child: ExcludeSemantics(
|
||||
child: DefaultTextStyle.merge(
|
||||
style: TextStyle(color: accent),
|
||||
child: const Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: ChatResponsePending(),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Text(
|
||||
'${data.label}… (${seconds}s)',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: style.copyWith(color: accent),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _line(
|
||||
BuildContext context,
|
||||
TerminalGlyphKind? glyph,
|
||||
Color glyphColor,
|
||||
List<TextSpan> spans, {
|
||||
bool indent = false,
|
||||
}) {
|
||||
final column = terminalGlyphColumn(context);
|
||||
return Padding(
|
||||
padding: EdgeInsetsDirectional.only(start: indent ? column * 0.5 : 0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (glyph == null)
|
||||
SizedBox(width: column)
|
||||
else
|
||||
TerminalGlyph(glyph, color: glyphColor),
|
||||
Flexible(
|
||||
child: Text.rich(
|
||||
TextSpan(children: spans),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// The width of a terminal transcript's glyph column: about two monospace
|
||||
/// cells of the ambient text, so lines after a glyph align like a CLI's.
|
||||
double terminalGlyphColumn(BuildContext context) {
|
||||
final style = DefaultTextStyle.of(context).style;
|
||||
final size = MediaQuery.textScalerOf(context).scale(style.fontSize ?? 14);
|
||||
return size * 1.3;
|
||||
}
|
||||
|
||||
/// The height of one line of the ambient text, so a painted glyph centres on
|
||||
/// the first line of the text beside it.
|
||||
double terminalLineHeight(BuildContext context, [TextStyle? style]) {
|
||||
final ambient = style ?? DefaultTextStyle.of(context).style;
|
||||
final size = MediaQuery.textScalerOf(context).scale(ambient.fontSize ?? 14);
|
||||
return size * (ambient.height ?? 1.35);
|
||||
}
|
||||
|
||||
/// The kind of mark a terminal transcript draws in its glyph column. They
|
||||
/// are painted rather than typed: the bundled monospace family has no
|
||||
/// record (U+25CF) or bracket corner (U+23BF), and the web engine would
|
||||
/// otherwise fetch a fallback font for them.
|
||||
enum TerminalGlyphKind {
|
||||
/// A filled dot: an answer, or a tool call (its colour gives the status).
|
||||
dot,
|
||||
|
||||
/// A bracket corner under a call: its result line.
|
||||
elbow,
|
||||
}
|
||||
|
||||
/// One painted terminal glyph, a glyph column wide and one text line tall,
|
||||
/// in [color].
|
||||
class TerminalGlyph extends StatelessWidget {
|
||||
const TerminalGlyph(this.kind, {super.key, required this.color, this.style});
|
||||
|
||||
final TerminalGlyphKind kind;
|
||||
final Color color;
|
||||
|
||||
/// The text the glyph sits beside; the ambient style when null.
|
||||
final TextStyle? style;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ExcludeSemantics(
|
||||
child: SizedBox(
|
||||
width: terminalGlyphColumn(context),
|
||||
height: terminalLineHeight(context, style),
|
||||
child: CustomPaint(painter: _GlyphPainter(kind, color)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class _GlyphPainter extends CustomPainter {
|
||||
const _GlyphPainter(this.kind, this.color);
|
||||
|
||||
final TerminalGlyphKind kind;
|
||||
final Color color;
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final h = size.height;
|
||||
final paint = Paint()
|
||||
..color = color
|
||||
..isAntiAlias = true;
|
||||
switch (kind) {
|
||||
case TerminalGlyphKind.dot:
|
||||
canvas.drawCircle(Offset(h * 0.3, h / 2), h * 0.17, paint);
|
||||
case TerminalGlyphKind.elbow:
|
||||
paint
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 1;
|
||||
final x = h * 0.3;
|
||||
final path = Path()
|
||||
..moveTo(x, 0)
|
||||
..lineTo(x, h * 0.55)
|
||||
..lineTo(size.width * 0.95, h * 0.55);
|
||||
canvas.drawPath(path, paint);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(_GlyphPainter old) =>
|
||||
old.kind != kind || old.color != color;
|
||||
}
|
||||
|
||||
/// [child] after a [glyph] in the glyph column, the glyph centred on the
|
||||
/// child's first line.
|
||||
class TerminalGlyphRow extends StatelessWidget {
|
||||
const TerminalGlyphRow({super.key, required this.glyph, required this.child});
|
||||
|
||||
final Widget glyph;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
glyph,
|
||||
Expanded(child: child),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../../ui/theme/app_design_tokens.dart';
|
||||
import '../../sessions/chat_color_palette.dart';
|
||||
import '../chat_message_bubble.dart';
|
||||
|
||||
/// How strongly a coloured chat's shade washes a prompt line's band.
|
||||
const double terminalPromptTint = 0.1;
|
||||
|
||||
/// The operator's turn under a terminal design: a prompt line, the prompt
|
||||
/// glyph then the message, over a faint band with a dim gutter on its
|
||||
/// leading edge (in the chat's colour when it has one). It spans the reading
|
||||
/// column instead of shrinking into a bubble.
|
||||
class TerminalPromptLine extends StatelessWidget {
|
||||
const TerminalPromptLine({super.key, required this.child});
|
||||
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
final scheme = Theme.of(context).colorScheme;
|
||||
final shade = chatColorShade(context, ChatBubbleColor.of(context));
|
||||
final gutter = shade ?? scheme.outline;
|
||||
final glyph = shade ?? scheme.primary;
|
||||
return Material(
|
||||
key: const Key('chat-terminal-prompt-line'),
|
||||
// A faint wash of the chat's colour: its gutter and glyph carry it.
|
||||
color: shade == null
|
||||
? scheme.surfaceContainerLow
|
||||
: Color.alphaBlend(
|
||||
shade.withValues(alpha: terminalPromptTint),
|
||||
scheme.surfaceContainerLow,
|
||||
),
|
||||
shape: BorderDirectional(start: BorderSide(color: gutter, width: 2)),
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(10, 6, 12, 6),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
ExcludeSemantics(
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(end: 10),
|
||||
child: Text(
|
||||
tokens.promptGlyph,
|
||||
style: chatMessageTextStyle(
|
||||
context,
|
||||
)?.copyWith(color: glyph, fontWeight: FontWeight.w700),
|
||||
),
|
||||
),
|
||||
),
|
||||
Flexible(child: child),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -105,10 +105,7 @@ class GraphStageNode extends StatelessWidget {
|
||||
// coloured, smaller text in the status's own hue.
|
||||
final color = status == null
|
||||
? null
|
||||
: runStatusColor(
|
||||
graphStatusState(status),
|
||||
Theme.of(context).colorScheme,
|
||||
);
|
||||
: runStatusColorOf(context, graphStatusState(status));
|
||||
final caption = node.kindCaption;
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
||||
@@ -278,10 +278,7 @@ class PipelineListPanel extends StatelessWidget {
|
||||
? null
|
||||
: AppListStatusDot(
|
||||
key: Key('pipeline-status-${pipeline.id}'),
|
||||
color: runStatusColor(
|
||||
badge.state,
|
||||
Theme.of(context).colorScheme,
|
||||
),
|
||||
color: runStatusColorOf(context, badge.state),
|
||||
semanticLabel: runStateLabel(badge.state),
|
||||
),
|
||||
subtitle: Text(
|
||||
|
||||
@@ -74,7 +74,7 @@ class RunCheckCommandRow extends StatelessWidget {
|
||||
final mono = (theme.textTheme.bodyMedium ?? const TextStyle()).copyWith(
|
||||
fontFamily: appMonospaceFamily,
|
||||
);
|
||||
final color = runStatusColor(_state(check.status), theme.colorScheme);
|
||||
final color = runStatusColorOf(context, _state(check.status));
|
||||
final meta = check.meta;
|
||||
return ExpansionTile(
|
||||
tilePadding: EdgeInsets.zero,
|
||||
|
||||
@@ -111,7 +111,7 @@ class RunTimelineRow extends StatelessWidget {
|
||||
context,
|
||||
visit.outcome,
|
||||
)
|
||||
: runStatusColor(_state, Theme.of(context).colorScheme);
|
||||
: runStatusColorOf(context, _state);
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
@@ -139,7 +139,7 @@ class RunTimelineRow extends StatelessWidget {
|
||||
divider: divider,
|
||||
onTap: onTap,
|
||||
leading: AppListAvatar(
|
||||
foreground: runStatusColor(state, Theme.of(context).colorScheme),
|
||||
foreground: runStatusColorOf(context, state),
|
||||
child: RunStatusIcon(
|
||||
state: state,
|
||||
label: visit.status.isEmpty ? 'Status unavailable' : visit.status,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../ui/theme/app_design_tokens.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../../../ui/status/run_status_icon.dart';
|
||||
@@ -116,11 +117,11 @@ class _FactGrid extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _pill(BuildContext context, VisitFact fact) {
|
||||
final color = runStatusColor(_stateOf(fact), Theme.of(context).colorScheme);
|
||||
final color = runStatusColorOf(context, _stateOf(fact));
|
||||
return DecoratedBox(
|
||||
decoration: ShapeDecoration(
|
||||
color: color.withValues(alpha: 0.16),
|
||||
shape: const StadiumBorder(),
|
||||
shape: AppDesignTokens.of(context).shape(const StadiumBorder()),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../ui/theme/app_design_tokens.dart';
|
||||
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../../../core/api_gateway.dart';
|
||||
@@ -46,6 +47,9 @@ class RunGraphPreview extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
final border = Theme.of(context).colorScheme.outlineVariant;
|
||||
final corners = AppDesignTokens.of(
|
||||
context,
|
||||
).corners(BorderRadius.circular(12));
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
||||
child: Semantics(
|
||||
@@ -60,10 +64,10 @@ class RunGraphPreview extends StatelessWidget {
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: border),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderRadius: corners,
|
||||
),
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
borderRadius: corners,
|
||||
child: SizedBox(
|
||||
height: height,
|
||||
child: Stack(
|
||||
|
||||
@@ -136,7 +136,7 @@ class RunListRow extends StatelessWidget {
|
||||
onLongPress: selecting ? null : onLongPress,
|
||||
selectionControl: selecting ? _checkbox(context) : null,
|
||||
leading: AppListAvatar(
|
||||
foreground: runStatusColor(state, Theme.of(context).colorScheme),
|
||||
foreground: runStatusColorOf(context, state),
|
||||
child: RunStatusIcon(state: state, label: runStatusLabel(run)),
|
||||
),
|
||||
title: Text(title),
|
||||
|
||||
@@ -59,7 +59,7 @@ class RunPathMini extends StatelessWidget {
|
||||
width: 14,
|
||||
height: 10,
|
||||
decoration: BoxDecoration(
|
||||
color: runStatusColor(stage.state, Theme.of(context).colorScheme),
|
||||
color: runStatusColorOf(context, stage.state),
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
),
|
||||
);
|
||||
@@ -81,9 +81,9 @@ class RunPathMini extends StatelessWidget {
|
||||
height: 8,
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: runStatusColor(
|
||||
color: runStatusColorOf(
|
||||
context,
|
||||
end == '#success' ? 'succeeded' : 'failed',
|
||||
Theme.of(context).colorScheme,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -91,13 +91,7 @@ class RunsStatsPage extends StatelessWidget {
|
||||
key: const ValueKey('runs.stats.pie'),
|
||||
painter: _PiePainter([
|
||||
for (final entry in byState.entries)
|
||||
(
|
||||
runStatusColor(
|
||||
entry.key,
|
||||
Theme.of(context).colorScheme,
|
||||
),
|
||||
entry.value,
|
||||
),
|
||||
(runStatusColorOf(context, entry.key), entry.value),
|
||||
]),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../ui/theme/app_design.dart';
|
||||
import '../../ui/theme/app_design_controller.dart';
|
||||
import 'settings_group.dart';
|
||||
import 'settings_theme.dart';
|
||||
|
||||
const designSectionTitle = 'Design';
|
||||
const designSectionFooter =
|
||||
'Saved on this device only and applied at once. Light and dark follow '
|
||||
'the system under every design; Terminal uses its monospace font '
|
||||
'instead of the Font choice below.';
|
||||
const designSaveFailedText =
|
||||
'Not saved on this device; it applies until reload.';
|
||||
|
||||
ValueKey<String> settingsDesignKey(AppDesign design) =>
|
||||
ValueKey<String>('settings-design-${design.id}');
|
||||
|
||||
/// The device's app-wide design: one radio row per [AppDesign], each with a
|
||||
/// one-line summary. A choice applies at once, without a restart.
|
||||
class SettingsDesignSection extends StatelessWidget {
|
||||
const SettingsDesignSection({super.key, required this.controller});
|
||||
|
||||
final AppDesignController controller;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ListenableBuilder(
|
||||
listenable: controller,
|
||||
builder: (context, _) => RadioGroup<AppDesign>(
|
||||
groupValue: controller.design,
|
||||
onChanged: (design) {
|
||||
if (design != null) unawaited(controller.select(design));
|
||||
},
|
||||
child: SettingsGroup(
|
||||
title: designSectionTitle,
|
||||
footer: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const Text(designSectionFooter),
|
||||
if (controller.saveFailed)
|
||||
Text(
|
||||
designSaveFailedText,
|
||||
style: TextStyle(color: settingsErrorColor(context)),
|
||||
),
|
||||
],
|
||||
),
|
||||
children: [
|
||||
for (final design in AppDesign.values)
|
||||
RadioListTile<AppDesign>(
|
||||
key: settingsDesignKey(design),
|
||||
value: design,
|
||||
title: Text(design.label),
|
||||
subtitle: Text(design.description),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../ui/theme/app_design_tokens.dart';
|
||||
|
||||
import 'settings_layout.dart';
|
||||
|
||||
@@ -31,6 +32,7 @@ class SettingsGroup extends StatelessWidget {
|
||||
final title = this.title;
|
||||
final footer = this.footer;
|
||||
final theme = Theme.of(context);
|
||||
final tokens = AppDesignTokens.of(context);
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
@@ -50,10 +52,17 @@ class SettingsGroup extends StatelessWidget {
|
||||
if (children.isNotEmpty)
|
||||
Material(
|
||||
type: MaterialType.card,
|
||||
color: theme.colorScheme.surfaceContainer,
|
||||
color: tokens.flat
|
||||
? theme.colorScheme.surfaceContainerLow
|
||||
: theme.colorScheme.surfaceContainer,
|
||||
elevation: 0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(settingsGroupRadius),
|
||||
borderRadius: tokens.corners(
|
||||
BorderRadius.circular(settingsGroupRadius),
|
||||
),
|
||||
side: tokens.frame == null
|
||||
? BorderSide.none
|
||||
: BorderSide(color: tokens.frame!),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: Column(
|
||||
|
||||
@@ -28,6 +28,14 @@ extension _SettingsPageSections on _SettingsScreenState {
|
||||
widget.animationSpeed ?? AnimationSpeedController.instance,
|
||||
),
|
||||
),
|
||||
SettingsSection(
|
||||
id: 'design',
|
||||
title: designSectionTitle,
|
||||
keywords: 'design theme look style terminal monospace appearance',
|
||||
builder: (_) => SettingsDesignSection(
|
||||
controller: widget.designs ?? AppDesignController.instance,
|
||||
),
|
||||
),
|
||||
SettingsSection(
|
||||
id: 'font',
|
||||
title: fontSectionTitle,
|
||||
|
||||
@@ -11,10 +11,12 @@ import '../attention/notify/notification_controller.dart';
|
||||
import '../attention/notify/notification_models.dart';
|
||||
import 'default_endpoint.dart';
|
||||
import 'settings_controller.dart';
|
||||
import 'settings_design_section.dart';
|
||||
import 'settings_font_section.dart';
|
||||
import 'settings_animation_section.dart';
|
||||
import 'settings_scale_section.dart';
|
||||
import '../../ui/motion/animation_speed.dart';
|
||||
import '../../ui/theme/app_design_controller.dart';
|
||||
import '../../ui/theme/app_font_controller.dart';
|
||||
import 'settings_group.dart';
|
||||
import 'storage/settings_storage_section.dart';
|
||||
@@ -72,6 +74,7 @@ class SettingsScreen extends StatefulWidget {
|
||||
this.deliveryService,
|
||||
this.deliveryServiceController,
|
||||
this.fonts,
|
||||
this.designs,
|
||||
this.animationSpeed,
|
||||
this.terminalLayout,
|
||||
this.onShowWalkthrough,
|
||||
@@ -83,6 +86,9 @@ class SettingsScreen extends StatefulWidget {
|
||||
|
||||
/// The device's interface font; defaults to the app's shared controller.
|
||||
final AppFontController? fonts;
|
||||
|
||||
/// The device's app-wide design; defaults to the app's shared controller.
|
||||
final AppDesignController? designs;
|
||||
final AnimationSpeedController? animationSpeed;
|
||||
|
||||
/// The terminal surface's layout (its mode is chosen here); null is the
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../ui/theme/app_design_tokens.dart';
|
||||
|
||||
import 'destination.dart';
|
||||
import 'list_detail_policy.dart';
|
||||
@@ -165,7 +166,9 @@ class _SettingsRailItem extends StatelessWidget {
|
||||
height: 32,
|
||||
alignment: Alignment.center,
|
||||
decoration: ShapeDecoration(
|
||||
shape: const StadiumBorder(),
|
||||
shape: AppDesignTokens.of(
|
||||
context,
|
||||
).shape(const StadiumBorder()),
|
||||
color: selected ? scheme.secondaryContainer : null,
|
||||
),
|
||||
child: Icon(item.icon, color: foreground),
|
||||
|
||||
@@ -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