e34fa1050e
- SegmentedBar.titleWidget (and ShellBar/ShellBarSpec titleWidget, backgroundColor): a bar's main pill can be an input in place of the title; Search uses it so the field fills the bar with Kind and info, capped at the result column width so field and results share edges on wide windows. - Templates page/frame drop the top SafeArea again (BelowTopBar gate, TopBarNotices banners); Cupertino uses the grouped background. - Settings on Cupertino in the shell publishes the grouped background so the bar scrim matches the page (no white band or seam). - TopGlassStrip: the run detail header (status, actions, decision, notices) and the Schedules search/filter toolbar float as glass under the bar; tabs and lists scroll behind both. - Stage page: stage title and Visit/Run subtitle in the bar, facts lead the Summary scroll, sections scroll behind the bar under floating tabs. - Tests for content-behind-bar on each page and the title-widget bar mode; notes/chrome-gaps-fixes.md.
214 lines
6.6 KiB
Dart
214 lines
6.6 KiB
Dart
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';
|
|
import 'search_layout.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: the result column's
|
|
/// width, so on a wide window the field and the results share both edges.
|
|
const double kSearchPillMaxWidth = kSearchContentMaxWidth;
|
|
|
|
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 the top bar's main pill (in place of a title): the
|
|
/// search field filling the pill, 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(
|
|
children: [
|
|
Expanded(
|
|
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'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|