Merge main into pipelines/run-20261111-0456-cupertino-out-runs-ui-part-1-2ad5

This commit is contained in:
2026-11-11 05:13:28 +00:00
56 changed files with 1177 additions and 2822 deletions
+1 -20
View File
@@ -13,7 +13,6 @@ import 'pipeline_repository.dart';
import 'pipelines_controller.dart';
import 'pending_run_store.dart';
import 'widgets/pipeline_bar_buttons.dart';
import 'widgets/pipeline_controls.dart';
import 'widgets/pipeline_detail_panel.dart';
import 'widgets/pipeline_list_panel.dart';
@@ -273,9 +272,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
},
);
if (widget.embedded) return _embeddedBody(context, body);
return useCupertinoControls(context)
? _cupertinoShell(context, body)
: _materialShell(context, body);
return _materialShell(context, body);
},
);
}
@@ -352,20 +349,4 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
body: SafeArea(top: false, child: body),
);
}
Widget _cupertinoShell(BuildContext context, Widget body) {
return CupertinoPageScaffold(
navigationBar: SegmentedBar(
cupertino: true,
title: 'Pipelines',
actions: [
...pipelineListActions(context, _controller),
if (widget.onOpenSchedules != null) _schedulesButton(context),
_refreshButton(context),
if (widget.onOpenSettings != null) _settingsButton(context),
],
),
child: SafeArea(top: false, child: body),
);
}
}
@@ -8,7 +8,6 @@ import '../pipeline_models.dart';
import '../pipelines_controller.dart';
import '../run_pipeline_intent.dart';
import '../widgets/pipeline_bar_buttons.dart';
import '../widgets/pipeline_controls.dart';
import 'run_pipeline_dialog.dart';
import 'run_pipeline_wording.dart';
@@ -181,13 +180,6 @@ class _RunPipelineActionState extends State<RunPipelineAction> {
onPressed: _open,
);
}
if (useCupertinoControls(context)) {
return CupertinoButton.filled(
key: runPipelineActionKey,
onPressed: _open,
child: label,
);
}
return FilledButton(
key: runPipelineActionKey,
onPressed: _open,
@@ -1,13 +1,11 @@
import '../../schedules/data/schedules_repository.dart';
import '../../schedules/domain/editor/schedule_draft.dart';
import '../../schedules/ui/pipeline/schedule_pipeline_editor.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../core/servers/server_scope.dart';
import '../../../core/api_gateway.dart';
import '../../settings/settings_store.dart';
import '../../../ui/adaptive/host.dart';
import '../pipeline_models.dart';
import '../run_pipeline_intent.dart';
import 'run_pipeline_fields.dart';
@@ -45,23 +43,16 @@ Future<void> showRunPipelineDialog({
detail: detail,
gateway: gateway,
pending: pending,
cupertino: usesCupertinoHost(context),
onSubmit: onSubmit,
onPendingChanged: onPendingChanged,
onAccepted: onAccepted,
onSchedule: schedule,
);
return dialog.cupertino
? showCupertinoDialog<void>(
context: context,
barrierDismissible: false,
builder: (_) => dialog,
)
: showDialog<void>(
context: context,
barrierDismissible: false,
builder: (_) => dialog,
);
return showDialog<void>(
context: context,
barrierDismissible: false,
builder: (_) => dialog,
);
}
class _RunPipelineDialog extends StatefulWidget {
@@ -69,7 +60,6 @@ class _RunPipelineDialog extends StatefulWidget {
required this.detail,
required this.gateway,
required this.pending,
required this.cupertino,
required this.onSubmit,
required this.onPendingChanged,
required this.onAccepted,
@@ -81,7 +71,6 @@ class _RunPipelineDialog extends StatefulWidget {
final PipelineDetail detail;
final ApiGateway gateway;
final RunPipelineIntent? pending;
final bool cupertino;
final Future<RunPipelineOutcome> Function(RunPipelineIntent intent) onSubmit;
final ValueChanged<RunPipelineIntent?> onPendingChanged;
final ValueChanged<JsonMap> onAccepted;
@@ -219,8 +208,7 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> {
@override
Widget build(BuildContext context) {
final dialog = widget.cupertino ? _cupertino(context) : _material(context);
return PopScope(canPop: !_sending, child: dialog);
return PopScope(canPop: !_sending, child: _material(context));
}
Widget _material(BuildContext context) {
@@ -248,31 +236,6 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> {
);
}
Widget _cupertino(BuildContext context) {
return CupertinoAlertDialog(
title: Text(runPipelineDialogTitle(widget.detail.name)),
content: _content(context),
actions: [
CupertinoDialogAction(
key: runPipelineCancelKey,
onPressed: _sending ? null : _cancel,
child: const Text(runPipelineCancelLabel),
),
CupertinoDialogAction(
key: const Key('run-pipeline-schedule'),
onPressed: _sending ? null : _schedule,
child: const Text('Schedule…'),
),
CupertinoDialogAction(
key: runPipelineConfirmKey,
isDefaultAction: true,
onPressed: _sending ? null : _confirm,
child: Text(_confirmLabel),
),
],
);
}
/// Leaves the dialog for the schedule editor with the typed prompt,
/// workspace and the pinned version.
void _schedule() {
@@ -294,9 +257,7 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> {
}
Widget _content(BuildContext context) {
final errorStyle = widget.cupertino
? TextStyle(color: CupertinoColors.systemRed.resolveFrom(context))
: TextStyle(color: Theme.of(context).colorScheme.error);
final errorStyle = TextStyle(color: Theme.of(context).colorScheme.error);
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -305,7 +266,7 @@ class _RunPipelineDialogState extends State<_RunPipelineDialog> {
prompt: _prompt,
workspace: _workspace,
directories: _directories,
cupertino: widget.cupertino,
cupertino: false,
onChooseDirectory: _chooseDirectory,
notifyMode: _notify,
outputFormat: _outputFormat,
@@ -1,11 +1,9 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/host.dart';
import '../run_pipeline_intent.dart';
import 'run_pipeline_wording.dart';
/// The dialog's three web fields, in the host's native controls.
/// The dialog's three web fields in standard Material controls.
///
/// A confirmed launch locks every field: the request is immutable until its
/// admission is known, exactly like the browser's disabled inputs.
@@ -27,7 +25,10 @@ class RunPipelineFields extends StatelessWidget {
final TextEditingController prompt;
final TextEditingController workspace;
final List<String> directories;
/// Retained for callers; the fields are Material on every host.
final bool cupertino;
final ValueChanged<String> onChooseDirectory;
final RunNotifyMode notifyMode;
final RunOutputFormat outputFormat;
@@ -37,44 +38,28 @@ class RunPipelineFields extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_FieldLabel(runPipelinePromptLabel, cupertino: cupertino),
_promptField(context, cupertino),
const _FieldLabel(runPipelinePromptLabel),
_promptField(),
const SizedBox(height: 12),
_FieldLabel(runPipelineWorkspaceLabel, cupertino: cupertino),
_workspaceField(context, cupertino),
_helper(context, runPipelineWorkspaceHelper, cupertino),
const _FieldLabel(runPipelineWorkspaceLabel),
_workspaceField(),
_helper(context, runPipelineWorkspaceHelper),
const SizedBox(height: 12),
_FieldLabel(runPipelineNotifyLabel, cupertino: cupertino),
_notifyField(context, cupertino),
const _FieldLabel(runPipelineNotifyLabel),
_notifyField(),
const SizedBox(height: 12),
_FieldLabel(runPipelineOutputFormatLabel, cupertino: cupertino),
_outputFormatField(context, cupertino),
_helper(context, runPipelineOutputFormatHelper, cupertino),
const _FieldLabel(runPipelineOutputFormatLabel),
_outputFormatField(),
_helper(context, runPipelineOutputFormatHelper),
],
);
}
Widget _promptField(BuildContext context, bool cupertino) {
if (cupertino) {
return CupertinoTextField(
key: runPipelinePromptKey,
controller: prompt,
placeholder: runPipelinePromptPlaceholder,
placeholderStyle: _cupertinoPlaceholder(context),
style: CupertinoTheme.of(context).textTheme.textStyle,
minLines: 3,
maxLines: 5,
enabled: !locked,
autofocus: !locked,
padding: const EdgeInsets.all(8),
textCapitalization: TextCapitalization.sentences,
);
}
Widget _promptField() {
return TextField(
key: runPipelinePromptKey,
controller: prompt,
@@ -90,51 +75,26 @@ class RunPipelineFields extends StatelessWidget {
);
}
Widget _workspaceField(BuildContext context, bool cupertino) {
final field = cupertino
? _cupertinoWorkspace(context)
: _materialWorkspace();
Widget _workspaceField() {
return Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(child: field),
Expanded(child: _materialWorkspace()),
if (directories.isNotEmpty)
cupertino
? CupertinoButton(
key: runPipelineWorkspaceSuggestionsKey,
padding: EdgeInsets.zero,
onPressed: locked
? null
: () => _chooseCupertinoDirectory(context),
child: const Icon(CupertinoIcons.folder),
)
: PopupMenuButton<String>(
key: runPipelineWorkspaceSuggestionsKey,
tooltip: runPipelineWorkspaceLabel,
enabled: !locked,
onSelected: onChooseDirectory,
itemBuilder: (_) => [
for (final path in directories)
PopupMenuItem(value: path, child: Text(path)),
],
),
PopupMenuButton<String>(
key: runPipelineWorkspaceSuggestionsKey,
tooltip: runPipelineWorkspaceLabel,
enabled: !locked,
onSelected: onChooseDirectory,
itemBuilder: (_) => [
for (final path in directories)
PopupMenuItem(value: path, child: Text(path)),
],
),
],
);
}
Widget _cupertinoWorkspace(BuildContext context) {
return CupertinoTextField(
key: runPipelineWorkspaceKey,
controller: workspace,
placeholder: runPipelineWorkspacePlaceholder,
placeholderStyle: _cupertinoPlaceholder(context),
style: CupertinoTheme.of(context).textTheme.textStyle,
enabled: !locked,
autocorrect: false,
padding: const EdgeInsets.all(8),
);
}
Widget _materialWorkspace() {
return TextField(
key: runPipelineWorkspaceKey,
@@ -148,44 +108,7 @@ class RunPipelineFields extends StatelessWidget {
);
}
Future<void> _chooseCupertinoDirectory(BuildContext context) async {
final chosen = await showCupertinoModalPopup<String>(
context: context,
builder: (sheetContext) => CupertinoActionSheet(
title: const Text(runPipelineWorkspaceLabel),
actions: [
for (final path in directories)
CupertinoActionSheetAction(
onPressed: () => Navigator.of(sheetContext).pop(path),
child: Text(path),
),
],
cancelButton: CupertinoActionSheetAction(
onPressed: () => Navigator.of(sheetContext).pop(),
child: const Text(runPipelineCancelLabel),
),
),
);
if (chosen != null) onChooseDirectory(chosen);
}
Widget _notifyField(BuildContext context, bool cupertino) {
if (cupertino) {
return CupertinoButton(
key: runPipelineNotifyKey,
padding: EdgeInsets.zero,
alignment: AlignmentDirectional.centerStart,
onPressed: locked ? null : () => _chooseNotify(context),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(child: Text(notifyMode.label)),
const SizedBox(width: 4),
const Icon(CupertinoIcons.chevron_down, size: 14),
],
),
);
}
Widget _notifyField() {
return DropdownButtonFormField<RunNotifyMode>(
key: runPipelineNotifyKey,
initialValue: notifyMode,
@@ -202,45 +125,7 @@ class RunPipelineFields extends StatelessWidget {
);
}
Future<void> _chooseNotify(BuildContext context) async {
final chosen = await showCupertinoModalPopup<RunNotifyMode>(
context: context,
builder: (sheetContext) => CupertinoActionSheet(
title: const Text(runPipelineNotifyLabel),
actions: [
for (final mode in RunNotifyMode.values)
CupertinoActionSheetAction(
onPressed: () => Navigator.of(sheetContext).pop(mode),
child: Text(mode.label),
),
],
cancelButton: CupertinoActionSheetAction(
isDefaultAction: true,
onPressed: () => Navigator.of(sheetContext).pop(),
child: const Text(runPipelineCancelLabel),
),
),
);
if (chosen != null) onNotifyChanged(chosen);
}
Widget _outputFormatField(BuildContext context, bool cupertino) {
if (cupertino) {
return CupertinoButton(
key: runPipelineOutputFormatKey,
padding: EdgeInsets.zero,
alignment: AlignmentDirectional.centerStart,
onPressed: locked ? null : () => _chooseOutputFormat(context),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Flexible(child: Text(outputFormat.label)),
const SizedBox(width: 4),
const Icon(CupertinoIcons.chevron_down, size: 14),
],
),
);
}
Widget _outputFormatField() {
return DropdownButtonFormField<RunOutputFormat>(
key: runPipelineOutputFormatKey,
initialValue: outputFormat,
@@ -257,75 +142,34 @@ class RunPipelineFields extends StatelessWidget {
);
}
Future<void> _chooseOutputFormat(BuildContext context) async {
final chosen = await showCupertinoModalPopup<RunOutputFormat>(
context: context,
builder: (sheetContext) => CupertinoActionSheet(
title: const Text(runPipelineOutputFormatLabel),
actions: [
for (final format in RunOutputFormat.values)
CupertinoActionSheetAction(
onPressed: () => Navigator.of(sheetContext).pop(format),
child: Text(format.label),
),
],
cancelButton: CupertinoActionSheetAction(
isDefaultAction: true,
onPressed: () => Navigator.of(sheetContext).pop(),
child: const Text(runPipelineCancelLabel),
),
),
);
if (chosen != null) onOutputFormatChanged(chosen);
}
TextStyle _cupertinoPlaceholder(BuildContext context) {
// The host's own dynamic placeholder colour (light and dark), resolved for
// the dialog's inherited Cupertino brightness.
return TextStyle(
color: CupertinoColors.placeholderText.resolveFrom(context),
);
}
Widget _helper(BuildContext context, String text, bool cupertino) {
Widget _helper(BuildContext context, String text) {
return Padding(
padding: const EdgeInsets.only(top: 4),
child: Text(text, style: _secondaryStyle(context, cupertino)),
child: Text(text, style: _secondaryStyle(context)),
);
}
}
/// Secondary copy under a field: the host's own secondary role, never a
/// borrowed palette or invented point size.
TextStyle _secondaryStyle(BuildContext context, bool cupertino) {
if (cupertino) {
return CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
color: CupertinoColors.secondaryLabel.resolveFrom(context),
);
}
/// Secondary copy under a field: the theme's secondary role, never a borrowed
/// palette or invented point size.
TextStyle? _secondaryStyle(BuildContext context) {
final theme = Theme.of(context);
return (theme.textTheme.bodySmall ?? const TextStyle()).copyWith(
color: theme.colorScheme.onSurfaceVariant,
);
}
/// The label above each native field, using the web's exact words.
/// The label above each field, using the web's exact words.
class _FieldLabel extends StatelessWidget {
const _FieldLabel(this.text, {required this.cupertino});
const _FieldLabel(this.text);
final String text;
final bool cupertino;
@override
Widget build(BuildContext context) {
// A theme label role with the primary label colour, matching the app's
// Cupertino form pattern; secondaryLabel is for helper copy only.
final style = cupertino
? CupertinoTheme.of(context).textTheme.textStyle
: Theme.of(context).textTheme.labelLarge;
return Padding(
padding: const EdgeInsets.only(bottom: 4),
child: Text(text, style: style),
child: Text(text, style: Theme.of(context).textTheme.labelLarge),
);
}
}
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/segmented_bar_overflow.dart';
@@ -28,9 +27,7 @@ Widget pipelineActionsMenu(
return SegmentedOverflowAction(
overflowEntry: SegmentedOverflowEntry(
label: archived ? 'Unarchive pipeline' : 'Archive pipeline…',
icon: useCupertinoControls(context)
? CupertinoIcons.archivebox
: Icons.archive_outlined,
icon: Icons.archive_outlined,
onPressed: () => run(context),
),
child: AppOverflowMenu<bool>(
@@ -104,64 +101,28 @@ class PipelineArchivedNotice extends StatelessWidget {
Future<bool> _confirmArchive(BuildContext context, String name) async {
final title = Text('Archive $name?');
final body = Text(archiveConfirmation(name));
final confirmed = useCupertinoControls(context)
? await showCupertinoDialog<bool>(
context: context,
builder: (context) => CupertinoAlertDialog(
title: title,
content: body,
actions: [
CupertinoDialogAction(
onPressed: () => Navigator.pop(context, false),
child: const Text('Cancel'),
),
CupertinoDialogAction(
key: const Key('pipeline-archive-confirm'),
isDefaultAction: true,
onPressed: () => Navigator.pop(context, true),
child: const Text('Archive'),
),
],
),
)
: await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
title: title,
content: body,
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('Cancel'),
),
FilledButton(
key: const Key('pipeline-archive-confirm'),
onPressed: () => Navigator.pop(context, true),
child: const Text('Archive'),
),
],
),
);
final confirmed = await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
title: title,
content: body,
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('Cancel'),
),
FilledButton(
key: const Key('pipeline-archive-confirm'),
onPressed: () => Navigator.pop(context, true),
child: const Text('Archive'),
),
],
),
);
return confirmed == true;
}
Future<void> _showRefusal(BuildContext context, String title, String message) {
if (useCupertinoControls(context)) {
return showCupertinoDialog<void>(
context: context,
builder: (context) => CupertinoAlertDialog(
title: Text(title),
content: Text(message),
actions: [
CupertinoDialogAction(
isDefaultAction: true,
onPressed: () => Navigator.pop(context),
child: const Text('OK'),
),
],
),
);
}
return showDialog<void>(
context: context,
builder: (context) => AlertDialog(
@@ -2,11 +2,12 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/segmented_bar_overflow.dart';
import 'pipeline_controls.dart';
/// One icon action in the Pipelines bar's actions pill: a Material
/// [IconButton] with its tooltip, or a Cupertino button named for
/// accessibility. A narrow bar moves it into its More menu.
/// [IconButton] with its tooltip. A narrow bar moves it into its More menu.
///
/// [cupertinoIcon] is retained in the signature for callers that still pass
/// it; the Material icon is drawn.
Widget pipelineBarIconButton(
BuildContext context, {
required Key key,
@@ -15,33 +16,23 @@ Widget pipelineBarIconButton(
required IconData cupertinoIcon,
required VoidCallback? onPressed,
}) {
final Widget button;
final cupertino = useCupertinoControls(context);
if (cupertino) {
button = CupertinoButton(
key: key,
padding: EdgeInsets.zero,
onPressed: onPressed,
child: Icon(cupertinoIcon),
);
} else {
button = IconButton(
key: key,
tooltip: label,
onPressed: onPressed,
icon: Icon(icon),
);
}
return SegmentedOverflowAction(
overflowEntry: SegmentedOverflowEntry(
label: label,
icon: cupertino ? cupertinoIcon : icon,
icon: icon,
onPressed: onPressed,
),
child: Semantics(
button: true,
label: label,
child: ExcludeSemantics(child: button),
child: ExcludeSemantics(
child: IconButton(
key: key,
tooltip: label,
onPressed: onPressed,
icon: Icon(icon),
),
),
),
);
}
@@ -1,17 +1,11 @@
import '../../../ui/adaptive/app_menu_anchor.dart';
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';
/// The one control-family decision for this feature: Cupertino only under an
/// explicit Cupertino host, Material on every platform otherwise.
bool useCupertinoControls(BuildContext context) => usesCupertinoHost(context);
/// Standard platform activity indicator with an accessible status label.
/// Standard Material activity indicator with an accessible status label.
class PipelineProgress extends StatelessWidget {
const PipelineProgress({super.key, this.label = 'Loading'});
@@ -22,14 +16,12 @@ class PipelineProgress extends StatelessWidget {
return Semantics(
label: label,
liveRegion: true,
child: useCupertinoControls(context)
? const CupertinoActivityIndicator()
: const CircularProgressIndicator(),
child: const CircularProgressIndicator(),
);
}
}
/// A standard text action in the current platform's style.
/// A standard Material text action.
class PipelineTextButton extends StatelessWidget {
const PipelineTextButton({
super.key,
@@ -42,18 +34,11 @@ class PipelineTextButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (useCupertinoControls(context)) {
return CupertinoButton(
padding: EdgeInsets.zero,
onPressed: onPressed,
child: Text(label),
);
}
return TextButton(onPressed: onPressed, child: Text(label));
}
}
/// Native back affordance used by the narrow list/detail layout.
/// Back affordance used by the narrow list/detail layout.
class PipelineBackButton extends StatelessWidget {
const PipelineBackButton({super.key, required this.onPressed});
@@ -62,19 +47,18 @@ class PipelineBackButton extends StatelessWidget {
/// The same round Back as every page's segmented bar.
@override
Widget build(BuildContext context) {
final cupertino = useCupertinoControls(context);
return Semantics(
label: 'Back to pipelines',
child: SegmentedPill(
cupertino: cupertino,
child: SegmentedBackButton(cupertino: cupertino, onPressed: onPressed),
cupertino: false,
child: SegmentedBackButton(cupertino: false, onPressed: onPressed),
),
);
}
}
/// The list's sort control: a Material menu on Android/desktop, an action
/// sheet on iOS. The label is the current choice, exactly as on web.
/// The list's sort control: a Material menu. The label is the current choice,
/// exactly as on web.
class PipelineSortButton extends StatelessWidget {
const PipelineSortButton({
super.key,
@@ -92,23 +76,6 @@ class PipelineSortButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
final label = 'Sort: ${sort.label}';
if (useCupertinoControls(context)) {
return Semantics(
button: true,
label: icon ? 'Sort pipelines: ${sort.label}' : null,
excludeSemantics: icon,
child: CupertinoButton(
padding: EdgeInsets.zero,
minimumSize: icon
? const Size.square(kMinInteractiveDimensionCupertino)
: null,
onPressed: () => _showCupertinoSheet(context),
child: icon
? const Icon(CupertinoIcons.arrow_up_arrow_down)
: Text(label),
),
);
}
return AppMenuAnchor(
menuChildren: [
for (final option in PipelineSort.values)
@@ -129,30 +96,6 @@ class PipelineSortButton extends StatelessWidget {
),
);
}
Future<void> _showCupertinoSheet(BuildContext context) {
return showCupertinoModalPopup<void>(
context: context,
builder: (sheetContext) => CupertinoActionSheet(
title: const Text('Sort pipelines'),
actions: [
for (final option in PipelineSort.values)
CupertinoActionSheetAction(
onPressed: () {
Navigator.of(sheetContext).pop();
onSelected(option);
},
child: Text(option.label),
),
],
cancelButton: CupertinoActionSheetAction(
isDefaultAction: true,
onPressed: () => Navigator.of(sheetContext).pop(),
child: const Text('Cancel'),
),
),
);
}
}
/// A truthful, non-blocking error line with an optional retry action.
@@ -170,10 +113,7 @@ class PipelineErrorBanner extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cupertino = useCupertinoControls(context);
final color = cupertino
? CupertinoColors.systemRed.resolveFrom(context)
: Theme.of(context).colorScheme.error;
final color = Theme.of(context).colorScheme.error;
return Semantics(
liveRegion: true,
child: Padding(
@@ -1,8 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/host.dart';
import '../../../ui/layout/warnings_section.dart';
// The gateway bounds this cache to one server connection. Retain at most sixteen
@@ -100,15 +98,10 @@ class _PipelineDefinitionValidationState
if (snapshot.hasError || !validReply)
Align(
alignment: AlignmentDirectional.centerStart,
child: usesCupertinoHost(context)
? CupertinoButton(
onPressed: () => setState(() => _load(retry: true)),
child: const Text('Retry validation'),
)
: TextButton(
onPressed: () => setState(() => _load(retry: true)),
child: const Text('Retry validation'),
),
child: TextButton(
onPressed: () => setState(() => _load(retry: true)),
child: const Text('Retry validation'),
),
),
],
);
@@ -1,35 +1,19 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'pipeline_controls.dart';
TextStyle? pipelineTitleStyle(BuildContext context) =>
useCupertinoControls(context)
? CupertinoTheme.of(context).textTheme.navLargeTitleTextStyle
: Theme.of(context).textTheme.headlineSmall;
Theme.of(context).textTheme.headlineSmall;
TextStyle? pipelineSectionStyle(BuildContext context) =>
useCupertinoControls(context)
? CupertinoTheme.of(context).textTheme.navTitleTextStyle
: Theme.of(context).textTheme.titleMedium;
Theme.of(context).textTheme.titleMedium;
TextStyle? pipelineValueStyle(BuildContext context, {bool monospace = false}) {
final base = useCupertinoControls(context)
// SelectableText requires an explicit baseline when it inherits no style;
// merge the Cupertino system style with the ambient text style.
? CupertinoTheme.of(context).textTheme.textStyle.copyWith(inherit: true)
: Theme.of(context).textTheme.bodyMedium;
final base = Theme.of(context).textTheme.bodyMedium;
// Metadata can identify code-like values, but the user requested native
// typography even for source/hash surfaces; do not replace the host font.
return base;
}
TextStyle? pipelineMutedStyle(BuildContext context) {
if (useCupertinoControls(context)) {
return CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
color: CupertinoColors.secondaryLabel.resolveFrom(context),
);
}
final theme = Theme.of(context);
return theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
@@ -14,5 +14,7 @@ enum PipelineDetailTab {
/// The tab's glyph, the only thing the bottom bar draws (the label is its
/// accessible name); distinct from the shell's Pipelines tab beneath it.
final IconData icon;
/// Retained for callers; the Material [icon] is drawn.
final IconData cupertinoIcon;
}
@@ -1,129 +0,0 @@
import '../../../ui/theme/app_theme.dart';
import 'package:flutter/cupertino.dart';
import '../pipeline_filter.dart';
/// Cupertino filter form using native grouped lists and checkboxes.
class PipelineFilterCupertinoBody extends StatelessWidget {
const PipelineFilterCupertinoBody({
super.key,
required this.filters,
required this.name,
required this.hasUnclassified,
required this.onChanged,
required this.onClear,
});
final PipelineFilters filters;
final TextEditingController name;
final bool hasUnclassified;
final ValueChanged<PipelineFilters> onChanged;
final VoidCallback onClear;
@override
Widget build(BuildContext context) {
return ListView(
children: [
Padding(
padding: const EdgeInsets.all(16),
child: CupertinoTextField(
controller: name,
placeholder: 'Pipeline name contains',
),
),
CupertinoListSection.insetGrouped(
backgroundColor: AppColors.groupedBackground,
header: const Text('RUNS'),
children: [
for (final presence in RunPresence.values)
_choice(
label: presence.label,
selected: filters.presence == presence,
onTap: () => onChanged(filters.copyWith(presence: presence)),
),
],
),
CupertinoListSection.insetGrouped(
backgroundColor: AppColors.groupedBackground,
header: const Text('LAST RUN STATUS'),
children: [
for (final status in runStatusFilters)
_check(
label: status,
checked: filters.lastRunStatuses.contains(status),
onChanged: (checked) {
final next = {...filters.lastRunStatuses};
if (checked) {
next.add(status);
} else {
next.remove(status);
}
onChanged(filters.copyWith(lastRunStatuses: next));
},
),
],
),
CupertinoListSection.insetGrouped(
backgroundColor: AppColors.groupedBackground,
header: const Text('SCHEDULING'),
footer: const Text('Configured schedules, including paused.'),
children: [
for (final schedule in ScheduleFilter.values)
_choice(
label: schedule.label,
selected: filters.schedule == schedule,
onTap: () => onChanged(filters.copyWith(schedule: schedule)),
),
],
),
Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (hasUnclassified)
const Padding(
padding: EdgeInsets.only(bottom: 12),
child: Text(
'Some records have no scheduling metadata; they stay unclassified.',
),
),
CupertinoButton(
padding: EdgeInsets.zero,
onPressed: onClear,
child: const Text('Clear filters'),
),
],
),
),
],
);
}
Widget _choice({
required String label,
required bool selected,
required VoidCallback onTap,
}) {
return CupertinoListTile(
title: Text(label),
trailing: CupertinoCheckbox(value: selected, onChanged: (_) => onTap()),
onTap: onTap,
);
}
Widget _check({
required String label,
required bool checked,
required ValueChanged<bool> onChanged,
}) {
return CupertinoListTile(
title: Text(label),
trailing: CupertinoCheckbox(
value: checked,
onChanged: (value) => onChanged(value ?? false),
),
onTap: () => onChanged(!checked),
);
}
}
@@ -1,40 +1,27 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/segmented_bar.dart';
import '../pipeline_filter.dart';
import 'pipeline_controls.dart';
import 'pipeline_filter_cupertino_body.dart';
import 'pipeline_filter_material_body.dart';
/// Opens the platform's native full-screen filter editor.
/// Opens the full-screen filter editor.
Future<void> openPipelineFilters(
BuildContext context, {
required PipelineFilters initial,
required bool hasUnclassified,
required ValueChanged<PipelineFilters> onApply,
}) {
final cupertino = useCupertinoControls(context);
final route = cupertino
? CupertinoPageRoute<void>(
fullscreenDialog: true,
builder: (_) => PipelineFilterPage(
initial: initial,
hasUnclassified: hasUnclassified,
onApply: onApply,
cupertino: true,
),
)
: MaterialPageRoute<void>(
fullscreenDialog: true,
builder: (_) => PipelineFilterPage(
initial: initial,
hasUnclassified: hasUnclassified,
onApply: onApply,
cupertino: false,
),
);
return Navigator.of(context).push(route);
return Navigator.of(context).push(
MaterialPageRoute<void>(
fullscreenDialog: true,
builder: (_) => PipelineFilterPage(
initial: initial,
hasUnclassified: hasUnclassified,
onApply: onApply,
cupertino: false,
),
),
);
}
/// A draft copy of the filters. Changes take effect on Done; leaving the page
@@ -51,6 +38,8 @@ class PipelineFilterPage extends StatefulWidget {
final PipelineFilters initial;
final bool hasUnclassified;
final ValueChanged<PipelineFilters> onApply;
/// Retained for callers; the page is Material on every host.
final bool cupertino;
@override
@@ -83,37 +72,6 @@ class _PipelineFilterPageState extends State<PipelineFilterPage> {
@override
Widget build(BuildContext context) {
final body = widget.cupertino
? PipelineFilterCupertinoBody(
filters: _draft,
name: _name,
hasUnclassified: widget.hasUnclassified,
onChanged: (filters) => setState(() => _draft = filters),
onClear: _clear,
)
: PipelineFilterMaterialBody(
filters: _draft,
name: _name,
hasUnclassified: widget.hasUnclassified,
onChanged: (filters) => setState(() => _draft = filters),
onClear: _clear,
);
if (widget.cupertino) {
return CupertinoPageScaffold(
navigationBar: SegmentedBar(
cupertino: true,
title: 'Filter pipelines',
actions: [
CupertinoButton(
padding: const EdgeInsets.symmetric(horizontal: 16),
onPressed: _apply,
child: const Text('Done'),
),
],
),
child: SafeArea(top: false, bottom: false, child: body),
);
}
return Scaffold(
extendBodyBehindAppBar: true,
appBar: SegmentedBar(
@@ -121,7 +79,17 @@ class _PipelineFilterPageState extends State<PipelineFilterPage> {
title: 'Filter pipelines',
actions: [TextButton(onPressed: _apply, child: const Text('Done'))],
),
body: SafeArea(top: false, bottom: false, child: body),
body: SafeArea(
top: false,
bottom: false,
child: PipelineFilterMaterialBody(
filters: _draft,
name: _name,
hasUnclassified: widget.hasUnclassified,
onChanged: (filters) => setState(() => _draft = filters),
onClear: _clear,
),
),
);
}
}
@@ -1,11 +1,9 @@
import 'dart:math' as math;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../graph/widgets/definition_graph_view.dart';
import '../pipeline_models.dart';
import 'pipeline_controls.dart';
import 'pipeline_detail_styles.dart';
/// The Graph tab's guidance note. Gestures stay the host's own: wheel or pinch
@@ -207,14 +205,6 @@ class _GraphGuidanceNoteState extends State<_GraphGuidanceNote> {
/// The host's own scrollbar: visible whenever the note is clipped, and
/// draggable with the pointer, so the rest is discoverable without a wheel.
Widget _scrollbar(Widget child) {
if (useCupertinoControls(context)) {
return CupertinoScrollbar(
key: const Key('pipeline-graph-note-scrollbar'),
controller: _scrollController,
thumbVisibility: true,
child: child,
);
}
return Scrollbar(
key: const Key('pipeline-graph-note-scrollbar'),
controller: _scrollController,
@@ -1,7 +1,6 @@
import '../../../core/servers/server_context.dart';
import '../../../ui/layout/app_list_avatar.dart';
import '../../../ui/layout/app_list_row.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../shell/shell_list_shortcuts.dart';
@@ -213,7 +212,6 @@ class PipelineListPanel extends StatelessWidget {
List<PipelineSummary> items,
) {
final now = DateTime.now();
final cupertino = useCupertinoControls(context);
// The default padding is the media padding: the controls start below the
// top bar and the last row clears the floating tab bar.
return ListView.builder(
@@ -228,12 +226,12 @@ class PipelineListPanel extends StatelessWidget {
final badge = run == null ? null : runBadge(run, now);
return AppListRow(
key: Key('pipeline-row-${pipeline.id}'),
cupertino: cupertino,
cupertino: false,
selected: controller.selectedId == pipeline.id,
divider: index < header.length + items.length - 1,
onTap: () =>
controller.openPipeline(pipeline.id, version: pipeline.version),
leading: _pipelineIdentityIcon(context, pipeline, cupertino),
leading: _pipelineIdentityIcon(context, pipeline),
title: Text(pipeline.displayName),
time: badge?.ranAgo,
subtitleLeading: badge == null
@@ -274,11 +272,6 @@ class PipelineListPanel extends StatelessWidget {
}
TextStyle? _mutedStyle(BuildContext context) {
if (useCupertinoControls(context)) {
return CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
color: CupertinoColors.secondaryLabel.resolveFrom(context),
);
}
final theme = Theme.of(context);
return theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
@@ -290,19 +283,9 @@ class PipelineListPanel extends StatelessWidget {
Widget _pipelineIdentityIcon(
BuildContext context,
PipelineSummary pipeline,
bool cupertino,
) {
final List<Color> colors;
if (cupertino) {
colors = [
CupertinoTheme.of(context).primaryColor,
CupertinoColors.systemIndigo.resolveFrom(context),
CupertinoColors.systemTeal.resolveFrom(context),
];
} else {
final scheme = Theme.of(context).colorScheme;
colors = [scheme.primary, scheme.secondary, scheme.tertiary];
}
final scheme = Theme.of(context).colorScheme;
final colors = [scheme.primary, scheme.secondary, scheme.tertiary];
return Semantics(
label: 'Pipeline ${pipeline.displayName}',
child: ExcludeSemantics(
@@ -334,34 +317,17 @@ List<Widget> pipelineListActions(
final label = filters.count == 0
? 'Filter pipelines'
: '${filters.count} active ${filters.count == 1 ? 'filter' : 'filters'}';
final cupertino = useCupertinoControls(context);
final filterIcon = cupertino
? (filters.count > 0
? CupertinoIcons.line_horizontal_3_decrease_circle_fill
: CupertinoIcons.line_horizontal_3_decrease_circle)
: (filters.count > 0 ? Icons.filter_alt : Icons.filter_alt_outlined);
final filter = cupertino
? Semantics(
button: true,
label: label,
excludeSemantics: true,
child: CupertinoButton(
key: const Key('pipeline-filter'),
padding: EdgeInsets.zero,
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
onPressed: openFilters,
child: Icon(filterIcon),
),
)
: IconButton(
key: const Key('pipeline-filter'),
tooltip: label,
isSelected: filters.count > 0,
onPressed: openFilters,
icon: Icon(filterIcon),
);
// A narrow bar moves either into its More menu; sorting is then a
// submenu (Material) or a second action sheet (Cupertino).
final filterIcon = filters.count > 0
? Icons.filter_alt
: Icons.filter_alt_outlined;
final filter = IconButton(
key: const Key('pipeline-filter'),
tooltip: label,
isSelected: filters.count > 0,
onPressed: openFilters,
icon: Icon(filterIcon),
);
// A narrow bar moves either into its More menu; sorting is then a submenu.
return [
SegmentedOverflowAction(
overflowEntry: SegmentedOverflowEntry(
@@ -374,7 +340,7 @@ List<Widget> pipelineListActions(
SegmentedOverflowAction(
overflowEntry: SegmentedOverflowEntry(
label: 'Sort pipelines: ${controller.sort.label}',
icon: cupertino ? CupertinoIcons.arrow_up_arrow_down : Icons.sort,
icon: Icons.sort,
choices: [
for (final option in PipelineSort.values)
SegmentedMenuChoice(
@@ -1,8 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'pipeline_controls.dart';
/// The list's scope: every active pipeline, only scheduled ones, or the
/// archived pipelines (which the other two never show).
enum PipelineScope {
@@ -15,7 +12,7 @@ enum PipelineScope {
final String label;
}
/// Uses a native picker when the segmented labels cannot fit at the user's
/// Uses a standard dropdown when the segmented labels cannot fit at the user's
/// text scale. The decision is content-measured, not a fixed pane width.
class PipelineScopeControl extends StatelessWidget {
const PipelineScopeControl({
@@ -32,10 +29,7 @@ class PipelineScopeControl extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cupertino = useCupertinoControls(context);
final style = cupertino
? CupertinoTheme.of(context).textTheme.textStyle
: Theme.of(context).textTheme.labelLarge;
final style = Theme.of(context).textTheme.labelLarge;
var requiredWidth = kMinInteractiveDimension * labels.length;
for (final label in labels.values) {
final painter = TextPainter(
@@ -49,84 +43,35 @@ class PipelineScopeControl extends StatelessWidget {
return LayoutBuilder(
builder: (context, constraints) {
if (constraints.maxWidth >= requiredWidth) {
return cupertino
? CupertinoSlidingSegmentedControl<PipelineScope>(
key: const Key('pipeline-scope'),
groupValue: scope,
onValueChanged: (value) =>
onSelected(value ?? PipelineScope.all),
children: {
for (final entry in labels.entries)
entry.key: Text(entry.value),
},
)
: SegmentedButton<PipelineScope>(
key: const Key('pipeline-scope'),
showSelectedIcon: false,
segments: [
for (final entry in labels.entries)
ButtonSegment(value: entry.key, label: Text(entry.value)),
],
selected: {scope},
onSelectionChanged: (value) => onSelected(value.single),
);
}
if (!cupertino) {
return DropdownButton<PipelineScope>(
return SegmentedButton<PipelineScope>(
key: const Key('pipeline-scope'),
value: scope,
isExpanded: true,
items: [
showSelectedIcon: false,
segments: [
for (final entry in labels.entries)
DropdownMenuItem(
value: entry.key,
child: Text(
entry.value,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
ButtonSegment(value: entry.key, label: Text(entry.value)),
],
onChanged: (value) {
if (value != null) onSelected(value);
},
selected: {scope},
onSelectionChanged: (value) => onSelected(value.single),
);
}
return CupertinoButton(
return DropdownButton<PipelineScope>(
key: const Key('pipeline-scope'),
padding: EdgeInsets.zero,
onPressed: () => showCupertinoModalPopup<void>(
context: context,
builder: (sheetContext) => CupertinoActionSheet(
title: const Text('Pipeline scope'),
actions: [
for (final entry in labels.entries)
CupertinoActionSheetAction(
onPressed: () {
Navigator.of(sheetContext).pop();
if (context.mounted) onSelected(entry.key);
},
child: Text(entry.value),
),
],
cancelButton: CupertinoActionSheetAction(
onPressed: () => Navigator.of(sheetContext).pop(),
child: const Text('Cancel'),
),
),
),
child: Row(
children: [
Expanded(
value: scope,
isExpanded: true,
items: [
for (final entry in labels.entries)
DropdownMenuItem(
value: entry.key,
child: Text(
labels[scope]!,
entry.value,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
const Icon(CupertinoIcons.chevron_down),
],
),
],
onChanged: (value) {
if (value != null) onSelected(value);
},
);
},
);
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
@@ -10,7 +9,6 @@ import '../pipeline_format.dart';
import '../pipeline_models.dart';
import '../pipeline_query.dart';
import '../pipelines_controller.dart';
import 'pipeline_controls.dart';
import 'pipeline_definition_validation.dart';
import 'pipeline_detail_styles.dart';
@@ -85,7 +83,7 @@ class PipelineSummaryView extends StatelessWidget {
if (fields.isEmpty) return const SizedBox.shrink();
return FactsGrid(
key: pipelineSummaryFactsKey,
cupertino: useCupertinoControls(context),
cupertino: false,
items: [
for (final field in fields)
FactsGridItem(
@@ -101,7 +99,6 @@ class PipelineSummaryView extends StatelessWidget {
}
Widget _versions(BuildContext context) {
final cupertino = useCupertinoControls(context);
final effective = detail.resolvedVersion;
final showingLatest = effective == detail.latestVersion;
final versions = detail.versions;
@@ -109,7 +106,7 @@ class PipelineSummaryView extends StatelessWidget {
if (!showingLatest)
AppListRow(
key: const Key('pipeline-latest-version'),
cupertino: cupertino,
cupertino: false,
title: Text('View latest v${detail.latestVersion}'),
subtitle: const Text('Return to the latest version'),
divider: versions.isNotEmpty,
@@ -118,7 +115,7 @@ class PipelineSummaryView extends StatelessWidget {
for (var index = 0; index < versions.length; index += 1)
AppListRow(
key: Key('pipeline-version-${versions[index].version}'),
cupertino: cupertino,
cupertino: false,
selected: versions[index].version == effective,
title: Text('v${versions[index].version}'),
time: formatLocalTimestamp(versions[index].createdAt),
@@ -2,7 +2,6 @@ import 'package:flutter/widgets.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/floating_destination_bar.dart';
import 'pipeline_controls.dart';
import 'pipeline_detail_tab.dart';
export 'pipeline_detail_tab.dart';
@@ -30,12 +29,11 @@ class PipelineDetailTabs extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cupertino = useCupertinoControls(context);
const tabs = PipelineDetailTab.values;
return KeyedSubtree(
key: const Key('pipeline-detail-tabs'),
child: FloatingDestinationBar(
cupertino: cupertino,
cupertino: false,
currentIndex: tabs.indexOf(selected),
edge: edge,
onTap: (value) => onSelected(tabs[value]),
@@ -43,7 +41,7 @@ class PipelineDetailTabs extends StatelessWidget {
for (final tab in tabs)
FloatingDestinationItem(
key: ValueKey('pipeline-detail-tab-${tab.name}'),
icon: Icon(cupertino ? tab.cupertinoIcon : tab.icon),
icon: Icon(tab.icon),
label: tab.label,
),
],
@@ -1,6 +1,5 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
@@ -9,7 +8,6 @@ import 'settings_controller.dart';
import 'settings_group.dart';
import 'settings_row.dart';
import 'settings_sections.dart';
import 'settings_theme.dart';
/// The short line under the managed connection's rows.
const String managedConnectionHelp =
@@ -33,7 +31,6 @@ class ManagedConnectionSection extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoControls(context);
return SettingsGroup(
title: 'Connection',
leadingRows: true,
@@ -52,24 +49,20 @@ class ManagedConnectionSection extends StatelessWidget {
children: <Widget>[
SettingsStatusRow(controller: controller),
SettingsRow(
leading: Icon(cupertino ? CupertinoIcons.link : Icons.link),
leading: Icon(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,
),
leading: Icon(Icons.refresh),
title: const Text('Reconnect'),
onTap: () => unawaited(client.connectAny(client.endpoints)),
),
SettingsRow(
action: true,
leading: Icon(
cupertino ? CupertinoIcons.stop_circle : Icons.link_off,
),
leading: Icon(Icons.link_off),
title: const Text('Disconnect'),
onTap: () => unawaited(client.disconnect()),
),
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../ui/motion/quick_switch_animation.dart';
import '../chat/workspace/chat_workspace.dart';
@@ -51,7 +50,6 @@ class _QuickSwitchPreviewState extends State<QuickSwitchPreview> {
@override
Widget build(BuildContext context) {
final reduced = MediaQuery.disableAnimationsOf(context);
final cupertino = usesCupertinoControls(context);
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
@@ -60,16 +58,11 @@ class _QuickSwitchPreviewState extends State<QuickSwitchPreview> {
crossAxisAlignment: WrapCrossAlignment.center,
children: [
Text('Preview', style: settingsTextStyle(context, title: true)),
cupertino
? CupertinoButton(
onPressed: reduced ? null : _replay,
child: const Text('Replay animation'),
)
: TextButton.icon(
onPressed: reduced ? null : _replay,
icon: const Icon(Icons.replay),
label: const Text('Replay animation'),
),
TextButton.icon(
onPressed: reduced ? null : _replay,
icon: const Icon(Icons.replay),
label: const Text('Replay animation'),
),
],
),
Center(
@@ -120,16 +113,10 @@ class _PreviewChat extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoControls(context);
final color = cupertino
? (alternate ? CupertinoColors.systemTeal : CupertinoColors.systemBlue)
.resolveFrom(context)
: (alternate
? Theme.of(context).colorScheme.tertiary
: Theme.of(context).colorScheme.primary);
final background = cupertino
? CupertinoColors.secondarySystemGroupedBackground.resolveFrom(context)
: Theme.of(context).colorScheme.surfaceContainerHigh;
final color = alternate
? Theme.of(context).colorScheme.tertiary
: Theme.of(context).colorScheme.primary;
final background = Theme.of(context).colorScheme.surfaceContainerHigh;
return DecoratedBox(
decoration: BoxDecoration(
color: background,
@@ -1,9 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../core/servers/machine_access.dart';
import '../../core/servers/server_catalog.dart';
import '../../ui/adaptive/host.dart';
import '../../ui/adaptive/segmented_bar.dart';
import '../onboarding/discovery/discovered_server.dart';
import '../onboarding/discovery/discovery_panel.dart';
@@ -28,9 +26,7 @@ Future<SavedServer?> editSavedServer(
discovery: discovery ?? platformServerDiscovery(),
);
return Navigator.of(context).push<SavedServer>(
usesCupertinoHost(context)
? CupertinoPageRoute(builder: (_) => page)
: MaterialPageRoute(builder: (_) => page),
MaterialPageRoute(builder: (_) => page),
);
}
@@ -125,27 +121,6 @@ class _ServerEditorState extends State<_ServerEditor> {
required String key,
bool multiline = false,
}) {
if (usesCupertinoHost(context)) {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(label),
const SizedBox(height: 8),
CupertinoTextField(
key: Key(key),
controller: controller,
enabled: !_saving,
placeholder: multiline ? 'wss://server.example/connect' : 'Home',
minLines: multiline ? 3 : 1,
maxLines: multiline ? null : 1,
keyboardType: multiline
? TextInputType.multiline
: TextInputType.text,
autocorrect: !multiline,
),
],
);
}
return TextField(
key: Key(key),
controller: controller,
@@ -163,18 +138,12 @@ class _ServerEditorState extends State<_ServerEditor> {
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final title = widget.server == null ? 'Add server' : 'Edit server';
final saveLabel = _saving ? 'Saving server…' : 'Save server';
final save = cupertino
? CupertinoButton.filled(
onPressed: _saving ? null : _save,
child: Text(saveLabel),
)
: FilledButton(
onPressed: _saving ? null : _save,
child: Text(saveLabel),
);
final save = FilledButton(
onPressed: _saving ? null : _save,
child: Text(saveLabel),
);
final saved = _saved;
if (saved != null && widget.authenticator != null) {
final step = SafeArea(
@@ -189,7 +158,7 @@ class _ServerEditorState extends State<_ServerEditor> {
],
),
);
return _scaffold(cupertino, 'Sign in to ${saved.name}', step);
return _scaffold('Sign in to ${saved.name}', step);
}
final body = SafeArea(
child: ListView(
@@ -232,9 +201,7 @@ class _ServerEditorState extends State<_ServerEditor> {
child: Text(
_error!,
style: TextStyle(
color: cupertino
? CupertinoColors.systemRed.resolveFrom(context)
: Theme.of(context).colorScheme.error,
color: Theme.of(context).colorScheme.error,
),
),
),
@@ -244,17 +211,12 @@ class _ServerEditorState extends State<_ServerEditor> {
],
),
);
return PopScope(canPop: !_saving, child: _scaffold(cupertino, title, body));
return PopScope(canPop: !_saving, child: _scaffold(title, body));
}
Widget _scaffold(bool cupertino, String title, Widget body) => cupertino
? CupertinoPageScaffold(
navigationBar: SegmentedBar(cupertino: true, title: title),
child: body,
)
: Scaffold(
extendBodyBehindAppBar: true,
appBar: SegmentedBar(cupertino: false, title: title),
body: body,
);
Widget _scaffold(String title, Widget body) => Scaffold(
extendBodyBehindAppBar: true,
appBar: SegmentedBar(cupertino: false, title: title),
body: body,
);
}
+14 -57
View File
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../core/servers/machine_access.dart';
@@ -64,69 +63,27 @@ class SavedServerRow extends StatelessWidget {
: 'Unreachable: ${status!.detail}',
};
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 menu = 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 = !allowSelection
? Icon(cupertino ? CupertinoIcons.desktopcomputer : Icons.computer)
? Icon(Icons.computer)
: selected
? Icon(
cupertino
? CupertinoIcons.checkmark_circle_fill
: Icons.check_circle,
Icons.check_circle,
semanticLabel: 'Selected',
color: cupertino
? CupertinoTheme.of(context).primaryColor
: Theme.of(context).colorScheme.primary,
color: Theme.of(context).colorScheme.primary,
)
: Icon(
cupertino ? CupertinoIcons.circle : Icons.radio_button_unchecked,
color: cupertino
? CupertinoColors.tertiaryLabel.resolveFrom(context)
: null,
);
: Icon(Icons.radio_button_unchecked);
final needsPassword = status?.needsPassword ?? false;
final state = _stateText;
return SettingsRow(
@@ -1,9 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../core/servers/machine_access.dart';
import '../../core/servers/server_catalog.dart';
import '../../ui/adaptive/host.dart';
/// What the editor does once a machine is saved: ask it whether this device
/// may use it, then either sign in with its own password or explain why it
@@ -92,21 +90,16 @@ class _SavedServerSignInStepState extends State<SavedServerSignInStep> {
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final name = widget.server.name;
final errorColor = cupertino
? CupertinoColors.systemRed.resolveFrom(context)
: Theme.of(context).colorScheme.error;
final errorColor = Theme.of(context).colorScheme.error;
final result = _result;
if (result == null) {
return Row(
children: [
cupertino
? const CupertinoActivityIndicator()
: const SizedBox.square(
dimension: 16,
child: CircularProgressIndicator(strokeWidth: 2),
),
const SizedBox.square(
dimension: 16,
child: CircularProgressIndicator(strokeWidth: 2),
),
const SizedBox(width: 12),
Expanded(
child: Text('Saved. Checking whether $name needs a sign-in…'),
@@ -114,51 +107,29 @@ class _SavedServerSignInStepState extends State<SavedServerSignInStep> {
],
);
}
final later = cupertino
? CupertinoButton(
key: const Key('server-sign-in-later'),
onPressed: _busy ? null : widget.onDone,
child: const Text('Later'),
)
: TextButton(
key: const Key('server-sign-in-later'),
onPressed: _busy ? null : widget.onDone,
child: const Text('Later'),
);
final later = TextButton(
key: const Key('server-sign-in-later'),
onPressed: _busy ? null : widget.onDone,
child: const Text('Later'),
);
if (result.needsPassword) {
final field = cupertino
? CupertinoTextField(
key: const Key('server-profile-password'),
controller: _password,
obscureText: true,
autofocus: true,
enabled: !_busy,
placeholder: 'Password',
onSubmitted: (_) => _signIn(),
)
: TextField(
key: const Key('server-profile-password'),
controller: _password,
obscureText: true,
autofocus: true,
enabled: !_busy,
decoration: const InputDecoration(
labelText: 'Password',
border: OutlineInputBorder(),
),
onSubmitted: (_) => _signIn(),
);
final signIn = cupertino
? CupertinoButton.filled(
key: const Key('server-profile-sign-in'),
onPressed: _busy ? null : _signIn,
child: Text(_busy ? 'Signing in…' : 'Sign in'),
)
: FilledButton(
key: const Key('server-profile-sign-in'),
onPressed: _busy ? null : _signIn,
child: Text(_busy ? 'Signing in…' : 'Sign in'),
);
final field = TextField(
key: const Key('server-profile-password'),
controller: _password,
obscureText: true,
autofocus: true,
enabled: !_busy,
decoration: const InputDecoration(
labelText: 'Password',
border: OutlineInputBorder(),
),
onSubmitted: (_) => _signIn(),
);
final signIn = FilledButton(
key: const Key('server-profile-sign-in'),
onPressed: _busy ? null : _signIn,
child: Text(_busy ? 'Signing in…' : 'Sign in'),
);
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
@@ -182,17 +153,11 @@ class _SavedServerSignInStepState extends State<SavedServerSignInStep> {
],
);
}
final retry = cupertino
? CupertinoButton.filled(
key: const Key('server-profile-retry'),
onPressed: _busy ? null : _probe,
child: const Text('Try again'),
)
: FilledButton(
key: const Key('server-profile-retry'),
onPressed: _busy ? null : _probe,
child: const Text('Try again'),
);
final retry = FilledButton(
key: const Key('server-profile-retry'),
onPressed: _busy ? null : _probe,
child: const Text('Try again'),
);
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
@@ -1,12 +1,10 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import '../../core/servers/chat/machine_sign_in_dialog.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';
@@ -47,47 +45,25 @@ class SavedServersSection extends StatelessWidget {
}
Future<void> _remove(BuildContext context, SavedServer server) async {
final cupertino = usesCupertinoHost(context);
final confirmed = cupertino
? await showCupertinoDialog<bool>(
context: context,
builder: (context) => CupertinoAlertDialog(
title: Text('Remove ${server.name}?'),
content: const Text(
'This removes the saved configuration, not data on the server.',
),
actions: [
CupertinoDialogAction(
onPressed: () => Navigator.pop(context, false),
child: const Text('Cancel'),
),
CupertinoDialogAction(
isDestructiveAction: true,
onPressed: () => Navigator.pop(context, true),
child: const Text('Remove'),
),
],
),
)
: await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
title: Text('Remove ${server.name}?'),
content: const Text(
'This removes the saved configuration, not data on the server.',
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('Cancel'),
),
TextButton(
onPressed: () => Navigator.pop(context, true),
child: const Text('Remove'),
),
],
),
);
final confirmed = await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
title: Text('Remove ${server.name}?'),
content: const Text(
'This removes the saved configuration, not data on the server.',
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('Cancel'),
),
TextButton(
onPressed: () => Navigator.pop(context, true),
child: const Text('Remove'),
),
],
),
);
if (confirmed == true) await connections.remove(server.id);
}
@@ -116,7 +92,6 @@ class SavedServersSection extends StatelessWidget {
Widget build(BuildContext context) => ListenableBuilder(
listenable: Listenable.merge([connections, ?connections.authenticator]),
builder: (context, _) {
final cupertino = usesCupertinoHost(context);
final error = connections.error;
final allowSelection = allowPrimarySelection ?? !kIsWeb;
return SettingsGroup(
@@ -150,7 +125,7 @@ class SavedServersSection extends StatelessWidget {
SettingsRow(
action: true,
enabled: !connections.busy,
leading: Icon(cupertino ? CupertinoIcons.add : Icons.add),
leading: Icon(Icons.add),
title: const Text('Add server'),
onTap: () => unawaited(_edit(context)),
),
@@ -1,9 +1,7 @@
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../ui/adaptive/host.dart';
import '../artifacts/ui/artifact_external_open.dart';
import '../artifacts/ui/artifact_viewer_fetch.dart';
import '../updates/app_updates.dart';
@@ -71,14 +69,9 @@ class _SettingsAndroidDownloadSectionState
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final muted = cupertino
? CupertinoTheme.of(context).textTheme.textStyle.copyWith(
color: CupertinoColors.secondaryLabel.resolveFrom(context),
)
: Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
);
final muted = Theme.of(context).textTheme.bodySmall?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
);
final update = _update;
if (_loading) {
return Text('Checking for the Android app…', style: muted);
@@ -89,18 +82,12 @@ class _SettingsAndroidDownloadSectionState
style: muted,
);
}
final button = cupertino
? CupertinoButton.filled(
key: const Key('settings-android-download'),
onPressed: () => _download(update),
child: const Text('Download APK'),
)
: FilledButton.icon(
key: const Key('settings-android-download'),
onPressed: () => _download(update),
icon: const Icon(Icons.download),
label: const Text('Download APK'),
);
final button = FilledButton.icon(
key: const Key('settings-android-download'),
onPressed: () => _download(update),
icon: const Icon(Icons.download),
label: const Text('Download APK'),
);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@@ -1,5 +1,4 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../ui/motion/animation_speed.dart';
import '../../ui/motion/quick_switch_animation.dart';
@@ -20,7 +19,6 @@ class SettingsAnimationSection extends StatelessWidget {
Widget build(BuildContext context) => ListenableBuilder(
listenable: controller,
builder: (context, _) {
final cupertino = usesCupertinoControls(context);
final speed = controller.speed;
final label = '${speed.toStringAsFixed(1)}×';
final reset = speed == 1 ? null : () => unawaited(controller.reset());
@@ -49,39 +47,22 @@ class SettingsAnimationSection extends StatelessWidget {
crossAxisAlignment: WrapCrossAlignment.center,
children: [
Text(label, style: settingsTextStyle(context, title: true)),
cupertino
? CupertinoButton(
onPressed: reset,
child: const Text('Reset'),
)
: TextButton(
onPressed: reset,
child: const Text('Reset'),
),
TextButton(onPressed: reset, child: const Text('Reset')),
],
),
Semantics(
label: 'Animation speed',
child: cupertino
? CupertinoSlider(
value: speed,
min: minAnimationSpeed,
max: maxAnimationSpeed,
divisions: 15,
onChanged: controller.setSpeed,
onChangeEnd: (_) => unawaited(controller.save()),
)
: Slider(
value: speed,
min: minAnimationSpeed,
max: maxAnimationSpeed,
divisions: 15,
label: label,
semanticFormatterCallback: (value) =>
'${value.toStringAsFixed(1)} times',
onChanged: controller.setSpeed,
onChangeEnd: (_) => unawaited(controller.save()),
),
child: Slider(
value: speed,
min: minAnimationSpeed,
max: maxAnimationSpeed,
divisions: 15,
label: label,
semanticFormatterCallback: (value) =>
'${value.toStringAsFixed(1)} times',
onChanged: controller.setSpeed,
onChangeEnd: (_) => unawaited(controller.save()),
),
),
const Wrap(
alignment: WrapAlignment.spaceBetween,
@@ -1,15 +1,13 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'settings_layout.dart';
import 'settings_theme.dart';
export 'settings_theme.dart';
/// A native text field with a label and one supporting line. Both platforms lay
/// the label out as wrapping text above the field; Material uses an outlined
/// [TextField] and iOS a [CupertinoTextField]. The label is a compact secondary
/// line (like the web field label) while the section title carries the weight.
/// A native text field with a label and one supporting line. The label is laid
/// out as wrapping text above the field; Material uses an outlined
/// [TextField]. The label is a compact secondary line (like the web field
/// label) while the section title carries the weight.
/// Labels and helper/error copy are never line-capped, so large text cannot
/// truncate them. No font sizes, heights or colours are fixed here.
class SettingsTextField extends StatelessWidget {
@@ -44,58 +42,11 @@ class SettingsTextField extends StatelessWidget {
final labelWidget = ExcludeSemantics(
child: Text(
label,
style: usesCupertinoControls(context)
? settingsTextStyle(context, secondary: true)
: theme.textTheme.labelMedium?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
style: theme.textTheme.labelMedium?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
);
if (!usesCupertinoControls(context)) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
labelWidget,
const SizedBox(height: settingsFieldGap),
Semantics(
label: label,
child: TextField(
controller: controller,
onChanged: onChanged,
keyboardType: TextInputType.url,
minLines: 1,
maxLines: maxLines,
autocorrect: false,
enableSuggestions: false,
textInputAction: TextInputAction.done,
decoration: InputDecoration(
hintText: placeholder,
// `helperText`/`errorText` single-line-ellipsize unless capped
// by `helperMaxLines`/`errorMaxLines`. Widgets wrap with no line
// cap, so the full instructions stay readable at 2x.
helper: hasError
? null
: Text(
helper,
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
error: hasError
? Text(
error,
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.error,
),
)
: null,
border: const OutlineInputBorder(),
),
),
),
],
);
}
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
@@ -103,26 +54,38 @@ class SettingsTextField extends StatelessWidget {
const SizedBox(height: settingsFieldGap),
Semantics(
label: label,
child: CupertinoTextField(
child: TextField(
controller: controller,
onChanged: onChanged,
placeholder: placeholder,
keyboardType: TextInputType.url,
minLines: 1,
maxLines: maxLines,
autocorrect: false,
enableSuggestions: false,
clearButtonMode: OverlayVisibilityMode.editing,
textInputAction: TextInputAction.done,
),
),
const SizedBox(height: settingsFieldGap),
Text(
hasError ? error : helper,
style: settingsTextStyle(
context,
error: hasError,
secondary: !hasError,
decoration: InputDecoration(
hintText: placeholder,
// `helperText`/`errorText` single-line-ellipsize unless capped
// by `helperMaxLines`/`errorMaxLines`. Widgets wrap with no line
// cap, so the full instructions stay readable at 2x.
helper: hasError
? null
: Text(
helper,
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
),
),
error: hasError
? Text(
error,
style: theme.textTheme.bodySmall?.copyWith(
color: theme.colorScheme.error,
),
)
: null,
border: const OutlineInputBorder(),
),
),
),
],
@@ -152,24 +115,6 @@ class SettingsActions extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (usesCupertinoControls(context)) {
return Wrap(
spacing: settingsControlGap,
runSpacing: settingsControlGap,
children: <Widget>[
CupertinoButton.filled(
key: primaryKey,
onPressed: onPrimary,
child: Text(primaryLabel),
),
CupertinoButton(
key: secondaryKey,
onPressed: onSecondary,
child: Text(secondaryLabel),
),
],
);
}
return Wrap(
spacing: settingsControlGap,
runSpacing: settingsControlGap,
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../ui/theme/app_font_controller.dart';
@@ -6,7 +5,6 @@ import '../../ui/theme/custom_fonts/custom_font.dart';
import '../../ui/theme/custom_fonts/custom_font_draft.dart';
import '../../ui/theme/custom_fonts/font_file_picker.dart';
import 'settings_custom_font_dialogs.dart';
import 'settings_theme.dart';
const addCustomFontText = 'Add font…';
const addingCustomFontText = 'Adding…';
@@ -104,45 +102,8 @@ class CustomFontMenu extends StatelessWidget {
}
}
Future<void> _cupertinoSheet(BuildContext context) async {
final action = await showCupertinoModalPopup<_CustomFontAction>(
context: context,
builder: (context) => CupertinoActionSheet(
title: Text(font.name),
actions: <Widget>[
CupertinoActionSheetAction(
onPressed: () => Navigator.pop(context, _CustomFontAction.rename),
child: const Text(renameCustomFontText),
),
CupertinoActionSheetAction(
isDestructiveAction: true,
onPressed: () => Navigator.pop(context, _CustomFontAction.remove),
child: const Text(removeCustomFontText),
),
],
cancelButton: CupertinoActionSheetAction(
onPressed: () => Navigator.pop(context),
child: const Text('Cancel'),
),
),
);
if (action != null && context.mounted) await _run(context, action);
}
@override
Widget build(BuildContext context) {
if (usesCupertinoControls(context)) {
return Semantics(
label: customFontActionsTooltip,
button: true,
excludeSemantics: true,
child: CupertinoButton(
padding: EdgeInsets.zero,
onPressed: () => _cupertinoSheet(context),
child: const Icon(CupertinoIcons.ellipsis_circle),
),
);
}
return PopupMenuButton<_CustomFontAction>(
tooltip: customFontActionsTooltip,
onSelected: (action) => _run(context, action),
@@ -1,8 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../ui/theme/custom_fonts/custom_font_draft.dart';
import 'settings_theme.dart';
const customFontNameLabel = 'Name';
const addCustomFontTitle = 'Add font';
@@ -24,9 +22,7 @@ Future<String?> showFontNameDialog(
confirm: confirm,
detail: detail,
);
return usesCupertinoControls(context)
? showCupertinoDialog<String>(context: context, builder: (_) => dialog)
: showDialog<String>(context: context, builder: (_) => dialog);
return showDialog<String>(context: context, builder: (_) => dialog);
}
class _FontNameDialog extends StatefulWidget {
@@ -69,25 +65,16 @@ class _FontNameDialogState extends State<_FontNameDialog> {
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoControls(context);
final field = cupertino
? CupertinoTextField(
controller: _name,
autofocus: true,
placeholder: customFontNameLabel,
maxLength: CustomFontLimits.maxNameLength,
onSubmitted: (_) => _submit(),
)
: TextField(
controller: _name,
autofocus: true,
maxLength: CustomFontLimits.maxNameLength,
decoration: InputDecoration(
labelText: customFontNameLabel,
errorText: _problem,
),
onSubmitted: (_) => _submit(),
);
final field = TextField(
controller: _name,
autofocus: true,
maxLength: CustomFontLimits.maxNameLength,
decoration: InputDecoration(
labelText: customFontNameLabel,
errorText: _problem,
),
onSubmitted: (_) => _submit(),
);
final content = Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -97,30 +84,8 @@ class _FontNameDialogState extends State<_FontNameDialog> {
const SizedBox(height: 12),
],
field,
if (cupertino && _problem != null)
Text(_problem!, style: TextStyle(color: settingsErrorColor(context))),
],
);
if (cupertino) {
return CupertinoAlertDialog(
title: Text(widget.title),
content: Padding(
padding: const EdgeInsets.only(top: 8),
child: content,
),
actions: <Widget>[
CupertinoDialogAction(
onPressed: () => Navigator.pop(context),
child: const Text('Cancel'),
),
CupertinoDialogAction(
isDefaultAction: true,
onPressed: _submit,
child: Text(widget.confirm),
),
],
);
}
return AlertDialog(
title: Text(widget.title),
content: SingleChildScrollView(child: content),
@@ -139,42 +104,23 @@ class _FontNameDialogState extends State<_FontNameDialog> {
Future<bool> confirmRemoveFont(BuildContext context, String name) async {
final title = Text('Remove $name?');
const body = Text('Its files are deleted from this device.');
final confirmed = usesCupertinoControls(context)
? await showCupertinoDialog<bool>(
context: context,
builder: (context) => CupertinoAlertDialog(
title: title,
content: body,
actions: <Widget>[
CupertinoDialogAction(
onPressed: () => Navigator.pop(context, false),
child: const Text('Cancel'),
),
CupertinoDialogAction(
isDestructiveAction: true,
onPressed: () => Navigator.pop(context, true),
child: const Text('Remove'),
),
],
),
)
: await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
title: title,
content: body,
actions: <Widget>[
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('Cancel'),
),
TextButton(
onPressed: () => Navigator.pop(context, true),
child: const Text('Remove'),
),
],
),
);
final confirmed = await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
title: title,
content: body,
actions: <Widget>[
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('Cancel'),
),
TextButton(
onPressed: () => Navigator.pop(context, true),
child: const Text('Remove'),
),
],
),
);
return confirmed ?? false;
}
@@ -183,31 +129,16 @@ Future<void> showFontProblem(
BuildContext context,
String title,
String message,
) => usesCupertinoControls(context)
? showCupertinoDialog<void>(
context: context,
builder: (context) => CupertinoAlertDialog(
title: Text(title),
content: Text(message),
actions: <Widget>[
CupertinoDialogAction(
isDefaultAction: true,
onPressed: () => Navigator.pop(context),
child: const Text('OK'),
),
],
),
)
: showDialog<void>(
context: context,
builder: (context) => AlertDialog(
title: Text(title),
content: Text(message),
actions: <Widget>[
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('OK'),
),
],
),
);
) => showDialog<void>(
context: context,
builder: (context) => AlertDialog(
title: Text(title),
content: Text(message),
actions: <Widget>[
TextButton(
onPressed: () => Navigator.pop(context),
child: const Text('OK'),
),
],
),
);
@@ -1,6 +1,5 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../notification_service/notification_service_bridge.dart';
@@ -84,7 +83,6 @@ class _SettingsDeviceDeliverySectionState
);
Widget _body(BuildContext context) {
final cupertino = usesCupertinoControls(context);
final status = _controller.status;
final enabled = status?.enabled ?? false;
final onChanged = status == null || _controller.busy
@@ -105,20 +103,12 @@ class _SettingsDeviceDeliverySectionState
],
),
children: <Widget>[
if (cupertino)
CupertinoListTile(
key: DeviceDeliveryKeys.toggle,
title: const Text(deviceDeliverySwitchLabel),
trailing: CupertinoSwitch(value: enabled, onChanged: onChanged),
onTap: onChanged == null ? null : () => onChanged(!enabled),
)
else
SwitchListTile(
key: DeviceDeliveryKeys.toggle,
title: const Text(deviceDeliverySwitchLabel),
value: enabled,
onChanged: onChanged,
),
SwitchListTile(
key: DeviceDeliveryKeys.toggle,
title: const Text(deviceDeliverySwitchLabel),
value: enabled,
onChanged: onChanged,
),
SettingsRow(
key: DeviceDeliveryKeys.status,
title: const Text('Status'),
@@ -1,6 +1,5 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../ui/theme/app_font.dart';
@@ -30,7 +29,7 @@ const ValueKey<String> settingsAddFontKey = ValueKey<String>(
/// The device's interface font: one row per option, each named in its own
/// face, the user's added fonts below the bundled ones, then "Add font…".
/// Material rows are radio tiles, Cupertino rows carry the checkmark.
/// Material rows are radio tiles.
/// A choice is stored locally and applies as soon as its files load.
class SettingsFontSection extends StatefulWidget {
const SettingsFontSection({
@@ -98,7 +97,6 @@ class _SettingsFontSectionState extends State<SettingsFontSection> {
Widget _group(BuildContext context) {
final controller = widget.controller;
final cupertino = usesCupertinoControls(context);
final options = <FontChoice>[...AppFont.values, ...controller.customFonts];
final group = SettingsGroup(
title: fontSectionTitle,
@@ -114,10 +112,7 @@ class _SettingsFontSectionState extends State<SettingsFontSection> {
],
),
children: <Widget>[
for (final font in options)
cupertino
? _cupertinoRow(context, font)
: _materialRow(context, font),
for (final font in options) _materialRow(context, font),
// Its own node: a bare list tile would lend its label and tap to the
// section around it.
Semantics(
@@ -126,7 +121,7 @@ class _SettingsFontSectionState extends State<SettingsFontSection> {
key: settingsAddFontKey,
action: true,
enabled: !_adding,
leading: Icon(cupertino ? CupertinoIcons.add : Icons.add),
leading: Icon(Icons.add),
title: const Text(addCustomFontText),
subtitle: _adding ? const Text(addingCustomFontText) : null,
onTap: () => unawaited(_add()),
@@ -134,7 +129,6 @@ class _SettingsFontSectionState extends State<SettingsFontSection> {
),
],
);
if (cupertino) return group;
return RadioGroup<FontChoice>(
groupValue: controller.selected,
onChanged: (font) {
@@ -166,39 +160,6 @@ class _SettingsFontSectionState extends State<SettingsFontSection> {
);
}
Widget _cupertinoRow(BuildContext context, FontChoice font) {
final check = widget.controller.selected == font
? Icon(
CupertinoIcons.check_mark,
color: CupertinoTheme.of(context).primaryColor,
)
: null;
// One node per option, announced as selected.
final row = Semantics(
container: true,
selected: check != null,
child: SettingsRow(
key: settingsFontKey(font),
title: _name(context, font),
subtitle: _status(context, font),
trailing: check,
onTap: () => unawaited(widget.controller.select(font)),
),
);
if (font is! CustomFont) return row;
// Beside the row, not in it: the list tile merges its children's
// semantics (see [_materialRow]).
return Row(
children: <Widget>[
Expanded(child: row),
Padding(
padding: const EdgeInsetsDirectional.only(end: 12),
child: CustomFontMenu(fonts: widget.controller, font: font),
),
],
);
}
/// The option's name in its own face once its regular weight has loaded;
/// the system face until then (and always for the system option).
Widget _name(BuildContext context, FontChoice font) {
@@ -225,10 +186,9 @@ class _SettingsFontSectionState extends State<SettingsFontSection> {
}
}
/// The platform's own interface family (Roboto, or the Cupertino system
/// face), independent of the font the theme currently applies.
String? _systemFamily(BuildContext context) => usesCupertinoControls(context)
? const CupertinoTextThemeData().textStyle.fontFamily
: Typography.material2021(
platform: Theme.of(context).platform,
).black.bodyLarge?.fontFamily;
/// The platform's own interface family (Roboto), independent of the font the
/// theme currently applies.
String? _systemFamily(BuildContext context) =>
Typography.material2021(
platform: Theme.of(context).platform,
).black.bodyLarge?.fontFamily;
+6 -34
View File
@@ -1,18 +1,12 @@
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,
@@ -28,26 +22,14 @@ class SettingsGroup extends StatelessWidget {
/// 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.
/// Whether the rows carry leading icons: kept for callers, the Material
/// group does not depend on it.
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,
@@ -96,17 +78,10 @@ class SettingsGroup extends StatelessWidget {
}
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 style = 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,
@@ -121,9 +96,6 @@ class SettingsGroup extends StatelessWidget {
/// 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,
@@ -142,7 +114,7 @@ class SettingsGroupItem extends StatelessWidget {
width: double.infinity,
child: Padding(
padding: EdgeInsetsDirectional.symmetric(
horizontal: usesCupertinoControls(context) ? 20 : settingsRowInset,
horizontal: settingsRowInset,
vertical: 12,
),
child: child,
@@ -1,8 +1,8 @@
/// The one place the Settings screen keeps its necessary layout constraints.
///
/// Everything else (control heights, font sizes, colours, button padding) comes
/// from the active Material or Cupertino theme, so text scaling and platform
/// defaults are never overridden here.
/// from the active Material theme, so text scaling and platform defaults are
/// never overridden here.
///
/// 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
@@ -1,6 +1,5 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../core/api_gateway.dart';
@@ -82,7 +81,6 @@ class _SettingsNtfySectionState extends State<SettingsNtfySection> {
);
Widget _body(BuildContext context) {
final cupertino = usesCupertinoControls(context);
final values = _controller.values;
final enabled = widget.connected && _controller.enabled;
final status = !widget.connected
@@ -97,7 +95,6 @@ class _SettingsNtfySectionState extends State<SettingsNtfySection> {
if (hasNtfySwitch) ntfyEnabledSetting,
])
_tile(
cupertino,
setting,
values?[setting.key] ?? false,
enabled ? (value) => _controller.toggle(setting.key, value) : null,
@@ -123,16 +120,10 @@ class _SettingsNtfySectionState extends State<SettingsNtfySection> {
if (_controller.error.isNotEmpty && retry)
Align(
alignment: AlignmentDirectional.centerStart,
child: cupertino
? CupertinoButton(
padding: EdgeInsets.zero,
onPressed: _controller.load,
child: const Text('Retry'),
)
: TextButton(
onPressed: _controller.load,
child: const Text('Retry'),
),
child: TextButton(
onPressed: _controller.load,
child: const Text('Retry'),
),
),
],
),
@@ -141,22 +132,10 @@ class _SettingsNtfySectionState extends State<SettingsNtfySection> {
}
Widget _tile(
bool cupertino,
NtfySetting setting,
bool value,
ValueChanged<bool>? onChanged,
) {
if (cupertino) {
return CupertinoListTile(
key: ntfySettingKey(setting.key),
title: Text(setting.label),
subtitle: setting.subtitle == null ? null : Text(setting.subtitle!),
// 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),
title: Text(setting.label),
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/application/pipelines_app.dart';
@@ -12,83 +11,66 @@ import 'pipelines_replies.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
void main() {
for (final cupertino in [false, true]) {
testWidgets(
'the /pipelines route renders real rows, detail and source ($cupertino)',
(tester) async {
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
if (cupertino) {
tester.platformDispatcher.platformBrightnessTestValue =
Brightness.dark;
addTearDown(
tester.platformDispatcher.clearPlatformBrightnessTestValue,
);
}
testWidgets('the /pipelines route renders real rows, detail and source', (
tester,
) async {
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final fixture = PipelineFixture();
final channel = FakeChannel()..readyCompleter.complete();
var sockets = 0;
final client = PipelinesClient(
channelFactory: (_) {
sockets++;
return channel;
},
);
final provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(
uri: Uri.parse('/pipelines'),
),
);
addTearDown(provider.dispose);
await tester.pumpWidget(
PipelinesApp(
server: webServer(),
client: client,
cupertino: cupertino,
routeInformationProvider: provider,
),
);
await tester.pump();
await replyPipelines(tester, channel, fixture);
await tester.pump();
expect(find.text('Alpha review'), findsOneWidget);
expect(find.text('2 stages · 1 schedule'), findsOneWidget);
expect(find.text('Pipelines — Not implemented'), findsNothing);
expect(sockets, 1);
// The shell owns the only navigation bar; the embedded screen adds no
// second bar.
expect(find.byType(SegmentedBar), findsOneWidget);
if (cupertino) {
expect(find.byType(CupertinoPageScaffold), findsOneWidget);
expect(find.byType(Material), findsNothing);
} else {
expect(find.byType(Scaffold), findsOneWidget);
}
await tester.tap(find.byKey(const Key('pipeline-row-1')));
await tester.pump();
await replyPipelineDetail(tester, channel, fixture);
await tester.pump();
expect(find.text('hash-alpha'), findsOneWidget);
await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
await tester.pump();
expect(
selectableText(
'name: Alpha review\nstages:\n review:\n type: model',
),
findsOneWidget,
);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
final fixture = PipelineFixture();
final channel = FakeChannel()..readyCompleter.complete();
var sockets = 0;
final client = PipelinesClient(
channelFactory: (_) {
sockets++;
return channel;
},
);
}
final provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(uri: Uri.parse('/pipelines')),
);
addTearDown(provider.dispose);
await tester.pumpWidget(
PipelinesApp(
server: webServer(),
client: client,
cupertino: false,
routeInformationProvider: provider,
),
);
await tester.pump();
await replyPipelines(tester, channel, fixture);
await tester.pump();
expect(find.text('Alpha review'), findsOneWidget);
expect(find.text('2 stages · 1 schedule'), findsOneWidget);
expect(find.text('Pipelines — Not implemented'), findsNothing);
expect(sockets, 1);
// The shell owns the only navigation bar; the embedded screen adds no
// second bar.
expect(find.byType(SegmentedBar), findsOneWidget);
expect(find.byType(Scaffold), findsOneWidget);
await tester.tap(find.byKey(const Key('pipeline-row-1')));
await tester.pump();
await replyPipelineDetail(tester, channel, fixture);
await tester.pump();
expect(find.text('hash-alpha'), findsOneWidget);
await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
await tester.pump();
expect(
selectableText(
'name: Alpha review\nstages:\n review:\n type: model',
),
findsOneWidget,
);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
});
}
+59 -66
View File
@@ -1,5 +1,4 @@
import '../features/settings/settings_topic_test_helper.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/application/pipelines_app.dart';
@@ -20,7 +19,6 @@ import 'pipelines_replies.dart';
void main() {
Future<PlatformRouteInformationProvider> pumpApp(
WidgetTester tester, {
required bool cupertino,
required String location,
required Size size,
}) async {
@@ -37,7 +35,7 @@ void main() {
PipelinesApp(
server: webServer(),
client: PipelinesClient(channelFactory: (_) => channel),
cupertino: cupertino,
cupertino: false,
routeInformationProvider: provider,
),
);
@@ -52,82 +50,77 @@ void main() {
.widget<FloatingDestinationBar>(find.byType(FloatingDestinationBar))
.currentIndex;
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
for (final size in [const Size(390, 844), const Size(1200, 800)]) {
testWidgets('$host ${size.width}: the Pipelines bar gear opens Settings '
'as a page and Back returns', (tester) async {
final provider = await pumpApp(
tester,
cupertino: cupertino,
location: '/pipelines',
size: size,
);
// Four tabs; Settings is none of them.
expect(
tester
.widget<FloatingDestinationBar>(
find.byType(FloatingDestinationBar),
)
.items
.map((item) => item.label),
['Pipelines', 'Runs', 'Chat', 'Search'],
);
expect(
find.byKey(const ValueKey('shell.destination.settings')),
findsNothing,
);
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
await tapBarAction(
tester,
find.byKey(const Key('pipelines-open-settings')),
'Settings',
);
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/settings');
expect(find.byType(SettingsScreen), findsOneWidget);
expect(find.text('Quick switch animation'), findsOneWidget);
await selectSettingsTopic(tester, 'Connection');
expect(find.text('Server URL'), findsOneWidget);
// A page of Pipelines: Back in its bar, Pipelines still selected.
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
expect(find.byKey(const ValueKey('shell.search')), findsNothing);
expect(selectedTab(tester), 0);
expect(tester.takeException(), isNull);
await tester.tap(find.byKey(const ValueKey('shell.back')));
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/pipelines');
expect(find.byKey(const Key('pipelines-open-settings')), findsWidgets);
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
});
}
testWidgets('$host: the /settings deep link opens the Settings page and '
'the system Back closes it to Pipelines', (tester) async {
for (final size in [const Size(390, 844), const Size(1200, 800)]) {
testWidgets('${size.width}: the Pipelines bar gear opens Settings '
'as a page and Back returns', (tester) async {
final provider = await pumpApp(
tester,
cupertino: cupertino,
location: '/settings',
size: const Size(390, 844),
location: '/pipelines',
size: size,
);
// Four tabs; Settings is none of them.
expect(
tester
.widget<FloatingDestinationBar>(
find.byType(FloatingDestinationBar),
)
.items
.map((item) => item.label),
['Pipelines', 'Runs', 'Chat', 'Search'],
);
expect(
find.byKey(const ValueKey('shell.destination.settings')),
findsNothing,
);
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
await tapBarAction(
tester,
find.byKey(const Key('pipelines-open-settings')),
'Settings',
);
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/settings');
expect(find.byType(SettingsScreen), findsOneWidget);
expect(find.text('Quick switch animation'), findsOneWidget);
await selectSettingsTopic(tester, 'Connection');
expect(find.text('Server URL'), findsOneWidget);
// A page of Pipelines: Back in its bar, Pipelines still selected.
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
expect(find.byKey(const ValueKey('shell.search')), findsNothing);
expect(selectedTab(tester), 0);
expect(tester.takeException(), isNull);
final handled = await tester.binding.handlePopRoute();
expect(handled, isTrue, reason: 'Back closes the page, not the app');
await tester.tap(find.byKey(const ValueKey('shell.back')));
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/pipelines');
expect(find.byKey(const Key('pipelines-open-settings')), findsWidgets);
expect(find.byKey(const ValueKey('shell.back')), findsNothing);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
});
}
testWidgets('the /settings deep link opens the Settings page and '
'the system Back closes it to Pipelines', (tester) async {
final provider = await pumpApp(
tester,
location: '/settings',
size: const Size(390, 844),
);
await tester.pump();
expect(find.byType(SettingsScreen), findsOneWidget);
expect(find.byKey(const ValueKey('shell.back')), findsOneWidget);
expect(selectedTab(tester), 0);
final handled = await tester.binding.handlePopRoute();
expect(handled, isTrue, reason: 'Back closes the page, not the app');
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/pipelines');
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
});
}
@@ -1,7 +1,6 @@
import '../features/settings/settings_topic_test_helper.dart';
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/application/pipelines_app.dart';
@@ -16,89 +15,73 @@ import 'pipelines_replies.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
void main() {
for (final cupertino in [false, true]) {
testWidgets('Settings shares socket and one native bar ($cupertino)', (
tester,
) async {
SharedPreferences.setMockInitialValues({});
if (cupertino) {
tester.platformDispatcher.platformBrightnessTestValue = Brightness.dark;
addTearDown(tester.platformDispatcher.clearPlatformBrightnessTestValue);
}
final channel = FakeChannel()..readyCompleter.complete();
var sockets = 0;
final client = PipelinesClient(
channelFactory: (_) {
sockets++;
return channel;
},
);
final provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(uri: Uri.parse('/pipelines')),
);
addTearDown(provider.dispose);
await tester.pumpWidget(
PipelinesApp(
server: webServer(),
client: client,
cupertino: cupertino,
routeInformationProvider: provider,
),
);
await tester.pump();
expect(
requestOf(channel, 'ping'),
isNull,
reason: 'Unvisited settings must not issue hidden requests',
);
await replyPipelines(tester, channel, PipelineFixture());
testWidgets('Settings shares socket and one native bar', (tester) async {
SharedPreferences.setMockInitialValues({});
final channel = FakeChannel()..readyCompleter.complete();
var sockets = 0;
final client = PipelinesClient(
channelFactory: (_) {
sockets++;
return channel;
},
);
final provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation(uri: Uri.parse('/pipelines')),
);
addTearDown(provider.dispose);
await tester.pumpWidget(
PipelinesApp(
server: webServer(),
client: client,
cupertino: false,
routeInformationProvider: provider,
),
);
await tester.pump();
expect(
requestOf(channel, 'ping'),
isNull,
reason: 'Unvisited settings must not issue hidden requests',
);
await replyPipelines(tester, channel, PipelineFixture());
await tapBarAction(
tester,
find.byKey(const Key('pipelines-open-settings')),
'Settings',
);
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/settings');
expect(find.text('Quick switch animation'), findsOneWidget);
await selectSettingsTopic(tester, 'Connection');
expect(find.text('Server URL'), findsOneWidget);
if (cupertino) {
final title = tester.widget<Text>(find.text('Connection').last);
expect(
title.style!.color!.computeLuminance(),
greaterThan(0.5),
reason: 'Cupertino dark host must not inherit light Material text',
);
}
expect(find.text('Settings — Not implemented'), findsNothing);
expect(sockets, 1);
expect(find.byType(SegmentedBar), findsOneWidget);
final ping = requestOf(channel, 'ping')!;
channel.incoming.add(
jsonEncode({
'id': ping['id'],
'type': 'pong',
'build': {'version': 'settings-fixture'},
'time': 'fixture time',
'protocol': 2,
}),
);
await tester.pump();
await tester.pump();
expect(find.textContaining('settings-fixture'), findsOneWidget);
expect(
find.text(
'Protocol mismatch: this page speaks protocol 1, '
'the server reports 2.',
),
findsOneWidget,
reason: 'a mismatched server must stay visibly flagged in Settings',
);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
});
}
await tapBarAction(
tester,
find.byKey(const Key('pipelines-open-settings')),
'Settings',
);
await tester.pump();
await tester.pump();
expect(provider.value.uri.path, '/settings');
expect(find.text('Quick switch animation'), findsOneWidget);
await selectSettingsTopic(tester, 'Connection');
expect(find.text('Server URL'), findsOneWidget);
expect(find.text('Settings — Not implemented'), findsNothing);
expect(sockets, 1);
expect(find.byType(SegmentedBar), findsOneWidget);
final ping = requestOf(channel, 'ping')!;
channel.incoming.add(
jsonEncode({
'id': ping['id'],
'type': 'pong',
'build': {'version': 'settings-fixture'},
'time': 'fixture time',
'protocol': 2,
}),
);
await tester.pump();
await tester.pump();
expect(find.textContaining('settings-fixture'), findsOneWidget);
expect(
find.text(
'Protocol mismatch: this page speaks protocol 1, '
'the server reports 2.',
),
findsOneWidget,
reason: 'a mismatched server must stay visibly flagged in Settings',
);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox.shrink());
await tester.pump();
});
}
@@ -22,7 +22,6 @@ Future<({PlatformRouteInformationProvider provider, FakeChannel channel})>
mount(
WidgetTester tester, {
String route = '/pipelines',
bool cupertino = false,
TabLocationsStore? store,
}) async {
tester.view.physicalSize = const Size(560, 1000);
@@ -39,7 +38,7 @@ mount(
PipelinesApp(
server: webServer(),
client: client,
cupertino: cupertino,
cupertino: false,
serverId: 'navigation-test',
routeInformationProvider: provider,
tabLocationsStore: store,
@@ -58,44 +57,41 @@ Future<void> tab(WidgetTester tester, String name) async {
void main() {
setUp(() => SharedPreferences.setMockInitialValues({}));
for (final cupertino in [false, true]) {
testWidgets(
'Settings is retained inside Pipelines across tab switches ($cupertino)',
(tester) async {
final app = await mount(tester, cupertino: cupertino);
await replyPipelines(tester, app.channel, PipelineFixture());
await tester.pumpAndSettle();
await tapBarAction(
tester,
find.byKey(const Key('pipelines-open-settings')),
'Settings',
);
await tester.pumpAndSettle();
expect(app.provider.value.uri.path, '/settings');
final settingsState = tester.state(find.byType(SettingsScreen));
await tab(tester, 'chat');
expect(app.provider.value.uri.path, '/chat');
await tab(tester, 'pipelines');
expect(app.provider.value.uri.path, '/settings');
expect(tester.state(find.byType(SettingsScreen)), same(settingsState));
await tab(tester, 'pipelines');
expect(
app.provider.value.uri.path,
'/settings',
reason: 'tab retap is not Back',
);
await tester.tap(find.byKey(const ValueKey('shell.back')));
await tester.pump();
await tester.pump(const Duration(milliseconds: 500));
expect(
app.provider.value.uri.path,
'/pipelines',
reason: 'explicit Back still exits Settings',
);
expect(tester.takeException(), isNull);
},
testWidgets('Settings is retained inside Pipelines across tab switches', (
tester,
) async {
final app = await mount(tester);
await replyPipelines(tester, app.channel, PipelineFixture());
await tester.pumpAndSettle();
await tapBarAction(
tester,
find.byKey(const Key('pipelines-open-settings')),
'Settings',
);
}
await tester.pumpAndSettle();
expect(app.provider.value.uri.path, '/settings');
final settingsState = tester.state(find.byType(SettingsScreen));
await tab(tester, 'chat');
expect(app.provider.value.uri.path, '/chat');
await tab(tester, 'pipelines');
expect(app.provider.value.uri.path, '/settings');
expect(tester.state(find.byType(SettingsScreen)), same(settingsState));
await tab(tester, 'pipelines');
expect(
app.provider.value.uri.path,
'/settings',
reason: 'tab retap is not Back',
);
await tester.tap(find.byKey(const ValueKey('shell.back')));
await tester.pump();
await tester.pump(const Duration(milliseconds: 500));
expect(
app.provider.value.uri.path,
'/pipelines',
reason: 'explicit Back still exits Settings',
);
expect(tester.takeException(), isNull);
});
testWidgets(
'per-tab locations survive app recreation; an explicit deep link wins',
(tester) async {
@@ -209,24 +205,19 @@ void main() {
);
expect(tester.takeException(), isNull);
});
for (final cupertino in [false, true]) {
testWidgets('ordinary root with query restores its tab ($cupertino)', (
tester,
) async {
final store = MemoryTabLocationsStore()
..value = const TabLocationsSnapshot(
routes: {AppDestination.pipelines: AppRoute.settings},
);
final app = await mount(
tester,
route: '/?appearance=cupertino',
cupertino: cupertino,
store: store,
testWidgets('ordinary root with query restores its tab', (tester) async {
final store = MemoryTabLocationsStore()
..value = const TabLocationsSnapshot(
routes: {AppDestination.pipelines: AppRoute.settings},
);
await tester.pumpAndSettle();
expect(app.provider.value.uri.path, '/settings');
expect(find.byType(SettingsScreen), findsOneWidget);
expect(tester.takeException(), isNull);
});
}
final app = await mount(
tester,
route: '/?appearance=cupertino',
store: store,
);
await tester.pumpAndSettle();
expect(app.provider.value.uri.path, '/settings');
expect(find.byType(SettingsScreen), findsOneWidget);
expect(tester.takeException(), isNull);
});
}
@@ -1,5 +1,3 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/pipelines/screen.dart';
@@ -52,19 +50,13 @@ FakeGateway archiveGateway(PipelineFixture fixture, {String? refusal}) {
});
}
Future<void> pump(
WidgetTester tester,
FakeGateway gateway, {
bool cupertino = false,
}) async {
Future<void> pump(WidgetTester tester, FakeGateway gateway) async {
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final screen = PipelinesScreen(gateway: gateway);
await tester.pumpWidget(
cupertino ? CupertinoApp(home: screen) : MaterialApp(home: screen),
);
await tester.pumpWidget(MaterialApp(home: screen));
await tester.pumpAndSettle();
}
@@ -161,24 +153,4 @@ void main() {
await tester.pumpAndSettle();
expect(rowNamed('Alpha review'), findsOneWidget);
});
testWidgets('Cupertino archives through the action sheet and alert', (
tester,
) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
try {
final gateway = archiveGateway(PipelineFixture());
await pump(tester, gateway, cupertino: true);
await tester.tap(rowNamed('Beta deploy'));
await tester.pumpAndSettle();
await openMenuItem(tester, 'pipeline-archive');
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
await tester.tap(find.byKey(const Key('pipeline-archive-confirm')));
await tester.pumpAndSettle();
expect(gateway.callsOf('archive_pipeline'), hasLength(1));
expect(rowNamed('Beta deploy'), findsNothing);
} finally {
debugDefaultTargetPlatformOverride = null;
}
});
}
@@ -1,6 +1,5 @@
import 'dart:async';
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';
@@ -21,44 +20,31 @@ class _Gateway implements ApiGateway {
Stream<JsonMap> get frames => const Stream.empty();
}
Widget _host(
_Gateway gateway, {
bool cupertino = false,
String source = '# stage build',
}) {
Widget _host(_Gateway gateway, {String source = '# stage build'}) {
final body = Column(
children: [
const Text('Pipeline source remains available'),
PipelineDefinitionValidation(gateway: gateway, source: source),
],
);
return cupertino
? CupertinoApp(
home: CupertinoPageScaffold(child: SafeArea(child: body)),
)
: MaterialApp(home: Scaffold(body: body));
return MaterialApp(home: Scaffold(body: body));
}
void main() {
for (final cupertino in [false, true]) {
testWidgets(
'definition warnings stay visible on ${cupertino ? 'Cupertino' : 'Material'}',
(tester) async {
final gateway = _Gateway()
..answer = () async => {
'type': 'validated',
'warnings': ['Review prompt exceeds 2000 bytes.', '', 42],
};
await tester.pumpWidget(_host(gateway, cupertino: cupertino));
await tester.pumpAndSettle();
expect(find.text('Definition warnings'), findsOneWidget);
expect(find.text('Review prompt exceeds 2000 bytes.'), findsOneWidget);
expect(find.text('42'), findsNothing);
expect(gateway.calls.single, {'source': '# stage build'});
expect(tester.takeException(), isNull);
},
);
}
testWidgets('definition warnings stay visible', (tester) async {
final gateway = _Gateway()
..answer = () async => {
'type': 'validated',
'warnings': ['Review prompt exceeds 2000 bytes.', '', 42],
};
await tester.pumpWidget(_host(gateway));
await tester.pumpAndSettle();
expect(find.text('Definition warnings'), findsOneWidget);
expect(find.text('Review prompt exceeds 2000 bytes.'), findsOneWidget);
expect(find.text('42'), findsNothing);
expect(gateway.calls.single, {'source': '# stage build'});
expect(tester.takeException(), isNull);
});
testWidgets(
'loading validation never hides detail and a source is checked once',
@@ -1,7 +1,5 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
@@ -211,34 +209,4 @@ void main() {
);
expect(tester.takeException(), isNull);
});
testWidgets('Cupertino keeps the shared row with the same row identity', (
tester,
) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
try {
await tester.pumpWidget(
CupertinoApp(
home: PipelinesScreen(gateway: gatewayFor(PipelineFixture())),
),
);
await tester.pumpAndSettle();
expect(
tester
.widget<AppListRow>(find.byKey(const Key('pipeline-row-1')))
.cupertino,
isTrue,
);
expect(find.text('2 stages · 1 schedule'), findsOneWidget);
expect(find.textContaining('v2 · #'), findsNothing);
expect(find.byKey(const Key('pipeline-avatar-1')), findsOneWidget);
expect(find.byKey(const Key('pipeline-status-1')), findsOneWidget);
} finally {
debugDefaultTargetPlatformOverride = null;
}
});
}
@@ -1,45 +1,35 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_scope_control.dart';
void main() {
for (final cupertino in [false, true]) {
for (final width in [120.0, 500.0]) {
testWidgets(
'native scope remains usable at $width, Cupertino=$cupertino',
(tester) async {
var scope = PipelineScope.all;
final control = StatefulBuilder(
builder: (context, setState) => Center(
child: SizedBox(
width: width,
child: PipelineScopeControl(
scope: scope,
onSelected: (value) => setState(() => scope = value),
),
),
for (final width in [120.0, 500.0]) {
testWidgets('native scope remains usable at $width', (tester) async {
var scope = PipelineScope.all;
final control = StatefulBuilder(
builder: (context, setState) => Center(
child: SizedBox(
width: width,
child: PipelineScopeControl(
scope: scope,
onSelected: (value) => setState(() => scope = value),
),
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: control))
: MaterialApp(home: Scaffold(body: control)),
);
await tester.pumpAndSettle();
if (width == 120) {
await tester.tap(find.byKey(const Key('pipeline-scope')));
await tester.pumpAndSettle();
await tester.tap(find.text('Scheduled').last);
} else {
await tester.tap(find.text('Scheduled'));
}
await tester.pumpAndSettle();
expect(scope, PipelineScope.scheduled);
expect(tester.takeException(), isNull);
},
),
),
);
}
await tester.pumpWidget(MaterialApp(home: Scaffold(body: control)));
await tester.pumpAndSettle();
if (width == 120) {
await tester.tap(find.byKey(const Key('pipeline-scope')));
await tester.pumpAndSettle();
await tester.tap(find.text('Scheduled').last);
} else {
await tester.tap(find.text('Scheduled'));
}
await tester.pumpAndSettle();
expect(scope, PipelineScope.scheduled);
expect(tester.takeException(), isNull);
});
}
testWidgets('wide scope control hugs its labels', (tester) async {
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/pipelines/screen.dart';
@@ -8,68 +7,62 @@ import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'fixtures.dart';
/// The pipeline Summary is flat on both hosts: facts in the shared grid,
/// Schedules with Add as its heading's only action (no body Refresh), and
/// versions as the shared list row.
/// The pipeline Summary is flat: facts in the shared grid, Schedules with Add
/// as its heading's only action (no body Refresh), and versions as the shared
/// list row.
void main() {
for (final cupertino in [false, true]) {
testWidgets('pipeline Summary is a facts grid with flat sections '
'(${cupertino ? 'cupertino' : 'material'})', (tester) async {
final gateway = FakeGateway((type, fields) {
return switch (type) {
'list_pipelines' => pipelineListReply([
pipelineSummary(id: 1, name: 'Alpha review', version: 3),
]),
'list_runs' => runListReply([]),
'get_pipeline' => pipelineDetailReply(
pipelineDetail(
id: 1,
name: 'Alpha review',
version: 3,
latestVersion: 3,
versions: [versionSummary(2), versionSummary(3)],
),
testWidgets('pipeline Summary is a facts grid with flat sections', (
tester,
) async {
final gateway = FakeGateway((type, fields) {
return switch (type) {
'list_pipelines' => pipelineListReply([
pipelineSummary(id: 1, name: 'Alpha review', version: 3),
]),
'list_runs' => runListReply([]),
'get_pipeline' => pipelineDetailReply(
pipelineDetail(
id: 1,
name: 'Alpha review',
version: 3,
latestVersion: 3,
versions: [versionSummary(2), versionSummary(3)],
),
'list_schedules' => {'type': 'schedules', 'schedules': <dynamic>[]},
_ => errorReply('unexpected $type'),
};
});
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final screen = PipelinesScreen(gateway: gateway);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: screen))
: MaterialApp(home: screen),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('pipeline-row-1')));
await tester.pumpAndSettle();
expect(find.byKey(pipelineSummaryFactsKey), findsOneWidget);
// Short facts share a line instead of one label/value row each.
final latest = tester.getRect(
find.byKey(const ValueKey('pipeline-summary-latest-version')),
);
final versionCreated = tester.getRect(
find.byKey(const ValueKey('pipeline-summary-version-created')),
);
expect(versionCreated.top, moreOrLessEquals(latest.top));
expect(versionCreated.left, greaterThan(latest.right));
expect(find.text('Refresh'), findsNothing);
expect(find.text(scheduleAddLabel), findsNothing);
expect(find.byKey(scheduleAddKey), findsOneWidget);
expect(find.byType(CupertinoListSection), findsNothing);
expect(find.byType(ListTile), findsNothing);
final row = tester.widget<AppListRow>(
find.byKey(const Key('pipeline-version-3')),
);
expect(row.selected, isTrue);
expect(row.cupertino, cupertino);
expect(tester.takeException(), isNull);
),
'list_schedules' => {'type': 'schedules', 'schedules': <dynamic>[]},
_ => errorReply('unexpected $type'),
};
});
}
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final screen = PipelinesScreen(gateway: gateway);
await tester.pumpWidget(MaterialApp(home: screen));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('pipeline-row-1')));
await tester.pumpAndSettle();
expect(find.byKey(pipelineSummaryFactsKey), findsOneWidget);
// Short facts share a line instead of one label/value row each.
final latest = tester.getRect(
find.byKey(const ValueKey('pipeline-summary-latest-version')),
);
final versionCreated = tester.getRect(
find.byKey(const ValueKey('pipeline-summary-version-created')),
);
expect(versionCreated.top, moreOrLessEquals(latest.top));
expect(versionCreated.left, greaterThan(latest.right));
expect(find.text('Refresh'), findsNothing);
expect(find.text(scheduleAddLabel), findsNothing);
expect(find.byKey(scheduleAddKey), findsOneWidget);
expect(find.byType(ListTile), findsNothing);
final row = tester.widget<AppListRow>(
find.byKey(const Key('pipeline-version-3')),
);
expect(row.selected, isTrue);
expect(row.cupertino, isFalse);
expect(tester.takeException(), isNull);
});
}
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_tabs.dart';
@@ -26,64 +25,52 @@ void main() {
);
});
for (final cupertino in [false, true]) {
for (final width in [320.0, 390.0, 720.0, 1200.0]) {
testWidgets('floating tabs at $width, 2x, Cupertino=$cupertino', (
tester,
) async {
tester.view.physicalSize = Size(width, 640);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
PipelineDetailTab? selected;
final body = Align(
alignment: Alignment.bottomCenter,
child: PipelineDetailTabs(
selected: PipelineDetailTab.summary,
onSelected: (value) => selected = value,
),
for (final width in [320.0, 390.0, 720.0, 1200.0]) {
testWidgets('floating tabs at $width, 2x', (tester) async {
tester.view.physicalSize = Size(width, 640);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
PipelineDetailTab? selected;
final body = Align(
alignment: Alignment.bottomCenter,
child: PipelineDetailTabs(
selected: PipelineDetailTab.summary,
onSelected: (value) => selected = value,
),
);
Widget scaled(BuildContext context, Widget? child) => MediaQuery(
data: MediaQuery.of(
context,
).copyWith(textScaler: TextScaler.linear(2)),
child: child!,
);
await tester.pumpWidget(
MaterialApp(builder: scaled, home: Scaffold(body: body)),
);
await tester.pumpAndSettle();
// One floating bar of separate round tab buttons.
expect(find.byType(FloatingDestinationBar), findsOneWidget);
final pill = tester.getRect(find.byKey(FloatingDestinationBar.rowKey));
// Sized to its three tabs at the right edge, on a phone as when wide.
expect(pill.right, width - 16);
expect(
pill.width,
FloatingDestinationBar.rowWidth(
cupertino: false,
tabs: PipelineDetailTab.values.length,
),
);
for (final tab in PipelineDetailTab.values) {
final rect = tester.getRect(
find.byKey(ValueKey('pipeline-detail-tab-${tab.name}')),
);
Widget scaled(BuildContext context, Widget? child) => MediaQuery(
data: MediaQuery.of(
context,
).copyWith(textScaler: TextScaler.linear(2)),
child: child!,
);
await tester.pumpWidget(
cupertino
? CupertinoApp(
builder: scaled,
home: CupertinoPageScaffold(child: body),
)
: MaterialApp(
builder: scaled,
home: Scaffold(body: body),
),
);
await tester.pumpAndSettle();
// One floating bar of separate round tab buttons.
expect(find.byType(FloatingDestinationBar), findsOneWidget);
final pill = tester.getRect(find.byKey(FloatingDestinationBar.rowKey));
// Sized to its three tabs at the right edge, on a phone as when wide.
expect(pill.right, width - 16);
expect(
pill.width,
FloatingDestinationBar.rowWidth(
cupertino: cupertino,
tabs: PipelineDetailTab.values.length,
),
);
for (final tab in PipelineDetailTab.values) {
final rect = tester.getRect(
find.byKey(ValueKey('pipeline-detail-tab-${tab.name}')),
);
expect(rect.left, greaterThanOrEqualTo(pill.left), reason: tab.name);
expect(rect.right, lessThanOrEqualTo(pill.right), reason: tab.name);
}
await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
await tester.pumpAndSettle();
expect(selected, PipelineDetailTab.source);
expect(tester.takeException(), isNull);
});
}
expect(rect.left, greaterThanOrEqualTo(pill.left), reason: tab.name);
expect(rect.right, lessThanOrEqualTo(pill.right), reason: tab.name);
}
await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
await tester.pumpAndSettle();
expect(selected, PipelineDetailTab.source);
expect(tester.takeException(), isNull);
});
}
}
@@ -1,15 +1,11 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import '../../native_back.dart';
import 'package:pipelines_app/features/graph/widgets/definition_graph_view.dart';
import 'package:pipelines_app/features/pipelines/pipeline_repository.dart';
import 'package:pipelines_app/features/pipelines/pipelines_controller.dart';
import 'package:pipelines_app/features/pipelines/screen.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_detail_panel.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'fixtures.dart';
import 'test_helpers.dart';
@@ -110,66 +106,6 @@ void main() {
expect(find.byKey(const Key('pipeline-detail')), findsOneWidget);
});
testWidgets('iOS uses Cupertino scaffolds, list tiles and segmented tabs', (
tester,
) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final fixture = PipelineFixture();
try {
await tester.pumpWidget(
CupertinoApp(home: PipelinesScreen(gateway: gatewayFor(fixture))),
);
await tester.pumpAndSettle();
expect(find.byType(CupertinoPageScaffold), findsOneWidget);
// The shared list row, in its Cupertino form.
expect(
tester
.widget<AppListRow>(find.byKey(const Key('pipeline-row-1')))
.cupertino,
isTrue,
);
expect(find.byType(CupertinoActionSheet), findsNothing);
await tester.tap(find.byKey(const Key('pipeline-row-1')));
await tester.pumpAndSettle();
// The tabs are the floating glass Cupertino tab bar.
expect(
find.descendant(
of: find.byKey(const Key('pipeline-detail-tabs')),
matching: find.byType(FloatingDestinationBar),
),
findsOneWidget,
);
// Versions are the shared row in its Cupertino form, flat on the page.
expect(
tester
.widget<AppListRow>(find.byKey(const Key('pipeline-version-1')))
.cupertino,
isTrue,
);
expect(find.byType(CupertinoListSection), findsNothing);
await tester.tap(find.byKey(const Key('pipeline-version-1')));
await tester.pumpAndSettle();
expect(find.text('Viewing v1 (latest v2).'), findsOneWidget);
await tester.tap(find.byKey(const Key('pipeline-detail-tab-source')));
await tester.pump();
expect(
selectableText(
'name: Alpha review\nstages:\n review:\n type: model\n'
'# selected version 1',
),
findsOneWidget,
);
} finally {
debugDefaultTargetPlatformOverride = null;
}
});
testWidgets('3x text in a very short panel keeps the tabs reachable', (
tester,
) async {
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/pipelines/screen.dart';
@@ -136,21 +135,15 @@ void main() {
expect(find.text('Beta deploy'), findsOneWidget);
});
for (final cupertino in [false, true]) {
testWidgets('Schedules opens from the bar (cupertino: $cupertino)', (
tester,
) async {
var opened = 0;
final screen = PipelinesScreen(
gateway: gatewayFor(PipelineFixture()),
onOpenSchedules: () => opened++,
);
await tester.pumpWidget(
cupertino ? CupertinoApp(home: screen) : MaterialApp(home: screen),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('pipelines-open-schedules')));
expect(opened, 1);
});
}
testWidgets('Schedules opens from the bar', (tester) async {
var opened = 0;
final screen = PipelinesScreen(
gateway: gatewayFor(PipelineFixture()),
onOpenSchedules: () => opened++,
);
await tester.pumpWidget(MaterialApp(home: screen));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('pipelines-open-schedules')));
expect(opened, 1);
});
}
@@ -1,7 +1,6 @@
import 'dart:async';
import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
@@ -53,17 +52,14 @@ JsonMap noRun() => {'type': 'run', 'run_detail': null};
Future<void> pumpScreen(
WidgetTester tester,
FakeGateway gateway,
List<int> navigated, {
bool cupertino = false,
}) async {
List<int> navigated,
) async {
tester.view.physicalSize = const Size(1100, 900);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
final screen = PipelinesScreen(gateway: gateway, onRunStarted: navigated.add);
await tester.pumpWidget(
cupertino ? CupertinoApp(home: screen) : MaterialApp(home: screen),
);
await tester.pumpWidget(MaterialApp(home: screen));
await tester.pumpAndSettle();
}
@@ -582,74 +578,6 @@ void main() {
expect(navigated, [86]);
});
testWidgets('the Cupertino host shows the same native prompt and words', (
tester,
) async {
final fixture = PipelineFixture();
final navigated = <int>[];
final gateway = launchGateway(
fixture,
onLaunch: (fields) => acceptedRun(84),
);
await pumpScreen(tester, gateway, navigated, cupertino: true);
await openDetail(tester);
await tester.tap(find.byKey(runPipelineActionKey));
await tester.pumpAndSettle();
expect(find.byType(CupertinoAlertDialog), findsOneWidget);
expect(find.byType(AlertDialog), findsNothing);
expect(find.text('Run Alpha review'), findsOneWidget);
expect(find.text(runPipelinePromptLabel), findsOneWidget);
expect(find.text(runPipelineWorkspaceLabel), findsOneWidget);
expect(find.text(runPipelineNotifyLabel), findsOneWidget);
expect(
find.descendant(
of: find.byType(CupertinoAlertDialog),
matching: find.text(runPipelineConfirmLabel),
),
findsOneWidget,
);
expect(find.text(runPipelineCancelLabel), findsOneWidget);
expect(gateway.callsOf('run_pipeline'), isEmpty);
await tester.tap(find.byKey(runPipelineCancelKey));
await tester.pumpAndSettle();
expect(find.byType(CupertinoAlertDialog), findsNothing);
expect(gateway.callsOf('run_pipeline'), isEmpty);
});
testWidgets('Cupertino field labels and helper use theme label roles', (
tester,
) async {
final fixture = PipelineFixture();
final gateway = launchGateway(
fixture,
onLaunch: (fields) => acceptedRun(87),
);
await pumpScreen(tester, gateway, <int>[], cupertino: true);
await openDetail(tester);
await tester.tap(find.byKey(runPipelineActionKey));
await tester.pumpAndSettle();
final context = tester.element(find.byType(CupertinoAlertDialog));
final theme = CupertinoTheme.of(context);
final labelStyle = theme.textTheme.textStyle;
for (final label in [
runPipelinePromptLabel,
runPipelineWorkspaceLabel,
runPipelineNotifyLabel,
]) {
final style = tester.widget<Text>(find.text(label)).style;
expect(style?.color, labelStyle.color, reason: label);
expect(style?.fontSize, labelStyle.fontSize, reason: label);
}
final helper = tester
.widget<Text>(find.text(runPipelineWorkspaceHelper))
.style;
expect(helper?.color, CupertinoColors.secondaryLabel.resolveFrom(context));
expect(helper?.fontSize, theme.textTheme.tabLabelTextStyle.fontSize);
});
testWidgets('Schedule… leaves the run dialog for the schedule editor', (
tester,
) async {
@@ -1,6 +1,5 @@
import 'dart:async';
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';
@@ -26,20 +25,13 @@ class _ControlledStore extends MemoryServerCatalogStore {
Future<void> _openEditor(
WidgetTester tester,
ServerConnections connections,
bool cupertino, {
ServerConnections connections, {
bool edit = false,
}) async {
final body = SingleChildScrollView(
child: SavedServersSection(connections: connections),
);
await tester.pumpWidget(
cupertino
? CupertinoApp(
home: CupertinoPageScaffold(child: SafeArea(child: body)),
)
: MaterialApp(home: Scaffold(body: body)),
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: body)));
if (edit) await openSavedServerMenu(tester);
await tester.tap(find.text(edit ? 'Edit Home' : 'Add server'));
await tester.pumpAndSettle();
@@ -56,125 +48,114 @@ Future<void> _openEditor(
}
void main() {
for (final cupertino in [false, true]) {
testWidgets('Back cancels an unsaved draft ($cupertino)', (tester) async {
testWidgets('Back cancels an unsaved draft', (tester) async {
final store = _ControlledStore();
final connections = ServerConnections(
store: store,
onSelected: (_) async => fail('Cancel must not select a server'),
);
addTearDown(connections.dispose);
await _openEditor(tester, connections);
await tester.binding.handlePopRoute();
await tester.pumpAndSettle();
expect(find.byKey(const Key('server-profile-name')), findsNothing);
expect(store.writes, isEmpty);
expect(connections.catalog.servers, isEmpty);
});
testWidgets('failed edit keeps draft and blocks duplicate save', (
tester,
) async {
final original = SavedServer.validated(
id: 'home',
name: 'Home',
endpoints: ['wss://home.test/connect'],
);
final store = _ControlledStore(
catalog: ServerCatalog(servers: [original], selectedId: original.id),
)..pending = Completer<bool>();
final activations = <SavedServer?>[];
final connections = ServerConnections(
store: store,
onSelected: (server) async => activations.add(server),
);
addTearDown(connections.dispose);
await connections.load();
await _openEditor(tester, connections, edit: true);
await tester.tap(find.text('Save server'));
await tester.pump();
expect(find.text('Saving server…'), findsOneWidget);
final button = find.widgetWithText(FilledButton, 'Saving server…');
expect(tester.widget<FilledButton>(button).onPressed, isNull);
await tester.tap(find.text('Saving server…'));
await tester.binding.handlePopRoute();
await tester.pump();
expect(find.byKey(const Key('server-profile-name')), findsOneWidget);
expect(store.writes, hasLength(1));
expect(connections.catalog.active?.name, 'Home');
expect(activations, isEmpty);
store.pending!.complete(false);
await tester.pumpAndSettle();
expect(find.textContaining('could not be saved'), findsOneWidget);
final name = tester.widget<EditableText>(
find.descendant(
of: find.byKey(const Key('server-profile-name')),
matching: find.byType(EditableText),
),
);
final addresses = tester.widget<EditableText>(
find.descendant(
of: find.byKey(const Key('server-profile-addresses')),
matching: find.byType(EditableText),
),
);
expect(name.controller.text, 'My home');
expect(addresses.controller.text, contains('ws://192.168.1.2:8083'));
expect(connections.catalog.active?.name, 'Home');
store.pending = null;
await tester.ensureVisible(find.text('Save server'));
await tester.tap(find.text('Save server'));
await tester.pumpAndSettle();
expect(find.byKey(const Key('server-profile-name')), findsNothing);
expect(connections.catalog.active?.name, 'My home');
expect(store.catalog?.active?.endpoints, hasLength(2));
expect(store.writes, hasLength(2));
expect(activations.single?.id, original.id);
expect(tester.takeException(), isNull);
});
testWidgets(
'activation failure retry does not duplicate new profile',
(tester) async {
final store = _ControlledStore();
var attempts = 0;
final connections = ServerConnections(
store: store,
onSelected: (_) async => fail('Cancel must not select a server'),
onSelected: (_) async {
if (++attempts == 1) throw StateError('Connection unavailable');
},
);
addTearDown(connections.dispose);
await _openEditor(tester, connections, cupertino);
await tester.binding.handlePopRoute();
await connections.load();
await _openEditor(tester, connections);
await tester.tap(find.text('Save server'));
await tester.pumpAndSettle();
expect(find.textContaining('Connection unavailable'), findsOneWidget);
expect(find.byKey(const Key('server-profile-name')), findsOneWidget);
expect(store.catalog?.servers, hasLength(1));
final savedId = store.catalog!.servers.single.id;
await tester.ensureVisible(find.text('Save server'));
await tester.tap(find.text('Save server'));
await tester.pumpAndSettle();
expect(attempts, 2);
expect(store.catalog?.servers, hasLength(1));
expect(store.catalog?.servers.single.id, savedId);
expect(find.byKey(const Key('server-profile-name')), findsNothing);
expect(store.writes, isEmpty);
expect(connections.catalog.servers, isEmpty);
});
testWidgets(
'failed edit keeps draft and blocks duplicate save ($cupertino)',
(tester) async {
final original = SavedServer.validated(
id: 'home',
name: 'Home',
endpoints: ['wss://home.test/connect'],
);
final store = _ControlledStore(
catalog: ServerCatalog(servers: [original], selectedId: original.id),
)..pending = Completer<bool>();
final activations = <SavedServer?>[];
final connections = ServerConnections(
store: store,
onSelected: (server) async => activations.add(server),
);
addTearDown(connections.dispose);
await connections.load();
await _openEditor(tester, connections, cupertino, edit: true);
await tester.tap(find.text('Save server'));
await tester.pump();
expect(find.text('Saving server…'), findsOneWidget);
final button = find.widgetWithText(
cupertino ? CupertinoButton : FilledButton,
'Saving server…',
);
expect(
cupertino
? tester.widget<CupertinoButton>(button).onPressed
: tester.widget<FilledButton>(button).onPressed,
isNull,
);
await tester.tap(find.text('Saving server…'));
await tester.binding.handlePopRoute();
await tester.pump();
expect(find.byKey(const Key('server-profile-name')), findsOneWidget);
expect(store.writes, hasLength(1));
expect(connections.catalog.active?.name, 'Home');
expect(activations, isEmpty);
store.pending!.complete(false);
await tester.pumpAndSettle();
expect(find.textContaining('could not be saved'), findsOneWidget);
final name = tester.widget<EditableText>(
find.descendant(
of: find.byKey(const Key('server-profile-name')),
matching: find.byType(EditableText),
),
);
final addresses = tester.widget<EditableText>(
find.descendant(
of: find.byKey(const Key('server-profile-addresses')),
matching: find.byType(EditableText),
),
);
expect(name.controller.text, 'My home');
expect(addresses.controller.text, contains('ws://192.168.1.2:8083'));
expect(connections.catalog.active?.name, 'Home');
store.pending = null;
await tester.ensureVisible(find.text('Save server'));
await tester.tap(find.text('Save server'));
await tester.pumpAndSettle();
expect(find.byKey(const Key('server-profile-name')), findsNothing);
expect(connections.catalog.active?.name, 'My home');
expect(store.catalog?.active?.endpoints, hasLength(2));
expect(store.writes, hasLength(2));
expect(activations.single?.id, original.id);
expect(tester.takeException(), isNull);
},
);
testWidgets(
'activation failure retry does not duplicate new profile ($cupertino)',
(tester) async {
final store = _ControlledStore();
var attempts = 0;
final connections = ServerConnections(
store: store,
onSelected: (_) async {
if (++attempts == 1) throw StateError('Connection unavailable');
},
);
addTearDown(connections.dispose);
await connections.load();
await _openEditor(tester, connections, cupertino);
await tester.tap(find.text('Save server'));
await tester.pumpAndSettle();
expect(find.textContaining('Connection unavailable'), findsOneWidget);
expect(find.byKey(const Key('server-profile-name')), findsOneWidget);
expect(store.catalog?.servers, hasLength(1));
final savedId = store.catalog!.servers.single.id;
await tester.ensureVisible(find.text('Save server'));
await tester.tap(find.text('Save server'));
await tester.pumpAndSettle();
expect(attempts, 2);
expect(store.catalog?.servers, hasLength(1));
expect(store.catalog?.servers.single.id, savedId);
expect(find.byKey(const Key('server-profile-name')), findsNothing);
expect(tester.takeException(), isNull);
},
);
}
expect(tester.takeException(), isNull);
},
);
}
@@ -1,4 +1,3 @@
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';
@@ -108,95 +107,79 @@ void main() {
},
);
for (final cupertino in [false, true]) {
testWidgets('add, edit and select ordered server aliases ($cupertino)', (
tester,
) async {
final calls = <String?>[];
final connections = ServerConnections(
store: MemoryServerCatalogStore(),
onSelected: (s) async => calls.add(s?.id),
);
addTearDown(connections.dispose);
await connections.load();
final body = SingleChildScrollView(
child: SavedServersSection(connections: connections),
);
await tester.pumpWidget(
cupertino
? CupertinoApp(
home: CupertinoPageScaffold(child: SafeArea(child: body)),
)
: MaterialApp(home: Scaffold(body: body)),
);
await tester.tap(find.text('Add server'));
await tester.pumpAndSettle();
await tester.enterText(
find.byKey(const Key('server-profile-name')),
'Home',
);
await tester.enterText(
find.byKey(const Key('server-profile-addresses')),
'wss://tail.example/connect\nws://192.168.1.2:8083/connect',
);
await revealSave(tester);
await tester.tap(find.text('Save server'));
await tester.pumpAndSettle();
expect(connections.catalog.active?.name, 'Home');
expect(connections.catalog.active?.endpoints, [
'wss://tail.example/connect',
'ws://192.168.1.2:8083/connect',
]);
expect(
find.text('Backup address: ws://192.168.1.2:8083/connect'),
findsOneWidget,
);
await openSavedServerMenu(tester);
await tester.tap(find.text('Edit Home'));
await tester.pumpAndSettle();
await tester.enterText(
find.byKey(const Key('server-profile-name')),
'My home',
);
await revealSave(tester);
await tester.tap(find.text('Save server'));
await tester.pumpAndSettle();
expect(connections.catalog.active?.name, 'My home');
expect(calls, hasLength(2));
expect(calls.first, calls.last);
expect(tester.takeException(), isNull);
});
testWidgets('add, edit and select ordered server aliases', (tester) async {
final calls = <String?>[];
final connections = ServerConnections(
store: MemoryServerCatalogStore(),
onSelected: (s) async => calls.add(s?.id),
);
addTearDown(connections.dispose);
await connections.load();
final body = SingleChildScrollView(
child: SavedServersSection(connections: connections),
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: body)));
await tester.tap(find.text('Add server'));
await tester.pumpAndSettle();
await tester.enterText(
find.byKey(const Key('server-profile-name')),
'Home',
);
await tester.enterText(
find.byKey(const Key('server-profile-addresses')),
'wss://tail.example/connect\nws://192.168.1.2:8083/connect',
);
await revealSave(tester);
await tester.tap(find.text('Save server'));
await tester.pumpAndSettle();
expect(connections.catalog.active?.name, 'Home');
expect(connections.catalog.active?.endpoints, [
'wss://tail.example/connect',
'ws://192.168.1.2:8083/connect',
]);
expect(
find.text('Backup address: ws://192.168.1.2:8083/connect'),
findsOneWidget,
);
await openSavedServerMenu(tester);
await tester.tap(find.text('Edit Home'));
await tester.pumpAndSettle();
await tester.enterText(
find.byKey(const Key('server-profile-name')),
'My home',
);
await revealSave(tester);
await tester.tap(find.text('Save server'));
await tester.pumpAndSettle();
expect(connections.catalog.active?.name, 'My home');
expect(calls, hasLength(2));
expect(calls.first, calls.last);
expect(tester.takeException(), isNull);
});
testWidgets('invalid server addresses stay in editor ($cupertino)', (
tester,
) async {
final connections = ServerConnections(
store: MemoryServerCatalogStore(),
onSelected: (_) async {},
);
addTearDown(connections.dispose);
final body = SavedServersSection(connections: connections);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: body))
: MaterialApp(home: Scaffold(body: body)),
);
await tester.tap(find.text('Add server'));
await tester.pumpAndSettle();
await tester.enterText(
find.byKey(const Key('server-profile-name')),
'Home',
);
await tester.enterText(
find.byKey(const Key('server-profile-addresses')),
'not-a-url',
);
await revealSave(tester);
await tester.tap(find.text('Save server'));
await tester.pumpAndSettle();
expect(find.byKey(const Key('server-profile-addresses')), findsOneWidget);
expect(connections.catalog.servers, isEmpty);
expect(find.textContaining('valid URL'), findsOneWidget);
});
}
testWidgets('invalid server addresses stay in editor', (tester) async {
final connections = ServerConnections(
store: MemoryServerCatalogStore(),
onSelected: (_) async {},
);
addTearDown(connections.dispose);
final body = SavedServersSection(connections: connections);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: body)));
await tester.tap(find.text('Add server'));
await tester.pumpAndSettle();
await tester.enterText(
find.byKey(const Key('server-profile-name')),
'Home',
);
await tester.enterText(
find.byKey(const Key('server-profile-addresses')),
'not-a-url',
);
await revealSave(tester);
await tester.tap(find.text('Save server'));
await tester.pumpAndSettle();
expect(find.byKey(const Key('server-profile-addresses')), findsOneWidget);
expect(connections.catalog.servers, isEmpty);
expect(find.textContaining('valid URL'), findsOneWidget);
});
}
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -18,47 +17,31 @@ class _Store implements AnimationSpeedStore {
void main() {
tearDown(() => timeDilation = 1);
for (final cupertino in [false, true]) {
testWidgets(
'native slider updates global speed and Reset restores normal ($cupertino)',
(tester) async {
final store = _Store();
final controller = AnimationSpeedController(store: store);
final section = SettingsAnimationSection(controller: controller);
await tester.pumpWidget(
cupertino
? CupertinoApp(
home: CupertinoPageScaffold(
child: SingleChildScrollView(child: section),
),
)
: MaterialApp(
home: Scaffold(body: SingleChildScrollView(child: section)),
),
);
if (cupertino) {
final slider = tester.widget<CupertinoSlider>(
find.byType(CupertinoSlider),
);
slider.onChanged!(1.8);
slider.onChangeEnd!(1.8);
} else {
final slider = tester.widget<Slider>(find.byType(Slider));
slider.onChanged!(1.8);
slider.onChangeEnd!(1.8);
}
await tester.pump();
expect(find.text('1.8×'), findsWidgets);
expect(timeDilation, closeTo(1 / 1.8, 0.001));
expect(store.saved, 1.8);
await tester.tap(find.text('Reset'));
await tester.pump();
expect(controller.speed, 1);
expect(timeDilation, 1);
expect(store.saved, 1);
expect(tester.takeException(), isNull);
controller.dispose();
},
);
}
testWidgets(
'layout slider updates global speed and Reset restores normal',
(tester) async {
final store = _Store();
final controller = AnimationSpeedController(store: store);
final section = SettingsAnimationSection(controller: controller);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(body: SingleChildScrollView(child: section)),
),
);
final slider = tester.widget<Slider>(find.byType(Slider));
slider.onChanged!(1.8);
slider.onChangeEnd!(1.8);
await tester.pump();
expect(find.text('1.8×'), findsWidgets);
expect(timeDilation, closeTo(1 / 1.8, 0.001));
expect(store.saved, 1.8);
await tester.tap(find.text('Reset'));
await tester.pump();
expect(controller.speed, 1);
expect(timeDilation, 1);
expect(store.saved, 1);
expect(tester.takeException(), isNull);
controller.dispose();
},
);
}
@@ -2,7 +2,6 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/settings/settings_custom_font_actions.dart';
@@ -12,7 +11,6 @@ import 'package:pipelines_app/features/settings/settings_row.dart';
import 'package:pipelines_app/ui/theme/app_font.dart';
import 'package:pipelines_app/ui/theme/app_font_controller.dart';
import 'package:pipelines_app/ui/theme/app_font_store.dart';
import 'package:pipelines_app/ui/theme/custom_fonts/custom_font.dart';
import 'package:pipelines_app/ui/theme/custom_fonts/custom_font_draft.dart';
import 'package:pipelines_app/ui/theme/custom_fonts/custom_font_library.dart';
import 'package:pipelines_app/ui/theme/custom_fonts/font_bytes_store.dart';
@@ -42,7 +40,6 @@ class _Harness {
Future<void> _pump(
WidgetTester tester,
_Harness harness, {
bool cupertino = false,
FontFilePicker? pick,
}) async {
final section = SingleChildScrollView(
@@ -51,11 +48,7 @@ Future<void> _pump(
pickFiles: pick ?? harness.pick,
),
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: section))
: MaterialApp(home: Scaffold(body: section)),
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: section)));
await tester.pumpAndSettle();
}
@@ -243,35 +236,4 @@ void main() {
final row = tester.widget<SettingsRow>(find.byKey(settingsAddFontKey));
expect(row.enabled, isTrue);
});
testWidgets('Cupertino: an added font has the checkmark and options', (
tester,
) async {
final harness = _Harness()..next = <PickedFontFile>[regular];
await _pump(tester, harness, cupertino: true);
await tester.tap(find.text(addCustomFontText));
await tester.pumpAndSettle();
await tester.tap(find.text('Add'));
await tester.pumpAndSettle();
final CustomFont font = harness.fonts.customFonts.single;
final row = find.byKey(settingsFontKey(font));
expect(
find.descendant(
of: row,
matching: find.byIcon(CupertinoIcons.check_mark),
),
findsOneWidget,
);
// The options button is its own control beside the row.
expect(find.bySemanticsLabel(customFontActionsTooltip), findsOneWidget);
await tester.tap(find.byIcon(CupertinoIcons.ellipsis_circle));
await tester.pumpAndSettle();
await tester.tap(find.text(removeCustomFontText));
await tester.pumpAndSettle();
await tester.tap(find.widgetWithText(CupertinoDialogAction, 'Remove'));
await tester.pumpAndSettle();
expect(harness.fonts.customFonts, isEmpty);
expect(harness.fonts.selected, AppFont.system);
});
}
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/notification_service/notification_service_bridge.dart';
@@ -8,7 +7,6 @@ import '../notification_service/fake_notification_service.dart';
Widget _host(
NotificationServiceBridge bridge, {
required bool cupertino,
Future<void> Function()? requestPermission,
}) {
final body = SingleChildScrollView(
@@ -17,59 +15,44 @@ Widget _host(
requestNotificationPermission: requestPermission,
),
);
return cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: body))
: MaterialApp(home: Scaffold(body: body));
return MaterialApp(home: Scaffold(body: body));
}
bool _switchValue(WidgetTester tester, {required bool cupertino}) {
bool _switchValue(WidgetTester tester) {
final tile = find.byKey(DeviceDeliveryKeys.toggle);
if (cupertino) {
return tester
.widget<CupertinoSwitch>(
find.descendant(of: tile, matching: find.byType(CupertinoSwitch)),
)
.value;
}
return tester.widget<SwitchListTile>(tile).value;
}
void main() {
for (final cupertino in [false, true]) {
final style = cupertino ? 'Cupertino' : 'Material';
testWidgets('shows the switch, status and ntfy note', (tester) async {
final service = FakeNotificationService();
await tester.pumpWidget(_host(service));
await tester.pumpAndSettle();
expect(find.text(deviceDeliverySwitchLabel), findsOneWidget);
expect(_switchValue(tester), isTrue);
expect(find.text('Connected'), findsOneWidget);
expect(find.text(deviceDeliveryNote), findsOneWidget);
expect(find.text(deviceDeliveryBatteryLabel), findsOneWidget);
expect(find.byKey(DeviceDeliveryKeys.permission), findsNothing);
});
testWidgets('$style shows the switch, status and ntfy note', (
tester,
) async {
final service = FakeNotificationService();
await tester.pumpWidget(_host(service, cupertino: cupertino));
await tester.pumpAndSettle();
expect(find.text(deviceDeliverySwitchLabel), findsOneWidget);
expect(_switchValue(tester, cupertino: cupertino), isTrue);
expect(find.text('Connected'), findsOneWidget);
expect(find.text(deviceDeliveryNote), findsOneWidget);
expect(find.text(deviceDeliveryBatteryLabel), findsOneWidget);
expect(find.byKey(DeviceDeliveryKeys.permission), findsNothing);
});
testWidgets('$style switching off stops delivery', (tester) async {
final service = FakeNotificationService();
await tester.pumpWidget(_host(service, cupertino: cupertino));
await tester.pumpAndSettle();
await tester.tap(find.byKey(DeviceDeliveryKeys.toggle));
await tester.pumpAndSettle();
expect(service.calls.last.$1, 'setEnabled');
expect(service.calls.last.$2, {'enabled': false});
expect(_switchValue(tester, cupertino: cupertino), isFalse);
expect(find.text('Off'), findsOneWidget);
// The grants only matter while delivery is on.
expect(find.text(deviceDeliveryBatteryLabel), findsNothing);
});
}
testWidgets('switching off stops delivery', (tester) async {
final service = FakeNotificationService();
await tester.pumpWidget(_host(service));
await tester.pumpAndSettle();
await tester.tap(find.byKey(DeviceDeliveryKeys.toggle));
await tester.pumpAndSettle();
expect(service.calls.last.$1, 'setEnabled');
expect(service.calls.last.$2, {'enabled': false});
expect(_switchValue(tester), isFalse);
expect(find.text('Off'), findsOneWidget);
// The grants only matter while delivery is on.
expect(find.text(deviceDeliveryBatteryLabel), findsNothing);
});
testWidgets('live status pushed by the service is shown', (tester) async {
final service = FakeNotificationService();
await tester.pumpWidget(_host(service, cupertino: false));
await tester.pumpWidget(_host(service));
await tester.pumpAndSettle();
service.push(service.copy(state: DeliveryState.reconnecting));
await tester.pumpAndSettle();
@@ -80,7 +63,7 @@ void main() {
tester,
) async {
final service = FakeNotificationService();
await tester.pumpWidget(_host(service, cupertino: false));
await tester.pumpWidget(_host(service));
await tester.pumpAndSettle();
await tester.tap(find.text(deviceDeliveryBatteryLabel));
await tester.pumpAndSettle();
@@ -103,7 +86,6 @@ void main() {
await tester.pumpWidget(
_host(
service,
cupertino: false,
requestPermission: () async {
asked++;
service.current = service.copy(notificationsAllowed: true);
@@ -128,7 +110,7 @@ void main() {
notificationsAllowed: false,
);
await tester.pumpWidget(
_host(service, cupertino: false, requestPermission: () async => asked++),
_host(service, requestPermission: () async => asked++),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(DeviceDeliveryKeys.toggle));
@@ -139,7 +121,7 @@ void main() {
});
testWidgets('a failing platform is reported, not hidden', (tester) async {
await tester.pumpWidget(_host(_FailingService(), cupertino: false));
await tester.pumpWidget(_host(_FailingService()));
await tester.pumpAndSettle();
expect(find.byKey(DeviceDeliveryKeys.error), findsOneWidget);
});
@@ -1,6 +1,5 @@
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/settings/settings_font_section.dart';
@@ -29,19 +28,11 @@ class _Harness {
);
}
Future<void> _pump(
WidgetTester tester,
_Harness harness, {
bool cupertino = false,
}) async {
Future<void> _pump(WidgetTester tester, _Harness harness) async {
final section = SingleChildScrollView(
child: SettingsFontSection(controller: harness.fonts),
);
await tester.pumpWidget(
cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: section))
: MaterialApp(home: Scaffold(body: section)),
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: section)));
await tester.pumpAndSettle();
}
@@ -102,28 +93,6 @@ void main() {
expect(harness.fonts.family, 'Source Sans 3');
});
testWidgets('Cupertino: the chosen row carries the checkmark', (
tester,
) async {
final harness = _Harness();
await _pump(tester, harness, cupertino: true);
expect(find.byType(RadioListTile<FontChoice>), findsNothing);
expect(_familyOf(tester, AppFont.system), 'CupertinoSystemText');
Finder check(AppFont font) => find.descendant(
of: find.byKey(settingsFontKey(font)),
matching: find.byIcon(CupertinoIcons.check_mark),
);
expect(check(AppFont.system), findsOneWidget);
await tester.tap(find.text('Inter'));
await tester.pumpAndSettle();
expect(check(AppFont.system), findsNothing);
expect(check(AppFont.inter), findsOneWidget);
expect(harness.store.id, AppFont.inter.id);
expect(harness.fonts.family, 'Inter');
});
testWidgets('a failed save is said under the group', (tester) async {
final harness = _Harness();
harness.store.failSaves = true;
@@ -1,4 +1,3 @@
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';
@@ -15,7 +14,6 @@ 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';
import 'settings_topic_test_helper.dart';
@@ -94,29 +92,6 @@ void main() {
);
});
testWidgets('Cupertino uses inset-grouped sections on the grouped page', (
tester,
) async {
await _pump(tester, cupertino: true);
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,
);
});
testWidgets('the notification tile is the section\'s only title', (
tester,
) async {
@@ -131,77 +106,54 @@ void main() {
expect(find.text('Connection').last, findsOneWidget);
});
testWidgets('Cupertino keeps the compact secondary field label', (
tester,
) async {
await _pump(tester, cupertino: true);
final label = tester.widget<Text>(find.text('Server URL'));
final context = tester.element(find.text('Server URL'));
expect(
label.style?.color,
CupertinoColors.secondaryLabel.resolveFrom(context),
testWidgets('server rows show which server is selected', (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 {},
);
expect(find.byType(CupertinoTextField), findsNWidgets(2));
addTearDown(connections.dispose);
await connections.load();
final body = SingleChildScrollView(
child: SavedServersSection(connections: connections),
);
await tester.pumpWidget(MaterialApp(home: Scaffold(body: body)));
expect(find.byType(SavedServerRow), findsNWidgets(2));
expect(find.text('Pipelines and runs server'), findsOneWidget);
expect(
find.byWidgetPredicate(
(widget) => widget is Icon && widget.semanticLabel == 'Selected',
),
findsOneWidget,
);
expect(find.text('Address: 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');
});
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('Pipelines and runs server'), findsOneWidget);
expect(
find.byWidgetPredicate(
(widget) => widget is Icon && widget.semanticLabel == 'Selected',
),
findsOneWidget,
);
expect(find.text('Address: 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, {
bool cupertino = false,
NotificationController? notifications,
Size size = const Size(800, 1600),
double topPadding = 0,
@@ -224,15 +176,10 @@ Future<void> _pump(
child: child!,
);
await tester.pumpWidget(
cupertino
? CupertinoApp(
builder: padded,
home: CupertinoPageScaffold(child: screen),
)
: MaterialApp(
builder: padded,
home: Scaffold(body: screen),
),
MaterialApp(
builder: padded,
home: Scaffold(body: screen),
),
);
await tester.pump();
await tester.pump();
@@ -1,6 +1,5 @@
import 'dart:async';
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';
@@ -33,120 +32,96 @@ JsonMap _reply(bool run, bool needs, bool reply) => {
},
};
Widget _host(ApiGateway gateway, {required bool cupertino}) {
Widget _host(ApiGateway gateway) {
final body = SingleChildScrollView(
child: SettingsNtfySection(gateway: gateway, connected: true),
);
return cupertino
? CupertinoApp(home: CupertinoPageScaffold(child: body))
: MaterialApp(home: Scaffold(body: body));
return MaterialApp(home: Scaffold(body: body));
}
bool _checked(WidgetTester tester, String key, {required bool cupertino}) {
bool _checked(WidgetTester tester, String key) {
final tile = find.byKey(ntfySettingKey(key));
if (cupertino) {
return tester
.widget<CupertinoSwitch>(
find.descendant(of: tile, matching: find.byType(CupertinoSwitch)),
)
.value;
}
return tester.widget<CheckboxListTile>(tile).value!;
}
void main() {
for (final cupertino in [false, true]) {
final style = cupertino ? 'Cupertino' : 'Material';
testWidgets('loads the stored values', (tester) async {
final gateway = _Gateway((_, _) => _reply(true, false, true));
await tester.pumpWidget(_host(gateway));
await tester.pumpAndSettle();
expect(gateway.calls.single.$1, 'notification_settings');
expect(find.text('Notify when any run ends'), findsOneWidget);
expect(
find.text('Otherwise only runs started with Notify me'),
findsOneWidget,
);
expect(find.text('Chat needs your answer or approval'), findsOneWidget);
expect(find.text('Chat reply finished'), findsOneWidget);
expect(find.text(ntfySectionSubtitle), findsOneWidget);
expect(_checked(tester, 'run_finished'), isTrue);
expect(_checked(tester, 'chat_needs_you'), isFalse);
expect(_checked(tester, 'chat_reply_finished'), isTrue);
});
testWidgets('$style loads the stored values', (tester) async {
final gateway = _Gateway((_, _) => _reply(true, false, true));
await tester.pumpWidget(_host(gateway, cupertino: cupertino));
await tester.pumpAndSettle();
expect(gateway.calls.single.$1, 'notification_settings');
expect(find.text('Notify when any run ends'), findsOneWidget);
expect(
find.text('Otherwise only runs started with Notify me'),
findsOneWidget,
);
expect(find.text('Chat needs your answer or approval'), findsOneWidget);
expect(find.text('Chat reply finished'), findsOneWidget);
expect(find.text(ntfySectionSubtitle), findsOneWidget);
expect(_checked(tester, 'run_finished', cupertino: cupertino), isTrue);
expect(_checked(tester, 'chat_needs_you', cupertino: cupertino), isFalse);
expect(
_checked(tester, 'chat_reply_finished', cupertino: cupertino),
isTrue,
);
});
testWidgets('shows the server default: only marked runs', (tester) async {
// The server's defaults: run ends notify only for "Notify me" runs.
final gateway = _Gateway((_, _) => _reply(false, true, false));
await tester.pumpWidget(_host(gateway));
await tester.pumpAndSettle();
expect(_checked(tester, 'run_finished'), isFalse);
expect(_checked(tester, 'chat_needs_you'), isTrue);
expect(_checked(tester, 'chat_reply_finished'), isFalse);
});
testWidgets('$style shows the server default: only marked runs', (
tester,
) async {
// The server's defaults: run ends notify only for "Notify me" runs.
final gateway = _Gateway((_, _) => _reply(false, true, false));
await tester.pumpWidget(_host(gateway, cupertino: cupertino));
await tester.pumpAndSettle();
expect(_checked(tester, 'run_finished', cupertino: cupertino), isFalse);
expect(_checked(tester, 'chat_needs_you', cupertino: cupertino), isTrue);
expect(
_checked(tester, 'chat_reply_finished', cupertino: cupertino),
isFalse,
);
testWidgets('toggling writes only that setting', (tester) async {
final gateway = _Gateway((type, fields) {
if (type == 'set_notification_settings') {
return _reply(true, true, true);
}
return _reply(true, true, false);
});
await tester.pumpWidget(_host(gateway));
await tester.pumpAndSettle();
await tester.tap(find.byKey(ntfySettingKey('chat_reply_finished')));
await tester.pumpAndSettle();
expect(gateway.calls, hasLength(2));
expect(gateway.calls.last.$1, 'set_notification_settings');
expect(gateway.calls.last.$2, {
'notification_settings': {'chat_reply_finished': true},
});
expect(_checked(tester, 'chat_reply_finished'), isTrue);
expect(find.byKey(ntfyErrorKey), findsNothing);
});
testWidgets('$style toggling writes only that setting', (tester) async {
final gateway = _Gateway((type, fields) {
if (type == 'set_notification_settings') {
return _reply(true, true, true);
}
return _reply(true, true, false);
});
await tester.pumpWidget(_host(gateway, cupertino: cupertino));
await tester.pumpAndSettle();
await tester.tap(find.byKey(ntfySettingKey('chat_reply_finished')));
await tester.pumpAndSettle();
expect(gateway.calls, hasLength(2));
expect(gateway.calls.last.$1, 'set_notification_settings');
expect(gateway.calls.last.$2, {
'notification_settings': {'chat_reply_finished': true},
});
expect(
_checked(tester, 'chat_reply_finished', cupertino: cupertino),
isTrue,
);
expect(find.byKey(ntfyErrorKey), findsNothing);
testWidgets('failure reverts and shows the refusal', (tester) async {
final pending = Completer<JsonMap>();
final gateway = _Gateway((type, _) {
if (type == 'set_notification_settings') return pending.future;
return _reply(true, true, false);
});
testWidgets('$style failure reverts and shows the refusal', (tester) async {
final pending = Completer<JsonMap>();
final gateway = _Gateway((type, _) {
if (type == 'set_notification_settings') return pending.future;
return _reply(true, true, false);
});
await tester.pumpWidget(_host(gateway, cupertino: cupertino));
await tester.pumpAndSettle();
await tester.tap(find.byKey(ntfySettingKey('run_finished')));
await tester.pump();
// The change shows at once and the group is disabled while it saves.
expect(_checked(tester, 'run_finished', cupertino: cupertino), isFalse);
await tester.tap(find.byKey(ntfySettingKey('chat_needs_you')));
await tester.pump();
expect(gateway.calls, hasLength(2));
pending.completeError(const ProtocolError('settings are read-only'));
await tester.pumpAndSettle();
expect(_checked(tester, 'run_finished', cupertino: cupertino), isTrue);
expect(_checked(tester, 'chat_needs_you', cupertino: cupertino), isTrue);
expect(
find.text('Could not save: settings are read-only'),
findsOneWidget,
);
});
}
await tester.pumpWidget(_host(gateway));
await tester.pumpAndSettle();
await tester.tap(find.byKey(ntfySettingKey('run_finished')));
await tester.pump();
// The change shows at once and the group is disabled while it saves.
expect(_checked(tester, 'run_finished'), isFalse);
await tester.tap(find.byKey(ntfySettingKey('chat_needs_you')));
await tester.pump();
expect(gateway.calls, hasLength(2));
pending.completeError(const ProtocolError('settings are read-only'));
await tester.pumpAndSettle();
expect(_checked(tester, 'run_finished'), isTrue);
expect(_checked(tester, 'chat_needs_you'), isTrue);
expect(
find.text('Could not save: settings are read-only'),
findsOneWidget,
);
});
testWidgets('disabled while loading and offline', (tester) async {
final pending = Completer<JsonMap>();
final gateway = _Gateway((_, _) => pending.future);
await tester.pumpWidget(_host(gateway, cupertino: false));
await tester.pumpWidget(_host(gateway));
await tester.pump();
expect(find.text('Loading…'), findsOneWidget);
await tester.tap(find.byKey(ntfySettingKey('run_finished')));
@@ -181,7 +156,7 @@ void main() {
if (fail) throw const ProtocolError('no store');
return _reply(false, true, false);
});
await tester.pumpWidget(_host(gateway, cupertino: false));
await tester.pumpWidget(_host(gateway));
await tester.pumpAndSettle();
expect(
find.text('Could not load notification settings: no store'),
@@ -210,38 +185,27 @@ void main() {
testWidgets('hidden when the server does not send it', (tester) async {
final gateway = _Gateway((_, _) => _reply(true, true, false));
await tester.pumpWidget(_host(gateway, cupertino: false));
await tester.pumpWidget(_host(gateway));
await tester.pumpAndSettle();
expect(find.byKey(ntfySettingKey('ntfy_enabled')), findsNothing);
expect(find.text(ntfySectionSubtitle), findsOneWidget);
});
for (final cupertino in [false, true]) {
testWidgets(
'${cupertino ? 'Cupertino' : 'Material'} shows and writes it',
(tester) async {
final gateway = _Gateway(
(type, _) => withNtfy(type == 'set_notification_settings'),
);
await tester.pumpWidget(_host(gateway, cupertino: cupertino));
await tester.pumpAndSettle();
expect(find.text('Also send to ntfy'), findsOneWidget);
expect(find.text(ntfySectionAppSubtitle), findsOneWidget);
expect(
_checked(tester, 'ntfy_enabled', cupertino: cupertino),
isFalse,
);
await tester.tap(find.byKey(ntfySettingKey('ntfy_enabled')));
await tester.pumpAndSettle();
expect(gateway.calls.last.$2, {
'notification_settings': {'ntfy_enabled': true},
});
expect(
_checked(tester, 'ntfy_enabled', cupertino: cupertino),
isTrue,
);
},
testWidgets('shows and writes it', (tester) async {
final gateway = _Gateway(
(type, _) => withNtfy(type == 'set_notification_settings'),
);
}
await tester.pumpWidget(_host(gateway));
await tester.pumpAndSettle();
expect(find.text('Also send to ntfy'), findsOneWidget);
expect(find.text(ntfySectionAppSubtitle), findsOneWidget);
expect(_checked(tester, 'ntfy_enabled'), isFalse);
await tester.tap(find.byKey(ntfySettingKey('ntfy_enabled')));
await tester.pumpAndSettle();
expect(gateway.calls.last.$2, {
'notification_settings': {'ntfy_enabled': true},
});
expect(_checked(tester, 'ntfy_enabled'), isTrue);
});
});
}
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/settings/settings_animation_section.dart';
@@ -18,55 +17,42 @@ class _Store implements QuickSwitchAnimationStore {
}
void main() {
for (final cupertino in [false, true]) {
testWidgets('chooses and saves quick switch animation ($cupertino)', (
tester,
) async {
final store = _Store();
final controller = QuickSwitchAnimationController(store: store);
final speed = AnimationSpeedController();
final child = SettingsAnimationSection(
controller: speed,
quickSwitchController: controller,
);
await tester.pumpWidget(
cupertino
? CupertinoApp(
home: CupertinoPageScaffold(
child: SingleChildScrollView(child: child),
),
)
: MaterialApp(
home: Scaffold(body: SingleChildScrollView(child: child)),
),
);
expect(find.text('Quick switch animation'), findsOneWidget);
expect(
cupertino ? find.byType(CupertinoSlider) : find.byType(Slider),
findsOneWidget,
);
await tester.tap(find.text('Tape'));
await tester.pumpAndSettle();
await tester.tap(find.text('Card deck').last);
await tester.pumpAndSettle();
expect(controller.value, QuickSwitchAnimation.cardStack);
expect(store.saved, 'cardStack');
expect(
find.text(QuickSwitchAnimation.cardStack.description),
findsOneWidget,
);
store.success = false;
await tester.tap(find.text('Card deck'));
await tester.pumpAndSettle();
await tester.tap(find.text('Swap').last);
await tester.pumpAndSettle();
expect(
find.text('Could not save; applies until reload.'),
findsOneWidget,
);
expect(tester.takeException(), isNull);
controller.dispose();
speed.dispose();
});
}
testWidgets('chooses and saves quick switch animation', (tester) async {
final store = _Store();
final controller = QuickSwitchAnimationController(store: store);
final speed = AnimationSpeedController();
final child = SettingsAnimationSection(
controller: speed,
quickSwitchController: controller,
);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(body: SingleChildScrollView(child: child)),
),
);
expect(find.text('Quick switch animation'), findsOneWidget);
expect(find.byType(Slider), findsOneWidget);
await tester.tap(find.text('Tape'));
await tester.pumpAndSettle();
await tester.tap(find.text('Card deck').last);
await tester.pumpAndSettle();
expect(controller.value, QuickSwitchAnimation.cardStack);
expect(store.saved, 'cardStack');
expect(
find.text(QuickSwitchAnimation.cardStack.description),
findsOneWidget,
);
store.success = false;
await tester.tap(find.text('Card deck'));
await tester.pumpAndSettle();
await tester.tap(find.text('Swap').last);
await tester.pumpAndSettle();
expect(
find.text('Could not save; applies until reload.'),
findsOneWidget,
);
expect(tester.takeException(), isNull);
controller.dispose();
speed.dispose();
});
}
@@ -11,7 +11,6 @@ import 'package:pipelines_app/features/settings/settings_store.dart';
import 'fake_channel.dart';
import 'settings_topic_test_helper.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
void main() {
testWidgets('renders idle settings without opening a connection', (
@@ -258,23 +257,6 @@ void main() {
expect(find.byKey(SettingsKeys.connect), findsOneWidget);
});
testWidgets('an explicit Cupertino host uses Cupertino fields and buttons', (
tester,
) async {
final factory = FakeChannelFactory();
final client = transport.PipelinesClient(channelFactory: factory.call);
addTearDown(client.dispose);
await _pump(tester, client, cupertino: true);
expect(find.byType(SegmentedBar), findsOneWidget);
expect(find.byType(CupertinoTextField), findsNWidgets(2));
expect(find.byType(TextField), findsNothing);
expect(find.byType(FilledButton), findsNothing);
expect(find.byKey(SettingsKeys.connect), findsOneWidget);
expect(find.text('Trusted LAN/VPN only'), findsOneWidget);
});
testWidgets('narrow window with large text scrolls without overflow', (
tester,
) async {
@@ -375,26 +357,11 @@ Future<void> _pump(
transport.PipelinesClient client, {
SettingsStore? store,
TargetPlatform platform = TargetPlatform.android,
bool cupertino = false,
double textScale = 1,
Size size = const Size(800, 1200),
}) async {
await tester.binding.setSurfaceSize(size);
addTearDown(() => tester.binding.setSurfaceSize(null));
if (cupertino) {
await tester.pumpWidget(
CupertinoApp(
home: SettingsScreen(
client: client,
store: store ?? MemorySettingsStore(),
),
),
);
await tester.pump();
await tester.pump();
await selectSettingsTopic(tester, 'Connection');
return;
}
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(platform: platform),