import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../domain/search_row.dart'; /// Kind, recency and read-only affordance for one row. Deliberately unstyled /// beyond weight so Material and Cupertino inherit their own system typography /// and colours, including dark mode and text scaling. Widget searchRowMeta(SearchRowView row) { final parts = [row.kindLabel, if (row.recency != null) row.recency!]; return Text( parts.join(' ยท '), style: const TextStyle(fontWeight: FontWeight.w600), ); } /// The snippet with the first query occurrence emphasised by weight, never by /// parsing server text as markup or by a bespoke colour. Widget searchRowSnippet(BuildContext context, SearchRowView row) { final snippet = row.snippet; if (snippet == null) { return row.secondary.isEmpty ? const SizedBox.shrink() : Text(row.secondary); } return Text.rich( TextSpan( children: [ 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, };