feat(chat): frame attachment thumbnails with a subtle hairline
Sent images and composer thumbnails share ChatAttachmentFrame: rounded corners plus a faint outline in the host's outline role, so a dark screenshot no longer melts into a dark page. Adds a web probe that renders the streaming activity line at several text sizes.
This commit is contained in:
@@ -20,6 +20,7 @@ import '../ui/sessions/chat_adaptive.dart';
|
||||
import 'chat_command_actions.dart';
|
||||
import 'chat_command_palette.dart';
|
||||
import 'chat_composer_controller.dart';
|
||||
import '../ui/transcript/chat_attachment_frame.dart';
|
||||
|
||||
/// The composer's placeholder when the chat names no working directory.
|
||||
const String chatComposerPlaceholder = 'Message the agent';
|
||||
@@ -801,8 +802,8 @@ class _ChatComposerBarState extends State<ChatComposerBar> {
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Positioned.fill(
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: ChatAttachmentFrame(
|
||||
radius: BorderRadius.circular(10),
|
||||
child: Image.memory(
|
||||
bytes,
|
||||
key: ValueKey<String>('chat-composer-thumbnail-$index'),
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../sessions/chat_adaptive.dart';
|
||||
|
||||
/// Rounds an attachment thumbnail and draws a subtle hairline around it, so a
|
||||
/// dark screenshot on a dark page (or a light one on a light page) still reads
|
||||
/// as a separate object. The line sits over the image's edge, in the host's
|
||||
/// own outline role.
|
||||
class ChatAttachmentFrame extends StatelessWidget {
|
||||
const ChatAttachmentFrame({
|
||||
super.key,
|
||||
required this.radius,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
final BorderRadius radius;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino =
|
||||
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
|
||||
final line = cupertino
|
||||
? CupertinoColors.separator.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.outlineVariant;
|
||||
return Container(
|
||||
key: const Key('chat-attachment-frame'),
|
||||
foregroundDecoration: BoxDecoration(
|
||||
borderRadius: radius,
|
||||
border: Border.all(color: line.withValues(alpha: 0.8)),
|
||||
),
|
||||
child: ClipRRect(borderRadius: radius, child: child),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../data/chat_attachment_images.dart';
|
||||
import 'chat_attachment_frame.dart';
|
||||
import 'chat_image_viewer.dart';
|
||||
|
||||
/// The largest edge a sent image's thumbnail takes in the transcript.
|
||||
@@ -105,8 +106,8 @@ class _ChatAttachmentThumbnailState extends State<ChatAttachmentThumbnail> {
|
||||
|
||||
Widget _thumbnail(BuildContext context, Uint8List bytes) {
|
||||
final ratio = MediaQuery.devicePixelRatioOf(context);
|
||||
final image = ClipRRect(
|
||||
borderRadius: _radius,
|
||||
final image = ChatAttachmentFrame(
|
||||
radius: _radius,
|
||||
child: Image(
|
||||
key: const Key('chat-attachment-thumbnail-image'),
|
||||
// Decode at the thumbnail's size, not the photo's, while scrolling.
|
||||
|
||||
@@ -90,6 +90,11 @@ void main() {
|
||||
find.byKey(const Key('chat-attachment-thumbnail-image')),
|
||||
findsOneWidget,
|
||||
);
|
||||
// A hairline frames the image so it reads against the page.
|
||||
final frame = tester.widget<Container>(
|
||||
find.byKey(const Key('chat-attachment-frame')),
|
||||
);
|
||||
expect((frame.foregroundDecoration as BoxDecoration).border, isNotNull);
|
||||
// No paperclip row and no base64 shown as a file name.
|
||||
expect(find.byIcon(Icons.attach_file), findsNothing);
|
||||
expect(find.byIcon(CupertinoIcons.paperclip), findsNothing);
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:pipelines_app/features/chat/ui/transcript/chat_turn_activity_view.dart';
|
||||
|
||||
const _style = String.fromEnvironment('PROBE_STYLE', defaultValue: 'material');
|
||||
|
||||
/// Visual check for the streaming activity line: the pending dots beside
|
||||
/// "Responding Ns" at a few text sizes, in light and dark.
|
||||
void main() {
|
||||
Widget line(double scale) => MediaQuery.withClampedTextScaling(
|
||||
minScaleFactor: scale,
|
||||
maxScaleFactor: scale,
|
||||
child: const Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: ChatTurnActivityView(
|
||||
parts: [
|
||||
{'type': 'text', 'text': 'Partial answer'},
|
||||
],
|
||||
streaming: true,
|
||||
),
|
||||
),
|
||||
);
|
||||
final body = ListView(children: [line(1), line(1.5), line(2)]);
|
||||
runApp(
|
||||
_style == 'cupertino'
|
||||
? CupertinoApp(
|
||||
theme: const CupertinoThemeData(brightness: Brightness.dark),
|
||||
home: CupertinoPageScaffold(child: SafeArea(child: body)),
|
||||
)
|
||||
: MaterialApp(
|
||||
theme: ThemeData(brightness: Brightness.dark),
|
||||
home: Scaffold(body: SafeArea(child: body)),
|
||||
),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user