9551eceaed
Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
104 lines
3.1 KiB
Dart
104 lines
3.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../../ui/adaptive/app_popups.dart';
|
|
|
|
/// The quiet chip under an agent turn (its tools, its permissions) and the
|
|
/// native sheet it opens.
|
|
class ChatTurnChip extends StatelessWidget {
|
|
const ChatTurnChip({
|
|
super.key,
|
|
required this.chipKey,
|
|
required this.leading,
|
|
required this.label,
|
|
required this.color,
|
|
required this.semanticsLabel,
|
|
this.sheet,
|
|
this.open,
|
|
this.ellipsizeLabel = false,
|
|
this.labelSpans,
|
|
}) : assert(sheet != null || open != null);
|
|
|
|
final Key chipKey;
|
|
final Widget leading;
|
|
final String label;
|
|
final Color color;
|
|
final String semanticsLabel;
|
|
|
|
/// The detail content the chip opens, unless [open] presents it instead.
|
|
final Widget? sheet;
|
|
|
|
/// A custom presentation (a full-screen route on a narrow window).
|
|
final Future<void> Function(BuildContext context)? open;
|
|
|
|
/// Shrink a long label to one ellipsized line. Only for a chip whose parent
|
|
/// bounds its width (a turn footer's Wrap, an aligned row).
|
|
final bool ellipsizeLabel;
|
|
|
|
/// Styled pieces of [label] (e.g. coloured counts); [label] stays the
|
|
/// plain text. Pieces without their own style inherit the chip's style.
|
|
final List<InlineSpan> Function(BuildContext context)? labelSpans;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final content = Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
leading,
|
|
const SizedBox(width: 6),
|
|
if (ellipsizeLabel)
|
|
Flexible(child: _label(maxLines: 1, overflow: TextOverflow.ellipsis))
|
|
else
|
|
_label(),
|
|
Icon(Icons.expand_less, size: 14, color: color),
|
|
],
|
|
);
|
|
return Semantics(
|
|
button: true,
|
|
// The child's own action is excluded with its label, so the node
|
|
// carries the activation for assistive technology.
|
|
onTap: () => _open(context),
|
|
label: semanticsLabel,
|
|
excludeSemantics: true,
|
|
child: Padding(
|
|
padding: const EdgeInsets.only(top: 2),
|
|
child: InkWell(
|
|
key: chipKey,
|
|
borderRadius: BorderRadius.circular(8),
|
|
onTap: () => _open(context),
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 6),
|
|
child: content,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _label({int? maxLines, TextOverflow? overflow}) {
|
|
final style = TextStyle(color: color, fontSize: 13);
|
|
final spans = labelSpans;
|
|
if (spans == null) {
|
|
return Text(label, maxLines: maxLines, overflow: overflow, style: style);
|
|
}
|
|
return Builder(
|
|
builder: (context) => Text.rich(
|
|
TextSpan(children: spans(context)),
|
|
maxLines: maxLines,
|
|
overflow: overflow,
|
|
style: style,
|
|
),
|
|
);
|
|
}
|
|
|
|
Future<void> _open(BuildContext context) {
|
|
if (open case final open?) return open(context);
|
|
return showChatTurnSheet(context, sheet!);
|
|
}
|
|
}
|
|
|
|
/// The detail surface a turn chip opens: a dialog on desktop and a bottom
|
|
/// sheet on a phone.
|
|
Future<void> showChatTurnSheet(BuildContext context, Widget sheet) {
|
|
return showAppDetails<void>(context, builder: (_) => sheet);
|
|
}
|