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.3 KiB
Dart
104 lines
3.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../core/api_gateway.dart';
|
|
import '../../../ui/layout/app_list_avatar.dart';
|
|
import '../../../ui/layout/app_list_row.dart';
|
|
import '../domain/search_row.dart';
|
|
import 'search_result_view.dart';
|
|
|
|
/// One search hit in the app's shared row: the kind's icon (or an image
|
|
/// artifact's picture), the title with its recency, and one muted line that
|
|
/// names the kind and then shows the snippet (its first query occurrence
|
|
/// emphasised by weight, never by parsing server text as markup) or, without
|
|
/// one, the kind's own facts. A chat hit with a matching message shows its
|
|
/// harness and directory, then the snippet on a second line. An artifact
|
|
/// hit's open choices are its menu.
|
|
class SearchResultRow extends StatelessWidget {
|
|
const SearchResultRow({
|
|
super.key,
|
|
required this.hit,
|
|
required this.query,
|
|
required this.onOpen,
|
|
this.divider = true,
|
|
});
|
|
|
|
final JsonMap hit;
|
|
final String query;
|
|
final ValueChanged<JsonMap> onOpen;
|
|
final bool divider;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final row = searchRowView(hit, query);
|
|
final kind = '${hit['kind'] ?? ''}';
|
|
return AppListRow(
|
|
key: ValueKey('search.result.${hit['target']}'),
|
|
divider: divider,
|
|
onTap: row.openable ? () => onOpen(hit) : null,
|
|
leading:
|
|
searchArtifactThumbnail(context, hit) ??
|
|
AppListAvatar(child: Icon(searchMaterialIcon(kind))),
|
|
title: Text(row.title),
|
|
time: row.recency,
|
|
subtitle: kind == 'chat' && row.snippet != null
|
|
? Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text.rich(_facts(row)),
|
|
Text.rich(TextSpan(children: _snippet(row))),
|
|
],
|
|
)
|
|
: Text.rich(_line(row)),
|
|
compactSubtitle: kind == 'chat' && row.snippet != null
|
|
? Text.rich(TextSpan(children: _snippet(row)))
|
|
: null,
|
|
menu: searchArtifactActions(context, hit),
|
|
);
|
|
}
|
|
|
|
TextSpan _line(SearchRowView row) => row.snippet == null
|
|
? _facts(row)
|
|
: TextSpan(children: [_kind(row), ..._snippet(row)]);
|
|
|
|
/// The kind, then the kind's own facts (a chat's harness and directory).
|
|
TextSpan _facts(SearchRowView row) => TextSpan(
|
|
children: [
|
|
_kind(row),
|
|
TextSpan(text: row.secondary),
|
|
],
|
|
);
|
|
|
|
TextSpan _kind(SearchRowView row) => TextSpan(
|
|
children: [
|
|
TextSpan(
|
|
text: row.kindLabel,
|
|
style: const TextStyle(fontWeight: FontWeight.w600),
|
|
),
|
|
const TextSpan(text: ' · '),
|
|
],
|
|
);
|
|
|
|
/// The snippet with its first query occurrence emphasised by weight.
|
|
List<TextSpan> _snippet(SearchRowView row) => [
|
|
for (final span in row.snippetSpans)
|
|
TextSpan(
|
|
text: span.text,
|
|
style: span.matched
|
|
? const TextStyle(fontWeight: FontWeight.bold)
|
|
: null,
|
|
),
|
|
];
|
|
}
|
|
|
|
IconData searchMaterialIcon(String kind) => switch (kind) {
|
|
'pipeline' => Icons.account_tree_outlined,
|
|
'version' => Icons.layers_outlined,
|
|
'run' => Icons.play_circle_outline,
|
|
'step' => Icons.arrow_forward,
|
|
'field' => Icons.notes,
|
|
'artifact' => Icons.attach_file,
|
|
'chat' => Icons.chat_bubble_outline,
|
|
_ => Icons.help_outline,
|
|
};
|