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.
182 lines
4.9 KiB
Dart
182 lines
4.9 KiB
Dart
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';
|
|
|
|
/// The Cupertino search view: native search/kind controls and grouped list rows
|
|
/// in one scroll view, with standard activity and retry controls.
|
|
class CupertinoSearchBody extends StatelessWidget {
|
|
const CupertinoSearchBody({
|
|
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: Padding(
|
|
padding: EdgeInsets.symmetric(vertical: 8),
|
|
child: CupertinoActivityIndicator(),
|
|
),
|
|
),
|
|
..._content(context),
|
|
const SliverFloatingBarClearance(),
|
|
],
|
|
);
|
|
}
|
|
|
|
List<Widget> _content(BuildContext context) {
|
|
switch (controller.bodyKind) {
|
|
case SearchBodyKind.error:
|
|
return [
|
|
SliverFillRemaining(
|
|
hasScrollBody: false,
|
|
child: _CupertinoError(
|
|
message: controller.error!,
|
|
onRetry: controller.retry,
|
|
),
|
|
),
|
|
];
|
|
case SearchBodyKind.searching:
|
|
return const [
|
|
SliverFillRemaining(
|
|
hasScrollBody: false,
|
|
child: _CupertinoSearching(),
|
|
),
|
|
];
|
|
case SearchBodyKind.results:
|
|
return [
|
|
SliverToBoxAdapter(
|
|
child: CupertinoListSection.insetGrouped(
|
|
backgroundColor: AppColors.groupedBackground,
|
|
children: [
|
|
for (final hit in controller.shownResults)
|
|
_CupertinoResult(hit: hit, query: query, onOpen: onOpen),
|
|
],
|
|
),
|
|
),
|
|
];
|
|
case SearchBodyKind.empty:
|
|
return [
|
|
SliverToBoxAdapter(
|
|
child: _CupertinoMessage(message: controller.emptyMessage!),
|
|
),
|
|
];
|
|
case SearchBodyKind.idle:
|
|
return const [
|
|
SliverFillRemaining(
|
|
hasScrollBody: false,
|
|
child: _CupertinoMessage(
|
|
message: 'Search pipelines, runs and artifacts.',
|
|
),
|
|
),
|
|
];
|
|
}
|
|
}
|
|
}
|
|
|
|
class _CupertinoResult extends StatelessWidget {
|
|
const _CupertinoResult({
|
|
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 CupertinoListTile(
|
|
key: ValueKey('search.result.${hit['target']}'),
|
|
leading:
|
|
searchArtifactThumbnail(context, hit) ??
|
|
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)],
|
|
),
|
|
onTap: row.openable ? () => onOpen(hit) : null,
|
|
);
|
|
}
|
|
}
|
|
|
|
class _CupertinoSearching extends StatelessWidget {
|
|
const _CupertinoSearching();
|
|
|
|
@override
|
|
Widget build(BuildContext context) => const Center(
|
|
child: Padding(
|
|
padding: EdgeInsets.all(24),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
spacing: 12,
|
|
children: [CupertinoActivityIndicator(), Text('Searching…')],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
class _CupertinoMessage extends StatelessWidget {
|
|
const _CupertinoMessage({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 _CupertinoError extends StatelessWidget {
|
|
const _CupertinoError({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),
|
|
CupertinoButton.filled(
|
|
key: const ValueKey('search.retry'),
|
|
onPressed: onRetry,
|
|
child: const Text('Retry'),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|