Search field in the bar, refresh and Back as bar pieces, even Cupertino actions (F8/F28/F10/F11/F20/F1)
- Search: field, compact Kind menu and syntax help in the bar's actions pill; bounds shown only when truncated; rows with bold title, kind tag and one muted line; results run behind the bar in a start-aligned 840 column. - AppSearchField: one search field per platform (Search, Schedules, Runs filter). - BarIconButton: whole 44pt/48dp bar actions; Runs, bell and Pipelines icons use the same 44pt targets on Cupertino. - Templates and Schedules pages put Refresh in the bar and use the shared round SegmentedBackButton; Templates shows one Back at a time. - PipelineBackButton is the round segmented Back. - notes/pages-fixes.md records the batch, tests and evidence.
This commit is contained in:
@@ -6,11 +6,16 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import '../features/schedules/data/schedules_repository.dart';
|
import '../features/schedules/data/schedules_repository.dart';
|
||||||
import '../features/schedules/ui/list/schedule_list_controller.dart';
|
import '../features/schedules/ui/list/schedule_list_controller.dart';
|
||||||
|
import '../features/schedules/ui/list/schedule_list_toolbar.dart'
|
||||||
|
show ScheduleRefreshAction;
|
||||||
import '../features/schedules/ui/list/schedule_list_view.dart';
|
import '../features/schedules/ui/list/schedule_list_view.dart';
|
||||||
import '../ui/adaptive/host.dart';
|
import '../ui/adaptive/host.dart';
|
||||||
import 'app_session.dart';
|
import 'app_session.dart';
|
||||||
import 'server_endpoint.dart';
|
import 'server_endpoint.dart';
|
||||||
|
|
||||||
|
/// The Back control of the app-level Schedules page.
|
||||||
|
const schedulesPageBackKey = ValueKey<String>('schedules-page-back');
|
||||||
|
|
||||||
/// The saved-schedule list above Settings.
|
/// The saved-schedule list above Settings.
|
||||||
///
|
///
|
||||||
/// It is read-only: opening a row asks the composition to show the owning
|
/// It is read-only: opening a row asks the composition to show the owning
|
||||||
@@ -101,30 +106,33 @@ class _SchedulesDestinationState extends State<SchedulesDestination> {
|
|||||||
|
|
||||||
Widget _page(bool cupertino) {
|
Widget _page(bool cupertino) {
|
||||||
final body = _body(cupertino);
|
final body = _body(cupertino);
|
||||||
|
// The round Back closes the page; Refresh sits in the actions pill.
|
||||||
|
final bar = SegmentedBar(
|
||||||
|
cupertino: cupertino,
|
||||||
|
leading: SegmentedBackButton(
|
||||||
|
key: schedulesPageBackKey,
|
||||||
|
cupertino: cupertino,
|
||||||
|
onPressed: widget.onBack,
|
||||||
|
),
|
||||||
|
title: 'Schedules',
|
||||||
|
actions: [
|
||||||
|
if (widget.session.everConnected)
|
||||||
|
ScheduleRefreshAction(
|
||||||
|
controller: _controller,
|
||||||
|
cupertino: cupertino,
|
||||||
|
onRefresh: () => unawaited(_controller.refresh()),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
if (cupertino) {
|
if (cupertino) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: SegmentedBar(
|
navigationBar: bar,
|
||||||
cupertino: true,
|
|
||||||
leading: CupertinoButton(
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
onPressed: widget.onBack,
|
|
||||||
child: const Icon(CupertinoIcons.back, semanticLabel: 'Back'),
|
|
||||||
),
|
|
||||||
title: 'Schedules',
|
|
||||||
),
|
|
||||||
child: SafeArea(child: body),
|
child: SafeArea(child: body),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
appBar: SegmentedBar(
|
appBar: bar,
|
||||||
cupertino: false,
|
|
||||||
leading: IconButton(
|
|
||||||
onPressed: widget.onBack,
|
|
||||||
icon: const Icon(Icons.arrow_back, semanticLabel: 'Back'),
|
|
||||||
),
|
|
||||||
title: 'Schedules',
|
|
||||||
),
|
|
||||||
body: SafeArea(left: false, right: false, bottom: false, child: body),
|
body: SafeArea(left: false, right: false, bottom: false, child: body),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -145,6 +153,7 @@ class _SchedulesDestinationState extends State<SchedulesDestination> {
|
|||||||
if (id != null) widget.onOpenPipeline(id);
|
if (id != null) widget.onOpenPipeline(id);
|
||||||
},
|
},
|
||||||
onRefresh: () => _controller.refresh(),
|
onRefresh: () => _controller.refresh(),
|
||||||
|
refreshInToolbar: false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../ui/adaptive/segmented_bar.dart';
|
|
||||||
import '../core/api_gateway.dart';
|
import '../core/api_gateway.dart';
|
||||||
import '../features/templates/screen.dart';
|
import '../features/templates/screen.dart';
|
||||||
|
import '../features/templates/ui/template_detail.dart'
|
||||||
|
show templateDetailBackKey;
|
||||||
|
import '../shell/destination.dart';
|
||||||
|
import '../shell/shell_bar.dart';
|
||||||
import '../ui/adaptive/host.dart';
|
import '../ui/adaptive/host.dart';
|
||||||
|
import '../ui/adaptive/segmented_bar.dart';
|
||||||
import 'app_session.dart';
|
import 'app_session.dart';
|
||||||
import 'connection_status.dart';
|
import 'connection_status.dart';
|
||||||
import 'server_endpoint.dart';
|
import 'server_endpoint.dart';
|
||||||
@@ -14,15 +18,17 @@ const templatesPageBackKey = ValueKey<String>('templates-page-back');
|
|||||||
|
|
||||||
/// The Templates destination: the landed gallery over the app's shared gateway.
|
/// The Templates destination: the landed gallery over the app's shared gateway.
|
||||||
///
|
///
|
||||||
/// The gallery is rendered in embedded mode, so the shell owns navigation; this
|
/// The gallery is rendered in embedded mode and publishes its controls to
|
||||||
/// destination contributes the page's one native bar (Back + Templates) and the
|
/// this page's one segmented bar (through a [ShellBarScope] the page owns):
|
||||||
/// same honest connection states as the other destinations. No socket is opened
|
/// the round Back closes the page from the gallery and returns to the gallery
|
||||||
|
/// from an open template, and Refresh sits in the actions pill. The same
|
||||||
|
/// honest connection states as the other destinations. No socket is opened
|
||||||
/// here: [session] owns the only connection, and a template read, validate or
|
/// here: [session] owns the only connection, and a template read, validate or
|
||||||
/// create request travels over it.
|
/// create request travels over it.
|
||||||
///
|
///
|
||||||
/// [onCreated] forwards the server-confirmed detail once, so the caller can
|
/// [onCreated] forwards the server-confirmed detail once, so the caller can
|
||||||
/// invalidate the Pipelines list. This screen never inserts a row itself.
|
/// invalidate the Pipelines list. This screen never inserts a row itself.
|
||||||
class TemplatesDestination extends StatelessWidget {
|
class TemplatesDestination extends StatefulWidget {
|
||||||
const TemplatesDestination({
|
const TemplatesDestination({
|
||||||
super.key,
|
super.key,
|
||||||
required this.session,
|
required this.session,
|
||||||
@@ -42,24 +48,74 @@ class TemplatesDestination extends StatelessWidget {
|
|||||||
/// The template detail the route names, or null for the gallery.
|
/// The template detail the route names, or null for the gallery.
|
||||||
final String? initialKey;
|
final String? initialKey;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<TemplatesDestination> createState() => _TemplatesDestinationState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _TemplatesDestinationState extends State<TemplatesDestination> {
|
||||||
|
final ShellBarRegistry _bar = ShellBarRegistry();
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_bar.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final cupertino = usesCupertinoHost(context);
|
final cupertino = usesCupertinoHost(context);
|
||||||
return AnimatedBuilder(
|
final body = ShellBarScope(
|
||||||
animation: session,
|
registry: _bar,
|
||||||
builder: (context, _) => _TemplatesPage(
|
destination: AppDestination.settings,
|
||||||
cupertino: cupertino,
|
child: AnimatedBuilder(
|
||||||
onBack: onBack,
|
animation: widget.session,
|
||||||
child: _body(cupertino),
|
builder: (context, _) => _body(cupertino),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
final bar = ListenableBuilder(
|
||||||
|
listenable: _bar,
|
||||||
|
builder: (context, _) => _segmentedBar(cupertino),
|
||||||
|
);
|
||||||
|
if (cupertino) {
|
||||||
|
return CupertinoPageScaffold(
|
||||||
|
navigationBar: _BarSlot(cupertino: true, child: bar),
|
||||||
|
child: SafeArea(child: body),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return Scaffold(
|
||||||
|
extendBodyBehindAppBar: true,
|
||||||
|
appBar: _BarSlot(cupertino: false, child: bar),
|
||||||
|
body: SafeArea(child: body),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
SegmentedBar _segmentedBar(bool cupertino) {
|
||||||
|
final spec = _bar.specFor(AppDestination.settings);
|
||||||
|
final onDetailBack = spec?.onBack;
|
||||||
|
return SegmentedBar(
|
||||||
|
cupertino: cupertino,
|
||||||
|
leading: onDetailBack != null
|
||||||
|
? SegmentedBackButton(
|
||||||
|
key: templateDetailBackKey,
|
||||||
|
cupertino: cupertino,
|
||||||
|
onPressed: onDetailBack,
|
||||||
|
)
|
||||||
|
: SegmentedBackButton(
|
||||||
|
key: templatesPageBackKey,
|
||||||
|
cupertino: cupertino,
|
||||||
|
onPressed: widget.onBack,
|
||||||
|
),
|
||||||
|
title: spec?.title ?? 'Templates',
|
||||||
|
actions: spec?.actions ?? const [],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _body(bool cupertino) {
|
Widget _body(bool cupertino) {
|
||||||
|
final session = widget.session;
|
||||||
if (!session.everConnected) {
|
if (!session.everConnected) {
|
||||||
return ConnectionGate(
|
return ConnectionGate(
|
||||||
session: session,
|
session: session,
|
||||||
server: server,
|
server: widget.server,
|
||||||
cupertino: cupertino,
|
cupertino: cupertino,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -71,8 +127,8 @@ class TemplatesDestination extends StatelessWidget {
|
|||||||
child: TemplatesScreen(
|
child: TemplatesScreen(
|
||||||
gateway: session.gateway,
|
gateway: session.gateway,
|
||||||
embedded: true,
|
embedded: true,
|
||||||
onCreated: onCreated,
|
onCreated: widget.onCreated,
|
||||||
initialKey: initialKey,
|
initialKey: widget.initialKey,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -80,52 +136,22 @@ class TemplatesDestination extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The page's standard native bar. Back is named explicitly so it cannot be
|
/// Gives the scaffold a [SegmentedBar]'s size and obstruction while the bar
|
||||||
/// confused with the gallery's own Back-to-gallery control.
|
/// itself is rebuilt from the published controls.
|
||||||
class _TemplatesPage extends StatelessWidget {
|
class _BarSlot extends StatelessWidget
|
||||||
const _TemplatesPage({
|
implements ObstructingPreferredSizeWidget {
|
||||||
required this.cupertino,
|
const _BarSlot({required this.cupertino, required this.child});
|
||||||
required this.onBack,
|
|
||||||
required this.child,
|
|
||||||
});
|
|
||||||
|
|
||||||
final bool cupertino;
|
final bool cupertino;
|
||||||
final VoidCallback onBack;
|
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Size get preferredSize =>
|
||||||
if (cupertino) {
|
SegmentedBar(cupertino: cupertino, title: '').preferredSize;
|
||||||
return CupertinoPageScaffold(
|
|
||||||
navigationBar: SegmentedBar(
|
@override
|
||||||
cupertino: true,
|
bool shouldFullyObstruct(BuildContext context) => false;
|
||||||
leading: CupertinoButton(
|
|
||||||
key: templatesPageBackKey,
|
@override
|
||||||
padding: EdgeInsets.zero,
|
Widget build(BuildContext context) => child;
|
||||||
onPressed: onBack,
|
|
||||||
child: const Icon(
|
|
||||||
CupertinoIcons.back,
|
|
||||||
semanticLabel: 'Back to Settings',
|
|
||||||
),
|
|
||||||
),
|
|
||||||
title: 'Templates',
|
|
||||||
),
|
|
||||||
child: SafeArea(child: child),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Scaffold(
|
|
||||||
extendBodyBehindAppBar: true,
|
|
||||||
appBar: SegmentedBar(
|
|
||||||
cupertino: false,
|
|
||||||
leading: IconButton(
|
|
||||||
key: templatesPageBackKey,
|
|
||||||
tooltip: 'Back to Settings',
|
|
||||||
onPressed: onBack,
|
|
||||||
icon: const Icon(Icons.arrow_back),
|
|
||||||
),
|
|
||||||
title: 'Templates',
|
|
||||||
),
|
|
||||||
body: SafeArea(child: child),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,9 +185,12 @@ class _NeedsYouBellState extends State<NeedsYouBell> {
|
|||||||
|
|
||||||
Widget _cupertino(BuildContext context) {
|
Widget _cupertino(BuildContext context) {
|
||||||
final theme = CupertinoTheme.of(context);
|
final theme = CupertinoTheme.of(context);
|
||||||
|
// The whole 44pt target and no extra padding, like every bar action.
|
||||||
return CupertinoButton(
|
return CupertinoButton(
|
||||||
key: attentionBellKey,
|
key: attentionBellKey,
|
||||||
focusNode: _focus,
|
focusNode: _focus,
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
|
||||||
onPressed: _open,
|
onPressed: _open,
|
||||||
child: _badged(
|
child: _badged(
|
||||||
context,
|
context,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../ui/adaptive/host.dart';
|
import '../../../ui/adaptive/host.dart';
|
||||||
|
import '../../../ui/adaptive/segmented_bar.dart';
|
||||||
|
|
||||||
import '../pipeline_query.dart';
|
import '../pipeline_query.dart';
|
||||||
|
|
||||||
@@ -59,23 +60,16 @@ class PipelineBackButton extends StatelessWidget {
|
|||||||
|
|
||||||
final VoidCallback onPressed;
|
final VoidCallback onPressed;
|
||||||
|
|
||||||
|
/// The same round Back as every page's segmented bar.
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (useCupertinoControls(context)) {
|
final cupertino = useCupertinoControls(context);
|
||||||
return Semantics(
|
return Semantics(
|
||||||
button: true,
|
label: 'Back to pipelines',
|
||||||
label: 'Back to pipelines',
|
child: SegmentedPill(
|
||||||
child: CupertinoButton(
|
cupertino: cupertino,
|
||||||
padding: EdgeInsets.zero,
|
child: SegmentedBackButton(cupertino: cupertino, onPressed: onPressed),
|
||||||
onPressed: onPressed,
|
),
|
||||||
child: const Icon(CupertinoIcons.back),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return IconButton(
|
|
||||||
tooltip: 'Back to pipelines',
|
|
||||||
onPressed: onPressed,
|
|
||||||
icon: const Icon(Icons.arrow_back),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,9 +99,10 @@ class PipelineSortButton extends StatelessWidget {
|
|||||||
label: icon ? 'Sort pipelines: ${sort.label}' : null,
|
label: icon ? 'Sort pipelines: ${sort.label}' : null,
|
||||||
excludeSemantics: icon,
|
excludeSemantics: icon,
|
||||||
child: CupertinoButton(
|
child: CupertinoButton(
|
||||||
padding: icon
|
padding: EdgeInsets.zero,
|
||||||
? const EdgeInsets.symmetric(horizontal: 6)
|
minimumSize: icon
|
||||||
: EdgeInsets.zero,
|
? const Size.square(kMinInteractiveDimensionCupertino)
|
||||||
|
: null,
|
||||||
onPressed: () => _showCupertinoSheet(context),
|
onPressed: () => _showCupertinoSheet(context),
|
||||||
child: icon
|
child: icon
|
||||||
? const Icon(CupertinoIcons.arrow_up_arrow_down)
|
? const Icon(CupertinoIcons.arrow_up_arrow_down)
|
||||||
|
|||||||
@@ -441,7 +441,8 @@ List<Widget> pipelineListActions(
|
|||||||
excludeSemantics: true,
|
excludeSemantics: true,
|
||||||
child: CupertinoButton(
|
child: CupertinoButton(
|
||||||
key: const Key('pipeline-filter'),
|
key: const Key('pipeline-filter'),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
padding: EdgeInsets.zero,
|
||||||
|
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
|
||||||
onPressed: openFilters,
|
onPressed: openFilters,
|
||||||
child: Icon(
|
child: Icon(
|
||||||
filters.count > 0
|
filters.count > 0
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import '../../../ui/input/app_search_field.dart';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
@@ -211,8 +212,10 @@ class RunsBarActions {
|
|||||||
excludeSemantics: true,
|
excludeSemantics: true,
|
||||||
child: CupertinoButton(
|
child: CupertinoButton(
|
||||||
key: key,
|
key: key,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
// The whole 44pt target and no extra padding, like every bar
|
||||||
minimumSize: Size.zero,
|
// action, so the icons are evenly spaced inside the pill.
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
child: Icon(ios),
|
child: Icon(ios),
|
||||||
),
|
),
|
||||||
@@ -372,23 +375,13 @@ class _RunsFilterSheetState extends State<_RunsFilterSheet> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final controller = widget.controller;
|
final controller = widget.controller;
|
||||||
final field = widget.cupertino
|
final field = AppSearchField(
|
||||||
? CupertinoSearchTextField(
|
fieldKey: const ValueKey('runs.filter.query'),
|
||||||
key: const ValueKey('runs.filter.query'),
|
controller: _text,
|
||||||
controller: _text,
|
cupertino: widget.cupertino,
|
||||||
placeholder: 'Filter runs',
|
placeholder: 'Filter runs',
|
||||||
onChanged: controller.setQuery,
|
onChanged: controller.setQuery,
|
||||||
)
|
);
|
||||||
: TextField(
|
|
||||||
key: const ValueKey('runs.filter.query'),
|
|
||||||
controller: _text,
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
hintText: 'Filter runs',
|
|
||||||
prefixIcon: Icon(Icons.search),
|
|
||||||
isDense: true,
|
|
||||||
),
|
|
||||||
onChanged: controller.setQuery,
|
|
||||||
);
|
|
||||||
return ListenableBuilder(
|
return ListenableBuilder(
|
||||||
listenable: controller,
|
listenable: controller,
|
||||||
builder: (context, _) => ConstrainedBox(
|
builder: (context, _) => ConstrainedBox(
|
||||||
|
|||||||
@@ -1,26 +1,56 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../../ui/input/app_search_field.dart';
|
||||||
|
import '../../../../ui/navigation/bar_icon_button.dart';
|
||||||
import 'schedule_list_controller.dart';
|
import 'schedule_list_controller.dart';
|
||||||
|
|
||||||
const scheduleSearchFieldKey = ValueKey<String>('schedule-search-field');
|
const scheduleSearchFieldKey = ValueKey<String>('schedule-search-field');
|
||||||
const scheduleFilterKey = ValueKey<String>('schedule-filter');
|
const scheduleFilterKey = ValueKey<String>('schedule-filter');
|
||||||
const scheduleRefreshKey = ValueKey<String>('schedule-refresh');
|
const scheduleRefreshKey = ValueKey<String>('schedule-refresh');
|
||||||
|
|
||||||
/// Search, enabled filter and the read-only refresh control.
|
/// Refresh for the list, as a bar action: the platform's activity indicator
|
||||||
|
/// in the same touch target while a read is in flight.
|
||||||
|
class ScheduleRefreshAction extends StatelessWidget {
|
||||||
|
const ScheduleRefreshAction({
|
||||||
|
super.key,
|
||||||
|
required this.controller,
|
||||||
|
required this.cupertino,
|
||||||
|
required this.onRefresh,
|
||||||
|
});
|
||||||
|
|
||||||
|
final SchedulesController controller;
|
||||||
|
final bool cupertino;
|
||||||
|
final VoidCallback onRefresh;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => BarIconButton(
|
||||||
|
key: controller.isLoading ? null : scheduleRefreshKey,
|
||||||
|
cupertino: cupertino,
|
||||||
|
icon: Icons.refresh,
|
||||||
|
cupertinoIcon: CupertinoIcons.refresh,
|
||||||
|
label: 'Refresh schedules',
|
||||||
|
busy: controller.isLoading,
|
||||||
|
busyLabel: 'Refreshing schedules',
|
||||||
|
onPressed: onRefresh,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Search and the enabled filter; the refresh control too when no bar above
|
||||||
|
/// carries it ([onRefresh] null leaves it to the bar).
|
||||||
class ScheduleListToolbar extends StatelessWidget {
|
class ScheduleListToolbar extends StatelessWidget {
|
||||||
const ScheduleListToolbar({
|
const ScheduleListToolbar({
|
||||||
super.key,
|
super.key,
|
||||||
required this.controller,
|
required this.controller,
|
||||||
required this.searchController,
|
required this.searchController,
|
||||||
required this.cupertino,
|
required this.cupertino,
|
||||||
required this.onRefresh,
|
this.onRefresh,
|
||||||
});
|
});
|
||||||
|
|
||||||
final SchedulesController controller;
|
final SchedulesController controller;
|
||||||
final TextEditingController searchController;
|
final TextEditingController searchController;
|
||||||
final bool cupertino;
|
final bool cupertino;
|
||||||
final VoidCallback onRefresh;
|
final VoidCallback? onRefresh;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -44,8 +74,14 @@ class ScheduleListToolbar extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 8),
|
if (onRefresh case final refresh?) ...[
|
||||||
_refresh(context),
|
const SizedBox(width: 8),
|
||||||
|
ScheduleRefreshAction(
|
||||||
|
controller: controller,
|
||||||
|
cupertino: cupertino,
|
||||||
|
onRefresh: refresh,
|
||||||
|
),
|
||||||
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -67,40 +103,14 @@ class ScheduleListToolbar extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _search(BuildContext context) {
|
Widget _search(BuildContext context) => AppSearchField(
|
||||||
if (cupertino) {
|
fieldKey: scheduleSearchFieldKey,
|
||||||
return CupertinoSearchTextField(
|
controller: searchController,
|
||||||
key: scheduleSearchFieldKey,
|
cupertino: cupertino,
|
||||||
controller: searchController,
|
placeholder: 'Search schedules',
|
||||||
placeholder: 'Search schedules',
|
onChanged: controller.setQuery,
|
||||||
onChanged: controller.setQuery,
|
onCleared: controller.clearQuery,
|
||||||
onSuffixTap: () {
|
);
|
||||||
searchController.clear();
|
|
||||||
controller.clearQuery();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return TextField(
|
|
||||||
key: scheduleSearchFieldKey,
|
|
||||||
controller: searchController,
|
|
||||||
onChanged: controller.setQuery,
|
|
||||||
textInputAction: TextInputAction.search,
|
|
||||||
decoration: InputDecoration(
|
|
||||||
hintText: 'Search schedules',
|
|
||||||
prefixIcon: const Icon(Icons.search),
|
|
||||||
suffixIcon: controller.query.isEmpty
|
|
||||||
? null
|
|
||||||
: IconButton(
|
|
||||||
tooltip: 'Clear search',
|
|
||||||
icon: const Icon(Icons.clear),
|
|
||||||
onPressed: () {
|
|
||||||
searchController.clear();
|
|
||||||
controller.clearQuery();
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _filter(BuildContext context) {
|
Widget _filter(BuildContext context) {
|
||||||
if (cupertino) {
|
if (cupertino) {
|
||||||
@@ -136,38 +146,6 @@ class ScheduleListToolbar extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _refresh(BuildContext context) {
|
|
||||||
if (controller.isLoading) {
|
|
||||||
return Semantics(
|
|
||||||
label: 'Refreshing schedules',
|
|
||||||
liveRegion: true,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(12),
|
|
||||||
child: cupertino
|
|
||||||
? const CupertinoActivityIndicator()
|
|
||||||
: const CircularProgressIndicator(strokeWidth: 2),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (cupertino) {
|
|
||||||
return Semantics(
|
|
||||||
label: 'Refresh schedules',
|
|
||||||
child: CupertinoButton(
|
|
||||||
key: scheduleRefreshKey,
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
onPressed: onRefresh,
|
|
||||||
child: const Icon(CupertinoIcons.refresh),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return IconButton(
|
|
||||||
key: scheduleRefreshKey,
|
|
||||||
tooltip: 'Refresh schedules',
|
|
||||||
onPressed: onRefresh,
|
|
||||||
icon: const Icon(Icons.refresh),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
TextStyle? _metaStyle(BuildContext context) => cupertino
|
TextStyle? _metaStyle(BuildContext context) => cupertino
|
||||||
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
|
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
|
||||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class SchedulesListView extends StatelessWidget {
|
|||||||
required this.cupertino,
|
required this.cupertino,
|
||||||
required this.onOpen,
|
required this.onOpen,
|
||||||
required this.onRefresh,
|
required this.onRefresh,
|
||||||
|
this.refreshInToolbar = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
final SchedulesController controller;
|
final SchedulesController controller;
|
||||||
@@ -29,6 +30,9 @@ class SchedulesListView extends StatelessWidget {
|
|||||||
final ValueChanged<SavedSchedule> onOpen;
|
final ValueChanged<SavedSchedule> onOpen;
|
||||||
final VoidCallback onRefresh;
|
final VoidCallback onRefresh;
|
||||||
|
|
||||||
|
/// False when the page's bar carries Refresh instead.
|
||||||
|
final bool refreshInToolbar;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Column(
|
||||||
@@ -37,7 +41,7 @@ class SchedulesListView extends StatelessWidget {
|
|||||||
controller: controller,
|
controller: controller,
|
||||||
searchController: searchController,
|
searchController: searchController,
|
||||||
cupertino: cupertino,
|
cupertino: cupertino,
|
||||||
onRefresh: onRefresh,
|
onRefresh: refreshInToolbar ? onRefresh : null,
|
||||||
),
|
),
|
||||||
Expanded(child: _body(context)),
|
Expanded(child: _body(context)),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,20 +1,23 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../ui/adaptive/segmented_bar.dart';
|
|
||||||
import '../../core/api_gateway.dart';
|
import '../../core/api_gateway.dart';
|
||||||
|
import '../../shell/shell_bar.dart';
|
||||||
import '../../ui/adaptive/host.dart';
|
import '../../ui/adaptive/host.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 'domain/search_models.dart';
|
|
||||||
import 'ui/cupertino_search_body.dart';
|
import 'ui/cupertino_search_body.dart';
|
||||||
import 'ui/search_result_view.dart';
|
|
||||||
import 'ui/material_search_body.dart';
|
import 'ui/material_search_body.dart';
|
||||||
|
import 'ui/search_bar_controls.dart';
|
||||||
|
import 'ui/search_bounds_note.dart';
|
||||||
|
import 'ui/search_result_view.dart';
|
||||||
|
|
||||||
/// Native omni-search over the Pipelines server: a standard search field, an
|
/// Native omni-search over the Pipelines server: the search field, a compact
|
||||||
/// explicit kind selector, and a flat result list whose rows open the server's
|
/// kind menu and the syntax help in the top bar's actions pill, and a flat
|
||||||
/// own target through [onOpen]. The screen never mutates server state and never
|
/// result list whose rows open the server's own target through [onOpen]. The
|
||||||
/// guesses a route for an unknown or targetless hit.
|
/// screen never mutates server state and never guesses a route for an unknown
|
||||||
|
/// or targetless hit.
|
||||||
class SearchScreen extends StatefulWidget {
|
class SearchScreen extends StatefulWidget {
|
||||||
const SearchScreen({
|
const SearchScreen({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -31,7 +34,7 @@ class SearchScreen extends StatefulWidget {
|
|||||||
/// Cupertino controls and every other platform uses Material.
|
/// Cupertino controls and every other platform uses Material.
|
||||||
final bool? cupertino;
|
final bool? cupertino;
|
||||||
|
|
||||||
/// True as the Search tab: the shell's bar names it, so no page bar.
|
/// True as the Search tab: the controls go into the shell's bar.
|
||||||
final bool embedded;
|
final bool embedded;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -68,35 +71,6 @@ class _SearchScreenState extends State<SearchScreen> {
|
|||||||
_controller.updateQuery('');
|
_controller.updateQuery('');
|
||||||
}
|
}
|
||||||
|
|
||||||
void _selectKind(SearchKind kind) => _controller.selectKind(kind);
|
|
||||||
|
|
||||||
bool get _showHint {
|
|
||||||
final body = _controller.bodyKind;
|
|
||||||
return body == SearchBodyKind.idle || body == SearchBodyKind.empty;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _pickKind(BuildContext context) async {
|
|
||||||
final selected = await showCupertinoModalPopup<SearchKind>(
|
|
||||||
context: context,
|
|
||||||
builder: (context) => CupertinoActionSheet(
|
|
||||||
title: const Text('Kind'),
|
|
||||||
actions: [
|
|
||||||
for (final kind in SearchKind.values)
|
|
||||||
CupertinoActionSheetAction(
|
|
||||||
onPressed: () => Navigator.pop(context, kind),
|
|
||||||
isDefaultAction: kind == _controller.parsed.kind,
|
|
||||||
child: Text(kind.label),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
cancelButton: CupertinoActionSheetAction(
|
|
||||||
onPressed: () => Navigator.pop(context),
|
|
||||||
child: const Text('Cancel'),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
if (selected != null) _selectKind(selected);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_controller.removeListener(_onState);
|
_controller.removeListener(_onState);
|
||||||
@@ -115,143 +89,78 @@ class _SearchScreenState extends State<SearchScreen> {
|
|||||||
(usesCupertinoHost(context) ||
|
(usesCupertinoHost(context) ||
|
||||||
Theme.of(context).platform == TargetPlatform.iOS ||
|
Theme.of(context).platform == TargetPlatform.iOS ||
|
||||||
Theme.of(context).platform == TargetPlatform.macOS);
|
Theme.of(context).platform == TargetPlatform.macOS);
|
||||||
return cupertino ? _cupertinoScreen() : _materialScreen();
|
if (widget.embedded) {
|
||||||
}
|
// The shell's bar carries the controls; without a shell (a bare embed)
|
||||||
|
// they lead the results instead.
|
||||||
Widget _materialScreen() {
|
if (!ShellBar.available(context)) {
|
||||||
// Results scroll behind a floating tab bar; the list clears it itself.
|
return _body(cupertino, controls: _controls(cupertino));
|
||||||
final body = SafeArea(
|
}
|
||||||
bottom: false,
|
return ShellBar(actions: [_controls(cupertino)], child: _body(cupertino));
|
||||||
child: SearchArtifactScope(
|
}
|
||||||
gateway: widget.gateway,
|
final bar = SegmentedBar(
|
||||||
onOpen: widget.onOpen,
|
cupertino: cupertino,
|
||||||
child: MaterialSearchBody(
|
title: 'Search',
|
||||||
controller: _controller,
|
actions: [_controls(cupertino)],
|
||||||
query: _controller.parsed.query,
|
|
||||||
onOpen: widget.onOpen,
|
|
||||||
header: _materialHeader(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
if (widget.embedded) return body;
|
if (cupertino) {
|
||||||
|
return CupertinoPageScaffold(navigationBar: bar, child: _body(cupertino));
|
||||||
|
}
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
appBar: const SegmentedBar(cupertino: false, title: 'Search'),
|
appBar: bar,
|
||||||
body: body,
|
body: _body(cupertino),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _materialHeader() => Padding(
|
Widget _controls(bool cupertino) => SearchBarControls(
|
||||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 8),
|
cupertino: cupertino,
|
||||||
child: Column(
|
text: _text,
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
kind: _controller.parsed.kind,
|
||||||
spacing: 8,
|
onChanged: _controller.updateQuery,
|
||||||
children: [
|
onSubmitted: _controller.submit,
|
||||||
SearchBar(
|
onCleared: _clear,
|
||||||
key: const ValueKey('search.field'),
|
onKind: _controller.selectKind,
|
||||||
controller: _text,
|
|
||||||
autoFocus: true,
|
|
||||||
hintText: 'Search pipelines, runs and artifacts',
|
|
||||||
leading: const Icon(Icons.search),
|
|
||||||
trailing: [
|
|
||||||
if (_text.text.isNotEmpty)
|
|
||||||
IconButton(
|
|
||||||
key: const ValueKey('search.clear'),
|
|
||||||
onPressed: _clear,
|
|
||||||
tooltip: 'Clear search',
|
|
||||||
icon: const Icon(Icons.close),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
textInputAction: TextInputAction.search,
|
|
||||||
onChanged: _controller.updateQuery,
|
|
||||||
onSubmitted: (_) => _controller.submit(),
|
|
||||||
),
|
|
||||||
InputDecorator(
|
|
||||||
decoration: const InputDecoration(
|
|
||||||
labelText: 'Kind',
|
|
||||||
border: OutlineInputBorder(),
|
|
||||||
),
|
|
||||||
child: DropdownButtonHideUnderline(
|
|
||||||
child: DropdownButton<SearchKind>(
|
|
||||||
key: const ValueKey('search.kind'),
|
|
||||||
value: _controller.parsed.kind,
|
|
||||||
isExpanded: true,
|
|
||||||
onChanged: (kind) {
|
|
||||||
if (kind != null) _selectKind(kind);
|
|
||||||
},
|
|
||||||
items: [
|
|
||||||
for (final kind in SearchKind.values)
|
|
||||||
DropdownMenuItem(value: kind, child: Text(kind.label)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (_showHint) const Text(_tokenHint),
|
|
||||||
if (_controller.boundsText case final bounds?) Text(bounds),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Widget _cupertinoScreen() {
|
/// The server's result and scan bounds, only when they cut the answer
|
||||||
final body = SafeArea(
|
/// short: a complete answer needs no statistics.
|
||||||
bottom: false,
|
Widget _header({Widget? controls}) {
|
||||||
child: SearchArtifactScope(
|
final bounds = _controller.truncated ? _controller.boundsText : null;
|
||||||
gateway: widget.gateway,
|
if (bounds == null && controls == null) return const SizedBox.shrink();
|
||||||
onOpen: widget.onOpen,
|
return Padding(
|
||||||
child: CupertinoSearchBody(
|
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||||
controller: _controller,
|
child: Column(
|
||||||
query: _controller.parsed.query,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
onOpen: widget.onOpen,
|
spacing: 8,
|
||||||
header: _cupertinoHeader(context),
|
children: [
|
||||||
),
|
?controls,
|
||||||
|
if (bounds != null)
|
||||||
|
SearchBoundsNote(key: searchBoundsKey, text: bounds),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (widget.embedded) return body;
|
|
||||||
return CupertinoPageScaffold(
|
|
||||||
navigationBar: const SegmentedBar(cupertino: true, title: 'Search'),
|
|
||||||
child: body,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _cupertinoHeader(BuildContext context) => Padding(
|
/// No top safe area: the results run behind the floating bar and the
|
||||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 8),
|
/// scroll view starts them below it.
|
||||||
child: Column(
|
Widget _body(bool cupertino, {Widget? controls}) {
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
final header = _header(controls: controls);
|
||||||
spacing: 8,
|
return SearchArtifactScope(
|
||||||
children: [
|
gateway: widget.gateway,
|
||||||
CupertinoSearchTextField(
|
onOpen: widget.onOpen,
|
||||||
key: const ValueKey('search.field'),
|
child: cupertino
|
||||||
controller: _text,
|
? CupertinoSearchBody(
|
||||||
autofocus: true,
|
controller: _controller,
|
||||||
placeholder: 'Search pipelines, runs and artifacts',
|
query: _controller.parsed.query,
|
||||||
onChanged: _controller.updateQuery,
|
onOpen: widget.onOpen,
|
||||||
onSubmitted: (_) => _controller.submit(),
|
header: header,
|
||||||
onSuffixTap: _clear,
|
)
|
||||||
),
|
: MaterialSearchBody(
|
||||||
Align(
|
controller: _controller,
|
||||||
alignment: AlignmentDirectional.centerStart,
|
query: _controller.parsed.query,
|
||||||
child: CupertinoButton(
|
onOpen: widget.onOpen,
|
||||||
key: const ValueKey('search.kind'),
|
header: header,
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
onPressed: () => _pickKind(context),
|
|
||||||
child: Row(
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
spacing: 6,
|
|
||||||
children: [
|
|
||||||
Expanded(child: Text('Kind: ${_controller.parsed.kind.label}')),
|
|
||||||
const Icon(CupertinoIcons.chevron_down),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
),
|
}
|
||||||
if (_showHint) const Text(_tokenHint),
|
|
||||||
if (_controller.boundsText case final bounds?) Text(bounds),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const _tokenHint =
|
|
||||||
'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.';
|
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import '../../../ui/theme/app_theme.dart';
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
|
|
||||||
import '../../../core/api_gateway.dart';
|
import '../../../core/api_gateway.dart';
|
||||||
import '../domain/search_controller.dart';
|
import '../domain/search_controller.dart';
|
||||||
import '../domain/search_row.dart';
|
import '../domain/search_row.dart';
|
||||||
import 'search_result_view.dart';
|
import 'search_result_view.dart';
|
||||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
import 'search_layout.dart';
|
||||||
|
|
||||||
/// The Cupertino search view: native search/kind controls and grouped list rows
|
/// The Cupertino search view: an optional status header and inset-grouped
|
||||||
/// in one scroll view, with standard activity and retry controls.
|
/// rows in one scroll view that runs behind the top bar, with standard
|
||||||
|
/// activity and retry controls.
|
||||||
class CupertinoSearchBody extends StatelessWidget {
|
class CupertinoSearchBody extends StatelessWidget {
|
||||||
const CupertinoSearchBody({
|
const CupertinoSearchBody({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -25,7 +25,7 @@ class CupertinoSearchBody extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return CustomScrollView(
|
return SearchScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
SliverToBoxAdapter(child: header),
|
SliverToBoxAdapter(child: header),
|
||||||
if (controller.showProgress)
|
if (controller.showProgress)
|
||||||
@@ -36,7 +36,6 @@ class CupertinoSearchBody extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
..._content(context),
|
..._content(context),
|
||||||
const SliverFloatingBarClearance(),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -64,7 +63,16 @@ class CupertinoSearchBody extends StatelessWidget {
|
|||||||
return [
|
return [
|
||||||
SliverToBoxAdapter(
|
SliverToBoxAdapter(
|
||||||
child: CupertinoListSection.insetGrouped(
|
child: CupertinoListSection.insetGrouped(
|
||||||
backgroundColor: AppColors.groupedBackground,
|
// The section sits on the page's own background (the shell's
|
||||||
|
// is not the grouped one), so it takes the bar pills' grey
|
||||||
|
// rather than a white card framed by a grey band.
|
||||||
|
backgroundColor: const Color(0x00000000),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: CupertinoColors.systemGrey6.resolveFrom(context),
|
||||||
|
borderRadius: const BorderRadius.all(Radius.circular(10)),
|
||||||
|
),
|
||||||
|
// The column already keeps the bar's inset.
|
||||||
|
margin: const EdgeInsets.symmetric(vertical: 8),
|
||||||
children: [
|
children: [
|
||||||
for (final hit in controller.shownResults)
|
for (final hit in controller.shownResults)
|
||||||
_CupertinoResult(hit: hit, query: query, onOpen: onOpen),
|
_CupertinoResult(hit: hit, query: query, onOpen: onOpen),
|
||||||
@@ -112,13 +120,8 @@ class _CupertinoResult extends StatelessWidget {
|
|||||||
Icon(searchCupertinoIcon('${hit['kind'] ?? ''}')),
|
Icon(searchCupertinoIcon('${hit['kind'] ?? ''}')),
|
||||||
leadingSize: 44,
|
leadingSize: 44,
|
||||||
trailing: searchArtifactActions(context, hit),
|
trailing: searchArtifactActions(context, hit),
|
||||||
title: Text(row.title),
|
title: searchRowTitle(context, row),
|
||||||
subtitle: Column(
|
subtitle: searchRowLine(context, row),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
spacing: 2,
|
|
||||||
children: [searchRowMeta(row), searchRowSnippet(context, row)],
|
|
||||||
),
|
|
||||||
onTap: row.openable ? () => onOpen(hit) : null,
|
onTap: row.openable ? () => onOpen(hit) : null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import '../../../core/api_gateway.dart';
|
|||||||
import '../domain/search_controller.dart';
|
import '../domain/search_controller.dart';
|
||||||
import '../domain/search_row.dart';
|
import '../domain/search_row.dart';
|
||||||
import 'search_result_view.dart';
|
import 'search_result_view.dart';
|
||||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
import 'search_layout.dart';
|
||||||
|
|
||||||
/// The Material search view: the controls header and a flat native result list
|
/// The Material search view: an optional status header and a flat native
|
||||||
/// in one scroll view, so text scaling can never clip the controls or a row.
|
/// result list in one scroll view that runs behind the top bar.
|
||||||
class MaterialSearchBody extends StatelessWidget {
|
class MaterialSearchBody extends StatelessWidget {
|
||||||
const MaterialSearchBody({
|
const MaterialSearchBody({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -24,13 +24,12 @@ class MaterialSearchBody extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return CustomScrollView(
|
return SearchScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
SliverToBoxAdapter(child: header),
|
SliverToBoxAdapter(child: header),
|
||||||
if (controller.showProgress)
|
if (controller.showProgress)
|
||||||
const SliverToBoxAdapter(child: LinearProgressIndicator()),
|
const SliverToBoxAdapter(child: LinearProgressIndicator()),
|
||||||
..._content(context),
|
..._content(context),
|
||||||
const SliverFloatingBarClearance(),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -100,13 +99,8 @@ class _MaterialResult extends StatelessWidget {
|
|||||||
searchArtifactThumbnail(context, hit) ??
|
searchArtifactThumbnail(context, hit) ??
|
||||||
Icon(searchMaterialIcon('${hit['kind'] ?? ''}')),
|
Icon(searchMaterialIcon('${hit['kind'] ?? ''}')),
|
||||||
trailing: searchArtifactActions(context, hit),
|
trailing: searchArtifactActions(context, hit),
|
||||||
title: Text(row.title),
|
title: searchRowTitle(context, row),
|
||||||
subtitle: Column(
|
subtitle: searchRowLine(context, row),
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
spacing: 2,
|
|
||||||
children: [searchRowMeta(row), searchRowSnippet(context, row)],
|
|
||||||
),
|
|
||||||
onTap: row.openable ? () => onOpen(hit) : null,
|
onTap: row.openable ? () => onOpen(hit) : null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,211 @@
|
|||||||
|
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';
|
||||||
|
|
||||||
|
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.
|
||||||
|
const double kSearchPillMaxWidth = 560;
|
||||||
|
|
||||||
|
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 one piece of the top bar's actions pill: the search
|
||||||
|
/// field, 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(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Flexible(
|
||||||
|
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'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../../../ui/adaptive/host.dart';
|
||||||
|
|
||||||
|
const searchBoundsKey = ValueKey<String>('search.bounds');
|
||||||
|
|
||||||
|
/// The server's note that a result set was cut short, in the host's muted
|
||||||
|
/// caption style with an info icon.
|
||||||
|
class SearchBoundsNote extends StatelessWidget {
|
||||||
|
const SearchBoundsNote({super.key, required this.text});
|
||||||
|
|
||||||
|
final String text;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final cupertino = usesCupertinoHost(context);
|
||||||
|
final TextStyle? style;
|
||||||
|
final IconData icon;
|
||||||
|
if (cupertino) {
|
||||||
|
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(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
spacing: 8,
|
||||||
|
children: [
|
||||||
|
Icon(icon, size: 16, color: style?.color),
|
||||||
|
Expanded(child: Text(text, style: style)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||||
|
|
||||||
|
/// The widest the result column grows on a wide window.
|
||||||
|
const double kSearchContentMaxWidth = 840;
|
||||||
|
|
||||||
|
/// The bar's own side inset, so the column starts under the title pill.
|
||||||
|
const double kSearchContentInset = 12;
|
||||||
|
|
||||||
|
/// Search's scroll view: it runs behind the floating top bar (the first item
|
||||||
|
/// starts below the bar's height, read from the media padding), ends clear of
|
||||||
|
/// a floating tab bar, and keeps each sliver to a start-aligned column no
|
||||||
|
/// wider than [kSearchContentMaxWidth].
|
||||||
|
class SearchScrollView extends StatelessWidget {
|
||||||
|
const SearchScrollView({super.key, required this.slivers});
|
||||||
|
|
||||||
|
final List<Widget> slivers;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final padding = MediaQuery.paddingOf(context);
|
||||||
|
return CustomScrollView(
|
||||||
|
slivers: [
|
||||||
|
SliverToBoxAdapter(child: SizedBox(height: padding.top + 4)),
|
||||||
|
for (final sliver in slivers)
|
||||||
|
SliverPadding(
|
||||||
|
padding: EdgeInsetsDirectional.only(
|
||||||
|
start: kSearchContentInset + padding.left,
|
||||||
|
end: kSearchContentInset + padding.right,
|
||||||
|
),
|
||||||
|
sliver: SliverConstrainedCrossAxis(
|
||||||
|
maxExtent: kSearchContentMaxWidth,
|
||||||
|
sliver: sliver,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SliverFloatingBarClearance(),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,39 +11,87 @@ import '../../artifacts/ui/artifact_tile.dart';
|
|||||||
import '../../artifacts/ui/artifact_viewer_fetch.dart';
|
import '../../artifacts/ui/artifact_viewer_fetch.dart';
|
||||||
import '../domain/search_row.dart';
|
import '../domain/search_row.dart';
|
||||||
|
|
||||||
/// Kind, recency and read-only affordance for one row. Deliberately unstyled
|
/// A row's title line: the bold title and, at its trailing edge, a small tag
|
||||||
/// beyond weight so Material and Cupertino inherit their own system typography
|
/// naming the kind.
|
||||||
/// and colours, including dark mode and text scaling.
|
Widget searchRowTitle(BuildContext context, SearchRowView row) => Row(
|
||||||
Widget searchRowMeta(SearchRowView row) {
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
final parts = [row.kindLabel, if (row.recency != null) row.recency!];
|
spacing: 8,
|
||||||
return Text(
|
children: [
|
||||||
parts.join(' · '),
|
Expanded(
|
||||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
child: Text(
|
||||||
|
row.title,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: const TextStyle(fontWeight: FontWeight.w600),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SearchKindTag(label: row.kindLabel),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
|
/// A row's one muted line: recency, then the snippet (its first query
|
||||||
|
/// occurrence emphasised by weight, never by parsing server text as markup)
|
||||||
|
/// or, without one, the kind's own facts.
|
||||||
|
Widget searchRowLine(BuildContext context, SearchRowView row) {
|
||||||
|
final snippet = row.snippet;
|
||||||
|
final lead = row.recency == null ? '' : '${row.recency} · ';
|
||||||
|
final spans = <InlineSpan>[
|
||||||
|
if (snippet == null)
|
||||||
|
TextSpan(text: '$lead${row.secondary}')
|
||||||
|
else ...[
|
||||||
|
if (lead.isNotEmpty) TextSpan(text: lead),
|
||||||
|
for (final span in row.snippetSpans)
|
||||||
|
TextSpan(
|
||||||
|
text: span.text,
|
||||||
|
style: span.matched
|
||||||
|
? const TextStyle(fontWeight: FontWeight.bold)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
return Text.rich(
|
||||||
|
TextSpan(children: spans),
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(color: _muted(context)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The snippet with the first query occurrence emphasised by weight, never by
|
Color _muted(BuildContext context) => usesCupertinoHost(context)
|
||||||
/// parsing server text as markup or by a bespoke colour.
|
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||||
Widget searchRowSnippet(BuildContext context, SearchRowView row) {
|
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||||
final snippet = row.snippet;
|
|
||||||
if (snippet == null) {
|
/// The result's kind as a small tinted capsule.
|
||||||
return row.secondary.isEmpty
|
class SearchKindTag extends StatelessWidget {
|
||||||
? const SizedBox.shrink()
|
const SearchKindTag({super.key, required this.label});
|
||||||
: Text(row.secondary);
|
|
||||||
|
final String label;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final cupertino = usesCupertinoHost(context);
|
||||||
|
final Color fill;
|
||||||
|
final TextStyle? style;
|
||||||
|
if (cupertino) {
|
||||||
|
fill = CupertinoColors.tertiarySystemFill.resolveFrom(context);
|
||||||
|
style = CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
|
||||||
|
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
final theme = Theme.of(context);
|
||||||
|
fill = theme.colorScheme.surfaceContainerHighest;
|
||||||
|
style = theme.textTheme.labelSmall?.copyWith(
|
||||||
|
color: theme.colorScheme.onSurfaceVariant,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return DecoratedBox(
|
||||||
|
decoration: ShapeDecoration(color: fill, shape: const StadiumBorder()),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||||
|
child: Text(label, style: style),
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return Text.rich(
|
|
||||||
TextSpan(
|
|
||||||
children: [
|
|
||||||
for (final span in row.snippetSpans)
|
|
||||||
TextSpan(
|
|
||||||
text: span.text,
|
|
||||||
style: span.matched
|
|
||||||
? const TextStyle(fontWeight: FontWeight.bold)
|
|
||||||
: null,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IconData searchMaterialIcon(String kind) => switch (kind) {
|
IconData searchMaterialIcon(String kind) => switch (kind) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'dart:async';
|
|||||||
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 '../../ui/adaptive/host.dart';
|
import '../../ui/adaptive/host.dart';
|
||||||
import 'data/template_repository.dart';
|
import 'data/template_repository.dart';
|
||||||
import 'domain/template_entry.dart';
|
import 'domain/template_entry.dart';
|
||||||
@@ -189,7 +190,7 @@ class _TemplatesScreenState extends State<TemplatesScreen> {
|
|||||||
)
|
)
|
||||||
: TemplateDetail(
|
: TemplateDetail(
|
||||||
entry: selected,
|
entry: selected,
|
||||||
showBack: widget.embedded,
|
showBack: widget.embedded && !ShellBar.available(context),
|
||||||
onBack: _back,
|
onBack: _back,
|
||||||
onCreate: () => _openCreate(selected),
|
onCreate: () => _openCreate(selected),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../ui/adaptive/host.dart';
|
import '../../../ui/adaptive/host.dart';
|
||||||
|
import '../../../ui/adaptive/segmented_bar.dart';
|
||||||
import '../domain/template_entry.dart';
|
import '../domain/template_entry.dart';
|
||||||
|
|
||||||
/// Browser wording for the gallery and the selected template, kept verbatim.
|
/// Browser wording for the gallery and the selected template, kept verbatim.
|
||||||
@@ -112,20 +113,21 @@ class TemplateDetail extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _backRow(BuildContext context, bool cupertino) {
|
Widget _backRow(BuildContext context, bool cupertino) {
|
||||||
final back = cupertino
|
// Only without a bar above: the same round Back the bar would show.
|
||||||
? CupertinoButton(
|
final back = SegmentedPill(
|
||||||
key: templateDetailBackKey,
|
cupertino: cupertino,
|
||||||
padding: EdgeInsets.zero,
|
child: SegmentedBackButton(
|
||||||
onPressed: onBack,
|
key: templateDetailBackKey,
|
||||||
child: const Icon(CupertinoIcons.back, semanticLabel: 'Back'),
|
cupertino: cupertino,
|
||||||
)
|
onPressed: onBack,
|
||||||
: BackButton(key: templateDetailBackKey, onPressed: onBack);
|
),
|
||||||
|
);
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(4, 4, 16, 0),
|
padding: const EdgeInsets.fromLTRB(12, 8, 16, 0),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
back,
|
back,
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 8),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text('Templates', style: templateSectionStyle(context)),
|
child: Text('Templates', style: templateSectionStyle(context)),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../ui/adaptive/segmented_bar.dart';
|
import '../../../shell/shell_bar.dart';
|
||||||
import '../../../ui/adaptive/host.dart';
|
import '../../../ui/adaptive/host.dart';
|
||||||
|
import '../../../ui/adaptive/segmented_bar.dart';
|
||||||
|
import '../../../ui/navigation/bar_icon_button.dart';
|
||||||
|
|
||||||
const templatesRefreshKey = ValueKey<String>('templates-refresh');
|
const templatesRefreshKey = ValueKey<String>('templates-refresh');
|
||||||
const templatesBackKey = ValueKey<String>('templates-back');
|
const templatesBackKey = ValueKey<String>('templates-back');
|
||||||
|
|
||||||
/// The screen's native chrome.
|
/// The screen's native chrome.
|
||||||
///
|
///
|
||||||
/// Standalone use keeps the host's own app bar with Back and Refresh. A shell
|
/// Standalone use draws the segmented bar: the round Back (back to the
|
||||||
/// that already owns navigation passes [embedded], which drops the bar and
|
/// gallery from a template, otherwise the route's own) and Refresh in the
|
||||||
/// keeps Refresh at the top of the body.
|
/// actions pill. A page that already owns a bar passes [embedded]; the
|
||||||
|
/// screen then publishes its Back and Refresh to that bar through
|
||||||
|
/// [ShellBar]. Only with no bar above at all does Refresh sit atop the body.
|
||||||
class TemplatesFrame extends StatelessWidget {
|
class TemplatesFrame extends StatelessWidget {
|
||||||
const TemplatesFrame({
|
const TemplatesFrame({
|
||||||
super.key,
|
super.key,
|
||||||
@@ -32,77 +36,60 @@ class TemplatesFrame extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
if (embedded) return _embedded(context);
|
final cupertino = usesCupertinoHost(context);
|
||||||
return usesCupertinoHost(context)
|
if (embedded) {
|
||||||
? _cupertino(context)
|
if (ShellBar.available(context)) {
|
||||||
: _material(context);
|
return ShellBar(
|
||||||
}
|
title: 'Templates',
|
||||||
|
onBack: canGoBack ? onBack : null,
|
||||||
Widget _embedded(BuildContext context) {
|
actions: [_refreshButton()],
|
||||||
return Column(
|
child: body,
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
);
|
||||||
children: [
|
}
|
||||||
Align(
|
return Column(
|
||||||
alignment: AlignmentDirectional.centerEnd,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
child: Padding(
|
children: [
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
Align(
|
||||||
child: _refreshButton(context),
|
alignment: AlignmentDirectional.centerEnd,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
|
child: _refreshButton(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
Expanded(child: body),
|
||||||
Expanded(child: body),
|
],
|
||||||
],
|
);
|
||||||
|
}
|
||||||
|
final bar = SegmentedBar(
|
||||||
|
cupertino: cupertino,
|
||||||
|
leading: canGoBack
|
||||||
|
? SegmentedBackButton(
|
||||||
|
key: templatesBackKey,
|
||||||
|
cupertino: cupertino,
|
||||||
|
onPressed: onBack,
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
title: 'Templates',
|
||||||
|
actions: [_refreshButton()],
|
||||||
);
|
);
|
||||||
}
|
if (cupertino) {
|
||||||
|
return CupertinoPageScaffold(
|
||||||
Widget _cupertino(BuildContext context) {
|
navigationBar: bar,
|
||||||
return CupertinoPageScaffold(
|
child: SafeArea(child: body),
|
||||||
navigationBar: SegmentedBar(
|
);
|
||||||
cupertino: true,
|
}
|
||||||
leading: canGoBack
|
|
||||||
? CupertinoButton(
|
|
||||||
key: templatesBackKey,
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
onPressed: onBack,
|
|
||||||
child: const Icon(CupertinoIcons.back, semanticLabel: 'Back'),
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
title: 'Templates',
|
|
||||||
actions: [_refreshButton(context)],
|
|
||||||
),
|
|
||||||
child: SafeArea(child: body),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _material(BuildContext context) {
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
appBar: SegmentedBar(
|
appBar: bar,
|
||||||
cupertino: false,
|
|
||||||
title: 'Templates',
|
|
||||||
leading: canGoBack
|
|
||||||
? BackButton(key: templatesBackKey, onPressed: onBack)
|
|
||||||
: null,
|
|
||||||
actions: [_refreshButton(context)],
|
|
||||||
),
|
|
||||||
body: SafeArea(child: body),
|
body: SafeArea(child: body),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _refreshButton(BuildContext context) {
|
Widget _refreshButton() => BarIconButton(
|
||||||
final onPressed = refreshing ? null : onRefresh;
|
key: templatesRefreshKey,
|
||||||
if (usesCupertinoHost(context)) {
|
icon: Icons.refresh,
|
||||||
return CupertinoButton(
|
cupertinoIcon: CupertinoIcons.refresh,
|
||||||
key: templatesRefreshKey,
|
label: 'Refresh',
|
||||||
padding: EdgeInsets.zero,
|
onPressed: refreshing ? null : onRefresh,
|
||||||
onPressed: onPressed,
|
);
|
||||||
child: const Icon(CupertinoIcons.refresh, semanticLabel: 'Refresh'),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return IconButton(
|
|
||||||
key: templatesRefreshKey,
|
|
||||||
tooltip: 'Refresh',
|
|
||||||
onPressed: onPressed,
|
|
||||||
icon: const Icon(Icons.refresh),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,116 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../adaptive/host.dart';
|
||||||
|
|
||||||
|
/// The app's one search field per platform.
|
||||||
|
///
|
||||||
|
/// Cupertino uses the stock [CupertinoSearchTextField]. Material uses a
|
||||||
|
/// [TextField] shaped like it: a stadium with a leading search icon, a clear
|
||||||
|
/// button once there is text, no underline and no elevation. On a page it is
|
||||||
|
/// filled with the host's raised surface; [inBar] drops the fill (and the
|
||||||
|
/// Cupertino grey) because a bar's glass pill is already its background.
|
||||||
|
class AppSearchField extends StatelessWidget {
|
||||||
|
const AppSearchField({
|
||||||
|
super.key,
|
||||||
|
required this.controller,
|
||||||
|
required this.placeholder,
|
||||||
|
this.fieldKey,
|
||||||
|
this.clearKey,
|
||||||
|
this.onChanged,
|
||||||
|
this.onSubmitted,
|
||||||
|
this.onCleared,
|
||||||
|
this.autofocus = false,
|
||||||
|
this.focusNode,
|
||||||
|
this.inBar = false,
|
||||||
|
this.cupertino,
|
||||||
|
});
|
||||||
|
|
||||||
|
final TextEditingController controller;
|
||||||
|
final String placeholder;
|
||||||
|
|
||||||
|
/// The key of the text field itself, for finders.
|
||||||
|
final Key? fieldKey;
|
||||||
|
|
||||||
|
/// The key of Material's clear button.
|
||||||
|
final Key? clearKey;
|
||||||
|
final ValueChanged<String>? onChanged;
|
||||||
|
final ValueChanged<String>? onSubmitted;
|
||||||
|
|
||||||
|
/// Runs after the clear control emptied the field; without it the clear
|
||||||
|
/// reports an empty [onChanged].
|
||||||
|
final VoidCallback? onCleared;
|
||||||
|
final bool autofocus;
|
||||||
|
final FocusNode? focusNode;
|
||||||
|
final bool inBar;
|
||||||
|
final bool? cupertino;
|
||||||
|
|
||||||
|
void _clear() {
|
||||||
|
controller.clear();
|
||||||
|
if (onCleared case final cleared?) {
|
||||||
|
cleared();
|
||||||
|
} else {
|
||||||
|
onChanged?.call('');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
if (cupertino ?? usesCupertinoHost(context)) {
|
||||||
|
return CupertinoSearchTextField(
|
||||||
|
key: fieldKey,
|
||||||
|
controller: controller,
|
||||||
|
focusNode: focusNode,
|
||||||
|
autofocus: autofocus,
|
||||||
|
placeholder: placeholder,
|
||||||
|
backgroundColor: inBar ? const Color(0x00000000) : null,
|
||||||
|
onChanged: onChanged,
|
||||||
|
onSubmitted: onSubmitted,
|
||||||
|
onSuffixTap: _clear,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final scheme = Theme.of(context).colorScheme;
|
||||||
|
const radius = BorderRadius.all(Radius.circular(28));
|
||||||
|
const stadium = OutlineInputBorder(
|
||||||
|
borderRadius: radius,
|
||||||
|
borderSide: BorderSide.none,
|
||||||
|
);
|
||||||
|
return ValueListenableBuilder<TextEditingValue>(
|
||||||
|
valueListenable: controller,
|
||||||
|
builder: (context, value, _) => TextField(
|
||||||
|
key: fieldKey,
|
||||||
|
controller: controller,
|
||||||
|
focusNode: focusNode,
|
||||||
|
autofocus: autofocus,
|
||||||
|
textInputAction: TextInputAction.search,
|
||||||
|
onChanged: onChanged,
|
||||||
|
onSubmitted: onSubmitted,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
hintText: placeholder,
|
||||||
|
prefixIcon: const Icon(Icons.search),
|
||||||
|
suffixIcon: value.text.isEmpty
|
||||||
|
? null
|
||||||
|
: IconButton(
|
||||||
|
key: clearKey,
|
||||||
|
tooltip: 'Clear search',
|
||||||
|
onPressed: _clear,
|
||||||
|
icon: const Icon(Icons.close),
|
||||||
|
),
|
||||||
|
filled: !inBar,
|
||||||
|
fillColor: scheme.surfaceContainerHigh,
|
||||||
|
isDense: true,
|
||||||
|
border: stadium,
|
||||||
|
enabledBorder: stadium,
|
||||||
|
// In the bar the pill is the field's outline; on a page the focused
|
||||||
|
// field shows the host's focus ring.
|
||||||
|
focusedBorder: inBar
|
||||||
|
? stadium
|
||||||
|
: OutlineInputBorder(
|
||||||
|
borderRadius: radius,
|
||||||
|
borderSide: BorderSide(color: scheme.primary, width: 2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../adaptive/host.dart';
|
||||||
|
|
||||||
|
/// One icon action of a segmented bar's actions pill (or any toolbar row).
|
||||||
|
///
|
||||||
|
/// Every action gets the platform's whole touch target and no extra padding,
|
||||||
|
/// so a row of them is evenly spaced and the last one never touches the
|
||||||
|
/// pill's edge: Material's [IconButton] (48dp, with its tooltip), Cupertino's
|
||||||
|
/// [CupertinoButton] at [kMinInteractiveDimensionCupertino] (44pt) square.
|
||||||
|
/// While [busy] the action shows the platform's activity indicator in the
|
||||||
|
/// same box and takes no taps.
|
||||||
|
class BarIconButton extends StatelessWidget {
|
||||||
|
const BarIconButton({
|
||||||
|
super.key,
|
||||||
|
required this.icon,
|
||||||
|
required this.cupertinoIcon,
|
||||||
|
required this.label,
|
||||||
|
required this.onPressed,
|
||||||
|
this.selected = false,
|
||||||
|
this.busy = false,
|
||||||
|
this.busyLabel,
|
||||||
|
this.cupertino,
|
||||||
|
});
|
||||||
|
|
||||||
|
final IconData icon;
|
||||||
|
final IconData cupertinoIcon;
|
||||||
|
|
||||||
|
/// The tooltip and accessible name.
|
||||||
|
final String label;
|
||||||
|
final VoidCallback? onPressed;
|
||||||
|
|
||||||
|
/// Material shows a toggled-on action as selected.
|
||||||
|
final bool selected;
|
||||||
|
final bool busy;
|
||||||
|
|
||||||
|
/// The accessible name while [busy]; defaults to [label].
|
||||||
|
final String? busyLabel;
|
||||||
|
|
||||||
|
/// The control family; defaults to the host's.
|
||||||
|
final bool? cupertino;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final native = cupertino ?? usesCupertinoHost(context);
|
||||||
|
if (busy) {
|
||||||
|
final side = native
|
||||||
|
? kMinInteractiveDimensionCupertino
|
||||||
|
: kMinInteractiveDimension;
|
||||||
|
return Semantics(
|
||||||
|
label: busyLabel ?? label,
|
||||||
|
liveRegion: true,
|
||||||
|
child: SizedBox.square(
|
||||||
|
dimension: side,
|
||||||
|
child: Center(
|
||||||
|
child: native
|
||||||
|
? const CupertinoActivityIndicator()
|
||||||
|
: const SizedBox.square(
|
||||||
|
dimension: 20,
|
||||||
|
child: CircularProgressIndicator(strokeWidth: 2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (native) {
|
||||||
|
return Semantics(
|
||||||
|
button: true,
|
||||||
|
label: label,
|
||||||
|
excludeSemantics: true,
|
||||||
|
child: CupertinoButton(
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
|
||||||
|
onPressed: onPressed,
|
||||||
|
child: Icon(cupertinoIcon),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return IconButton(
|
||||||
|
tooltip: label,
|
||||||
|
isSelected: selected,
|
||||||
|
onPressed: onPressed,
|
||||||
|
icon: Icon(icon),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,150 @@
|
|||||||
|
# Search, Settings and page-chrome fixes (style review batch C)
|
||||||
|
|
||||||
|
Fixes from the whole-app style review (`/tmp/app-style-review/report.md`):
|
||||||
|
F8/F28 Search, F9 Settings, F10 refresh placement, F11 back/close, F20
|
||||||
|
Cupertino action spacing, and F1 for Search and Settings.
|
||||||
|
|
||||||
|
## Shared pieces
|
||||||
|
|
||||||
|
- `lib/ui/input/app_search_field.dart` — `AppSearchField`, the one search field
|
||||||
|
per platform: Cupertino's stock `CupertinoSearchTextField`; on Material a
|
||||||
|
stadium `TextField` (leading search icon, clear button once there is text,
|
||||||
|
no underline, no elevation). It is filled with `surfaceContainerHigh` on a
|
||||||
|
page; `inBar` drops the fill (Cupertino: the grey) inside a bar's glass pill.
|
||||||
|
It is used by Search, the Schedules toolbar and the Runs filter sheet. The
|
||||||
|
chat search fields were left alone because chat belongs to another lane.
|
||||||
|
- `lib/ui/navigation/bar_icon_button.dart` — `BarIconButton`, one icon action
|
||||||
|
of an actions pill. Material uses an `IconButton` (48dp, tooltip). Cupertino
|
||||||
|
uses a `CupertinoButton` with no padding and a 44pt square minimum. `busy`
|
||||||
|
shows the platform activity indicator in the same box.
|
||||||
|
|
||||||
|
## Search (F8, F28, F1)
|
||||||
|
|
||||||
|
- The bar is the shell's title pill (Search) plus one actions pill holding
|
||||||
|
`SearchBarControls` (`features/search/ui/search_bar_controls.dart`): the
|
||||||
|
field, a compact Kind menu, and an info button for the query syntax.
|
||||||
|
- Kind is a filter icon while every kind is searched, and a small chip once
|
||||||
|
the search is narrowed. Material uses a `PopupMenuButton` of
|
||||||
|
`CheckedPopupMenuItem`s; Cupertino uses an action sheet.
|
||||||
|
- The info button opens the syntax help in a dialog.
|
||||||
|
- As the shell's tab the screen publishes the controls through `ShellBar`.
|
||||||
|
Standalone, it gives them to its own `SegmentedBar`.
|
||||||
|
- The pill is at most 560 wide (`kSearchPillMaxWidth`).
|
||||||
|
- `SegmentedBar` keeps a 25% title share and right-aligns its actions, and
|
||||||
|
`lib/shell` and `lib/ui/adaptive` were out of scope. So the field sits
|
||||||
|
beside the Search title rather than replacing it.
|
||||||
|
- The bounds line (`N results · cap · scanned …`) now appears only when the
|
||||||
|
server truncated the answer. It is a muted note with an info icon
|
||||||
|
(`search_bounds_note.dart`, key `search.bounds`).
|
||||||
|
- Result rows: a bold title (up to 2 lines), a small kind tag at the trailing
|
||||||
|
edge (`SearchKindTag`), and one muted line: recency, then the snippet (match
|
||||||
|
in bold) or the kind's facts. The old bold kind line between title and
|
||||||
|
metadata is gone.
|
||||||
|
- `SearchScrollView` (`search_layout.dart`):
|
||||||
|
- There is no top `SafeArea`. The scroll view reaches the top edge and starts
|
||||||
|
its content below the bar's media padding.
|
||||||
|
- Each sliver is start-aligned at the bar's 12px inset, at most 840 wide.
|
||||||
|
- The view ends with the floating tab bar's clearance.
|
||||||
|
- Cupertino results are one inset section filled with `systemGrey6`, the
|
||||||
|
same grey as the bar pills, instead of a white card framed by a grey band
|
||||||
|
on the shell's white page.
|
||||||
|
- Keys kept: `search.field`, `search.kind`, `search.clear`, `search.retry`,
|
||||||
|
`search.result.<target>`. New keys: `search.help`, `search.bar`,
|
||||||
|
`search.bounds`.
|
||||||
|
|
||||||
|
## Settings (F9, F1)
|
||||||
|
|
||||||
|
Done in a separate worktree and fast-forwarded here (commit `3ec580c2`).
|
||||||
|
|
||||||
|
- Flat grouped sections:
|
||||||
|
- `SettingsGroup`/`SettingsGroupItem`: a Material primary header over a flat
|
||||||
|
`surfaceContainer` group with dividers; Cupertino
|
||||||
|
`CupertinoListSection.insetGrouped`.
|
||||||
|
- `SettingsRow` and `SettingsStatusRow` rows.
|
||||||
|
- Server rows show a check mark, the address and a trailing
|
||||||
|
Use/Edit/Remove menu (key `settings.server.<id>.menu`), plus an Add server
|
||||||
|
row.
|
||||||
|
- Templates and Schedules are chevron rows in a "Library" group.
|
||||||
|
- The ntfy rows use a `CupertinoSwitch` on Cupertino.
|
||||||
|
- The disabled Save workspace is a `FilledButton.tonal`.
|
||||||
|
- No elevated cards: `SettingsCard` was removed.
|
||||||
|
- Helper copy is shorter, and the trust warning is a section footer.
|
||||||
|
- `SettingsPageBody`: no top `SafeArea`. The page pads by the bar's height,
|
||||||
|
and its column is start-aligned at x=12 with a maximum width of 720.
|
||||||
|
|
||||||
|
## Refresh and Back (F10, F11)
|
||||||
|
|
||||||
|
- Templates:
|
||||||
|
- `TemplatesFrame` puts Refresh in the bar's actions pill. Standalone, it
|
||||||
|
draws its own `SegmentedBar`. Embedded, it publishes Back and Refresh
|
||||||
|
through `ShellBar`.
|
||||||
|
- `TemplatesDestination` owns a `ShellBarRegistry`/`ShellBarScope` for its
|
||||||
|
page and builds its one `SegmentedBar` from what the gallery publishes.
|
||||||
|
- The round leading piece is the page Back (`templates-page-back`) on the
|
||||||
|
gallery and the detail Back (`template-detail-back`) on an open template,
|
||||||
|
so there is only ever one Back. The body back row in `TemplateDetail`
|
||||||
|
remains only with no bar above, as a `SegmentedPill` +
|
||||||
|
`SegmentedBackButton`.
|
||||||
|
- Schedules: `SchedulesDestination` uses `SegmentedBackButton` (new key
|
||||||
|
`schedules-page-back`) and puts `ScheduleRefreshAction` in the actions pill.
|
||||||
|
The toolbar shows Refresh only when no bar carries it
|
||||||
|
(`SchedulesListView.refreshInToolbar`; the standalone `SchedulesScreen`
|
||||||
|
still shows it in the body).
|
||||||
|
- `PipelineBackButton` is now the round `SegmentedPill` + `SegmentedBackButton`
|
||||||
|
(semantics "Back to pipelines" kept).
|
||||||
|
|
||||||
|
## Cupertino action spacing (F20)
|
||||||
|
|
||||||
|
The Runs stats/filter/sort actions, the Needs-you bell, and the Pipelines
|
||||||
|
filter and sort icons all use no padding and a 44pt square target. They are
|
||||||
|
evenly spaced, and the last one no longer touches the pill's edge.
|
||||||
|
|
||||||
|
## Tests
|
||||||
|
|
||||||
|
- New:
|
||||||
|
- `test/features/search/search_bar_layout_test.dart`, on both hosts:
|
||||||
|
- the controls are in the bar, with no SearchBar or dropdown
|
||||||
|
- the help is hidden until the info button is tapped
|
||||||
|
- stats show only when truncated
|
||||||
|
- rows have a kind tag and one line
|
||||||
|
- at 1200 the scroll view reaches y=0, rows start below the bar inside
|
||||||
|
the 12 inset and the 840 cap, and the pill is no wider than 560
|
||||||
|
- `test/ui/navigation/bar_icon_button_test.dart`: 44/48 targets that abut;
|
||||||
|
one stadium search field with a clear button; no Material under Cupertino.
|
||||||
|
- Updated:
|
||||||
|
- `search_screen_test.dart` and `search_screen_states_test.dart`
|
||||||
|
(`TextField` instead of `SearchBar`, the Kind menu item)
|
||||||
|
- `templates_wiring_test.dart` (Refresh and the single Back are in the bar;
|
||||||
|
one extra frame for the bar to hand Back back)
|
||||||
|
- `schedules_destination_test.dart` (Back and Refresh are bar pieces)
|
||||||
|
- the Settings tests listed in commit `3ec580c2`
|
||||||
|
|
||||||
|
## Evidence
|
||||||
|
|
||||||
|
The captures are in `/tmp/fix-c-evidence/`.
|
||||||
|
|
||||||
|
- Setup:
|
||||||
|
- Web build of `tool/templates_wiring_probe_entry.dart` (the real app with
|
||||||
|
`?host=cupertino`).
|
||||||
|
- Served by a copy of `tool/runs_probe_server.mjs` in `/tmp/fix-c-tools/`.
|
||||||
|
The copy adds fixture `list_templates`/`list_schedules` replies and marks
|
||||||
|
a search containing "many" as truncated.
|
||||||
|
- Driven by `/tmp/fix-c-tools/shoot.mjs` (headless Chrome).
|
||||||
|
- Files: `{m,c}-{search,settings,templates,schedules}-{560,1200}-{light,dark}`,
|
||||||
|
`{m,c}-search-560-{idle,truncated}`, `{m,c}-runs-560-light`,
|
||||||
|
`{m,c}-settings-560-scrolled`.
|
||||||
|
- The Settings worktree's own captures are `settings-app-*` and
|
||||||
|
`settings-probe-*`.
|
||||||
|
|
||||||
|
## Known gaps
|
||||||
|
|
||||||
|
- In the shell, Search and Settings content still stops below the bar: the
|
||||||
|
shell wraps each tab in a top `SafeArea` (`lib/shell`, out of scope). Both
|
||||||
|
pages already pad by the media padding, so they will run behind the bar once
|
||||||
|
the shell stops consuming it. A standalone `SearchScreen` (not mounted by
|
||||||
|
the app, only by tests) already runs behind its own bar.
|
||||||
|
- The Search field shares the bar with the Search title pill. Making it fill
|
||||||
|
the whole bar needs a `SegmentedBar`/shell change.
|
||||||
|
- The Cupertino Templates gallery still draws white rows in a grey band on the
|
||||||
|
white page (gallery styling was not part of this batch).
|
||||||
|
- No device run: Android and iOS are unverified.
|
||||||
@@ -6,6 +6,8 @@ import 'package:pipelines_app/application/app_session.dart';
|
|||||||
import 'package:pipelines_app/application/schedules_destination.dart';
|
import 'package:pipelines_app/application/schedules_destination.dart';
|
||||||
import 'package:pipelines_app/application/server_endpoint.dart';
|
import 'package:pipelines_app/application/server_endpoint.dart';
|
||||||
import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
||||||
|
import 'package:pipelines_app/features/schedules/ui/list/schedule_list_toolbar.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||||
|
|
||||||
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
||||||
|
|
||||||
@@ -67,5 +69,15 @@ void main() {
|
|||||||
await tester.pump();
|
await tester.pump();
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
expect(find.text('Nightly review'), findsOneWidget);
|
expect(find.text('Nightly review'), findsOneWidget);
|
||||||
|
|
||||||
|
// Back and Refresh are bar pieces; the body has neither.
|
||||||
|
Finder inBar(Key key) => find.descendant(
|
||||||
|
of: find.byType(SegmentedBar),
|
||||||
|
matching: find.byKey(key),
|
||||||
|
);
|
||||||
|
expect(inBar(schedulesPageBackKey), findsOneWidget);
|
||||||
|
expect(inBar(scheduleRefreshKey), findsOneWidget);
|
||||||
|
expect(find.byKey(scheduleRefreshKey), findsOneWidget);
|
||||||
|
expect(find.byType(SegmentedBackButton), findsOneWidget);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -211,14 +211,31 @@ void main() {
|
|||||||
expect(sockets, 1);
|
expect(sockets, 1);
|
||||||
expect(requestsOf(channel, 'list_templates'), hasLength(1));
|
expect(requestsOf(channel, 'list_templates'), hasLength(1));
|
||||||
|
|
||||||
|
// Refresh sits in the bar's actions pill, not in the body.
|
||||||
|
Finder inBar(Key key) => find.descendant(
|
||||||
|
of: find.byType(SegmentedBar),
|
||||||
|
matching: find.byKey(key),
|
||||||
|
);
|
||||||
|
expect(inBar(templatesRefreshKey), findsOneWidget);
|
||||||
|
expect(find.byKey(templatesRefreshKey), findsOneWidget);
|
||||||
|
expect(inBar(templatesPageBackKey), findsOneWidget);
|
||||||
|
|
||||||
await tester.tap(find.byKey(templateRowKey('release')));
|
await tester.tap(find.byKey(templateRowKey('release')));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
await tester.pump();
|
||||||
expect(find.text('Definition source'), findsOneWidget);
|
expect(find.text('Definition source'), findsOneWidget);
|
||||||
|
// One Back at a time, in the bar's round leading piece: the open
|
||||||
|
// template's Back replaces the page's.
|
||||||
|
expect(inBar(templateDetailBackKey), findsOneWidget);
|
||||||
|
expect(find.byKey(templateDetailBackKey), findsOneWidget);
|
||||||
|
expect(find.byKey(templatesPageBackKey), findsNothing);
|
||||||
|
|
||||||
// Detail Back returns to the gallery, then the page Back restores the
|
// Detail Back returns to the gallery, then the page Back restores the
|
||||||
// same Settings state.
|
// same Settings state.
|
||||||
await tester.tap(find.byKey(templateDetailBackKey));
|
await tester.tap(find.byKey(templateDetailBackKey));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
// The gallery hands the bar back to the page's Back on the next frame.
|
||||||
|
await tester.pump();
|
||||||
await tester.tap(find.byKey(templatesPageBackKey));
|
await tester.tap(find.byKey(templatesPageBackKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
@@ -333,6 +350,8 @@ void main() {
|
|||||||
await tester.pump();
|
await tester.pump();
|
||||||
await tester.tap(find.byKey(templateDetailBackKey));
|
await tester.tap(find.byKey(templateDetailBackKey));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
// The gallery hands the bar back to the page's Back on the next frame.
|
||||||
|
await tester.pump();
|
||||||
await tester.tap(find.byKey(templatesPageBackKey));
|
await tester.tap(find.byKey(templatesPageBackKey));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.tap(find.text('Pipelines').last);
|
await tester.tap(find.text('Pipelines').last);
|
||||||
|
|||||||
@@ -0,0 +1,157 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/features/search/search_screen.dart';
|
||||||
|
import 'package:pipelines_app/features/search/ui/search_bar_controls.dart';
|
||||||
|
import 'package:pipelines_app/features/search/ui/search_bounds_note.dart';
|
||||||
|
import 'package:pipelines_app/features/search/ui/search_layout.dart';
|
||||||
|
import 'package:pipelines_app/features/search/ui/search_result_view.dart';
|
||||||
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||||
|
|
||||||
|
import 'search_screen_test.dart'
|
||||||
|
show ImmediateGateway, field, pipeline, response;
|
||||||
|
|
||||||
|
void _size(WidgetTester tester, double width) {
|
||||||
|
tester.view.physicalSize = Size(width, 800);
|
||||||
|
tester.view.devicePixelRatio = 1;
|
||||||
|
addTearDown(tester.view.resetPhysicalSize);
|
||||||
|
addTearDown(tester.view.resetDevicePixelRatio);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _search(WidgetTester tester, String query) async {
|
||||||
|
await tester.enterText(find.byKey(searchFieldKey), query);
|
||||||
|
await tester.pump(const Duration(milliseconds: 300));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _app(bool cupertino, Widget child) =>
|
||||||
|
cupertino ? CupertinoApp(home: child) : MaterialApp(home: child);
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
for (final cupertino in [false, true]) {
|
||||||
|
final host = cupertino ? 'Cupertino' : 'Material';
|
||||||
|
|
||||||
|
testWidgets('$host: the field, Kind and help live in the bar pill', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
_size(tester, 390);
|
||||||
|
final gateway = ImmediateGateway((_, _) => response([pipeline]));
|
||||||
|
await tester.pumpWidget(
|
||||||
|
_app(
|
||||||
|
cupertino,
|
||||||
|
SearchScreen(gateway: gateway, onOpen: (_) {}, cupertino: cupertino),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
for (final key in [searchFieldKey, searchKindKey, searchHelpKey]) {
|
||||||
|
expect(
|
||||||
|
find.descendant(
|
||||||
|
of: find.byType(SegmentedBar),
|
||||||
|
matching: find.byKey(key),
|
||||||
|
),
|
||||||
|
findsOneWidget,
|
||||||
|
reason: '$key is in the bar',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// One field per platform: no elevated SearchBar, no dropdown.
|
||||||
|
expect(find.byType(SearchBar), findsNothing);
|
||||||
|
expect(find.byType(DropdownButton), findsNothing);
|
||||||
|
expect(
|
||||||
|
find.byType(CupertinoSearchTextField),
|
||||||
|
cupertino ? findsOneWidget : findsNothing,
|
||||||
|
);
|
||||||
|
// The syntax help is behind the info button, not on the page.
|
||||||
|
expect(find.text(searchTokenHint), findsNothing);
|
||||||
|
await tester.tap(find.byKey(searchHelpKey));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(find.text(searchTokenHint), findsOneWidget);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('$host: stats appear only for a truncated answer', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
_size(tester, 390);
|
||||||
|
var truncated = false;
|
||||||
|
final gateway = ImmediateGateway((_, _) {
|
||||||
|
final reply = response([pipeline]);
|
||||||
|
(reply['search_results'] as Map)['truncated'] = truncated;
|
||||||
|
return reply;
|
||||||
|
});
|
||||||
|
await tester.pumpWidget(
|
||||||
|
_app(
|
||||||
|
cupertino,
|
||||||
|
SearchScreen(gateway: gateway, onOpen: (_) {}, cupertino: cupertino),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
await _search(tester, 'release');
|
||||||
|
expect(find.text('Release planner'), findsOneWidget);
|
||||||
|
expect(find.byKey(searchBoundsKey), findsNothing);
|
||||||
|
expect(find.textContaining('scanned'), findsNothing);
|
||||||
|
|
||||||
|
truncated = true;
|
||||||
|
await _search(tester, 'releases');
|
||||||
|
expect(find.byKey(searchBoundsKey), findsOneWidget);
|
||||||
|
expect(find.textContaining('Results truncated'), findsOneWidget);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('$host: rows show a bold title, a kind tag and one line', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
_size(tester, 390);
|
||||||
|
final gateway = ImmediateGateway((_, _) => response([field]));
|
||||||
|
await tester.pumpWidget(
|
||||||
|
_app(
|
||||||
|
cupertino,
|
||||||
|
SearchScreen(gateway: gateway, onOpen: (_) {}, cupertino: cupertino),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await _search(tester, 'release');
|
||||||
|
|
||||||
|
final row = find.byKey(const ValueKey('search.result.run:11:4:output'));
|
||||||
|
expect(row, findsOneWidget);
|
||||||
|
expect(
|
||||||
|
find.descendant(of: row, matching: find.byType(SearchKindTag)),
|
||||||
|
findsOneWidget,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
find.descendant(
|
||||||
|
of: row,
|
||||||
|
matching: find.textContaining('the release is ready'),
|
||||||
|
),
|
||||||
|
findsOneWidget,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('$host: results run behind the bar in a capped column', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
_size(tester, 1200);
|
||||||
|
final gateway = ImmediateGateway((_, _) => response([pipeline]));
|
||||||
|
await tester.pumpWidget(
|
||||||
|
_app(
|
||||||
|
cupertino,
|
||||||
|
SearchScreen(gateway: gateway, onOpen: (_) {}, cupertino: cupertino),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await _search(tester, 'release');
|
||||||
|
|
||||||
|
// The scroll view reaches the top edge; its first row starts below
|
||||||
|
// the floating bar.
|
||||||
|
final scroll = find.byType(CustomScrollView);
|
||||||
|
expect(tester.getTopLeft(scroll).dy, 0);
|
||||||
|
final barBottom = tester.getBottomLeft(find.byType(SegmentedBar)).dy;
|
||||||
|
final row = find.byKey(const ValueKey('search.result.pipeline:7'));
|
||||||
|
expect(tester.getTopLeft(row).dy, greaterThanOrEqualTo(barBottom - 8));
|
||||||
|
// Start-aligned under the bar's inset, no wider than the cap.
|
||||||
|
final rect = tester.getRect(row);
|
||||||
|
expect(rect.left, greaterThanOrEqualTo(kSearchContentInset));
|
||||||
|
expect(rect.right, lessThanOrEqualTo(kSearchContentInset + 840));
|
||||||
|
// The search pill keeps to its own cap on a wide window.
|
||||||
|
expect(
|
||||||
|
tester.getSize(find.byKey(searchBarControlsKey)).width,
|
||||||
|
lessThanOrEqualTo(kSearchPillMaxWidth),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/core/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
|
import 'package:pipelines_app/features/search/domain/search_models.dart';
|
||||||
import 'package:pipelines_app/features/search/search_screen.dart';
|
import 'package:pipelines_app/features/search/search_screen.dart';
|
||||||
|
|
||||||
class RecordingGateway implements ApiGateway {
|
class RecordingGateway implements ApiGateway {
|
||||||
@@ -135,10 +136,15 @@ void main() {
|
|||||||
|
|
||||||
await tester.tap(find.byKey(const ValueKey('search.kind')));
|
await tester.tap(find.byKey(const ValueKey('search.kind')));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.tap(find.text('Pipelines').last);
|
await tester.tap(
|
||||||
|
find.ancestor(
|
||||||
|
of: find.text('Pipelines').last,
|
||||||
|
matching: find.byType(CheckedPopupMenuItem<SearchKind>),
|
||||||
|
),
|
||||||
|
);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
final field = tester.widget<SearchBar>(
|
final field = tester.widget<TextField>(
|
||||||
find.byKey(const ValueKey('search.field')),
|
find.byKey(const ValueKey('search.field')),
|
||||||
);
|
);
|
||||||
expect(field.controller!.text.trim(), 'plan');
|
expect(field.controller!.text.trim(), 'plan');
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import 'package:flutter/cupertino.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:pipelines_app/core/api_gateway.dart';
|
import 'package:pipelines_app/core/api_gateway.dart';
|
||||||
import 'package:pipelines_app/features/search/domain/search_models.dart';
|
|
||||||
import 'package:pipelines_app/features/search/search_screen.dart';
|
import 'package:pipelines_app/features/search/search_screen.dart';
|
||||||
|
|
||||||
class ImmediateGateway implements ApiGateway {
|
class ImmediateGateway implements ApiGateway {
|
||||||
@@ -116,9 +115,10 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(find.byType(SearchBar), findsOneWidget);
|
expect(find.byType(SearchBar), findsNothing);
|
||||||
expect(find.byType(DropdownButton<SearchKind>), findsOneWidget);
|
expect(find.byType(TextField), findsOneWidget);
|
||||||
expect(find.text('All kinds'), findsOneWidget);
|
expect(find.byKey(const ValueKey('search.kind')), findsOneWidget);
|
||||||
|
expect(find.byTooltip('Kind: All kinds'), findsOneWidget);
|
||||||
expect(gateway.calls, isEmpty);
|
expect(gateway.calls, isEmpty);
|
||||||
|
|
||||||
await search(tester, 'release');
|
await search(tester, 'release');
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:pipelines_app/ui/input/app_search_field.dart';
|
||||||
|
import 'package:pipelines_app/ui/navigation/bar_icon_button.dart';
|
||||||
|
|
||||||
|
Widget _row(bool cupertino, List<Widget> children) {
|
||||||
|
final row = Center(
|
||||||
|
child: Row(mainAxisSize: MainAxisSize.min, children: children),
|
||||||
|
);
|
||||||
|
return cupertino
|
||||||
|
? CupertinoApp(home: CupertinoPageScaffold(child: row))
|
||||||
|
: MaterialApp(home: Scaffold(body: row));
|
||||||
|
}
|
||||||
|
|
||||||
|
BarIconButton _action(Key key, {bool busy = false}) => BarIconButton(
|
||||||
|
key: key,
|
||||||
|
icon: Icons.refresh,
|
||||||
|
cupertinoIcon: CupertinoIcons.refresh,
|
||||||
|
label: 'Refresh',
|
||||||
|
busy: busy,
|
||||||
|
onPressed: () {},
|
||||||
|
);
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
for (final cupertino in [false, true]) {
|
||||||
|
final host = cupertino ? 'Cupertino' : 'Material';
|
||||||
|
final side = cupertino
|
||||||
|
? kMinInteractiveDimensionCupertino
|
||||||
|
: kMinInteractiveDimension;
|
||||||
|
|
||||||
|
testWidgets('$host bar actions are whole, evenly sized touch targets', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
_row(cupertino, [
|
||||||
|
_action(const ValueKey('a')),
|
||||||
|
_action(const ValueKey('b')),
|
||||||
|
_action(const ValueKey('c'), busy: true),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
for (final key in const ['a', 'b', 'c']) {
|
||||||
|
expect(tester.getSize(find.byKey(ValueKey(key))), Size(side, side));
|
||||||
|
}
|
||||||
|
// Adjacent actions abut: the spacing is the targets', not padding.
|
||||||
|
expect(
|
||||||
|
tester.getTopLeft(find.byKey(const ValueKey('b'))).dx -
|
||||||
|
tester.getTopLeft(find.byKey(const ValueKey('a'))).dx,
|
||||||
|
side,
|
||||||
|
);
|
||||||
|
if (cupertino) expect(find.byType(Material), findsNothing);
|
||||||
|
expect(find.bySemanticsLabel('Refresh'), findsWidgets);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('$host search field is one stadium field with a clear', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
final text = TextEditingController();
|
||||||
|
addTearDown(text.dispose);
|
||||||
|
var cleared = false;
|
||||||
|
await tester.pumpWidget(
|
||||||
|
_row(cupertino, [
|
||||||
|
SizedBox(
|
||||||
|
width: 300,
|
||||||
|
child: AppSearchField(
|
||||||
|
fieldKey: const ValueKey('field'),
|
||||||
|
controller: text,
|
||||||
|
placeholder: 'Search',
|
||||||
|
onCleared: () => cleared = true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
if (cupertino) {
|
||||||
|
expect(find.byType(CupertinoSearchTextField), findsOneWidget);
|
||||||
|
expect(find.byType(Material), findsNothing);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final field = tester.widget<TextField>(
|
||||||
|
find.byKey(const ValueKey('field')),
|
||||||
|
);
|
||||||
|
final border = field.decoration!.enabledBorder! as OutlineInputBorder;
|
||||||
|
expect(border.borderSide, BorderSide.none);
|
||||||
|
expect(field.decoration!.filled, isTrue);
|
||||||
|
expect(find.byTooltip('Clear search'), findsNothing);
|
||||||
|
|
||||||
|
await tester.enterText(find.byKey(const ValueKey('field')), 'abc');
|
||||||
|
await tester.pump();
|
||||||
|
await tester.tap(find.byTooltip('Clear search'));
|
||||||
|
await tester.pump();
|
||||||
|
expect(text.text, isEmpty);
|
||||||
|
expect(cleared, isTrue);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user