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:
@@ -185,9 +185,12 @@ class _NeedsYouBellState extends State<NeedsYouBell> {
|
||||
|
||||
Widget _cupertino(BuildContext context) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
// The whole 44pt target and no extra padding, like every bar action.
|
||||
return CupertinoButton(
|
||||
key: attentionBellKey,
|
||||
focusNode: _focus,
|
||||
padding: EdgeInsets.zero,
|
||||
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
|
||||
onPressed: _open,
|
||||
child: _badged(
|
||||
context,
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
|
||||
import '../pipeline_query.dart';
|
||||
|
||||
@@ -59,23 +60,16 @@ class PipelineBackButton extends StatelessWidget {
|
||||
|
||||
final VoidCallback onPressed;
|
||||
|
||||
/// The same round Back as every page's segmented bar.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (useCupertinoControls(context)) {
|
||||
return Semantics(
|
||||
button: true,
|
||||
label: 'Back to pipelines',
|
||||
child: CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onPressed,
|
||||
child: const Icon(CupertinoIcons.back),
|
||||
),
|
||||
);
|
||||
}
|
||||
return IconButton(
|
||||
tooltip: 'Back to pipelines',
|
||||
onPressed: onPressed,
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
final cupertino = useCupertinoControls(context);
|
||||
return Semantics(
|
||||
label: 'Back to pipelines',
|
||||
child: SegmentedPill(
|
||||
cupertino: cupertino,
|
||||
child: SegmentedBackButton(cupertino: cupertino, onPressed: onPressed),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -105,9 +99,10 @@ class PipelineSortButton extends StatelessWidget {
|
||||
label: icon ? 'Sort pipelines: ${sort.label}' : null,
|
||||
excludeSemantics: icon,
|
||||
child: CupertinoButton(
|
||||
padding: icon
|
||||
? const EdgeInsets.symmetric(horizontal: 6)
|
||||
: EdgeInsets.zero,
|
||||
padding: EdgeInsets.zero,
|
||||
minimumSize: icon
|
||||
? const Size.square(kMinInteractiveDimensionCupertino)
|
||||
: null,
|
||||
onPressed: () => _showCupertinoSheet(context),
|
||||
child: icon
|
||||
? const Icon(CupertinoIcons.arrow_up_arrow_down)
|
||||
|
||||
@@ -441,7 +441,8 @@ List<Widget> pipelineListActions(
|
||||
excludeSemantics: true,
|
||||
child: CupertinoButton(
|
||||
key: const Key('pipeline-filter'),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
||||
padding: EdgeInsets.zero,
|
||||
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
|
||||
onPressed: openFilters,
|
||||
child: Icon(
|
||||
filters.count > 0
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../../../ui/input/app_search_field.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
@@ -211,8 +212,10 @@ class RunsBarActions {
|
||||
excludeSemantics: true,
|
||||
child: CupertinoButton(
|
||||
key: key,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
||||
minimumSize: Size.zero,
|
||||
// The whole 44pt target and no extra padding, like every bar
|
||||
// action, so the icons are evenly spaced inside the pill.
|
||||
padding: EdgeInsets.zero,
|
||||
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
|
||||
onPressed: onPressed,
|
||||
child: Icon(ios),
|
||||
),
|
||||
@@ -372,23 +375,13 @@ class _RunsFilterSheetState extends State<_RunsFilterSheet> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final controller = widget.controller;
|
||||
final field = widget.cupertino
|
||||
? CupertinoSearchTextField(
|
||||
key: const ValueKey('runs.filter.query'),
|
||||
controller: _text,
|
||||
placeholder: 'Filter runs',
|
||||
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,
|
||||
);
|
||||
final field = AppSearchField(
|
||||
fieldKey: const ValueKey('runs.filter.query'),
|
||||
controller: _text,
|
||||
cupertino: widget.cupertino,
|
||||
placeholder: 'Filter runs',
|
||||
onChanged: controller.setQuery,
|
||||
);
|
||||
return ListenableBuilder(
|
||||
listenable: controller,
|
||||
builder: (context, _) => ConstrainedBox(
|
||||
|
||||
@@ -1,26 +1,56 @@
|
||||
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 'schedule_list_controller.dart';
|
||||
|
||||
const scheduleSearchFieldKey = ValueKey<String>('schedule-search-field');
|
||||
const scheduleFilterKey = ValueKey<String>('schedule-filter');
|
||||
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 {
|
||||
const ScheduleListToolbar({
|
||||
super.key,
|
||||
required this.controller,
|
||||
required this.searchController,
|
||||
required this.cupertino,
|
||||
required this.onRefresh,
|
||||
this.onRefresh,
|
||||
});
|
||||
|
||||
final SchedulesController controller;
|
||||
final TextEditingController searchController;
|
||||
final bool cupertino;
|
||||
final VoidCallback onRefresh;
|
||||
final VoidCallback? onRefresh;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -44,8 +74,14 @@ class ScheduleListToolbar extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
_refresh(context),
|
||||
if (onRefresh case final refresh?) ...[
|
||||
const SizedBox(width: 8),
|
||||
ScheduleRefreshAction(
|
||||
controller: controller,
|
||||
cupertino: cupertino,
|
||||
onRefresh: refresh,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -67,40 +103,14 @@ class ScheduleListToolbar extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _search(BuildContext context) {
|
||||
if (cupertino) {
|
||||
return CupertinoSearchTextField(
|
||||
key: scheduleSearchFieldKey,
|
||||
controller: searchController,
|
||||
placeholder: 'Search schedules',
|
||||
onChanged: controller.setQuery,
|
||||
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 _search(BuildContext context) => AppSearchField(
|
||||
fieldKey: scheduleSearchFieldKey,
|
||||
controller: searchController,
|
||||
cupertino: cupertino,
|
||||
placeholder: 'Search schedules',
|
||||
onChanged: controller.setQuery,
|
||||
onCleared: controller.clearQuery,
|
||||
);
|
||||
|
||||
Widget _filter(BuildContext context) {
|
||||
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
|
||||
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
|
||||
@@ -20,6 +20,7 @@ class SchedulesListView extends StatelessWidget {
|
||||
required this.cupertino,
|
||||
required this.onOpen,
|
||||
required this.onRefresh,
|
||||
this.refreshInToolbar = true,
|
||||
});
|
||||
|
||||
final SchedulesController controller;
|
||||
@@ -29,6 +30,9 @@ class SchedulesListView extends StatelessWidget {
|
||||
final ValueChanged<SavedSchedule> onOpen;
|
||||
final VoidCallback onRefresh;
|
||||
|
||||
/// False when the page's bar carries Refresh instead.
|
||||
final bool refreshInToolbar;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
@@ -37,7 +41,7 @@ class SchedulesListView extends StatelessWidget {
|
||||
controller: controller,
|
||||
searchController: searchController,
|
||||
cupertino: cupertino,
|
||||
onRefresh: onRefresh,
|
||||
onRefresh: refreshInToolbar ? onRefresh : null,
|
||||
),
|
||||
Expanded(child: _body(context)),
|
||||
],
|
||||
|
||||
@@ -1,20 +1,23 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../ui/adaptive/segmented_bar.dart';
|
||||
import '../../core/api_gateway.dart';
|
||||
import '../../shell/shell_bar.dart';
|
||||
import '../../ui/adaptive/host.dart';
|
||||
import '../../ui/adaptive/segmented_bar.dart';
|
||||
import 'data/search_repository.dart';
|
||||
import 'domain/search_controller.dart';
|
||||
import 'domain/search_models.dart';
|
||||
import 'ui/cupertino_search_body.dart';
|
||||
import 'ui/search_result_view.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
|
||||
/// explicit kind selector, and a flat result list whose rows open the server's
|
||||
/// own target through [onOpen]. The screen never mutates server state and never
|
||||
/// guesses a route for an unknown or targetless hit.
|
||||
/// Native omni-search over the Pipelines server: the search field, a compact
|
||||
/// kind menu and the syntax help in the top bar's actions pill, and a flat
|
||||
/// result list whose rows open the server's own target through [onOpen]. The
|
||||
/// screen never mutates server state and never guesses a route for an unknown
|
||||
/// or targetless hit.
|
||||
class SearchScreen extends StatefulWidget {
|
||||
const SearchScreen({
|
||||
super.key,
|
||||
@@ -31,7 +34,7 @@ class SearchScreen extends StatefulWidget {
|
||||
/// Cupertino controls and every other platform uses Material.
|
||||
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;
|
||||
|
||||
@override
|
||||
@@ -68,35 +71,6 @@ class _SearchScreenState extends State<SearchScreen> {
|
||||
_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
|
||||
void dispose() {
|
||||
_controller.removeListener(_onState);
|
||||
@@ -115,143 +89,78 @@ class _SearchScreenState extends State<SearchScreen> {
|
||||
(usesCupertinoHost(context) ||
|
||||
Theme.of(context).platform == TargetPlatform.iOS ||
|
||||
Theme.of(context).platform == TargetPlatform.macOS);
|
||||
return cupertino ? _cupertinoScreen() : _materialScreen();
|
||||
}
|
||||
|
||||
Widget _materialScreen() {
|
||||
// Results scroll behind a floating tab bar; the list clears it itself.
|
||||
final body = SafeArea(
|
||||
bottom: false,
|
||||
child: SearchArtifactScope(
|
||||
gateway: widget.gateway,
|
||||
onOpen: widget.onOpen,
|
||||
child: MaterialSearchBody(
|
||||
controller: _controller,
|
||||
query: _controller.parsed.query,
|
||||
onOpen: widget.onOpen,
|
||||
header: _materialHeader(),
|
||||
),
|
||||
),
|
||||
if (widget.embedded) {
|
||||
// The shell's bar carries the controls; without a shell (a bare embed)
|
||||
// they lead the results instead.
|
||||
if (!ShellBar.available(context)) {
|
||||
return _body(cupertino, controls: _controls(cupertino));
|
||||
}
|
||||
return ShellBar(actions: [_controls(cupertino)], child: _body(cupertino));
|
||||
}
|
||||
final bar = SegmentedBar(
|
||||
cupertino: cupertino,
|
||||
title: 'Search',
|
||||
actions: [_controls(cupertino)],
|
||||
);
|
||||
if (widget.embedded) return body;
|
||||
if (cupertino) {
|
||||
return CupertinoPageScaffold(navigationBar: bar, child: _body(cupertino));
|
||||
}
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: const SegmentedBar(cupertino: false, title: 'Search'),
|
||||
body: body,
|
||||
appBar: bar,
|
||||
body: _body(cupertino),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _materialHeader() => Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 8),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
spacing: 8,
|
||||
children: [
|
||||
SearchBar(
|
||||
key: const ValueKey('search.field'),
|
||||
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 _controls(bool cupertino) => SearchBarControls(
|
||||
cupertino: cupertino,
|
||||
text: _text,
|
||||
kind: _controller.parsed.kind,
|
||||
onChanged: _controller.updateQuery,
|
||||
onSubmitted: _controller.submit,
|
||||
onCleared: _clear,
|
||||
onKind: _controller.selectKind,
|
||||
);
|
||||
|
||||
Widget _cupertinoScreen() {
|
||||
final body = SafeArea(
|
||||
bottom: false,
|
||||
child: SearchArtifactScope(
|
||||
gateway: widget.gateway,
|
||||
onOpen: widget.onOpen,
|
||||
child: CupertinoSearchBody(
|
||||
controller: _controller,
|
||||
query: _controller.parsed.query,
|
||||
onOpen: widget.onOpen,
|
||||
header: _cupertinoHeader(context),
|
||||
),
|
||||
/// The server's result and scan bounds, only when they cut the answer
|
||||
/// short: a complete answer needs no statistics.
|
||||
Widget _header({Widget? controls}) {
|
||||
final bounds = _controller.truncated ? _controller.boundsText : null;
|
||||
if (bounds == null && controls == null) return const SizedBox.shrink();
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
spacing: 8,
|
||||
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(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 8),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
spacing: 8,
|
||||
children: [
|
||||
CupertinoSearchTextField(
|
||||
key: const ValueKey('search.field'),
|
||||
controller: _text,
|
||||
autofocus: true,
|
||||
placeholder: 'Search pipelines, runs and artifacts',
|
||||
onChanged: _controller.updateQuery,
|
||||
onSubmitted: (_) => _controller.submit(),
|
||||
onSuffixTap: _clear,
|
||||
),
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: CupertinoButton(
|
||||
key: const ValueKey('search.kind'),
|
||||
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),
|
||||
],
|
||||
/// No top safe area: the results run behind the floating bar and the
|
||||
/// scroll view starts them below it.
|
||||
Widget _body(bool cupertino, {Widget? controls}) {
|
||||
final header = _header(controls: controls);
|
||||
return SearchArtifactScope(
|
||||
gateway: widget.gateway,
|
||||
onOpen: widget.onOpen,
|
||||
child: cupertino
|
||||
? CupertinoSearchBody(
|
||||
controller: _controller,
|
||||
query: _controller.parsed.query,
|
||||
onOpen: widget.onOpen,
|
||||
header: header,
|
||||
)
|
||||
: MaterialSearchBody(
|
||||
controller: _controller,
|
||||
query: _controller.parsed.query,
|
||||
onOpen: widget.onOpen,
|
||||
header: header,
|
||||
),
|
||||
),
|
||||
),
|
||||
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 '../../../core/api_gateway.dart';
|
||||
import '../domain/search_controller.dart';
|
||||
import '../domain/search_row.dart';
|
||||
import 'search_result_view.dart';
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import 'search_layout.dart';
|
||||
|
||||
/// The Cupertino search view: native search/kind controls and grouped list rows
|
||||
/// in one scroll view, with standard activity and retry controls.
|
||||
/// The Cupertino search view: an optional status header and inset-grouped
|
||||
/// rows in one scroll view that runs behind the top bar, with standard
|
||||
/// activity and retry controls.
|
||||
class CupertinoSearchBody extends StatelessWidget {
|
||||
const CupertinoSearchBody({
|
||||
super.key,
|
||||
@@ -25,7 +25,7 @@ class CupertinoSearchBody extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CustomScrollView(
|
||||
return SearchScrollView(
|
||||
slivers: [
|
||||
SliverToBoxAdapter(child: header),
|
||||
if (controller.showProgress)
|
||||
@@ -36,7 +36,6 @@ class CupertinoSearchBody extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
..._content(context),
|
||||
const SliverFloatingBarClearance(),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -64,7 +63,16 @@ class CupertinoSearchBody extends StatelessWidget {
|
||||
return [
|
||||
SliverToBoxAdapter(
|
||||
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: [
|
||||
for (final hit in controller.shownResults)
|
||||
_CupertinoResult(hit: hit, query: query, onOpen: onOpen),
|
||||
@@ -112,13 +120,8 @@ class _CupertinoResult extends StatelessWidget {
|
||||
Icon(searchCupertinoIcon('${hit['kind'] ?? ''}')),
|
||||
leadingSize: 44,
|
||||
trailing: searchArtifactActions(context, hit),
|
||||
title: Text(row.title),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 2,
|
||||
children: [searchRowMeta(row), searchRowSnippet(context, row)],
|
||||
),
|
||||
title: searchRowTitle(context, row),
|
||||
subtitle: searchRowLine(context, row),
|
||||
onTap: row.openable ? () => onOpen(hit) : null,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ import '../../../core/api_gateway.dart';
|
||||
import '../domain/search_controller.dart';
|
||||
import '../domain/search_row.dart';
|
||||
import 'search_result_view.dart';
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import 'search_layout.dart';
|
||||
|
||||
/// The Material search view: the controls header and a flat native result list
|
||||
/// in one scroll view, so text scaling can never clip the controls or a row.
|
||||
/// The Material search view: an optional status header and a flat native
|
||||
/// result list in one scroll view that runs behind the top bar.
|
||||
class MaterialSearchBody extends StatelessWidget {
|
||||
const MaterialSearchBody({
|
||||
super.key,
|
||||
@@ -24,13 +24,12 @@ class MaterialSearchBody extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return CustomScrollView(
|
||||
return SearchScrollView(
|
||||
slivers: [
|
||||
SliverToBoxAdapter(child: header),
|
||||
if (controller.showProgress)
|
||||
const SliverToBoxAdapter(child: LinearProgressIndicator()),
|
||||
..._content(context),
|
||||
const SliverFloatingBarClearance(),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -100,13 +99,8 @@ class _MaterialResult extends StatelessWidget {
|
||||
searchArtifactThumbnail(context, hit) ??
|
||||
Icon(searchMaterialIcon('${hit['kind'] ?? ''}')),
|
||||
trailing: searchArtifactActions(context, hit),
|
||||
title: Text(row.title),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 2,
|
||||
children: [searchRowMeta(row), searchRowSnippet(context, row)],
|
||||
),
|
||||
title: searchRowTitle(context, row),
|
||||
subtitle: searchRowLine(context, row),
|
||||
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 '../domain/search_row.dart';
|
||||
|
||||
/// Kind, recency and read-only affordance for one row. Deliberately unstyled
|
||||
/// beyond weight so Material and Cupertino inherit their own system typography
|
||||
/// and colours, including dark mode and text scaling.
|
||||
Widget searchRowMeta(SearchRowView row) {
|
||||
final parts = [row.kindLabel, if (row.recency != null) row.recency!];
|
||||
return Text(
|
||||
parts.join(' · '),
|
||||
style: const TextStyle(fontWeight: FontWeight.w600),
|
||||
/// A row's title line: the bold title and, at its trailing edge, a small tag
|
||||
/// naming the kind.
|
||||
Widget searchRowTitle(BuildContext context, SearchRowView row) => Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
spacing: 8,
|
||||
children: [
|
||||
Expanded(
|
||||
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
|
||||
/// parsing server text as markup or by a bespoke colour.
|
||||
Widget searchRowSnippet(BuildContext context, SearchRowView row) {
|
||||
final snippet = row.snippet;
|
||||
if (snippet == null) {
|
||||
return row.secondary.isEmpty
|
||||
? const SizedBox.shrink()
|
||||
: Text(row.secondary);
|
||||
Color _muted(BuildContext context) => usesCupertinoHost(context)
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
|
||||
/// The result's kind as a small tinted capsule.
|
||||
class SearchKindTag extends StatelessWidget {
|
||||
const SearchKindTag({super.key, required this.label});
|
||||
|
||||
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) {
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../core/api_gateway.dart';
|
||||
import '../../shell/shell_bar.dart';
|
||||
import '../../ui/adaptive/host.dart';
|
||||
import 'data/template_repository.dart';
|
||||
import 'domain/template_entry.dart';
|
||||
@@ -189,7 +190,7 @@ class _TemplatesScreenState extends State<TemplatesScreen> {
|
||||
)
|
||||
: TemplateDetail(
|
||||
entry: selected,
|
||||
showBack: widget.embedded,
|
||||
showBack: widget.embedded && !ShellBar.available(context),
|
||||
onBack: _back,
|
||||
onCreate: () => _openCreate(selected),
|
||||
);
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../domain/template_entry.dart';
|
||||
|
||||
/// 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) {
|
||||
final back = cupertino
|
||||
? CupertinoButton(
|
||||
key: templateDetailBackKey,
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onBack,
|
||||
child: const Icon(CupertinoIcons.back, semanticLabel: 'Back'),
|
||||
)
|
||||
: BackButton(key: templateDetailBackKey, onPressed: onBack);
|
||||
// Only without a bar above: the same round Back the bar would show.
|
||||
final back = SegmentedPill(
|
||||
cupertino: cupertino,
|
||||
child: SegmentedBackButton(
|
||||
key: templateDetailBackKey,
|
||||
cupertino: cupertino,
|
||||
onPressed: onBack,
|
||||
),
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(4, 4, 16, 0),
|
||||
padding: const EdgeInsets.fromLTRB(12, 8, 16, 0),
|
||||
child: Row(
|
||||
children: [
|
||||
back,
|
||||
const SizedBox(width: 4),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text('Templates', style: templateSectionStyle(context)),
|
||||
),
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
import 'package:flutter/cupertino.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/segmented_bar.dart';
|
||||
import '../../../ui/navigation/bar_icon_button.dart';
|
||||
|
||||
const templatesRefreshKey = ValueKey<String>('templates-refresh');
|
||||
const templatesBackKey = ValueKey<String>('templates-back');
|
||||
|
||||
/// The screen's native chrome.
|
||||
///
|
||||
/// Standalone use keeps the host's own app bar with Back and Refresh. A shell
|
||||
/// that already owns navigation passes [embedded], which drops the bar and
|
||||
/// keeps Refresh at the top of the body.
|
||||
/// Standalone use draws the segmented bar: the round Back (back to the
|
||||
/// gallery from a template, otherwise the route's own) and Refresh in the
|
||||
/// 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 {
|
||||
const TemplatesFrame({
|
||||
super.key,
|
||||
@@ -32,77 +36,60 @@ class TemplatesFrame extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (embedded) return _embedded(context);
|
||||
return usesCupertinoHost(context)
|
||||
? _cupertino(context)
|
||||
: _material(context);
|
||||
}
|
||||
|
||||
Widget _embedded(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerEnd,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
child: _refreshButton(context),
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
if (embedded) {
|
||||
if (ShellBar.available(context)) {
|
||||
return ShellBar(
|
||||
title: 'Templates',
|
||||
onBack: canGoBack ? onBack : null,
|
||||
actions: [_refreshButton()],
|
||||
child: body,
|
||||
);
|
||||
}
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Align(
|
||||
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()],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertino(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
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) {
|
||||
if (cupertino) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: bar,
|
||||
child: SafeArea(child: body),
|
||||
);
|
||||
}
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(
|
||||
cupertino: false,
|
||||
title: 'Templates',
|
||||
leading: canGoBack
|
||||
? BackButton(key: templatesBackKey, onPressed: onBack)
|
||||
: null,
|
||||
actions: [_refreshButton(context)],
|
||||
),
|
||||
appBar: bar,
|
||||
body: SafeArea(child: body),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _refreshButton(BuildContext context) {
|
||||
final onPressed = refreshing ? null : onRefresh;
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoButton(
|
||||
key: templatesRefreshKey,
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onPressed,
|
||||
child: const Icon(CupertinoIcons.refresh, semanticLabel: 'Refresh'),
|
||||
);
|
||||
}
|
||||
return IconButton(
|
||||
key: templatesRefreshKey,
|
||||
tooltip: 'Refresh',
|
||||
onPressed: onPressed,
|
||||
icon: const Icon(Icons.refresh),
|
||||
);
|
||||
}
|
||||
Widget _refreshButton() => BarIconButton(
|
||||
key: templatesRefreshKey,
|
||||
icon: Icons.refresh,
|
||||
cupertinoIcon: CupertinoIcons.refresh,
|
||||
label: 'Refresh',
|
||||
onPressed: refreshing ? null : onRefresh,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user