963adec122
One floating frosted tab bar (host NavigationBar / CupertinoTabBar in the shared GlassPill) replaces the NavigationRail, the Cupertino sidebar and the run detail, stage page and pipeline detail tab strips. Below 600px it spans the width minus 16px margins; wider it is sized to its tabs at the right edge. Content keeps the full width, scrolls behind the bar and learns its height as bottom media padding; lists pad their end clear of it and FABs sit above it. The bar now sizes itself from its own constraints instead of the screen size, which fixes the widget_test failure where a MediaQuery without a size gave it negative width constraints.
171 lines
4.6 KiB
Dart
171 lines
4.6 KiB
Dart
import 'package:flutter/material.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';
|
|
|
|
/// 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.
|
|
class MaterialSearchBody extends StatelessWidget {
|
|
const MaterialSearchBody({
|
|
super.key,
|
|
required this.controller,
|
|
required this.query,
|
|
required this.onOpen,
|
|
required this.header,
|
|
});
|
|
|
|
final OmniSearchController controller;
|
|
final String query;
|
|
final ValueChanged<JsonMap> onOpen;
|
|
final Widget header;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return CustomScrollView(
|
|
slivers: [
|
|
SliverToBoxAdapter(child: header),
|
|
if (controller.showProgress)
|
|
const SliverToBoxAdapter(child: LinearProgressIndicator()),
|
|
..._content(context),
|
|
const SliverFloatingBarClearance(),
|
|
],
|
|
);
|
|
}
|
|
|
|
List<Widget> _content(BuildContext context) {
|
|
switch (controller.bodyKind) {
|
|
case SearchBodyKind.error:
|
|
return [
|
|
SliverFillRemaining(
|
|
hasScrollBody: false,
|
|
child: _SearchError(
|
|
message: controller.error!,
|
|
onRetry: controller.retry,
|
|
),
|
|
),
|
|
];
|
|
case SearchBodyKind.searching:
|
|
return const [
|
|
SliverFillRemaining(hasScrollBody: false, child: _Searching()),
|
|
];
|
|
case SearchBodyKind.results:
|
|
return [
|
|
SliverList.builder(
|
|
itemCount: controller.shownResults.length,
|
|
itemBuilder: (context, index) {
|
|
final hit = controller.shownResults[index];
|
|
return _MaterialResult(hit: hit, query: query, onOpen: onOpen);
|
|
},
|
|
),
|
|
];
|
|
case SearchBodyKind.empty:
|
|
return [
|
|
SliverToBoxAdapter(
|
|
child: _SearchMessage(message: controller.emptyMessage!),
|
|
),
|
|
];
|
|
case SearchBodyKind.idle:
|
|
return const [
|
|
SliverFillRemaining(
|
|
hasScrollBody: false,
|
|
child: _SearchMessage(
|
|
message: 'Search pipelines, runs and artifacts.',
|
|
),
|
|
),
|
|
];
|
|
}
|
|
}
|
|
}
|
|
|
|
class _MaterialResult extends StatelessWidget {
|
|
const _MaterialResult({
|
|
required this.hit,
|
|
required this.query,
|
|
required this.onOpen,
|
|
});
|
|
|
|
final JsonMap hit;
|
|
final String query;
|
|
final ValueChanged<JsonMap> onOpen;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final row = searchRowView(hit, query);
|
|
return ListTile(
|
|
key: ValueKey('search.result.${hit['target']}'),
|
|
leading:
|
|
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)],
|
|
),
|
|
onTap: row.openable ? () => onOpen(hit) : null,
|
|
);
|
|
}
|
|
}
|
|
|
|
class _Searching extends StatelessWidget {
|
|
const _Searching();
|
|
|
|
@override
|
|
Widget build(BuildContext context) => const Center(
|
|
child: Padding(
|
|
padding: EdgeInsets.all(24),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
spacing: 12,
|
|
children: [CircularProgressIndicator(), Text('Searching…')],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
class _SearchMessage extends StatelessWidget {
|
|
const _SearchMessage({required this.message});
|
|
|
|
final String message;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Text(message, textAlign: TextAlign.center),
|
|
),
|
|
);
|
|
}
|
|
|
|
class _SearchError extends StatelessWidget {
|
|
const _SearchError({required this.message, required this.onRetry});
|
|
|
|
final String message;
|
|
final Future<void> Function() onRetry;
|
|
|
|
@override
|
|
Widget build(BuildContext context) => Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
spacing: 12,
|
|
children: [
|
|
Text(message, textAlign: TextAlign.center),
|
|
FilledButton.tonalIcon(
|
|
key: const ValueKey('search.retry'),
|
|
onPressed: onRetry,
|
|
icon: const Icon(Icons.refresh),
|
|
label: const Text('Retry'),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|