Search field in the bar, refresh and Back as bar pieces, even Cupertino actions (F8/F28/F10/F11/F20/F1)
- Search: field, compact Kind menu and syntax help in the bar's actions pill; bounds shown only when truncated; rows with bold title, kind tag and one muted line; results run behind the bar in a start-aligned 840 column. - AppSearchField: one search field per platform (Search, Schedules, Runs filter). - BarIconButton: whole 44pt/48dp bar actions; Runs, bell and Pipelines icons use the same 44pt targets on Cupertino. - Templates and Schedules pages put Refresh in the bar and use the shared round SegmentedBackButton; Templates shows one Back at a time. - PipelineBackButton is the round segmented Back. - notes/pages-fixes.md records the batch, tests and evidence.
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
import '../../../core/api_gateway.dart';
|
||||
import '../domain/search_controller.dart';
|
||||
import '../domain/search_row.dart';
|
||||
import 'search_result_view.dart';
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import 'search_layout.dart';
|
||||
|
||||
/// The Cupertino search view: native search/kind controls and grouped list rows
|
||||
/// in one scroll view, with standard activity and retry controls.
|
||||
/// The Cupertino search view: an optional status header and inset-grouped
|
||||
/// rows in one scroll view that runs behind the top bar, with standard
|
||||
/// activity and retry controls.
|
||||
class CupertinoSearchBody extends StatelessWidget {
|
||||
const CupertinoSearchBody({
|
||||
super.key,
|
||||
@@ -25,7 +25,7 @@ class CupertinoSearchBody extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CustomScrollView(
|
||||
return SearchScrollView(
|
||||
slivers: [
|
||||
SliverToBoxAdapter(child: header),
|
||||
if (controller.showProgress)
|
||||
@@ -36,7 +36,6 @@ class CupertinoSearchBody extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
..._content(context),
|
||||
const SliverFloatingBarClearance(),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -64,7 +63,16 @@ class CupertinoSearchBody extends StatelessWidget {
|
||||
return [
|
||||
SliverToBoxAdapter(
|
||||
child: CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
// The section sits on the page's own background (the shell's
|
||||
// is not the grouped one), so it takes the bar pills' grey
|
||||
// rather than a white card framed by a grey band.
|
||||
backgroundColor: const Color(0x00000000),
|
||||
decoration: BoxDecoration(
|
||||
color: CupertinoColors.systemGrey6.resolveFrom(context),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||
),
|
||||
// The column already keeps the bar's inset.
|
||||
margin: const EdgeInsets.symmetric(vertical: 8),
|
||||
children: [
|
||||
for (final hit in controller.shownResults)
|
||||
_CupertinoResult(hit: hit, query: query, onOpen: onOpen),
|
||||
@@ -112,13 +120,8 @@ class _CupertinoResult extends StatelessWidget {
|
||||
Icon(searchCupertinoIcon('${hit['kind'] ?? ''}')),
|
||||
leadingSize: 44,
|
||||
trailing: searchArtifactActions(context, hit),
|
||||
title: Text(row.title),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 2,
|
||||
children: [searchRowMeta(row), searchRowSnippet(context, row)],
|
||||
),
|
||||
title: searchRowTitle(context, row),
|
||||
subtitle: searchRowLine(context, row),
|
||||
onTap: row.openable ? () => onOpen(hit) : null,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ import '../../../core/api_gateway.dart';
|
||||
import '../domain/search_controller.dart';
|
||||
import '../domain/search_row.dart';
|
||||
import 'search_result_view.dart';
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import 'search_layout.dart';
|
||||
|
||||
/// The Material search view: the controls header and a flat native result list
|
||||
/// in one scroll view, so text scaling can never clip the controls or a row.
|
||||
/// The Material search view: an optional status header and a flat native
|
||||
/// result list in one scroll view that runs behind the top bar.
|
||||
class MaterialSearchBody extends StatelessWidget {
|
||||
const MaterialSearchBody({
|
||||
super.key,
|
||||
@@ -24,13 +24,12 @@ class MaterialSearchBody extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CustomScrollView(
|
||||
return SearchScrollView(
|
||||
slivers: [
|
||||
SliverToBoxAdapter(child: header),
|
||||
if (controller.showProgress)
|
||||
const SliverToBoxAdapter(child: LinearProgressIndicator()),
|
||||
..._content(context),
|
||||
const SliverFloatingBarClearance(),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -100,13 +99,8 @@ class _MaterialResult extends StatelessWidget {
|
||||
searchArtifactThumbnail(context, hit) ??
|
||||
Icon(searchMaterialIcon('${hit['kind'] ?? ''}')),
|
||||
trailing: searchArtifactActions(context, hit),
|
||||
title: Text(row.title),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 2,
|
||||
children: [searchRowMeta(row), searchRowSnippet(context, row)],
|
||||
),
|
||||
title: searchRowTitle(context, row),
|
||||
subtitle: searchRowLine(context, row),
|
||||
onTap: row.openable ? () => onOpen(hit) : null,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/input/app_search_field.dart';
|
||||
import '../../../ui/navigation/bar_icon_button.dart';
|
||||
import '../domain/search_models.dart';
|
||||
|
||||
const searchFieldKey = ValueKey<String>('search.field');
|
||||
const searchKindKey = ValueKey<String>('search.kind');
|
||||
const searchHelpKey = ValueKey<String>('search.help');
|
||||
const searchBarControlsKey = ValueKey<String>('search.bar');
|
||||
|
||||
/// The widest the search pill grows on a wide window.
|
||||
const double kSearchPillMaxWidth = 560;
|
||||
|
||||
const searchTokenHint =
|
||||
'Filter with t:pipeline or type:artifact (pipeline, run, step, field, '
|
||||
'artifact, version). Last type wins; choosing Kind replaces it. Quote '
|
||||
'tokens to search literally.';
|
||||
|
||||
/// Search's controls as one piece of the top bar's actions pill: the search
|
||||
/// field, a compact Kind menu and the query-syntax help behind an info button.
|
||||
class SearchBarControls extends StatelessWidget {
|
||||
const SearchBarControls({
|
||||
super.key,
|
||||
required this.cupertino,
|
||||
required this.text,
|
||||
required this.kind,
|
||||
required this.onChanged,
|
||||
required this.onSubmitted,
|
||||
required this.onCleared,
|
||||
required this.onKind,
|
||||
this.autofocus = true,
|
||||
});
|
||||
|
||||
final bool cupertino;
|
||||
final TextEditingController text;
|
||||
final SearchKind kind;
|
||||
final ValueChanged<String> onChanged;
|
||||
final VoidCallback onSubmitted;
|
||||
final VoidCallback onCleared;
|
||||
final ValueChanged<SearchKind> onKind;
|
||||
final bool autofocus;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ConstrainedBox(
|
||||
key: searchBarControlsKey,
|
||||
constraints: const BoxConstraints(maxWidth: kSearchPillMaxWidth),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.only(start: 4),
|
||||
child: AppSearchField(
|
||||
fieldKey: searchFieldKey,
|
||||
clearKey: const ValueKey('search.clear'),
|
||||
controller: text,
|
||||
autofocus: autofocus,
|
||||
inBar: true,
|
||||
cupertino: cupertino,
|
||||
placeholder: 'Search pipelines, runs and artifacts',
|
||||
onChanged: onChanged,
|
||||
onSubmitted: (_) => onSubmitted(),
|
||||
onCleared: onCleared,
|
||||
),
|
||||
),
|
||||
),
|
||||
SearchKindButton(cupertino: cupertino, kind: kind, onSelected: onKind),
|
||||
BarIconButton(
|
||||
key: searchHelpKey,
|
||||
cupertino: cupertino,
|
||||
icon: Icons.info_outline,
|
||||
cupertinoIcon: CupertinoIcons.info_circle,
|
||||
label: 'Search syntax',
|
||||
onPressed: () => showSearchHelp(context, cupertino: cupertino),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// Kind as a compact menu: a filter icon while every kind is searched, the
|
||||
/// chosen kind's name once narrowed.
|
||||
class SearchKindButton extends StatelessWidget {
|
||||
const SearchKindButton({
|
||||
super.key,
|
||||
required this.cupertino,
|
||||
required this.kind,
|
||||
required this.onSelected,
|
||||
});
|
||||
|
||||
final bool cupertino;
|
||||
final SearchKind kind;
|
||||
final ValueChanged<SearchKind> onSelected;
|
||||
|
||||
String get _label => 'Kind: ${kind.label}';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final narrowed = kind != SearchKind.all;
|
||||
if (cupertino) {
|
||||
final icon = Icon(
|
||||
narrowed
|
||||
? CupertinoIcons.line_horizontal_3_decrease_circle_fill
|
||||
: CupertinoIcons.line_horizontal_3_decrease_circle,
|
||||
);
|
||||
return Semantics(
|
||||
button: true,
|
||||
label: _label,
|
||||
excludeSemantics: true,
|
||||
child: CupertinoButton(
|
||||
key: searchKindKey,
|
||||
padding: EdgeInsets.symmetric(horizontal: narrowed ? 8 : 0),
|
||||
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
|
||||
onPressed: () => _pickCupertino(context),
|
||||
child: narrowed
|
||||
? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 4,
|
||||
children: [icon, Text(kind.label)],
|
||||
)
|
||||
: icon,
|
||||
),
|
||||
);
|
||||
}
|
||||
return PopupMenuButton<SearchKind>(
|
||||
key: searchKindKey,
|
||||
tooltip: _label,
|
||||
initialValue: kind,
|
||||
onSelected: onSelected,
|
||||
itemBuilder: (_) => [
|
||||
for (final value in SearchKind.values)
|
||||
CheckedPopupMenuItem(
|
||||
value: value,
|
||||
checked: value == kind,
|
||||
child: Text(value.label),
|
||||
),
|
||||
],
|
||||
child: narrowed
|
||||
? Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Chip(
|
||||
avatar: const Icon(Icons.filter_list),
|
||||
label: Text(kind.label),
|
||||
visualDensity: VisualDensity.compact,
|
||||
),
|
||||
)
|
||||
: const SizedBox.square(
|
||||
dimension: kMinInteractiveDimension,
|
||||
child: Icon(Icons.filter_list),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _pickCupertino(BuildContext context) async {
|
||||
final selected = await showCupertinoModalPopup<SearchKind>(
|
||||
context: context,
|
||||
builder: (context) => CupertinoActionSheet(
|
||||
title: const Text('Kind'),
|
||||
actions: [
|
||||
for (final value in SearchKind.values)
|
||||
CupertinoActionSheetAction(
|
||||
onPressed: () => Navigator.pop(context, value),
|
||||
isDefaultAction: value == kind,
|
||||
child: Text(value.label),
|
||||
),
|
||||
],
|
||||
cancelButton: CupertinoActionSheetAction(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
),
|
||||
);
|
||||
if (selected != null) onSelected(selected);
|
||||
}
|
||||
}
|
||||
|
||||
/// The query syntax, on demand instead of a paragraph above the results.
|
||||
Future<void> showSearchHelp(BuildContext context, {required bool cupertino}) {
|
||||
if (cupertino) {
|
||||
return showCupertinoDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
builder: (context) => CupertinoAlertDialog(
|
||||
title: const Text('Search syntax'),
|
||||
content: const Text(searchTokenHint),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
isDefaultAction: true,
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text('Search syntax'),
|
||||
content: const Text(searchTokenHint),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('OK'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
const searchBoundsKey = ValueKey<String>('search.bounds');
|
||||
|
||||
/// The server's note that a result set was cut short, in the host's muted
|
||||
/// caption style with an info icon.
|
||||
class SearchBoundsNote extends StatelessWidget {
|
||||
const SearchBoundsNote({super.key, required this.text});
|
||||
|
||||
final String text;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final TextStyle? style;
|
||||
final IconData icon;
|
||||
if (cupertino) {
|
||||
icon = CupertinoIcons.info_circle;
|
||||
style = CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
fontSize: 13,
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
);
|
||||
} else {
|
||||
icon = Icons.info_outline;
|
||||
final theme = Theme.of(context);
|
||||
style = theme.textTheme.bodySmall?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
);
|
||||
}
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 8,
|
||||
children: [
|
||||
Icon(icon, size: 16, color: style?.color),
|
||||
Expanded(child: Text(text, style: style)),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
|
||||
/// The widest the result column grows on a wide window.
|
||||
const double kSearchContentMaxWidth = 840;
|
||||
|
||||
/// The bar's own side inset, so the column starts under the title pill.
|
||||
const double kSearchContentInset = 12;
|
||||
|
||||
/// Search's scroll view: it runs behind the floating top bar (the first item
|
||||
/// starts below the bar's height, read from the media padding), ends clear of
|
||||
/// a floating tab bar, and keeps each sliver to a start-aligned column no
|
||||
/// wider than [kSearchContentMaxWidth].
|
||||
class SearchScrollView extends StatelessWidget {
|
||||
const SearchScrollView({super.key, required this.slivers});
|
||||
|
||||
final List<Widget> slivers;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final padding = MediaQuery.paddingOf(context);
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
SliverToBoxAdapter(child: SizedBox(height: padding.top + 4)),
|
||||
for (final sliver in slivers)
|
||||
SliverPadding(
|
||||
padding: EdgeInsetsDirectional.only(
|
||||
start: kSearchContentInset + padding.left,
|
||||
end: kSearchContentInset + padding.right,
|
||||
),
|
||||
sliver: SliverConstrainedCrossAxis(
|
||||
maxExtent: kSearchContentMaxWidth,
|
||||
sliver: sliver,
|
||||
),
|
||||
),
|
||||
const SliverFloatingBarClearance(),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -11,39 +11,87 @@ import '../../artifacts/ui/artifact_tile.dart';
|
||||
import '../../artifacts/ui/artifact_viewer_fetch.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),
|
||||
/// A row's title line: the bold title and, at its trailing edge, a small tag
|
||||
/// naming the kind.
|
||||
Widget searchRowTitle(BuildContext context, SearchRowView row) => Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 8,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
row.title,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
SearchKindTag(label: row.kindLabel),
|
||||
],
|
||||
);
|
||||
|
||||
/// A row's one muted line: recency, then the snippet (its first query
|
||||
/// occurrence emphasised by weight, never by parsing server text as markup)
|
||||
/// or, without one, the kind's own facts.
|
||||
Widget searchRowLine(BuildContext context, SearchRowView row) {
|
||||
final snippet = row.snippet;
|
||||
final lead = row.recency == null ? '' : '${row.recency} · ';
|
||||
final spans = <InlineSpan>[
|
||||
if (snippet == null)
|
||||
TextSpan(text: '$lead${row.secondary}')
|
||||
else ...[
|
||||
if (lead.isNotEmpty) TextSpan(text: lead),
|
||||
for (final span in row.snippetSpans)
|
||||
TextSpan(
|
||||
text: span.text,
|
||||
style: span.matched
|
||||
? const TextStyle(fontWeight: FontWeight.bold)
|
||||
: null,
|
||||
),
|
||||
],
|
||||
];
|
||||
return Text.rich(
|
||||
TextSpan(children: spans),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(color: _muted(context)),
|
||||
);
|
||||
}
|
||||
|
||||
/// 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);
|
||||
Color _muted(BuildContext context) => usesCupertinoHost(context)
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
|
||||
/// The result's kind as a small tinted capsule.
|
||||
class SearchKindTag extends StatelessWidget {
|
||||
const SearchKindTag({super.key, required this.label});
|
||||
|
||||
final String label;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final Color fill;
|
||||
final TextStyle? style;
|
||||
if (cupertino) {
|
||||
fill = CupertinoColors.tertiarySystemFill.resolveFrom(context);
|
||||
style = CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
);
|
||||
} else {
|
||||
final theme = Theme.of(context);
|
||||
fill = theme.colorScheme.surfaceContainerHighest;
|
||||
style = theme.textTheme.labelSmall?.copyWith(
|
||||
color: theme.colorScheme.onSurfaceVariant,
|
||||
);
|
||||
}
|
||||
return DecoratedBox(
|
||||
decoration: ShapeDecoration(color: fill, shape: const StadiumBorder()),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
child: Text(label, style: style),
|
||||
),
|
||||
);
|
||||
}
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user