Remove Cupertino search branches
Keep the Material-only search implementation while preserving public signatures and required icon fallback parameters.
This commit is contained in:
@@ -1,14 +1,11 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../core/api_gateway.dart';
|
import '../../core/api_gateway.dart';
|
||||||
import '../../shell/shell_bar.dart';
|
import '../../shell/shell_bar.dart';
|
||||||
import '../../shell/shell_search_focus.dart';
|
import '../../shell/shell_search_focus.dart';
|
||||||
import '../../ui/adaptive/host.dart';
|
|
||||||
import '../../ui/adaptive/segmented_bar.dart';
|
import '../../ui/adaptive/segmented_bar.dart';
|
||||||
import 'data/search_repository.dart';
|
import 'data/search_repository.dart';
|
||||||
import 'domain/search_controller.dart';
|
import 'domain/search_controller.dart';
|
||||||
import 'ui/cupertino_search_body.dart';
|
|
||||||
import 'ui/material_search_body.dart';
|
import 'ui/material_search_body.dart';
|
||||||
import 'ui/search_bar_controls.dart';
|
import 'ui/search_bar_controls.dart';
|
||||||
import 'ui/search_bounds_note.dart';
|
import 'ui/search_bounds_note.dart';
|
||||||
@@ -31,8 +28,7 @@ class SearchScreen extends StatefulWidget {
|
|||||||
final ApiGateway gateway;
|
final ApiGateway gateway;
|
||||||
final ValueChanged<JsonMap> onOpen;
|
final ValueChanged<JsonMap> onOpen;
|
||||||
|
|
||||||
/// Lets the shell state the surface it composed. When omitted, iOS/macOS use
|
/// Retained for the shell's surface contract; search is Material-only.
|
||||||
/// Cupertino controls and every other platform uses Material.
|
|
||||||
final bool? cupertino;
|
final bool? cupertino;
|
||||||
|
|
||||||
/// True as the Search tab: the controls go into the shell's bar.
|
/// True as the Search tab: the controls go into the shell's bar.
|
||||||
@@ -127,39 +123,33 @@ class _SearchScreenState extends State<SearchScreen> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
Widget _build(BuildContext context) {
|
Widget _build(BuildContext context) {
|
||||||
// Follow the actual host app class: Cupertino only under an explicit
|
|
||||||
// Cupertino host, Material on every platform otherwise.
|
|
||||||
final cupertino = widget.cupertino ?? usesCupertinoHost(context);
|
|
||||||
if (widget.embedded) {
|
if (widget.embedded) {
|
||||||
// The shell's bar carries the controls; without a shell (a bare embed)
|
// The shell's bar carries the controls; without a shell (a bare embed)
|
||||||
// they lead the results instead.
|
// they lead the results instead.
|
||||||
if (!ShellBar.available(context)) {
|
if (!ShellBar.available(context)) {
|
||||||
return _body(cupertino, controls: _controls(cupertino));
|
return _body(controls: _controls());
|
||||||
}
|
}
|
||||||
// The field takes the title's place and fills the bar.
|
// The field takes the title's place and fills the bar.
|
||||||
return ShellBar(
|
return ShellBar(
|
||||||
titleWidget: _controls(cupertino),
|
titleWidget: _controls(),
|
||||||
child: _body(cupertino),
|
child: _body(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final bar = SegmentedBar(
|
final bar = SegmentedBar(
|
||||||
cupertino: cupertino,
|
cupertino: false,
|
||||||
title: 'Search',
|
title: 'Search',
|
||||||
titleWidget: _controls(cupertino),
|
titleWidget: _controls(),
|
||||||
);
|
);
|
||||||
if (cupertino) {
|
|
||||||
return CupertinoPageScaffold(navigationBar: bar, child: _body(cupertino));
|
|
||||||
}
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
appBar: bar,
|
appBar: bar,
|
||||||
body: _body(cupertino),
|
body: _body(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _controls(bool cupertino) => SearchBarControls(
|
Widget _controls() => SearchBarControls(
|
||||||
focusNode: _focus,
|
focusNode: _focus,
|
||||||
cupertino: cupertino,
|
cupertino: false,
|
||||||
text: _text,
|
text: _text,
|
||||||
kind: _controller.parsed.kind,
|
kind: _controller.parsed.kind,
|
||||||
onChanged: _controller.updateQuery,
|
onChanged: _controller.updateQuery,
|
||||||
@@ -189,24 +179,17 @@ class _SearchScreenState extends State<SearchScreen> {
|
|||||||
|
|
||||||
/// No top safe area: the results run behind the floating bar and the
|
/// No top safe area: the results run behind the floating bar and the
|
||||||
/// scroll view starts them below it.
|
/// scroll view starts them below it.
|
||||||
Widget _body(bool cupertino, {Widget? controls}) {
|
Widget _body({Widget? controls}) {
|
||||||
final header = _header(controls: controls);
|
final header = _header(controls: controls);
|
||||||
return SearchArtifactScope(
|
return SearchArtifactScope(
|
||||||
gateway: widget.gateway,
|
gateway: widget.gateway,
|
||||||
onOpen: widget.onOpen,
|
onOpen: widget.onOpen,
|
||||||
child: cupertino
|
child: MaterialSearchBody(
|
||||||
? CupertinoSearchBody(
|
controller: _controller,
|
||||||
controller: _controller,
|
query: _controller.parsed.query,
|
||||||
query: _controller.parsed.query,
|
onOpen: widget.onOpen,
|
||||||
onOpen: widget.onOpen,
|
header: header,
|
||||||
header: header,
|
),
|
||||||
)
|
|
||||||
: MaterialSearchBody(
|
|
||||||
controller: _controller,
|
|
||||||
query: _controller.parsed.query,
|
|
||||||
onOpen: widget.onOpen,
|
|
||||||
header: header,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,142 +0,0 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
|
||||||
import '../domain/search_controller.dart';
|
|
||||||
import 'search_result_slivers.dart';
|
|
||||||
import 'search_layout.dart';
|
|
||||||
|
|
||||||
/// The Cupertino search view: an optional status header and the shared list
|
|
||||||
/// 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,
|
|
||||||
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: Padding(
|
|
||||||
padding: EdgeInsets.symmetric(vertical: 8),
|
|
||||||
child: CupertinoActivityIndicator(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
..._content(context),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
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 searchResultSlivers(
|
|
||||||
controller: controller,
|
|
||||||
query: query,
|
|
||||||
onOpen: onOpen,
|
|
||||||
cupertino: true,
|
|
||||||
message: (text) => _CupertinoMessage(message: text),
|
|
||||||
);
|
|
||||||
case SearchBodyKind.empty:
|
|
||||||
return [
|
|
||||||
SliverToBoxAdapter(
|
|
||||||
child: _CupertinoMessage(message: controller.emptyMessage!),
|
|
||||||
),
|
|
||||||
];
|
|
||||||
case SearchBodyKind.idle:
|
|
||||||
return const [
|
|
||||||
SliverFillRemaining(
|
|
||||||
hasScrollBody: false,
|
|
||||||
child: _CupertinoMessage(
|
|
||||||
message: 'Search pipelines, runs, artifacts and chats.',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -59,7 +59,7 @@ class SearchBarControls extends StatelessWidget {
|
|||||||
autofocus: autofocus,
|
autofocus: autofocus,
|
||||||
focusNode: focusNode,
|
focusNode: focusNode,
|
||||||
inBar: true,
|
inBar: true,
|
||||||
cupertino: cupertino,
|
cupertino: false,
|
||||||
placeholder: 'Search pipelines, runs, artifacts and chats',
|
placeholder: 'Search pipelines, runs, artifacts and chats',
|
||||||
onChanged: onChanged,
|
onChanged: onChanged,
|
||||||
onSubmitted: (_) => onSubmitted(),
|
onSubmitted: (_) => onSubmitted(),
|
||||||
@@ -67,14 +67,14 @@ class SearchBarControls extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SearchKindButton(cupertino: cupertino, kind: kind, onSelected: onKind),
|
SearchKindButton(cupertino: false, kind: kind, onSelected: onKind),
|
||||||
BarIconButton(
|
BarIconButton(
|
||||||
key: searchHelpKey,
|
key: searchHelpKey,
|
||||||
cupertino: cupertino,
|
cupertino: false,
|
||||||
icon: Icons.info_outline,
|
icon: Icons.info_outline,
|
||||||
cupertinoIcon: CupertinoIcons.info_circle,
|
cupertinoIcon: CupertinoIcons.info_circle,
|
||||||
label: 'Search syntax',
|
label: 'Search syntax',
|
||||||
onPressed: () => showSearchHelp(context, cupertino: cupertino),
|
onPressed: () => showSearchHelp(context, cupertino: false),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -100,31 +100,6 @@ class SearchKindButton extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final narrowed = kind != SearchKind.all;
|
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>(
|
return PopupMenuButton<SearchKind>(
|
||||||
key: searchKindKey,
|
key: searchKindKey,
|
||||||
tooltip: _label,
|
tooltip: _label,
|
||||||
@@ -153,49 +128,10 @@ class SearchKindButton extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
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.
|
/// The query syntax, on demand instead of a paragraph above the results.
|
||||||
Future<void> showSearchHelp(BuildContext context, {required bool cupertino}) {
|
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>(
|
return showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => AlertDialog(
|
builder: (context) => AlertDialog(
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../ui/adaptive/host.dart';
|
|
||||||
|
|
||||||
const searchBoundsKey = ValueKey<String>('search.bounds');
|
const searchBoundsKey = ValueKey<String>('search.bounds');
|
||||||
|
|
||||||
/// The server's note that a result set was cut short, in the host's muted
|
/// The server's note that a result set was cut short, in the host's muted
|
||||||
@@ -14,22 +11,11 @@ class SearchBoundsNote extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final cupertino = usesCupertinoHost(context);
|
const icon = Icons.info_outline;
|
||||||
final TextStyle? style;
|
final theme = Theme.of(context);
|
||||||
final IconData icon;
|
final style = theme.textTheme.bodySmall?.copyWith(
|
||||||
if (cupertino) {
|
color: theme.colorScheme.onSurfaceVariant,
|
||||||
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(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||||
child: Row(
|
child: Row(
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
@@ -36,16 +35,12 @@ class SearchResultRow extends StatelessWidget {
|
|||||||
final kind = '${hit['kind'] ?? ''}';
|
final kind = '${hit['kind'] ?? ''}';
|
||||||
return AppListRow(
|
return AppListRow(
|
||||||
key: ValueKey('search.result.${hit['target']}'),
|
key: ValueKey('search.result.${hit['target']}'),
|
||||||
cupertino: cupertino,
|
cupertino: false,
|
||||||
divider: divider,
|
divider: divider,
|
||||||
onTap: row.openable ? () => onOpen(hit) : null,
|
onTap: row.openable ? () => onOpen(hit) : null,
|
||||||
leading:
|
leading:
|
||||||
searchArtifactThumbnail(context, hit) ??
|
searchArtifactThumbnail(context, hit) ??
|
||||||
AppListAvatar(
|
AppListAvatar(child: Icon(searchMaterialIcon(kind))),
|
||||||
child: Icon(
|
|
||||||
cupertino ? searchCupertinoIcon(kind) : searchMaterialIcon(kind),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
title: Text(row.title),
|
title: Text(row.title),
|
||||||
time: row.recency,
|
time: row.recency,
|
||||||
subtitle: kind == 'chat' && row.snippet != null
|
subtitle: kind == 'chat' && row.snippet != null
|
||||||
@@ -109,14 +104,3 @@ IconData searchMaterialIcon(String kind) => switch (kind) {
|
|||||||
'chat' => Icons.chat_bubble_outline,
|
'chat' => Icons.chat_bubble_outline,
|
||||||
_ => Icons.help_outline,
|
_ => Icons.help_outline,
|
||||||
};
|
};
|
||||||
|
|
||||||
IconData searchCupertinoIcon(String kind) => switch (kind) {
|
|
||||||
'pipeline' => CupertinoIcons.arrow_branch,
|
|
||||||
'version' => CupertinoIcons.square_stack_3d_up,
|
|
||||||
'run' => CupertinoIcons.play_circle,
|
|
||||||
'step' => CupertinoIcons.arrow_right,
|
|
||||||
'field' => CupertinoIcons.doc_text,
|
|
||||||
'artifact' => CupertinoIcons.paperclip,
|
|
||||||
'chat' => CupertinoIcons.chat_bubble,
|
|
||||||
_ => CupertinoIcons.question_circle,
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ List<Widget> searchResultSlivers({
|
|||||||
hit: hits[index],
|
hit: hits[index],
|
||||||
query: query,
|
query: query,
|
||||||
onOpen: onOpen,
|
onOpen: onOpen,
|
||||||
cupertino: cupertino,
|
cupertino: false,
|
||||||
divider: index < hits.length - 1,
|
divider: index < hits.length - 1,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user