9551eceaed
Remove obsolete control-family flags and icon metadata across all callers, dead alternate themes and host helpers, obsolete test setup, and the unused icon-font dependency. Preserve native Material Back transitions. Make navigation fixtures independent of update plugins and answer auxiliary shell snapshots so the complete application suite can run deterministically.
134 lines
3.4 KiB
Dart
134 lines
3.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../core/api_gateway.dart';
|
|
import '../domain/search_controller.dart';
|
|
import 'search_result_slivers.dart';
|
|
import 'search_layout.dart';
|
|
|
|
/// 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,
|
|
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 SearchScrollView(
|
|
slivers: [
|
|
SliverToBoxAdapter(child: header),
|
|
if (controller.showProgress)
|
|
const SliverToBoxAdapter(child: LinearProgressIndicator()),
|
|
..._content(context),
|
|
],
|
|
);
|
|
}
|
|
|
|
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 searchResultSlivers(
|
|
controller: controller,
|
|
query: query,
|
|
onOpen: onOpen,
|
|
message: (text) => _SearchMessage(message: text),
|
|
);
|
|
case SearchBodyKind.empty:
|
|
return [
|
|
SliverToBoxAdapter(
|
|
child: _SearchMessage(message: controller.emptyMessage!),
|
|
),
|
|
];
|
|
case SearchBodyKind.idle:
|
|
return const [
|
|
SliverFillRemaining(
|
|
hasScrollBody: false,
|
|
child: _SearchMessage(
|
|
message: 'Search pipelines, runs, artifacts and chats.',
|
|
),
|
|
),
|
|
];
|
|
}
|
|
}
|
|
}
|
|
|
|
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'),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|