3c56db37fd
AppListRow (Material + Cupertino) with avatar, bold title and trailing time, one muted line, one overflow menu style, inset dividers, selected and emphasised states and a compact mode. Pipelines get a legible initial avatar, schedule rows shrink to two lines with Edit/Pause/Delete in an overflow menu, and the shell chat list scrolls behind the bar.
97 lines
2.9 KiB
Dart
97 lines
2.9 KiB
Dart
import 'package:flutter/cupertino.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. 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,
|
|
required this.cupertino,
|
|
this.divider = true,
|
|
});
|
|
|
|
final JsonMap hit;
|
|
final String query;
|
|
final ValueChanged<JsonMap> onOpen;
|
|
final bool cupertino;
|
|
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']}'),
|
|
cupertino: cupertino,
|
|
divider: divider,
|
|
onTap: row.openable ? () => onOpen(hit) : null,
|
|
leading:
|
|
searchArtifactThumbnail(context, hit) ??
|
|
AppListAvatar(
|
|
child: Icon(
|
|
cupertino ? searchCupertinoIcon(kind) : searchMaterialIcon(kind),
|
|
),
|
|
),
|
|
title: Text(row.title),
|
|
time: row.recency,
|
|
subtitle: Text.rich(_line(row)),
|
|
menu: searchArtifactActions(context, hit),
|
|
);
|
|
}
|
|
|
|
TextSpan _line(SearchRowView row) {
|
|
final snippet = row.snippet;
|
|
return TextSpan(
|
|
children: [
|
|
TextSpan(
|
|
text: row.kindLabel,
|
|
style: const TextStyle(fontWeight: FontWeight.w600),
|
|
),
|
|
const TextSpan(text: ' · '),
|
|
if (snippet == null)
|
|
TextSpan(text: row.secondary)
|
|
else
|
|
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,
|
|
_ => Icons.help_outline,
|
|
};
|
|
|
|
IconData searchCupertinoIcon(String kind) => switch (kind) {
|
|
'pipeline' => CupertinoIcons.arrow_branch,
|
|
'version' => CupertinoIcons.square_stack_3d_up,
|
|
'run' => CupertinoIcons.play_circle,
|
|
'step' => CupertinoIcons.arrow_right,
|
|
'field' => CupertinoIcons.doc_text,
|
|
'artifact' => CupertinoIcons.paperclip,
|
|
_ => CupertinoIcons.question_circle,
|
|
};
|