027c2f800e
Agent replies sit on the page without a bubble and get a copy control; the operator's turn is a neutral rounded bubble; the composer is one filled pill with +, a borderless field and a round Send, and its placeholder names the chat's folder. Also fixes two picker tests left stale by the native picker.
69 lines
2.2 KiB
Dart
69 lines
2.2 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
/// The operator's turn: a neutral filled, evenly rounded bubble with no border,
|
|
/// in the host's own surface roles. The agent's turn has no bubble at all; its
|
|
/// text sits on the page, so only the operator's words are enclosed.
|
|
class ChatUserBubble extends StatelessWidget {
|
|
const ChatUserBubble({
|
|
super.key,
|
|
required this.cupertino,
|
|
required this.child,
|
|
});
|
|
|
|
final bool cupertino;
|
|
final Widget child;
|
|
|
|
static const BorderRadius _radius = BorderRadius.all(Radius.circular(20));
|
|
static const EdgeInsets _padding = EdgeInsets.symmetric(
|
|
horizontal: 16,
|
|
vertical: 10,
|
|
);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (cupertino) {
|
|
return DecoratedBox(
|
|
decoration: BoxDecoration(
|
|
color: CupertinoColors.systemGrey5.resolveFrom(context),
|
|
borderRadius: _radius,
|
|
),
|
|
child: Padding(padding: _padding, child: child),
|
|
);
|
|
}
|
|
// A Material surface (not a bare DecoratedBox) so a disclosure ListTile
|
|
// inside the bubble keeps its ink and background.
|
|
return Material(
|
|
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
|
clipBehavior: Clip.antiAlias,
|
|
shape: const RoundedRectangleBorder(borderRadius: _radius),
|
|
child: Padding(padding: _padding, child: child),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// The agent's answer drawn straight on the page. Material keeps a transparent
|
|
/// surface so disclosure ListTiles still paint their ink.
|
|
class ChatAgentSurface extends StatelessWidget {
|
|
const ChatAgentSurface({
|
|
super.key,
|
|
required this.cupertino,
|
|
required this.child,
|
|
});
|
|
|
|
final bool cupertino;
|
|
final Widget child;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => cupertino
|
|
? child
|
|
: Material(type: MaterialType.transparency, child: child);
|
|
}
|
|
|
|
/// The transcript's reading text: the host's large body role, so answers read
|
|
/// at a comfortable size and still follow the operator's text scaling.
|
|
TextStyle? chatMessageTextStyle(BuildContext context, bool cupertino) =>
|
|
cupertino
|
|
? CupertinoTheme.of(context).textTheme.textStyle
|
|
: Theme.of(context).textTheme.bodyLarge;
|