a3a59adb30
- Date once per calendar day: a muted centred divider above each day's
first timed row (chatDayDividers); rows show only their time ("10:16"),
with the full date and time kept in the tooltip and semantics. The user's
time shares the delivery line; a harness notice's time trails its line.
- Activity line and turn chips are secondary: bodyMedium, regular weight,
onSurfaceVariant (error colour kept for failures), a small chevron_right
that turns down while its details are open (replaces expand_less).
- Copy / Read aloud: 18 px muted icons; on pointer devices shown only while
the reply is hovered or an action is focused (also without the gutter);
touch keeps them visible with a full tap target. The time leads the
footer so hidden actions leave no gap.
- Settled questions: the question on one line, the operator's answer in
full on its own line beneath it.
- Meta rows (activity, chips, notices, compaction line) start at the reply
text's leading edge; turn chips sit in their own column under the answer.
- Scroll fixture: ?timestamps=1 spreads messages over two days.
Row keys are unchanged; the divider joins a row without replacing it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
79 lines
2.1 KiB
Dart
79 lines
2.1 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'chat_hover_actions.dart';
|
|
|
|
/// The accessible name of a reply's copy control, and its name just after a
|
|
/// copy succeeded.
|
|
const String chatCopyLabel = 'Copy';
|
|
const String chatCopiedLabel = 'Copied';
|
|
|
|
/// An icon-only control beneath a finished reply that puts the reply's text on
|
|
/// the clipboard. It shows a check for a moment after copying, so the operator
|
|
/// sees the copy landed without a separate toast.
|
|
class ChatCopyButton extends StatefulWidget {
|
|
const ChatCopyButton({super.key, required this.text, this.showLabel = false});
|
|
|
|
final String text;
|
|
final bool showLabel;
|
|
|
|
@override
|
|
State<ChatCopyButton> createState() => _ChatCopyButtonState();
|
|
}
|
|
|
|
class _ChatCopyButtonState extends State<ChatCopyButton> {
|
|
bool _copied = false;
|
|
Timer? _reset;
|
|
|
|
@override
|
|
void didUpdateWidget(ChatCopyButton oldWidget) {
|
|
super.didUpdateWidget(oldWidget);
|
|
if (oldWidget.text != widget.text) {
|
|
_reset?.cancel();
|
|
_copied = false;
|
|
}
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_reset?.cancel();
|
|
super.dispose();
|
|
}
|
|
|
|
Future<void> _copy() async {
|
|
final text = widget.text;
|
|
await Clipboard.setData(ClipboardData(text: text));
|
|
if (!mounted || widget.text != text) return;
|
|
setState(() => _copied = true);
|
|
_reset?.cancel();
|
|
_reset = Timer(const Duration(seconds: 2), () {
|
|
if (mounted) setState(() => _copied = false);
|
|
});
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final label = _copied ? chatCopiedLabel : chatCopyLabel;
|
|
if (widget.showLabel) {
|
|
final icon = Icon(_copied ? Icons.check : Icons.copy_outlined);
|
|
return Semantics(
|
|
identifier: 'chat-code-copy',
|
|
child: TextButton.icon(
|
|
onPressed: _copy,
|
|
icon: icon,
|
|
label: Text(label),
|
|
),
|
|
);
|
|
}
|
|
return IconButton(
|
|
key: const Key('chat-message-copy'),
|
|
style: chatMessageActionStyle(context),
|
|
tooltip: label,
|
|
onPressed: _copy,
|
|
icon: Icon(_copied ? Icons.check : Icons.copy_outlined),
|
|
);
|
|
}
|
|
}
|