Merge branch 'worktree-agent-a349ca4a1fb5fc7a3' into integrate/pages

This commit is contained in:
2026-10-31 03:32:09 +00:00
50 changed files with 2483 additions and 1165 deletions
+26 -17
View File
@@ -6,11 +6,16 @@ import 'package:flutter/material.dart';
import '../features/schedules/data/schedules_repository.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 '../ui/adaptive/host.dart';
import 'app_session.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.
///
/// 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) {
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) {
return CupertinoPageScaffold(
navigationBar: SegmentedBar(
cupertino: true,
leading: CupertinoButton(
padding: EdgeInsets.zero,
onPressed: widget.onBack,
child: const Icon(CupertinoIcons.back, semanticLabel: 'Back'),
),
title: 'Schedules',
),
navigationBar: bar,
child: SafeArea(child: body),
);
}
return Scaffold(
extendBodyBehindAppBar: true,
appBar: SegmentedBar(
cupertino: false,
leading: IconButton(
onPressed: widget.onBack,
icon: const Icon(Icons.arrow_back, semanticLabel: 'Back'),
),
title: 'Schedules',
),
appBar: bar,
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);
},
onRefresh: () => _controller.refresh(),
refreshInToolbar: false,
);
}
}
+83 -57
View File
@@ -1,10 +1,14 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../ui/adaptive/segmented_bar.dart';
import '../core/api_gateway.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/segmented_bar.dart';
import 'app_session.dart';
import 'connection_status.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 gallery is rendered in embedded mode, so the shell owns navigation; this
/// destination contributes the page's one native bar (Back + Templates) and the
/// same honest connection states as the other destinations. No socket is opened
/// The gallery is rendered in embedded mode and publishes its controls to
/// this page's one segmented bar (through a [ShellBarScope] the page owns):
/// 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
/// create request travels over it.
///
/// [onCreated] forwards the server-confirmed detail once, so the caller can
/// invalidate the Pipelines list. This screen never inserts a row itself.
class TemplatesDestination extends StatelessWidget {
class TemplatesDestination extends StatefulWidget {
const TemplatesDestination({
super.key,
required this.session,
@@ -42,24 +48,74 @@ class TemplatesDestination extends StatelessWidget {
/// The template detail the route names, or null for the gallery.
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
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
return AnimatedBuilder(
animation: session,
builder: (context, _) => _TemplatesPage(
cupertino: cupertino,
onBack: onBack,
child: _body(cupertino),
final body = ShellBarScope(
registry: _bar,
destination: AppDestination.settings,
child: AnimatedBuilder(
animation: widget.session,
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) {
final session = widget.session;
if (!session.everConnected) {
return ConnectionGate(
session: session,
server: server,
server: widget.server,
cupertino: cupertino,
);
}
@@ -71,8 +127,8 @@ class TemplatesDestination extends StatelessWidget {
child: TemplatesScreen(
gateway: session.gateway,
embedded: true,
onCreated: onCreated,
initialKey: initialKey,
onCreated: widget.onCreated,
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
/// confused with the gallery's own Back-to-gallery control.
class _TemplatesPage extends StatelessWidget {
const _TemplatesPage({
required this.cupertino,
required this.onBack,
required this.child,
});
/// Gives the scaffold a [SegmentedBar]'s size and obstruction while the bar
/// itself is rebuilt from the published controls.
class _BarSlot extends StatelessWidget
implements ObstructingPreferredSizeWidget {
const _BarSlot({required this.cupertino, required this.child});
final bool cupertino;
final VoidCallback onBack;
final Widget child;
@override
Widget build(BuildContext context) {
if (cupertino) {
return CupertinoPageScaffold(
navigationBar: SegmentedBar(
cupertino: true,
leading: CupertinoButton(
key: templatesPageBackKey,
padding: EdgeInsets.zero,
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),
);
}
Size get preferredSize =>
SegmentedBar(cupertino: cupertino, title: '').preferredSize;
@override
bool shouldFullyObstruct(BuildContext context) => false;
@override
Widget build(BuildContext context) => child;
}
@@ -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
+12 -19
View File
@@ -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)),
],
+72 -163
View File
@@ -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) {
@@ -5,12 +5,23 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import '../../core/transport/pipelines_client.dart';
import '../../ui/adaptive/host.dart';
import 'settings_controller.dart';
import 'settings_group.dart';
import 'settings_row.dart';
import 'settings_sections.dart';
import 'settings_trust_warning.dart';
import 'settings_theme.dart';
/// Status follows the actual attempted address, not just the preferred URL.
/// The short line under the managed connection's rows.
const String managedConnectionHelp =
'Reconnect tries the preferred address first, then the backups.';
/// The browser-only addition to [managedConnectionHelp].
const String managedConnectionWebHelp =
'In a browser the connection stays on this page’s origin.';
/// The saved-server connection: its state, the address actually attempted and
/// Reconnect / Disconnect rows. Status follows the actual attempted address,
/// not just the preferred URL.
class ManagedConnectionSection extends StatelessWidget {
const ManagedConnectionSection({
super.key,
@@ -20,43 +31,49 @@ class ManagedConnectionSection extends StatelessWidget {
final PipelinesClient client;
final SettingsController controller;
Widget _action(BuildContext context, String text, VoidCallback? press) =>
usesCupertinoHost(context)
? CupertinoButton(onPressed: press, child: Text(text))
: TextButton(onPressed: press, child: Text(text));
@override
Widget build(BuildContext context) => Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
SelectableText('Current address: ${client.endpoint ?? 'Not connected'}'),
const SizedBox(height: 8),
const Text(
'Reconnect tries the preferred address first. A dropped or '
'unreachable connection tries this server’s backup addresses automatically.',
),
if (kIsWeb)
const Text(
'In a browser, the connection stays on this page’s '
'origin. Use a saved server to open its page; native apps use automatic address fallback.',
),
Wrap(
spacing: 8,
children: [
_action(
context,
'Reconnect',
client.endpoints.isEmpty
? null
: () => unawaited(client.connectAny(client.endpoints)),
Widget build(BuildContext context) {
final cupertino = usesCupertinoControls(context);
return SettingsGroup(
title: 'Connection',
leadingRows: true,
footer: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Text(
kIsWeb
? '$managedConnectionHelp $managedConnectionWebHelp'
: managedConnectionHelp,
),
_action(context, 'Disconnect', () => unawaited(client.disconnect())),
const SizedBox(height: 12),
settingsConnectionFooter(controller),
],
),
SettingsStatusCard(controller: controller),
const SizedBox(height: 12),
const SettingsTrustWarning(),
if (controller.protocolWarning case final warning?) Text(warning),
],
);
children: <Widget>[
SettingsStatusRow(controller: controller),
SettingsRow(
leading: Icon(cupertino ? CupertinoIcons.link : Icons.link),
title: const Text('Current address'),
subtitle: SelectableText('${client.endpoint ?? 'Not connected'}'),
),
SettingsRow(
action: true,
enabled: client.endpoints.isNotEmpty,
leading: Icon(
cupertino ? CupertinoIcons.arrow_clockwise : Icons.refresh,
),
title: const Text('Reconnect'),
onTap: () => unawaited(client.connectAny(client.endpoints)),
),
SettingsRow(
action: true,
leading: Icon(
cupertino ? CupertinoIcons.stop_circle : Icons.link_off,
),
title: const Text('Disconnect'),
onTap: () => unawaited(client.disconnect()),
),
],
);
}
}
@@ -0,0 +1,121 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../core/servers/server_catalog.dart';
import 'settings_row.dart';
import 'settings_theme.dart';
/// What a saved server's menu can do.
enum SavedServerAction { use, edit, remove }
/// The key of a saved server's actions menu button.
ValueKey<String> savedServerMenuKey(String id) =>
ValueKey<String>('settings.server.$id.menu');
/// One saved server: a selection mark, the name, "Selected server" on the
/// active one and each address (preferred, then backups) as subtitle lines.
/// Tapping another server uses it; the trailing menu offers Use, Edit and
/// Remove.
class SavedServerRow extends StatelessWidget {
const SavedServerRow({
super.key,
required this.server,
required this.selected,
required this.busy,
required this.onAction,
});
final SavedServer server;
final bool selected;
final bool busy;
final ValueChanged<SavedServerAction> onAction;
String _label(SavedServerAction action) => switch (action) {
SavedServerAction.use => 'Use ${server.name}',
SavedServerAction.edit => 'Edit ${server.name}',
SavedServerAction.remove => 'Remove ${server.name}',
};
List<SavedServerAction> get _actions => <SavedServerAction>[
if (!selected) SavedServerAction.use,
SavedServerAction.edit,
SavedServerAction.remove,
];
Future<void> _cupertinoMenu(BuildContext context) async {
final action = await showCupertinoModalPopup<SavedServerAction>(
context: context,
builder: (context) => CupertinoActionSheet(
title: Text(server.name),
actions: <Widget>[
for (final action in _actions)
CupertinoActionSheetAction(
isDestructiveAction: action == SavedServerAction.remove,
onPressed: () => Navigator.pop(context, action),
child: Text(_label(action)),
),
],
cancelButton: CupertinoActionSheetAction(
onPressed: () => Navigator.pop(context),
child: const Text('Cancel'),
),
),
);
if (action != null) onAction(action);
}
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoControls(context);
final Widget menu = cupertino
? CupertinoButton(
key: savedServerMenuKey(server.id),
padding: EdgeInsets.zero,
onPressed: busy ? null : () => _cupertinoMenu(context),
child: Icon(
CupertinoIcons.ellipsis_circle,
semanticLabel: '${server.name} actions',
),
)
: PopupMenuButton<SavedServerAction>(
key: savedServerMenuKey(server.id),
enabled: !busy,
tooltip: '${server.name} actions',
onSelected: onAction,
itemBuilder: (context) => <PopupMenuEntry<SavedServerAction>>[
for (final action in _actions)
PopupMenuItem(value: action, child: Text(_label(action))),
],
);
final Widget mark = selected
? Icon(
cupertino
? CupertinoIcons.checkmark_circle_fill
: Icons.check_circle,
semanticLabel: 'Selected',
color: cupertino
? CupertinoTheme.of(context).primaryColor
: Theme.of(context).colorScheme.primary,
)
: Icon(
cupertino ? CupertinoIcons.circle : Icons.radio_button_unchecked,
color: cupertino
? CupertinoColors.tertiaryLabel.resolveFrom(context)
: null,
);
return SettingsRow(
leading: mark,
title: Text(server.name),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
if (selected) const Text('Selected server'),
for (final (index, address) in server.endpoints.indexed)
Text('${index == 0 ? 'Preferred' : 'Backup $index'}: $address'),
],
),
trailing: menu,
onTap: selected || busy ? null : () => onAction(SavedServerAction.use),
);
}
}
@@ -6,7 +6,11 @@ import 'package:flutter/material.dart';
import '../../core/servers/server_catalog.dart';
import '../../ui/adaptive/host.dart';
import 'saved_server_editor.dart';
import 'saved_server_row.dart';
import 'server_connections.dart';
import 'settings_group.dart';
import 'settings_row.dart';
import 'settings_theme.dart';
class _ServerSaveFailure implements Exception {
const _ServerSaveFailure(this.message);
@@ -79,73 +83,46 @@ class SavedServersSection extends StatelessWidget {
if (confirmed == true) await connections.remove(server.id);
}
Widget _button(BuildContext context, String label, VoidCallback? press) =>
usesCupertinoHost(context)
? CupertinoButton(onPressed: press, child: Text(label))
: TextButton(onPressed: press, child: Text(label));
void _act(BuildContext context, SavedServer server, SavedServerAction act) {
switch (act) {
case SavedServerAction.use:
unawaited(connections.select(server.id));
case SavedServerAction.edit:
unawaited(_edit(context, server));
case SavedServerAction.remove:
unawaited(_remove(context, server));
}
}
@override
Widget build(BuildContext context) => ListenableBuilder(
listenable: connections,
builder: (context, _) => Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
for (final server in connections.catalog.servers) ...[
Text(
server.name,
style: const TextStyle(fontWeight: FontWeight.w600),
),
if (server.id == connections.catalog.active?.id)
const Text('Selected server'),
for (final (index, address) in server.endpoints.indexed)
Text('${index == 0 ? 'Preferred' : 'Backup $index'}: $address'),
Wrap(
spacing: 8,
children: [
if (server.id != connections.catalog.active?.id)
_button(
context,
'Use ${server.name}',
connections.busy
? null
: () => unawaited(connections.select(server.id)),
),
_button(
context,
'Edit ${server.name}',
connections.busy
? null
: () => unawaited(_edit(context, server)),
),
_button(
context,
'Remove ${server.name}',
connections.busy
? null
: () => unawaited(_remove(context, server)),
),
],
),
const SizedBox(height: 12),
],
Align(
alignment: AlignmentDirectional.centerStart,
child: _button(
context,
'Add server',
connections.busy ? null : () => unawaited(_edit(context)),
),
),
if (connections.error != null)
Text(
connections.error!,
style: TextStyle(
color: usesCupertinoHost(context)
? CupertinoColors.systemRed.resolveFrom(context)
: Theme.of(context).colorScheme.error,
builder: (context, _) {
final cupertino = usesCupertinoHost(context);
final error = connections.error;
return SettingsGroup(
title: 'Servers',
leadingRows: true,
footer: error == null
? null
: Text(error, style: TextStyle(color: settingsErrorColor(context))),
children: [
for (final server in connections.catalog.servers)
SavedServerRow(
server: server,
selected: server.id == connections.catalog.active?.id,
busy: connections.busy,
onAction: (act) => _act(context, server, act),
),
SettingsRow(
action: true,
enabled: !connections.busy,
leading: Icon(cupertino ? CupertinoIcons.add : Icons.add),
title: const Text('Add server'),
onTap: () => unawaited(_edit(context)),
),
],
),
],
);
},
);
}
@@ -73,7 +73,7 @@ class _SettingsAndroidDownloadSectionState
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final muted = cupertino
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
? CupertinoTheme.of(context).textTheme.textStyle.copyWith(
color: CupertinoColors.secondaryLabel.resolveFrom(context),
)
: Theme.of(context).textTheme.bodySmall?.copyWith(
@@ -81,18 +81,12 @@ class _SettingsAndroidDownloadSectionState
);
final update = _update;
if (_loading) {
return Padding(
padding: const EdgeInsets.all(16),
child: Text('Checking for the Android app…', style: muted),
);
return Text('Checking for the Android app…', style: muted);
}
if (update == null) {
return Padding(
padding: const EdgeInsets.all(16),
child: Text(
'This server offers no Android app yet. Build one with ./install --apk.',
style: muted,
),
return Text(
'This server offers no Android app yet. Build one with ./install --apk.',
style: muted,
);
}
final button = cupertino
@@ -107,30 +101,27 @@ class _SettingsAndroidDownloadSectionState
icon: const Icon(Icons.download),
label: const Text('Download APK'),
);
return Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Pipelines for Android · build ${update.versionCode}'),
if (update.notes.isNotEmpty) ...[
const SizedBox(height: 4),
Text(update.notes, style: muted),
],
const SizedBox(height: 12),
button,
const SizedBox(height: 8),
Text(
'Open it on the phone, allow installs from this browser, then sign '
'in under Settings. Later builds arrive through Check for updates.',
style: muted,
),
if (_message case final message?) ...[
const SizedBox(height: 8),
Text(message, style: muted),
],
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Pipelines for Android · build ${update.versionCode}'),
if (update.notes.isNotEmpty) ...[
const SizedBox(height: 4),
Text(update.notes, style: muted),
],
),
const SizedBox(height: 12),
button,
const SizedBox(height: 8),
Text(
'Open it on the phone and allow installs from this browser; later '
'builds arrive through Check for updates.',
style: muted,
),
if (_message case final message?) ...[
const SizedBox(height: 8),
Text(message, style: muted),
],
],
);
}
}
@@ -1,4 +1,3 @@
import '../../ui/theme/app_theme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@@ -189,37 +188,3 @@ class SettingsActions extends StatelessWidget {
);
}
}
/// One standard settings card: a Material [Card] or an inset-grouped Cupertino
/// section, both using theme surfaces and native corner/padding defaults.
class SettingsCard extends StatelessWidget {
const SettingsCard({super.key, required this.child});
final Widget child;
@override
Widget build(BuildContext context) {
if (usesCupertinoControls(context)) {
return CupertinoListSection.insetGrouped(
backgroundColor: AppColors.groupedBackground,
margin: EdgeInsets.zero,
children: <Widget>[
SizedBox(
width: double.infinity,
child: Padding(
padding: const EdgeInsets.all(settingsCardPadding),
child: child,
),
),
],
);
}
return Card(
margin: EdgeInsets.zero,
child: Padding(
padding: const EdgeInsets.all(settingsCardPadding),
child: child,
),
);
}
}
+7 -8
View File
@@ -5,15 +5,14 @@ import '../../core/transport/pipelines_client.dart' as transport;
const String serverUrlPlaceholder = 'ws://192.168.1.20:8081/connect';
const String serverUrlHelper =
'ws:// only on a trusted LAN/VPN, or wss:// for TLS. '
'Use the authenticated web proxy’s /connect address when sign-in is required.';
'ws:// only on a trusted LAN/VPN, otherwise wss://. Use the web '
'proxy’s /connect address when sign-in is required.';
const String workspacePlaceholder = '/Users/you/repos/pipelines';
const String workspaceHelper =
'An absolute directory that already exists on the execution server. For '
'Docker, mount the host directory at the same absolute path with its '
"owner's UID/GID. This is not the phone's storage.";
'An existing absolute directory on the execution server, not the '
"phone's storage. With Docker, mount it at the same path and owner.";
const String workspacePathError =
'The workspace must be an absolute path that exists on the execution '
@@ -22,9 +21,9 @@ const String workspacePathError =
const String trustTitle = 'Trusted LAN/VPN only';
const String trustBody =
'Use the authenticated web address for remote access. Direct API access '
'has no authentication and must stay on a trusted LAN/VPN. ws:// traffic '
'is unencrypted; prefer wss://. Never enter provider credentials here.';
'Direct API access has no authentication: keep ws:// on a trusted '
'LAN/VPN, prefer wss://, and use the authenticated web address remotely. '
'Never enter provider credentials here.';
/// The workspace draft is valid when it is untouched (empty) or absolute. A
/// relative path is the one rejected value; the execution server resolves the
@@ -0,0 +1,151 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../ui/theme/app_theme.dart';
import 'settings_layout.dart';
import 'settings_theme.dart';
/// One grouped Settings section: a short header, a flat rounded group of rows
/// and an optional one-line footer.
///
/// Material draws the header in the theme's primary `titleSmall` and the rows
/// on a flat `surfaceContainer` with hairline dividers (no elevation).
/// Cupertino uses the stock inset-grouped [CupertinoListSection], whose rows
/// sit on `secondarySystemGroupedBackground` over the page's
/// `systemGroupedBackground`.
class SettingsGroup extends StatelessWidget {
const SettingsGroup({
super.key,
required this.children,
this.title,
this.footer,
this.leadingRows = false,
});
final String? title;
final List<Widget> children;
/// A short line (or two) under the group: helper copy, a warning.
final Widget? footer;
/// Whether the rows carry leading icons: Cupertino then starts its
/// dividers at the titles (the stock inset), otherwise at the row text.
final bool leadingRows;
@override
Widget build(BuildContext context) {
final title = this.title;
final footer = this.footer;
if (usesCupertinoControls(context)) {
return CupertinoListSection.insetGrouped(
margin: EdgeInsets.zero,
backgroundColor: AppColors.groupedBackground,
header: title == null
? null
: Text(title, style: settingsHeaderStyle(context)),
footer: footer == null ? null : _footer(context, footer),
additionalDividerMargin: leadingRows ? null : 6,
children: children.isEmpty ? null : children,
);
}
final theme = Theme.of(context);
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
if (title != null)
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(
settingsRowInset,
0,
settingsRowInset,
settingsTitleGap,
),
child: Semantics(
header: true,
child: Text(title, style: settingsHeaderStyle(context)),
),
),
if (children.isNotEmpty)
Material(
type: MaterialType.card,
color: theme.colorScheme.surfaceContainer,
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(settingsGroupRadius),
),
clipBehavior: Clip.antiAlias,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
for (final (index, child) in children.indexed) ...<Widget>[
if (index > 0)
Divider(
height: 1,
thickness: 1,
indent: settingsRowInset,
color: theme.colorScheme.outlineVariant,
),
child,
],
],
),
),
if (footer != null) _footer(context, footer),
],
);
}
Widget _footer(BuildContext context, Widget footer) {
final cupertino = usesCupertinoControls(context);
// Cupertino: the footnote size the stock plain list section uses for
// its own header and footer.
final style = cupertino
? settingsTextStyle(context, secondary: true).copyWith(fontSize: 13)
: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
);
final text = DefaultTextStyle.merge(style: style, child: footer);
// The Cupertino section pads its own footer.
if (cupertino) return text;
return Padding(
padding: const EdgeInsetsDirectional.fromSTEB(
settingsRowInset,
settingsFieldGap + 2,
settingsRowInset,
0,
),
child: text,
);
}
}
/// A group header's text style.
TextStyle settingsHeaderStyle(BuildContext context) {
if (usesCupertinoControls(context)) {
return settingsTextStyle(context).copyWith(fontWeight: FontWeight.w600);
}
final theme = Theme.of(context);
return (theme.textTheme.titleSmall ?? const TextStyle()).copyWith(
color: theme.colorScheme.primary,
);
}
/// Free-form content inside a group (a text field, a status block), padded
/// like a row so its edges line up with the rows' text.
class SettingsGroupItem extends StatelessWidget {
const SettingsGroupItem({super.key, required this.child});
final Widget child;
@override
Widget build(BuildContext context) => SizedBox(
width: double.infinity,
child: Padding(
padding: EdgeInsetsDirectional.symmetric(
horizontal: usesCupertinoControls(context) ? 20 : settingsRowInset,
vertical: 12,
),
child: child,
),
);
}
+20 -16
View File
@@ -4,34 +4,38 @@
/// from the active Material or Cupertino theme, so text scaling and platform
/// defaults are never overridden here.
///
/// The rhythm follows the web Settings page: one centred column, an 8px gap
/// between a section's compact title and its grouped body, and 16px between
/// sections. The web's 12px field label and helper lines are secondary type in
/// [settingsTextStyle]/[SettingsTextField], not fixed sizes.
/// The page is a column of grouped sections. It starts at the top bar's own
/// side inset, so on a wide window the groups line up under the title pill
/// instead of floating in the middle, and stops growing at a reading width.
library;
/// A comfortable reading width on wide windows; the body is centred inside it.
/// The widest the column of groups grows on a wide window.
const double settingsContentMaxWidth = 720;
/// Space between the Settings sections (web `.settings` grid gap).
const double settingsSectionGap = 16;
/// Space between the Settings groups.
const double settingsSectionGap = 24;
/// Space between a compact section title and its grouped body, and between the
/// blocks inside a section (web `.settings-section` grid gap).
/// Space between a group's header and its rows, and between stacked blocks
/// inside a row.
const double settingsTitleGap = 8;
/// Space between a field label and its field, and between stacked secondary
/// lines (web `.settings-field` gap).
/// lines.
const double settingsFieldGap = 4;
/// Space between wrapped action buttons.
const double settingsControlGap = 8;
/// Page insets on narrow windows: a little more room above the first title,
/// and a clear run-out below the last section (web `.settings` padding).
const double settingsPageTopPadding = 20;
const double settingsPageSidePadding = 16;
/// The page's side inset: the segmented bar's own, so the groups' edge lines
/// up with the title pill.
const double settingsPageSidePadding = 12;
/// Space below the top bar (added to its height) and below the last group.
const double settingsPageTopPadding = 8;
const double settingsPageBottomPadding = 32;
/// Padding inside a standard Material card / Cupertino inset row.
const double settingsCardPadding = 16;
/// The inset of a row's text inside a Material group (the [ListTile] default).
const double settingsRowInset = 16;
/// The corner radius of a Material group.
const double settingsGroupRadius = 16;
@@ -1,7 +1,9 @@
import 'package:flutter/widgets.dart';
import '../attention/notify/notification_controller.dart';
import '../attention/notify/notification_models.dart';
import '../attention/ui/notification_permission_tile.dart';
import 'settings_group.dart';
/// The Settings entry for the browser notification permission.
///
@@ -10,24 +12,28 @@ import '../attention/ui/notification_permission_tile.dart';
/// Enable action. The controller is shared with the Runs attention surface, so
/// the permission shown here is the one that gates the live notices.
class SettingsNotificationsSection extends StatelessWidget {
const SettingsNotificationsSection({
super.key,
required this.controller,
});
const SettingsNotificationsSection({super.key, required this.controller});
final NotificationController controller;
@override
Widget build(BuildContext context) => AnimatedBuilder(
animation: controller,
builder: (context, _) => NotificationPermissionTile(
state: controller.permission,
asked: controller.asked,
onRequest: () {
// The platform answer updates the controller; the AnimationBuilder above
// redraws the tile with its own words.
controller.requestPermission();
},
builder: (context, _) => SettingsGroup(
title: notificationSectionTitle,
children: <Widget>[
SettingsGroupItem(
child: NotificationPermissionTile(
state: controller.permission,
asked: controller.asked,
onRequest: () {
// The platform answer updates the controller; the
// AnimationBuilder above redraws the tile with its own words.
controller.requestPermission();
},
),
),
],
),
);
}
@@ -5,7 +5,7 @@ import 'package:flutter/material.dart';
import '../../core/api_gateway.dart';
import 'ntfy_settings_controller.dart';
import 'settings_layout.dart';
import 'settings_group.dart';
import 'settings_theme.dart';
/// The section title for the server's ntfy notification choices.
@@ -93,36 +93,24 @@ class _SettingsNtfySectionState extends State<SettingsNtfySection> {
enabled ? (value) => _controller.toggle(setting.key, value) : null,
),
];
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Text(
ntfySectionSubtitle,
style: settingsTextStyle(context, secondary: true),
),
if (status.isNotEmpty) ...<Widget>[
const SizedBox(height: settingsFieldGap),
Text(status, style: settingsTextStyle(context, secondary: true)),
],
const SizedBox(height: settingsFieldGap),
if (cupertino)
CupertinoListSection.insetGrouped(
margin: EdgeInsets.zero,
children: tiles,
)
else
...tiles,
if (_controller.error.isNotEmpty) ...<Widget>[
const SizedBox(height: settingsFieldGap),
Semantics(
liveRegion: true,
child: Text(
_controller.error,
key: ntfyErrorKey,
style: settingsTextStyle(context, error: true),
final retry = values == null && widget.connected && !_controller.loading;
return SettingsGroup(
title: ntfySectionTitle,
footer: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
const Text(ntfySectionSubtitle),
if (status.isNotEmpty) Text(status),
if (_controller.error.isNotEmpty)
Semantics(
liveRegion: true,
child: Text(
_controller.error,
key: ntfyErrorKey,
style: TextStyle(color: settingsErrorColor(context)),
),
),
),
if (values == null && widget.connected && !_controller.loading)
if (_controller.error.isNotEmpty && retry)
Align(
alignment: AlignmentDirectional.centerStart,
child: cupertino
@@ -137,7 +125,8 @@ class _SettingsNtfySectionState extends State<SettingsNtfySection> {
),
),
],
],
),
children: tiles,
);
}
@@ -151,16 +140,14 @@ class _SettingsNtfySectionState extends State<SettingsNtfySection> {
return CupertinoListTile(
key: ntfySettingKey(setting.key),
title: Text(setting.label),
trailing: CupertinoCheckbox(
value: value,
onChanged: onChanged == null ? null : (next) => onChanged(next!),
),
// iOS settings rows toggle with a switch; an unchecked checkbox is
// nearly invisible on the grouped row.
trailing: CupertinoSwitch(value: value, onChanged: onChanged),
onTap: onChanged == null ? null : () => onChanged(!value),
);
}
return CheckboxListTile(
key: ntfySettingKey(setting.key),
contentPadding: EdgeInsets.zero,
title: Text(setting.label),
value: value,
onChanged: onChanged == null ? null : (next) => onChanged(next!),
@@ -0,0 +1,63 @@
import 'package:flutter/cupertino.dart';
import '../../ui/theme/app_theme.dart';
import 'settings_layout.dart';
import 'settings_theme.dart';
/// The Settings page's scrolling column of groups.
///
/// It scrolls behind the floating top bar: instead of a top [SafeArea] it pads
/// its start by the bar's height (the top media padding), and its end by the
/// floating tab bar's (the bottom media padding), so at rest nothing is hidden
/// and scrolled groups pass behind the glass pills. The column starts at the
/// bar's own side inset, so the groups line up under the title pill, and stops
/// at [settingsContentMaxWidth] on a wide window. Cupertino paints the page in
/// the grouped background its inset-grouped sections are designed for.
class SettingsPageBody extends StatelessWidget {
const SettingsPageBody({super.key, required this.children});
final List<Widget> children;
@override
Widget build(BuildContext context) {
final insets = MediaQuery.paddingOf(context);
// The inset-grouped section already pads above its own header.
final gap = usesCupertinoControls(context)
? settingsTitleGap
: settingsSectionGap;
final Widget list = SingleChildScrollView(
key: const ValueKey<String>('settings.scroll'),
padding: EdgeInsets.fromLTRB(
insets.left + settingsPageSidePadding,
insets.top + settingsPageTopPadding,
insets.right + settingsPageSidePadding,
insets.bottom + settingsPageBottomPadding,
),
child: Align(
alignment: AlignmentDirectional.topStart,
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: settingsContentMaxWidth),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
for (final (index, child) in children.indexed) ...<Widget>[
if (index > 0) SizedBox(height: gap),
child,
],
],
),
),
),
);
if (!usesCupertinoControls(context)) return list;
return ColoredBox(
color: settingsCupertinoBackground.resolveFrom(context),
child: list,
);
}
}
/// The Cupertino Settings page background: the system grouped background, so
/// the inset sections' rows read as raised cards in light and dark.
const CupertinoDynamicColor settingsCupertinoBackground =
AppColors.groupedBackground;
@@ -0,0 +1,86 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'settings_theme.dart';
/// One row of a [SettingsGroup]: Material [ListTile], Cupertino
/// [CupertinoListTile]. The subtitle wraps (the Cupertino tile otherwise caps
/// it at one line), so addresses and status details stay readable at large
/// text.
class SettingsRow extends StatelessWidget {
const SettingsRow({
super.key,
required this.title,
this.subtitle,
this.leading,
this.trailing,
this.onTap,
this.chevron = false,
this.action = false,
this.enabled = true,
});
final Widget title;
final Widget? subtitle;
final Widget? leading;
final Widget? trailing;
final VoidCallback? onTap;
/// A navigation row: shows the platform's disclosure chevron.
final bool chevron;
/// A command row (Reconnect, Add server): the title takes the accent
/// colour, as a button would.
final bool action;
final bool enabled;
Widget _wrapping(Widget child) => Builder(
builder: (context) => DefaultTextStyle(
style: DefaultTextStyle.of(context).style,
child: child,
),
);
@override
Widget build(BuildContext context) {
final tap = enabled ? onTap : null;
final subtitle = this.subtitle;
if (usesCupertinoControls(context)) {
final accent = CupertinoTheme.of(context).primaryColor;
final disabled = CupertinoColors.tertiaryLabel.resolveFrom(context);
return CupertinoListTile(
leading: leading == null
? null
: IconTheme.merge(
data: IconThemeData(color: enabled ? accent : disabled),
child: leading!,
),
title: DefaultTextStyle.merge(
style: TextStyle(
color: !enabled
? disabled
: action
? accent
: null,
),
child: title,
),
subtitle: subtitle == null ? null : _wrapping(subtitle),
trailing:
trailing ?? (chevron ? const CupertinoListTileChevron() : null),
onTap: tap,
);
}
final scheme = Theme.of(context).colorScheme;
return ListTile(
enabled: enabled,
leading: leading,
iconColor: action ? scheme.primary : null,
textColor: action ? scheme.primary : null,
title: title,
subtitle: subtitle,
trailing: trailing ?? (chevron ? const Icon(Icons.chevron_right) : null),
onTap: tap,
);
}
}
@@ -1,8 +1,8 @@
import '../../ui/theme/app_theme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'settings_keys.dart';
import 'settings_row.dart';
import 'settings_theme.dart';
/// The Settings entry to the saved-schedule list.
@@ -13,37 +13,23 @@ const String settingsSchedulesLabel = 'Browse schedules';
const String settingsSchedulesSecondary =
'Saved run configurations for every pipeline.';
/// A navigation row (chevron) for a Settings group.
class SettingsSchedulesSection extends StatelessWidget {
const SettingsSchedulesSection({super.key, required this.onOpen});
final VoidCallback onOpen;
@override
Widget build(BuildContext context) {
if (usesCupertinoControls(context)) {
return CupertinoListSection.insetGrouped(
backgroundColor: AppColors.groupedBackground,
margin: EdgeInsets.zero,
children: <Widget>[
CupertinoListTile(
key: SettingsKeys.schedules,
title: const Text(settingsSchedulesLabel),
subtitle: const Text(settingsSchedulesSecondary),
trailing: const CupertinoListTileChevron(),
onTap: onOpen,
),
],
);
}
return Card(
margin: EdgeInsets.zero,
child: ListTile(
key: SettingsKeys.schedules,
title: const Text(settingsSchedulesLabel),
subtitle: const Text(settingsSchedulesSecondary),
trailing: const Icon(Icons.chevron_right),
onTap: onOpen,
),
);
}
Widget build(BuildContext context) => SettingsRow(
key: SettingsKeys.schedules,
leading: Icon(
usesCupertinoControls(context)
? CupertinoIcons.calendar
: Icons.event_repeat_outlined,
),
title: const Text(settingsSchedulesLabel),
subtitle: const Text(settingsSchedulesSecondary),
chevron: true,
onTap: onOpen,
);
}
+71 -160
View File
@@ -6,11 +6,11 @@ import 'package:flutter/material.dart';
import '../../core/transport/pipelines_client.dart' as transport;
import '../attention/notify/notification_controller.dart';
import '../attention/notify/notification_models.dart';
import 'default_endpoint.dart';
import 'settings_controller.dart';
import 'settings_controls.dart';
import 'settings_layout.dart';
import 'settings_group.dart';
import 'settings_page_body.dart';
import 'settings_notifications_section.dart';
import 'settings_ntfy_section.dart';
import 'settings_android_download_section.dart';
@@ -24,7 +24,6 @@ import 'settings_templates_section.dart';
import 'server_connections.dart';
import 'saved_servers_section.dart';
import 'managed_connection_section.dart';
import '../../ui/adaptive/floating_bar_layout.dart';
/// The Settings destination: the server connection and the server-side
/// workspace, in native Material (native platforms) or Cupertino (iOS) controls.
@@ -133,148 +132,79 @@ class _SettingsScreenState extends State<SettingsScreen> {
super.dispose();
}
String get _endpoint => widget.servers == null
? _controller.serverUrl
: widget.client.endpoint?.toString() ?? '';
void _reconnectAfterSignIn() {
final endpoint = widget.client.endpoint;
if (endpoint != null) {
widget.client.connectAny(
widget.client.endpoints.isEmpty ? [endpoint] : widget.client.endpoints,
);
}
}
@override
Widget build(BuildContext context) {
// The content scrolls behind a floating tab bar and pads its end clear of
// it (or of the system inset on its own page).
final content = SafeArea(
bottom: false,
child: SingleChildScrollView(
// Web `.settings` page insets: 20 above the title, 16 at the sides and
// a clear 32 below the last section.
padding: withFloatingBarClearance(
context,
const EdgeInsetsDirectional.fromSTEB(
settingsPageSidePadding,
settingsPageTopPadding,
settingsPageSidePadding,
settingsPageBottomPadding,
final servers = widget.servers;
final content = SettingsPageBody(
children: <Widget>[
if (servers != null) ...<Widget>[
SavedServersSection(connections: servers),
ManagedConnectionSection(
client: widget.client,
controller: _controller,
),
),
child: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: settingsContentMaxWidth,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
if (widget.servers != null) ...[
_SettingsSection(
title: 'Servers',
child: SavedServersSection(connections: widget.servers!),
),
const SizedBox(height: settingsSectionGap),
],
_SettingsSection(
title: 'Connection',
child: widget.servers != null
? ManagedConnectionSection(
client: widget.client,
controller: _controller,
)
: SettingsConnectionSection(
controller: _controller,
serverUrlField: _serverUrlField,
),
),
// A phone signs in at the web login; a browser has its own.
if (widget.showSignIn) ...<Widget>[
const SizedBox(height: settingsSectionGap),
_SettingsSection(
title: 'Sign in',
child: SettingsSignInSection(
endpoint: widget.servers == null
? _controller.serverUrl
: widget.client.endpoint?.toString() ?? '',
onChanged: () {
final endpoint = widget.client.endpoint;
if (endpoint != null) {
widget.client.connectAny(
widget.client.endpoints.isEmpty
? [endpoint]
: widget.client.endpoints,
);
}
},
),
),
],
// The web page links the Android app the server offers.
if (widget.showAndroidDownload) ...<Widget>[
const SizedBox(height: settingsSectionGap),
const _SettingsSection(
title: 'Android app',
child: SettingsAndroidDownloadSection(),
),
],
// A phone installs newer builds from the server.
if (widget.showSignIn && appUpdatesSupported) ...<Widget>[
const SizedBox(height: settingsSectionGap),
_SettingsSection(
title: 'App updates',
child: SettingsUpdatesSection(
endpoint: widget.servers == null
? _controller.serverUrl
: widget.client.endpoint?.toString() ?? '',
),
),
],
const SizedBox(height: settingsSectionGap),
_SettingsSection(
title: 'Workspace',
child: SettingsWorkspaceSection(
controller: _controller,
workspaceField: _workspaceField,
),
),
if (widget.notifications != null) ...<Widget>[
const SizedBox(height: settingsSectionGap),
_SettingsSection(
title: notificationSectionTitle,
child: SettingsNotificationsSection(
controller: widget.notifications!,
),
),
],
// The server's ntfy choices, beside the in-app permission.
const SizedBox(height: settingsSectionGap),
_SettingsSection(
title: ntfySectionTitle,
child: SettingsNtfySection(
gateway: widget.client,
connected:
widget.client.state.kind ==
transport.ConnectionKind.connected,
),
),
if (widget.onOpenSchedules != null) ...<Widget>[
const SizedBox(height: settingsSectionGap),
_SettingsSection(
title: 'Schedules',
child: SettingsSchedulesSection(
onOpen: widget.onOpenSchedules!,
),
),
],
if (widget.onOpenTemplates != null) ...<Widget>[
const SizedBox(height: settingsSectionGap),
_SettingsSection(
title: 'Templates',
child: SettingsTemplatesSection(
onOpen: widget.onOpenTemplates!,
),
),
],
],
] else
SettingsConnectionSection(
controller: _controller,
serverUrlField: _serverUrlField,
),
// A phone signs in at the web login; a browser has its own.
if (widget.showSignIn)
_single(
'Sign in',
SettingsSignInSection(
endpoint: _endpoint,
onChanged: _reconnectAfterSignIn,
),
),
// The web page links the Android app the server offers.
if (widget.showAndroidDownload)
_single('Android app', const SettingsAndroidDownloadSection()),
// A phone installs newer builds from the server.
if (widget.showSignIn && appUpdatesSupported)
_single('App updates', SettingsUpdatesSection(endpoint: _endpoint)),
SettingsWorkspaceSection(
controller: _controller,
workspaceField: _workspaceField,
),
),
if (widget.notifications case final notifications?)
SettingsNotificationsSection(controller: notifications),
// The server's ntfy choices, beside the in-app permission.
SettingsNtfySection(
gateway: widget.client,
connected:
widget.client.state.kind == transport.ConnectionKind.connected,
),
if (widget.onOpenSchedules != null || widget.onOpenTemplates != null)
SettingsGroup(
title: 'Library',
leadingRows: true,
children: <Widget>[
if (widget.onOpenSchedules case final open?)
SettingsSchedulesSection(onOpen: open),
if (widget.onOpenTemplates case final open?)
SettingsTemplatesSection(onOpen: open),
],
),
],
);
if (widget.embedded) return content;
if (usesCupertinoControls(context)) {
return CupertinoPageScaffold(
backgroundColor: settingsCupertinoBackground,
navigationBar: const SegmentedBar(cupertino: true, title: 'Settings'),
child: content,
);
@@ -285,29 +215,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
body: content,
);
}
}
/// One grouped Settings section: a compact title followed by its body at the
/// web's 8px title gap. Sections are separated by [settingsSectionGap]. A null
/// title lets a body (the notification tile) draw its own compact heading.
class _SettingsSection extends StatelessWidget {
const _SettingsSection({required this.child, this.title});
final String? title;
final Widget child;
@override
Widget build(BuildContext context) {
final title = this.title;
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
if (title != null) ...<Widget>[
Text(title, style: settingsTextStyle(context, title: true)),
const SizedBox(height: settingsTitleGap),
],
child,
],
);
}
/// A group holding one free-form block (a form, a status with buttons).
Widget _single(String title, Widget child) => SettingsGroup(
title: title,
children: <Widget>[SettingsGroupItem(child: child)],
);
}
+127 -158
View File
@@ -3,16 +3,20 @@ import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../core/transport/pipelines_client.dart' as transport;
import 'settings_controller.dart';
import 'settings_controls.dart';
import 'settings_copy.dart';
import 'settings_group.dart';
import 'settings_keys.dart';
import 'settings_trust_warning.dart';
import 'settings_layout.dart';
import 'settings_status_row.dart';
import 'settings_trust_warning.dart';
/// Connection controls: the editable endpoint, the truthful connection card and
/// the trusted-network warning. Every action goes through the shared client the
export 'settings_status_row.dart';
/// Connection controls for a single endpoint: the editable URL with Connect /
/// Disconnect, the connection's status row and the trusted-network warning as
/// the group's footer. Every action goes through the shared client the
/// controller was given; nothing here opens a second connection.
class SettingsConnectionSection extends StatelessWidget {
const SettingsConnectionSection({
@@ -26,133 +30,89 @@ class SettingsConnectionSection extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
final errors = <String>[
if (controller.endpointSaveError.isNotEmpty) controller.endpointSaveError,
if (controller.actionError.isNotEmpty) controller.actionError,
];
return SettingsGroup(
title: 'Connection',
footer: settingsConnectionFooter(controller),
children: <Widget>[
SettingsTextField(
controller: serverUrlField,
key: SettingsKeys.serverUrl,
label: 'Server URL',
placeholder: serverUrlPlaceholder,
helper: serverUrlHelper,
error: controller.urlError,
onChanged: controller.updateServerUrl,
maxLines: 2,
),
const SizedBox(height: settingsTitleGap),
SettingsActions(
primaryLabel: controller.primaryActionLabel,
secondaryLabel: controller.secondaryActionLabel,
primaryKey: controller.connectionActive
? SettingsKeys.disconnect
: SettingsKeys.connect,
secondaryKey: controller.connectionActive
? SettingsKeys.connect
: SettingsKeys.reconnect,
onPrimary: () => unawaited(
controller.connectionActive
? controller.disconnect()
: controller.connect(),
),
onSecondary: () => unawaited(
controller.connectionActive
? controller.connect()
: controller.reconnect(),
SettingsGroupItem(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
SettingsTextField(
controller: serverUrlField,
key: SettingsKeys.serverUrl,
label: 'Server URL',
placeholder: serverUrlPlaceholder,
helper: serverUrlHelper,
error: controller.urlError,
onChanged: controller.updateServerUrl,
maxLines: 2,
),
const SizedBox(height: settingsTitleGap),
SettingsActions(
primaryLabel: controller.primaryActionLabel,
secondaryLabel: controller.secondaryActionLabel,
primaryKey: controller.connectionActive
? SettingsKeys.disconnect
: SettingsKeys.connect,
secondaryKey: controller.connectionActive
? SettingsKeys.connect
: SettingsKeys.reconnect,
onPrimary: () => unawaited(
controller.connectionActive
? controller.disconnect()
: controller.connect(),
),
onSecondary: () => unawaited(
controller.connectionActive
? controller.connect()
: controller.reconnect(),
),
),
for (final error in errors) ...<Widget>[
const SizedBox(height: settingsFieldGap),
Text(error, style: settingsTextStyle(context, error: true)),
],
],
),
),
if (controller.endpointSaveError.isNotEmpty) ...<Widget>[
const SizedBox(height: settingsFieldGap),
Text(
controller.endpointSaveError,
style: settingsTextStyle(context, error: true),
),
],
if (controller.actionError.isNotEmpty) ...<Widget>[
const SizedBox(height: settingsFieldGap),
Text(
controller.actionError,
style: settingsTextStyle(context, error: true),
),
],
const SizedBox(height: settingsTitleGap),
SettingsStatusCard(controller: controller),
const SizedBox(height: settingsTitleGap),
const SettingsTrustWarning(),
if (controller.protocolWarning case final warning?) ...<Widget>[
const SizedBox(height: settingsTitleGap),
// The web page appends the same alert after the trust card. A live
// region announces a mismatch the operator did not ask to reveal.
Semantics(
liveRegion: true,
child: Text(
warning,
style: settingsTextStyle(context, error: true),
),
),
],
SettingsStatusRow(controller: controller),
],
);
}
}
/// The status card's first line is the state; the remaining lines are the
/// build/time/reason/backoff facts. Missing ping values stay explicit.
class SettingsStatusCard extends StatelessWidget {
const SettingsStatusCard({super.key, required this.controller});
final SettingsController controller;
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final state = controller.connection;
final lines = controller.connectionLines;
final title = lines.isEmpty ? '' : lines.first;
final details = lines.length > 1 ? lines.sublist(1) : const <String>[];
final titleColor = switch (state.kind) {
transport.ConnectionKind.connected =>
usesCupertinoControls(context)
? CupertinoTheme.of(context).primaryColor
: theme.colorScheme.primary,
transport.ConnectionKind.disconnected => settingsErrorColor(context),
_ => settingsTextStyle(context).color,
};
final titleWidget = Text(
title,
style: settingsTextStyle(
context,
title: true,
).copyWith(color: titleColor),
);
return SettingsCard(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
if (state.kind == transport.ConnectionKind.connecting)
Row(
children: <Widget>[
if (usesCupertinoControls(context))
const CupertinoActivityIndicator()
else
const CircularProgressIndicator(strokeWidth: 2),
const SizedBox(width: settingsControlGap),
Expanded(child: titleWidget),
],
)
else
titleWidget,
for (final line in details) ...<Widget>[
const SizedBox(height: settingsFieldGap),
Text(line, style: settingsTextStyle(context, secondary: true)),
],
],
/// The Connection group's footer: the trust warning, then a protocol
/// mismatch when the server reports one.
Widget settingsConnectionFooter(SettingsController controller) => Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
const SettingsTrustWarning(),
if (controller.protocolWarning case final warning?)
Builder(
// A live region announces a mismatch the operator did not ask to
// reveal.
builder: (context) => Padding(
padding: const EdgeInsets.only(top: settingsTitleGap),
child: Semantics(
liveRegion: true,
child: Text(
warning,
style: TextStyle(color: settingsErrorColor(context)),
),
),
),
),
);
}
}
],
);
/// Workspace controls. The path is resolved by the execution server, and the
/// helper says so explicitly; an empty saved value is named "(none)".
/// helper says so explicitly; an empty saved value is named "(none)". Save
/// stays a legible tonal (Cupertino: plain) button while it is unavailable.
class SettingsWorkspaceSection extends StatelessWidget {
const SettingsWorkspaceSection({
super.key,
@@ -167,46 +127,55 @@ class SettingsWorkspaceSection extends StatelessWidget {
Widget build(BuildContext context) {
final saveError = controller.workspaceSaveError;
final canSave = canSaveWorkspace(controller.workspaceDraft);
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
final save = canSave ? () => unawaited(controller.saveWorkspace()) : null;
return SettingsGroup(
title: 'Workspace',
children: <Widget>[
SettingsTextField(
controller: workspaceField,
key: SettingsKeys.workspace,
label: 'Workspace path (on the server)',
placeholder: workspacePlaceholder,
helper: workspaceHelper,
error: controller.workspaceError,
onChanged: controller.updateWorkspace,
SettingsGroupItem(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
SettingsTextField(
controller: workspaceField,
key: SettingsKeys.workspace,
label: 'Workspace path (on the server)',
placeholder: workspacePlaceholder,
helper: workspaceHelper,
error: controller.workspaceError,
onChanged: controller.updateWorkspace,
),
const SizedBox(height: settingsTitleGap),
Wrap(
spacing: settingsControlGap,
runSpacing: settingsFieldGap,
crossAxisAlignment: WrapCrossAlignment.center,
children: <Widget>[
if (usesCupertinoControls(context))
CupertinoButton(
key: SettingsKeys.saveWorkspace,
padding: EdgeInsets.zero,
onPressed: save,
child: const Text('Save workspace'),
)
else
FilledButton.tonal(
key: SettingsKeys.saveWorkspace,
onPressed: save,
child: const Text('Save workspace'),
),
Text(
savedWorkspaceLine(controller.savedWorkspace),
style: settingsTextStyle(context, secondary: true),
),
],
),
if (saveError.isNotEmpty) ...<Widget>[
const SizedBox(height: settingsFieldGap),
Text(saveError, style: settingsTextStyle(context, error: true)),
],
],
),
),
const SizedBox(height: settingsTitleGap),
Align(
alignment: AlignmentDirectional.centerStart,
child: usesCupertinoControls(context)
? CupertinoButton.filled(
key: SettingsKeys.saveWorkspace,
onPressed: canSave
? () => unawaited(controller.saveWorkspace())
: null,
child: const Text('Save workspace'),
)
: FilledButton(
key: SettingsKeys.saveWorkspace,
onPressed: canSave
? () => unawaited(controller.saveWorkspace())
: null,
child: const Text('Save workspace'),
),
),
const SizedBox(height: settingsFieldGap),
Text(
savedWorkspaceLine(controller.savedWorkspace),
style: settingsTextStyle(context),
),
if (saveError.isNotEmpty) ...<Widget>[
const SizedBox(height: settingsFieldGap),
Text(saveError, style: settingsTextStyle(context, error: true)),
],
],
);
}
@@ -0,0 +1,66 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../core/transport/pipelines_client.dart' as transport;
import 'settings_controller.dart';
import 'settings_row.dart';
import 'settings_theme.dart';
/// The connection's state as one row: a status icon, the state as the title
/// and the build/time/reason/backoff facts as its subtitle lines. Missing ping
/// values stay explicit.
class SettingsStatusRow extends StatelessWidget {
const SettingsStatusRow({super.key, required this.controller});
final SettingsController controller;
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoControls(context);
final state = controller.connection;
final lines = controller.connectionLines;
final title = lines.isEmpty ? '' : lines.first;
final details = lines.length > 1 ? lines.sublist(1) : const <String>[];
final connectedColor = cupertino
? CupertinoColors.systemGreen.resolveFrom(context)
: Theme.of(context).colorScheme.primary;
final Color? color = switch (state.kind) {
transport.ConnectionKind.connected => connectedColor,
transport.ConnectionKind.disconnected => settingsErrorColor(context),
_ => null,
};
final Widget leading = switch (state.kind) {
transport.ConnectionKind.connecting =>
cupertino
? const CupertinoActivityIndicator()
: const SizedBox.square(
dimension: 20,
child: CircularProgressIndicator(strokeWidth: 2),
),
transport.ConnectionKind.connected => Icon(
cupertino ? CupertinoIcons.checkmark_circle_fill : Icons.check_circle,
color: color,
),
transport.ConnectionKind.disconnected => Icon(
cupertino ? CupertinoIcons.xmark_circle_fill : Icons.error_outline,
color: color,
),
transport.ConnectionKind.idle => Icon(
cupertino ? CupertinoIcons.circle : Icons.radio_button_unchecked,
),
};
return SettingsRow(
leading: leading,
title: Text(
title,
style: TextStyle(color: color, fontWeight: FontWeight.w600),
),
subtitle: details.isEmpty
? null
: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[for (final line in details) Text(line)],
),
);
}
}
@@ -1,52 +1,36 @@
import '../../ui/theme/app_theme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'settings_keys.dart';
import 'settings_row.dart';
import 'settings_theme.dart';
/// The Settings entry to the Templates gallery.
///
/// The row wording matches the current web Settings page: `Browse templates`
/// with the server-catalogue secondary line, under its `Templates` heading. It
/// only opens the route; loading the catalogue is the gallery's own read.
/// The row wording matches the web Settings page: `Browse templates` with the
/// server-catalogue secondary line. It only opens the route; loading the
/// catalogue is the gallery's own read.
const String settingsTemplatesLabel = 'Browse templates';
const String settingsTemplatesSecondary =
'Reusable pipeline definitions offered by the server.';
/// A navigation row (chevron) for a Settings group.
class SettingsTemplatesSection extends StatelessWidget {
const SettingsTemplatesSection({super.key, required this.onOpen});
final VoidCallback onOpen;
@override
Widget build(BuildContext context) {
if (usesCupertinoControls(context)) {
return CupertinoListSection.insetGrouped(
backgroundColor: AppColors.groupedBackground,
margin: EdgeInsets.zero,
children: <Widget>[
CupertinoListTile(
key: SettingsKeys.templates,
title: const Text(settingsTemplatesLabel),
subtitle: const Text(settingsTemplatesSecondary),
trailing: const CupertinoListTileChevron(),
onTap: onOpen,
),
],
);
}
return Card(
margin: EdgeInsets.zero,
clipBehavior: Clip.antiAlias,
child: ListTile(
key: SettingsKeys.templates,
leading: const Icon(Icons.widgets_outlined),
title: const Text(settingsTemplatesLabel),
subtitle: const Text(settingsTemplatesSecondary),
trailing: const Icon(Icons.chevron_right),
onTap: onOpen,
),
);
}
Widget build(BuildContext context) => SettingsRow(
key: SettingsKeys.templates,
leading: Icon(
usesCupertinoControls(context)
? CupertinoIcons.square_grid_2x2
: Icons.widgets_outlined,
),
title: const Text(settingsTemplatesLabel),
subtitle: const Text(settingsTemplatesSecondary),
chevron: true,
onTap: onOpen,
);
}
@@ -1,12 +1,13 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'settings_controls.dart';
import 'settings_copy.dart';
import 'settings_layout.dart';
import 'settings_theme.dart';
/// The trusted-network warning, using the app's exact web/Android copy. It is a
/// card, not a dialog: no confirmation is required to read it.
/// The trusted-network warning, shown as the Connection group's footer: a
/// warning icon, the title in the error colour and the short body. It is not a
/// dialog: no confirmation is required to read it.
class SettingsTrustWarning extends StatelessWidget {
const SettingsTrustWarning({super.key});
@@ -15,30 +16,25 @@ class SettingsTrustWarning extends StatelessWidget {
final icon = usesCupertinoControls(context)
? CupertinoIcons.exclamationmark_triangle
: Icons.warning_amber_rounded;
return SettingsCard(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Icon(icon, color: settingsErrorColor(context)),
const SizedBox(width: settingsControlGap),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
trustTitle,
style: settingsTextStyle(context, title: true, error: true),
),
const SizedBox(height: settingsFieldGap),
Text(
trustBody,
style: settingsTextStyle(context, secondary: true),
),
],
),
final error = settingsErrorColor(context);
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Icon(icon, color: error, semanticLabel: 'Warning'),
const SizedBox(width: settingsControlGap),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
trustTitle,
style: TextStyle(color: error, fontWeight: FontWeight.w600),
),
const Text(trustBody),
],
),
],
),
),
],
);
}
}
+2 -1
View File
@@ -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,
);
}
+116
View File
@@ -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),
);
}
}
+150
View File
@@ -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/server_endpoint.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;
@@ -67,5 +69,15 @@ void main() {
await tester.pump();
await tester.pump();
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(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.pump();
await tester.pump();
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
// same Settings state.
await tester.tap(find.byKey(templateDetailBackKey));
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.pumpAndSettle();
@@ -333,6 +350,8 @@ void main() {
await tester.pump();
await tester.tap(find.byKey(templateDetailBackKey));
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.pumpAndSettle();
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_test/flutter_test.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';
class RecordingGateway implements ApiGateway {
@@ -135,10 +136,15 @@ void main() {
await tester.tap(find.byKey(const ValueKey('search.kind')));
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();
final field = tester.widget<SearchBar>(
final field = tester.widget<TextField>(
find.byKey(const ValueKey('search.field')),
);
expect(field.controller!.text.trim(), 'plan');
@@ -2,7 +2,6 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.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';
class ImmediateGateway implements ApiGateway {
@@ -116,9 +115,10 @@ void main() {
),
);
expect(find.byType(SearchBar), findsOneWidget);
expect(find.byType(DropdownButton<SearchKind>), findsOneWidget);
expect(find.text('All kinds'), findsOneWidget);
expect(find.byType(SearchBar), findsNothing);
expect(find.byType(TextField), findsOneWidget);
expect(find.byKey(const ValueKey('search.kind')), findsOneWidget);
expect(find.byTooltip('Kind: All kinds'), findsOneWidget);
expect(gateway.calls, isEmpty);
await search(tester, 'release');
@@ -8,6 +8,8 @@ import 'package:pipelines_app/core/servers/server_catalog_store.dart';
import 'package:pipelines_app/features/settings/saved_servers_section.dart';
import 'package:pipelines_app/features/settings/server_connections.dart';
import 'saved_server_menu.dart';
class _ControlledStore extends MemoryServerCatalogStore {
_ControlledStore({super.catalog});
@@ -38,6 +40,7 @@ Future<void> _openEditor(
)
: MaterialApp(home: Scaffold(body: body)),
);
if (edit) await openSavedServerMenu(tester);
await tester.tap(find.text(edit ? 'Edit Home' : 'Add server'));
await tester.pumpAndSettle();
await tester.enterText(
@@ -0,0 +1,15 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
/// Opens the only saved server's actions menu (Use, Edit, Remove).
Future<void> openSavedServerMenu(WidgetTester tester) async {
await tester.tap(
find.byWidgetPredicate((widget) {
final key = widget.key;
return key is ValueKey<String> &&
key.value.startsWith('settings.server.') &&
key.value.endsWith('.menu');
}),
);
await tester.pumpAndSettle();
}
@@ -6,6 +6,8 @@ import 'package:pipelines_app/core/servers/server_catalog_store.dart';
import 'package:pipelines_app/features/settings/saved_servers_section.dart';
import 'package:pipelines_app/features/settings/server_connections.dart';
import 'saved_server_menu.dart';
SavedServer profile(String id, List<String> urls) =>
SavedServer.validated(id: id, name: id, endpoints: urls);
@@ -140,6 +142,7 @@ void main() {
find.text('Backup 1: ws://192.168.1.2:8083/connect'),
findsOneWidget,
);
await openSavedServerMenu(tester);
await tester.tap(find.text('Edit Home'));
await tester.pumpAndSettle();
await tester.enterText(
@@ -1,48 +1,110 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/core/servers/server_catalog.dart';
import 'package:pipelines_app/core/servers/server_catalog_store.dart';
import 'package:pipelines_app/core/transport/pipelines_client.dart'
as transport;
import 'package:pipelines_app/features/attention/notify/notification_controller.dart';
import 'package:pipelines_app/features/attention/notify/notification_store.dart';
import 'package:pipelines_app/features/settings/saved_server_row.dart';
import 'package:pipelines_app/features/settings/saved_servers_section.dart';
import 'package:pipelines_app/features/settings/server_connections.dart';
import 'package:pipelines_app/features/settings/settings_group.dart';
import 'package:pipelines_app/features/settings/settings_layout.dart';
import 'package:pipelines_app/features/settings/settings_screen.dart';
import 'package:pipelines_app/features/settings/settings_store.dart';
import 'package:pipelines_app/features/settings/settings_trust_warning.dart';
import 'package:pipelines_app/ui/theme/app_theme.dart';
import 'fake_channel.dart';
void main() {
testWidgets('sections use one centred column and the web rhythm', (
testWidgets('groups start at the bar inset and stop at the reading width', (
tester,
) async {
await _pump(tester, size: const Size(1200, 1600));
final groups = find.byType(SettingsGroup);
expect(groups, findsWidgets);
for (final group in groups.evaluate()) {
final rect = tester.getRect(find.byWidget(group.widget));
// The column starts where the bar's title pill does, not centred.
expect(rect.left, closeTo(settingsPageSidePadding, 0.01));
expect(rect.width, closeTo(settingsContentMaxWidth, 0.01));
}
// A header's text lines up with its rows' text.
final header = tester.getRect(find.text('Connection'));
expect(
header.left,
closeTo(settingsPageSidePadding + settingsRowInset, 0.01),
);
});
testWidgets('Material groups are flat surfaces, not elevated cards', (
tester,
) async {
await _pump(tester);
final connection = tester.getRect(find.text('Connection'));
final serverUrlLabel = tester.getRect(find.text('Server URL'));
final warning = tester.getRect(find.byType(SettingsTrustWarning));
final workspace = tester.getRect(find.text('Workspace'));
// One column: the 720px reading width is centred in an 800px window.
expect(connection.left, closeTo(40, 0.01));
expect(connection.right, closeTo(760, 0.01));
// The compact title sits 8px above its grouped body, and sections are 16px
// apart, as on the web Settings page.
expect(
serverUrlLabel.top - connection.bottom,
closeTo(settingsTitleGap, 0.01),
expect(find.byType(Card), findsNothing);
final surfaces = tester.widgetList<Material>(
find.descendant(
of: find.byType(SettingsGroup),
matching: find.byType(Material),
),
);
expect(workspace.top - warning.bottom, closeTo(settingsSectionGap, 0.01));
final scheme = Theme.of(
tester.element(find.byType(SettingsGroup).first),
).colorScheme;
final groupSurfaces = surfaces.where(
(material) => material.color == scheme.surfaceContainer,
);
expect(groupSurfaces, isNotEmpty);
for (final material in groupSurfaces) {
expect(material.elevation, 0);
}
// The trust warning is the Connection group's footer, not a card.
expect(find.byType(SettingsTrustWarning), findsOneWidget);
final title = tester.widget<Text>(find.text('Connection'));
final theme = Theme.of(tester.element(find.text('Connection')));
expect(title.style?.color, theme.colorScheme.primary);
});
// The field label is a compact secondary line, not a second title.
final label = tester.widget<Text>(find.text('Server URL'));
final theme = Theme.of(tester.element(find.text('Server URL')));
expect(label.style?.color, theme.colorScheme.onSurfaceVariant);
expect(label.style?.fontSize, theme.textTheme.labelMedium?.fontSize);
testWidgets('content starts below the bar and scrolls behind it', (
tester,
) async {
const barHeight = 72.0;
await _pump(tester, topPadding: barHeight);
final first = tester.getRect(find.byType(SettingsGroup).first);
expect(first.top, closeTo(barHeight + settingsPageTopPadding, 0.01));
// No top SafeArea: the scroll view itself reaches the top edge.
expect(
label.style?.fontSize,
lessThan(theme.textTheme.titleMedium!.fontSize!),
tester.getRect(find.byKey(const ValueKey('settings.scroll'))).top,
0,
);
});
testWidgets('Cupertino uses inset-grouped sections on the grouped page', (
tester,
) async {
await _pump(tester, platform: TargetPlatform.iOS);
expect(find.byType(Card), findsNothing);
expect(find.byType(CupertinoListSection), findsWidgets);
for (final section in tester.widgetList<CupertinoListSection>(
find.byType(CupertinoListSection),
)) {
expect(section.type, CupertinoListSectionType.insetGrouped);
}
final context = tester.element(find.byType(SettingsGroup).first);
expect(
find.byWidgetPredicate(
(widget) =>
widget is ColoredBox &&
widget.color == AppColors.groupedBackground.resolveFrom(context),
),
findsWidgets,
);
});
@@ -72,14 +134,69 @@ void main() {
);
expect(find.byType(CupertinoTextField), findsNWidgets(2));
});
for (final cupertino in [false, true]) {
testWidgets('server rows show which server is selected ($cupertino)', (
tester,
) async {
final connections = ServerConnections(
store: MemoryServerCatalogStore(
catalog: ServerCatalog(
servers: [
SavedServer.validated(
id: 'Home',
name: 'Home',
endpoints: const ['wss://home.test/connect'],
),
SavedServer.validated(
id: 'Work',
name: 'Work',
endpoints: const ['wss://work.test/connect'],
),
],
selectedId: 'Home',
),
),
onSelected: (_) async {},
);
addTearDown(connections.dispose);
await connections.load();
final body = SingleChildScrollView(
child: SavedServersSection(connections: connections),
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: body))
: MaterialApp(home: Scaffold(body: body)),
);
expect(find.byType(SavedServerRow), findsNWidgets(2));
expect(find.text('Selected server'), findsOneWidget);
expect(
find.byWidgetPredicate(
(widget) => widget is Icon && widget.semanticLabel == 'Selected',
),
findsOneWidget,
);
expect(find.text('Preferred: wss://work.test/connect'), findsOneWidget);
expect(find.byKey(savedServerMenuKey('Home')), findsOneWidget);
expect(find.text('Add server'), findsOneWidget);
// Tapping another server's row uses it.
await tester.tap(find.text('Work'));
await tester.pumpAndSettle();
expect(connections.catalog.active?.id, 'Work');
});
}
}
Future<void> _pump(
WidgetTester tester, {
TargetPlatform platform = TargetPlatform.android,
NotificationController? notifications,
Size size = const Size(800, 1600),
double topPadding = 0,
}) async {
await tester.binding.setSurfaceSize(const Size(800, 1600));
await tester.binding.setSurfaceSize(size);
addTearDown(() => tester.binding.setSurfaceSize(null));
final factory = FakeChannelFactory();
final client = transport.PipelinesClient(channelFactory: factory.call);
@@ -87,10 +204,19 @@ Future<void> _pump(
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(platform: platform),
home: SettingsScreen(
client: client,
store: MemorySettingsStore(),
notifications: notifications,
builder: (context, child) => MediaQuery(
data: MediaQuery.of(
context,
).copyWith(padding: EdgeInsets.only(top: topPadding)),
child: child!,
),
home: Scaffold(
body: SettingsScreen(
client: client,
store: MemorySettingsStore(),
notifications: notifications,
embedded: true,
),
),
),
);
@@ -48,10 +48,10 @@ bool _checked(WidgetTester tester, String key, {required bool cupertino}) {
final tile = find.byKey(ntfySettingKey(key));
if (cupertino) {
return tester
.widget<CupertinoCheckbox>(
find.descendant(of: tile, matching: find.byType(CupertinoCheckbox)),
.widget<CupertinoSwitch>(
find.descendant(of: tile, matching: find.byType(CupertinoSwitch)),
)
.value!;
.value;
}
return tester.widget<CheckboxListTile>(tile).value!;
}
@@ -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);
});
}
}