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,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 {
|
||||
|
||||
Reference in New Issue
Block a user