Merge branch 'worktree-agent-aab11f4f1fe3dff6b' into integrate/r3-rest
This commit is contained in:
@@ -83,10 +83,10 @@ class _TemplatesDestinationState extends State<TemplatesDestination> {
|
||||
// behind the bar and pad their own content by its height.
|
||||
final page = SafeArea(top: false, bottom: false, child: body);
|
||||
if (cupertino) {
|
||||
// Inset-grouped rows on the grouped background, as in Settings; the
|
||||
// Plain list rows on the page background, like the other lists; the
|
||||
// bar's scrim takes the same colour.
|
||||
return CupertinoPageScaffold(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
backgroundColor: AppColors.background,
|
||||
navigationBar: _BarSlot(cupertino: true, child: bar),
|
||||
child: page,
|
||||
);
|
||||
@@ -115,6 +115,7 @@ class _TemplatesDestinationState extends State<TemplatesDestination> {
|
||||
onPressed: widget.onBack,
|
||||
),
|
||||
title: spec?.title ?? 'Templates',
|
||||
subtitle: spec?.subtitle,
|
||||
actions: spec?.actions ?? const [],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/// The viewer's words for a preview that could not be fetched.
|
||||
///
|
||||
/// The operator sees what happened in plain language and can retry; the raw
|
||||
/// exception text (`TypeError: Failed to fetch`) and bare status lines
|
||||
/// (`The server answered 404.`) never reach the screen. [status] is the HTTP
|
||||
/// status the server answered, or null when no answer arrived at all.
|
||||
String artifactPreviewFailureMessage({int? status}) {
|
||||
if (status == null) {
|
||||
return 'The preview could not be loaded. Check the connection and try '
|
||||
'again.';
|
||||
}
|
||||
if (status == 404 || status == 410) {
|
||||
return 'This file is no longer on the server.';
|
||||
}
|
||||
if (status == 401 || status == 403) {
|
||||
return 'The server did not allow this file to be opened.';
|
||||
}
|
||||
if (status >= 500) {
|
||||
return 'The server could not send this file right now.';
|
||||
}
|
||||
return 'The preview could not be loaded (status $status).';
|
||||
}
|
||||
@@ -41,8 +41,12 @@ class ArtifactViewerBody extends StatelessWidget {
|
||||
this.bytes,
|
||||
this.error,
|
||||
this.status,
|
||||
this.onRetry,
|
||||
});
|
||||
|
||||
/// Loads the current page's preview again after a failure.
|
||||
final VoidCallback? onRetry;
|
||||
|
||||
final PagedArtifact page;
|
||||
final ArtifactPreviewPlan plan;
|
||||
final int index;
|
||||
@@ -76,6 +80,7 @@ class ArtifactViewerBody extends StatelessWidget {
|
||||
text: text,
|
||||
bytes: bytes,
|
||||
error: error,
|
||||
onRetry: onRetry,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
import '../domain/artifact_preview.dart';
|
||||
import 'artifact_html_view.dart';
|
||||
import 'artifact_table_view.dart';
|
||||
@@ -35,8 +38,12 @@ class ArtifactPreviewBody extends StatelessWidget {
|
||||
this.error,
|
||||
this.videoControllerFactory = defaultArtifactVideoController,
|
||||
this.htmlBuilder = defaultArtifactHtml,
|
||||
this.onRetry,
|
||||
});
|
||||
|
||||
/// Offered under a fetch failure; absent, the message stands alone.
|
||||
final VoidCallback? onRetry;
|
||||
|
||||
final ArtifactPreviewPlan plan;
|
||||
final bool loading;
|
||||
final ArtifactMarkdownBuilder markdownBuilder;
|
||||
@@ -60,7 +67,7 @@ class ArtifactPreviewBody extends StatelessWidget {
|
||||
return const _Loading();
|
||||
}
|
||||
if (error != null) {
|
||||
return _Message(error!);
|
||||
return _Message(error!, onRetry: onRetry);
|
||||
}
|
||||
switch (plan.kind) {
|
||||
case ArtifactPreviewKind.image:
|
||||
@@ -201,17 +208,42 @@ class _PreviewPadding extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
const artifactPreviewRetryKey = Key('artifact-preview-retry');
|
||||
|
||||
class _Message extends StatelessWidget {
|
||||
const _Message(this.message);
|
||||
const _Message(this.message, {this.onRetry});
|
||||
|
||||
final String message;
|
||||
final VoidCallback? onRetry;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final retry = onRetry;
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Text(message, textAlign: TextAlign.center),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(message, textAlign: TextAlign.center),
|
||||
if (retry != null) ...[
|
||||
const SizedBox(height: 12),
|
||||
cupertino
|
||||
? CupertinoButton.tinted(
|
||||
key: artifactPreviewRetryKey,
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
onPressed: retry,
|
||||
child: const Text('Retry'),
|
||||
)
|
||||
: FilledButton.tonal(
|
||||
key: artifactPreviewRetryKey,
|
||||
onPressed: retry,
|
||||
child: const Text('Retry'),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import 'artifact_selection_facts.dart';
|
||||
import '../actions/artifact_file_bridge.dart';
|
||||
import '../domain/artifact_groups.dart';
|
||||
import '../domain/artifact_preview.dart';
|
||||
import '../domain/artifact_preview_failure.dart';
|
||||
import '../domain/artifact_url.dart';
|
||||
import '../domain/gallery_navigation.dart';
|
||||
import 'artifact_external_open.dart';
|
||||
@@ -157,7 +158,7 @@ class _ArtifactViewerPageState extends State<ArtifactViewerPage> {
|
||||
if (!result.ok) {
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_error = 'The server answered ${result.status}.';
|
||||
_error = artifactPreviewFailureMessage(status: result.status);
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -168,11 +169,11 @@ class _ArtifactViewerPageState extends State<ArtifactViewerPage> {
|
||||
_fetched = fetched;
|
||||
});
|
||||
},
|
||||
onError: (Object error) {
|
||||
onError: (Object _) {
|
||||
if (!mounted || generation != _generation) return;
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_error = 'Could not load preview: $error';
|
||||
_error = artifactPreviewFailureMessage();
|
||||
});
|
||||
},
|
||||
);
|
||||
@@ -259,6 +260,8 @@ class _ArtifactViewerPageState extends State<ArtifactViewerPage> {
|
||||
fileBridge: widget.fileBridge,
|
||||
onPrevious: () => _step(-1),
|
||||
onNext: () => _step(1),
|
||||
// A failure is never cached, so loading again fetches afresh.
|
||||
onRetry: _beginLoad,
|
||||
onOpen: plan.resolved == null ? () {} : () => _open(plan.resolved!),
|
||||
onCopy: plan.resolved == null ? () {} : () => _copy(plan.resolved!),
|
||||
);
|
||||
|
||||
@@ -67,6 +67,9 @@ const notificationRationale =
|
||||
const notificationSectionTitle = 'Notifications';
|
||||
const notificationRequestLabel = 'Enable notifications';
|
||||
|
||||
/// The compact row's visible action; [notificationRequestLabel] is its name.
|
||||
const notificationEnableShortLabel = 'Enable';
|
||||
|
||||
/// The honest wording for every state, verbatim from `web/src/notify.js`; each
|
||||
/// says plainly that the in-app `Needs you` surface is the only channel when the
|
||||
/// platform cannot notify.
|
||||
@@ -100,13 +103,21 @@ class NotificationPermissionView {
|
||||
const NotificationPermissionView({
|
||||
required this.state,
|
||||
required this.body,
|
||||
required this.headline,
|
||||
required this.helper,
|
||||
required this.canRequest,
|
||||
required this.actionLabel,
|
||||
required this.asked,
|
||||
});
|
||||
|
||||
final NotificationPermissionState state;
|
||||
|
||||
/// The browser's full sentence for the state (read out with the row).
|
||||
final String body;
|
||||
|
||||
/// The compact Settings row: a short state line and one short helper.
|
||||
final String headline;
|
||||
final String helper;
|
||||
final bool canRequest;
|
||||
final String? actionLabel;
|
||||
final bool asked;
|
||||
@@ -126,9 +137,39 @@ NotificationPermissionView notificationPermissionView(
|
||||
NotificationPermissionState.notRequested =>
|
||||
asked ? notificationDefaultAskedCopy : notificationDefaultCopy,
|
||||
};
|
||||
final (headline, helper) = switch (state) {
|
||||
NotificationPermissionState.unsupported => (
|
||||
'Not supported in this browser',
|
||||
'Runs that need you still appear in Needs you.',
|
||||
),
|
||||
NotificationPermissionState.needsSecureContext => (
|
||||
'Needs a secure page',
|
||||
'Open the app over https or localhost to turn them on.',
|
||||
),
|
||||
NotificationPermissionState.granted => (
|
||||
'Alerts are on',
|
||||
'Failed and waiting runs raise a notification.',
|
||||
),
|
||||
NotificationPermissionState.denied => (
|
||||
'Blocked by the browser',
|
||||
'Allow them in the site settings; Needs you still works.',
|
||||
),
|
||||
NotificationPermissionState.notRequested =>
|
||||
asked
|
||||
? (
|
||||
'Alerts are still off',
|
||||
'Permission was not granted. Ask again, or use Needs you.',
|
||||
)
|
||||
: (
|
||||
'Alerts are off',
|
||||
'Get told when a run fails or needs your decision.',
|
||||
),
|
||||
};
|
||||
return NotificationPermissionView(
|
||||
state: state,
|
||||
body: body,
|
||||
headline: headline,
|
||||
helper: helper,
|
||||
canRequest: canRequest,
|
||||
actionLabel: canRequest ? notificationRequestLabel : null,
|
||||
asked: asked,
|
||||
|
||||
@@ -4,7 +4,6 @@ import '../domain/attention_models.dart';
|
||||
const attentionSheetTitle = 'Needs you';
|
||||
const attentionEmptyCopy = 'Nothing needs you right now.';
|
||||
const attentionClearAllCopy = 'Clear all';
|
||||
const attentionCloseCopy = 'Close';
|
||||
|
||||
/// One row's dismissal name.
|
||||
///
|
||||
|
||||
@@ -12,6 +12,9 @@ const attentionSheetKey = ValueKey<String>('attention-sheet');
|
||||
/// The honest empty line shown when the open snapshot has no entries.
|
||||
const attentionEmptyKey = ValueKey<String>('attention-empty');
|
||||
|
||||
/// The header's Done action, which closes the sheet on both hosts.
|
||||
const attentionDoneKey = ValueKey<String>('attention-done');
|
||||
|
||||
/// The bulk dismissal action, present only while the snapshot has entries.
|
||||
const attentionClearAllKey = ValueKey<String>('attention-clear-all');
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../../../ui/layout/app_sheet_header.dart';
|
||||
import 'attention_status_icon.dart';
|
||||
import '../domain/attention_models.dart';
|
||||
import 'needs_you_copy.dart';
|
||||
@@ -65,25 +66,12 @@ class CupertinoNeedsYouSheet extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(20, 16, 8, 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Semantics(
|
||||
header: true,
|
||||
namesRoute: true,
|
||||
child: Text(
|
||||
attentionSheetTitle,
|
||||
style: theme.textTheme.navTitleTextStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: () => _close(context),
|
||||
child: const Text(attentionCloseCopy),
|
||||
),
|
||||
],
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: AppSheetHeader(
|
||||
title: attentionSheetTitle,
|
||||
cupertino: true,
|
||||
doneKey: attentionDoneKey,
|
||||
onDone: () => _close(context),
|
||||
),
|
||||
),
|
||||
if (rows.isEmpty)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/layout/app_sheet_header.dart';
|
||||
import 'attention_status_icon.dart';
|
||||
import '../domain/attention_models.dart';
|
||||
import 'needs_you_copy.dart';
|
||||
@@ -57,28 +58,18 @@ class MaterialNeedsYouSheet extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(24, 0, 12, 4),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Semantics(
|
||||
header: true,
|
||||
namesRoute: true,
|
||||
child: Text(
|
||||
attentionSheetTitle,
|
||||
style: theme.textTheme.titleLarge,
|
||||
),
|
||||
),
|
||||
AppSheetHeader(
|
||||
title: attentionSheetTitle,
|
||||
cupertino: false,
|
||||
doneKey: attentionDoneKey,
|
||||
actions: [
|
||||
if (rows.isNotEmpty)
|
||||
TextButton(
|
||||
key: attentionClearAllKey,
|
||||
onPressed: () => onClearAll(snapshot),
|
||||
child: const Text(attentionClearAllCopy),
|
||||
),
|
||||
if (rows.isNotEmpty)
|
||||
TextButton(
|
||||
key: attentionClearAllKey,
|
||||
onPressed: () => onClearAll(snapshot),
|
||||
child: const Text(attentionClearAllCopy),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
if (rows.isEmpty)
|
||||
Padding(
|
||||
|
||||
@@ -55,48 +55,68 @@ class NotificationPermissionTile extends StatelessWidget {
|
||||
final action = view.canRequest && onRequest != null
|
||||
? _action(native, view.actionLabel!, onRequest!)
|
||||
: null;
|
||||
final bodyStyle = native
|
||||
final titleStyle = native
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.bodyLarge;
|
||||
final helperStyle = native
|
||||
? CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
fontSize: 15,
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
)
|
||||
: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
);
|
||||
// The Settings section supplies the `Notifications` heading and the page
|
||||
// inset, as for every other section, so the body starts at that edge.
|
||||
return Column(
|
||||
// One compact row: the state, one short helper line and Enable at the
|
||||
// end. The full sentence for the state is what a screen reader hears.
|
||||
// The Settings section supplies the `Notifications` heading.
|
||||
return Row(
|
||||
key: notificationTileKey,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(notificationRationale, style: bodyStyle),
|
||||
const SizedBox(height: 8),
|
||||
Semantics(
|
||||
liveRegion: true,
|
||||
child: Text(view.body, key: notificationStateKey, style: bodyStyle),
|
||||
Expanded(
|
||||
child: Semantics(
|
||||
liveRegion: true,
|
||||
label: view.body,
|
||||
excludeSemantics: true,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
view.headline,
|
||||
key: notificationStateKey,
|
||||
style: titleStyle,
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(view.helper, style: helperStyle),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
// The action sits on its own row, as the browser's settings section
|
||||
// does: its label is too long to share a row at large text.
|
||||
if (action != null) ...[
|
||||
const SizedBox(height: 8),
|
||||
Align(alignment: AlignmentDirectional.centerStart, child: action),
|
||||
],
|
||||
if (action != null) ...[const SizedBox(width: 12), action],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// A short `Enable`, named in full for assistive technology.
|
||||
Widget _action(bool native, String label, VoidCallback onRequest) {
|
||||
if (native) {
|
||||
return CupertinoButton(
|
||||
key: notificationEnableKey,
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: onRequest,
|
||||
child: Text(label),
|
||||
);
|
||||
}
|
||||
return TextButton(
|
||||
key: notificationEnableKey,
|
||||
onPressed: onRequest,
|
||||
child: Text(label),
|
||||
const text = Text(notificationEnableShortLabel);
|
||||
final Widget button = native
|
||||
? CupertinoButton.tinted(
|
||||
key: notificationEnableKey,
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
onPressed: onRequest,
|
||||
child: text,
|
||||
)
|
||||
: FilledButton.tonal(
|
||||
key: notificationEnableKey,
|
||||
onPressed: onRequest,
|
||||
child: text,
|
||||
);
|
||||
return Semantics(
|
||||
button: true,
|
||||
label: label,
|
||||
excludeSemantics: true,
|
||||
onTap: onRequest,
|
||||
child: button,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import '../domain/run_decisions.dart';
|
||||
import '../domain/run_models.dart';
|
||||
import 'action_refusal.dart';
|
||||
import 'decision_option_row.dart';
|
||||
import 'decision_wording.dart';
|
||||
|
||||
/// Sends the draft to the server. Returns null on success, or an
|
||||
@@ -172,39 +173,20 @@ class _DecisionPromptState extends State<_DecisionPrompt> {
|
||||
errorStyle: TextStyle(
|
||||
color: CupertinoColors.systemRed.resolveFrom(context),
|
||||
),
|
||||
options: RadioGroup<String>(
|
||||
groupValue: _draft.selected,
|
||||
onChanged: (value) {
|
||||
if (value != null) _select(value);
|
||||
},
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
for (final option in widget.decision.options)
|
||||
CupertinoButton(
|
||||
onPressed: _sending ? null : () => _select(option.key),
|
||||
child: Row(
|
||||
children: [
|
||||
CupertinoRadio<String>(
|
||||
value: option.key,
|
||||
useCheckmarkStyle: true,
|
||||
enabled: !_sending,
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(option.key),
|
||||
if (_targetText(option) case final target?)
|
||||
Text(target),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
options: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
for (final (index, option) in widget.decision.options.indexed)
|
||||
DecisionOptionRow(
|
||||
key: decisionOptionKey(option.key),
|
||||
label: option.key,
|
||||
target: _targetText(option),
|
||||
selected: _draft.selected == option.key,
|
||||
divider: index > 0,
|
||||
onTap: _sending ? null : () => _select(option.key),
|
||||
),
|
||||
],
|
||||
),
|
||||
feedback: CupertinoTextField(
|
||||
key: decisionFeedbackKey,
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
/// One option row in the Cupertino decision prompt, keyed by the option.
|
||||
ValueKey<String> decisionOptionKey(String option) =>
|
||||
ValueKey<String>('human-decision-option-$option');
|
||||
|
||||
/// One choice of the Cupertino decision prompt: a check-list row.
|
||||
///
|
||||
/// The option reads as text in the label colour, not as a blue link, with its
|
||||
/// target underneath in the secondary colour. An empty circle marks an
|
||||
/// unpicked row and a filled check circle the picked one, so the choice is
|
||||
/// visible before Confirm. The whole row is the tap target; semantics report
|
||||
/// it as a selectable member of one exclusive group. A null [onTap] (while
|
||||
/// sending) dims the row.
|
||||
class DecisionOptionRow extends StatelessWidget {
|
||||
const DecisionOptionRow({
|
||||
super.key,
|
||||
required this.label,
|
||||
required this.selected,
|
||||
required this.onTap,
|
||||
this.target,
|
||||
this.divider = false,
|
||||
});
|
||||
|
||||
final String label;
|
||||
final String? target;
|
||||
final bool selected;
|
||||
final bool divider;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = CupertinoTheme.of(context);
|
||||
final enabled = onTap != null;
|
||||
final labelColor = enabled
|
||||
? CupertinoColors.label.resolveFrom(context)
|
||||
: CupertinoColors.tertiaryLabel.resolveFrom(context);
|
||||
final mark = selected
|
||||
? Icon(
|
||||
CupertinoIcons.checkmark_circle_fill,
|
||||
color: enabled
|
||||
? theme.primaryColor
|
||||
: CupertinoColors.tertiaryLabel.resolveFrom(context),
|
||||
)
|
||||
: Icon(
|
||||
CupertinoIcons.circle,
|
||||
color: CupertinoColors.tertiaryLabel.resolveFrom(context),
|
||||
);
|
||||
final row = Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: Row(
|
||||
children: [
|
||||
mark,
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
textAlign: TextAlign.start,
|
||||
style: theme.textTheme.textStyle.copyWith(
|
||||
color: labelColor,
|
||||
fontWeight: selected ? FontWeight.w600 : null,
|
||||
),
|
||||
),
|
||||
if (target case final target?)
|
||||
Text(
|
||||
target,
|
||||
textAlign: TextAlign.start,
|
||||
style: theme.textTheme.textStyle.copyWith(
|
||||
fontSize: 13,
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(
|
||||
context,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
return Semantics(
|
||||
inMutuallyExclusiveGroup: true,
|
||||
selected: selected,
|
||||
checked: selected,
|
||||
button: true,
|
||||
enabled: enabled,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
border: divider
|
||||
? Border(
|
||||
top: BorderSide(
|
||||
color: CupertinoColors.separator.resolveFrom(context),
|
||||
width: 0,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: onTap,
|
||||
child: row,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import '../actions/retry_eligibility.dart';
|
||||
import '../actions/retry_wording.dart';
|
||||
import '../actions/title_action.dart';
|
||||
import '../actions/title_wording.dart';
|
||||
import '../domain/run_models.dart' show runIdentity;
|
||||
|
||||
const runMoreMenuKey = ValueKey<String>('run-more-menu');
|
||||
|
||||
@@ -16,6 +17,13 @@ const runMoreMenuKey = ValueKey<String>('run-more-menu');
|
||||
bool showRunMoreMenu(JsonMap run) =>
|
||||
runTitleId(run) != null || canScheduleRun(run) || _canRetry(run);
|
||||
|
||||
/// The run's own name for its action sheet: its title or pipeline, else
|
||||
/// `Run <id>`, as its list row shows it.
|
||||
String runMoreMenuTitle(JsonMap run) {
|
||||
final label = runIdentity(run['title'], run['name']).label;
|
||||
return label.isEmpty ? 'Run ${run['id']}' : label;
|
||||
}
|
||||
|
||||
bool _canRetry(JsonMap run) => retryRunId(run) != null && canRetryRun(run);
|
||||
|
||||
enum _RunMoreItem { retry, rename, schedule }
|
||||
@@ -97,6 +105,8 @@ class _RunMoreMenuState extends State<RunMoreMenu> {
|
||||
return AppOverflowMenu<_RunMoreItem>(
|
||||
key: widget.menuKey,
|
||||
cupertino: widget.cupertino,
|
||||
// The Cupertino action sheet names the run it acts on.
|
||||
sheetTitle: runMoreMenuTitle(run),
|
||||
actions: [
|
||||
for (final (item, label) in _items)
|
||||
AppMenuAction(key: _keyOf(item), value: item, label: label),
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
import 'runs_controller.dart';
|
||||
|
||||
/// The Runs toolbar's choices and their labels, shared by the applied-filter
|
||||
/// chips, the filter sheet and the sort sheet. No widgets here.
|
||||
|
||||
const runSorts = [
|
||||
('newest_first', 'Newest first'),
|
||||
('oldest_first', 'Oldest first'),
|
||||
('longest_duration', 'Longest duration'),
|
||||
('shortest_duration', 'Shortest duration'),
|
||||
('pipeline_name', 'Pipeline name'),
|
||||
('status', 'Status'),
|
||||
];
|
||||
const runSchedules = [
|
||||
('any', 'Any trigger'),
|
||||
('scheduled', 'Scheduled runs'),
|
||||
('unscheduled', 'Not scheduled'),
|
||||
];
|
||||
const runTimeRanges = [
|
||||
('any_time', 'Any time'),
|
||||
('today', 'Today'),
|
||||
('last_7_days', 'Last 7 days'),
|
||||
('last_30_days', 'Last 30 days'),
|
||||
];
|
||||
|
||||
/// The pipelines the loaded runs belong to, by name then id.
|
||||
List<({int id, String name})> runFilterPipelines(RunsController controller) {
|
||||
final names = <int, String>{};
|
||||
final ids = <int>{};
|
||||
for (final run in controller.runs) {
|
||||
final id = run['pipeline_id'];
|
||||
if (id is! int) continue;
|
||||
ids.add(id);
|
||||
final name = '${run['name'] ?? ''}'.trim();
|
||||
if (name.isNotEmpty && !names.containsKey(id)) names[id] = name;
|
||||
}
|
||||
final options = ids
|
||||
.map((id) => (id: id, name: names[id] ?? 'Pipeline $id'))
|
||||
.toList();
|
||||
options.sort((a, b) {
|
||||
final nameOrder = a.name.toLowerCase().compareTo(b.name.toLowerCase());
|
||||
return nameOrder != 0 ? nameOrder : a.id.compareTo(b.id);
|
||||
});
|
||||
return options;
|
||||
}
|
||||
|
||||
/// Whether some loaded run carries no scheduling provenance at all.
|
||||
bool runsHaveUnclassified(RunsController controller) =>
|
||||
controller.runs.any((run) {
|
||||
final id = run['schedule_id'];
|
||||
return run['scheduled'] is! bool && !(id is num && id > 0);
|
||||
});
|
||||
|
||||
String runTimeRangeLabel(String value) => runTimeRanges
|
||||
.firstWhere((entry) => entry.$1 == value, orElse: () => runTimeRanges.first)
|
||||
.$2;
|
||||
String runSortLabel(String value) =>
|
||||
runSorts.firstWhere((e) => e.$1 == value, orElse: () => runSorts.first).$2;
|
||||
String runScheduleLabel(String value) => runSchedules
|
||||
.firstWhere((e) => e.$1 == value, orElse: () => runSchedules.first)
|
||||
.$2;
|
||||
@@ -0,0 +1,215 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/input/app_search_field.dart';
|
||||
import '../../../ui/layout/app_sheet_header.dart';
|
||||
import '../../pipelines/pipeline_format.dart' show runStateLabel;
|
||||
import '../domain/run_models.dart';
|
||||
import 'runs_controller.dart';
|
||||
import 'runs_filter_options.dart';
|
||||
|
||||
const runsFilterTitle = 'Filter runs';
|
||||
const runsFilterDoneKey = ValueKey<String>('runs.filter.done');
|
||||
const runsFilterClearKey = ValueKey<String>('runs.filter.clear');
|
||||
|
||||
/// The filter sheet: a header (title, Clear, Done), the text filter, then
|
||||
/// status (several may be picked), pipeline, time range and trigger (one
|
||||
/// each), every choice applied as it is picked.
|
||||
Future<void> showRunsFilterSheet(
|
||||
BuildContext context,
|
||||
RunsController controller,
|
||||
) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final sheet = _RunsFilterSheet(controller: controller, cupertino: cupertino);
|
||||
if (cupertino) {
|
||||
return showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (_) => CupertinoPopupSurface(child: SafeArea(child: sheet)),
|
||||
);
|
||||
}
|
||||
return showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
showDragHandle: true,
|
||||
useSafeArea: true,
|
||||
builder: (_) => sheet,
|
||||
);
|
||||
}
|
||||
|
||||
class _RunsFilterSheet extends StatefulWidget {
|
||||
const _RunsFilterSheet({required this.controller, required this.cupertino});
|
||||
|
||||
final RunsController controller;
|
||||
final bool cupertino;
|
||||
|
||||
@override
|
||||
State<_RunsFilterSheet> createState() => _RunsFilterSheetState();
|
||||
}
|
||||
|
||||
class _RunsFilterSheetState extends State<_RunsFilterSheet> {
|
||||
late final TextEditingController _text = TextEditingController(
|
||||
text: widget.controller.query,
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_text.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _clear() {
|
||||
_text.clear();
|
||||
widget.controller.setQuery('');
|
||||
widget.controller.clearFilters();
|
||||
}
|
||||
|
||||
Widget _section(BuildContext context, String title) {
|
||||
final style = widget.cupertino
|
||||
? CupertinoTheme.of(
|
||||
context,
|
||||
).textTheme.textStyle.copyWith(fontWeight: FontWeight.w600)
|
||||
: Theme.of(context).textTheme.titleSmall;
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 4),
|
||||
child: Semantics(header: true, child: Text(title, style: style)),
|
||||
);
|
||||
}
|
||||
|
||||
/// One status: several may be on at once, so Material uses a checkbox.
|
||||
Widget _multiChoice(String label, bool checked, VoidCallback onTap) {
|
||||
if (widget.cupertino) return _checkRow(label, checked, onTap);
|
||||
return CheckboxListTile(
|
||||
dense: true,
|
||||
title: Text(label),
|
||||
value: checked,
|
||||
onChanged: (_) => onTap(),
|
||||
);
|
||||
}
|
||||
|
||||
/// One choice of a single-choice group: a check mark on the picked row.
|
||||
Widget _singleChoice(String label, bool checked, VoidCallback onTap) =>
|
||||
Semantics(
|
||||
inMutuallyExclusiveGroup: true,
|
||||
child: _checkRow(label, checked, onTap),
|
||||
);
|
||||
|
||||
Widget _checkRow(String label, bool checked, VoidCallback onTap) {
|
||||
if (widget.cupertino) {
|
||||
return CupertinoListTile(
|
||||
title: Text(label),
|
||||
trailing: checked ? const Icon(CupertinoIcons.check_mark) : null,
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
return ListTile(
|
||||
dense: true,
|
||||
selected: checked,
|
||||
title: Text(label),
|
||||
trailing: checked ? const Icon(Icons.check) : null,
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final controller = widget.controller;
|
||||
final field = AppSearchField(
|
||||
fieldKey: const ValueKey('runs.filter.query'),
|
||||
controller: _text,
|
||||
cupertino: widget.cupertino,
|
||||
placeholder: 'Filter runs',
|
||||
onChanged: controller.setQuery,
|
||||
);
|
||||
return ListenableBuilder(
|
||||
listenable: controller,
|
||||
builder: (context, _) {
|
||||
final active =
|
||||
controller.activeFilterCount > 0 || controller.query.isNotEmpty;
|
||||
return ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.sizeOf(context).height * 0.85,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
AppSheetHeader(
|
||||
title: runsFilterTitle,
|
||||
cupertino: widget.cupertino,
|
||||
doneKey: runsFilterDoneKey,
|
||||
actions: [if (active) _clearButton()],
|
||||
),
|
||||
Flexible(child: _list(context, controller, field)),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _clearButton() => widget.cupertino
|
||||
? CupertinoButton(
|
||||
key: runsFilterClearKey,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
onPressed: _clear,
|
||||
child: const Text('Clear'),
|
||||
)
|
||||
: TextButton(
|
||||
key: runsFilterClearKey,
|
||||
onPressed: _clear,
|
||||
child: const Text('Clear'),
|
||||
);
|
||||
|
||||
Widget _list(BuildContext context, RunsController controller, Widget field) {
|
||||
return ListView(
|
||||
key: const ValueKey('runs.filter.sheet'),
|
||||
shrinkWrap: true,
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
children: [
|
||||
Padding(padding: const EdgeInsets.fromLTRB(16, 4, 16, 0), child: field),
|
||||
_section(context, 'Status'),
|
||||
for (final status in runStates)
|
||||
_multiChoice(
|
||||
runStateLabel(status),
|
||||
controller.statuses.contains(status),
|
||||
() => controller.setStatus(status),
|
||||
),
|
||||
_section(context, 'Pipeline'),
|
||||
_singleChoice(
|
||||
'Any pipeline',
|
||||
controller.pipelineId == null,
|
||||
() => controller.setPipeline(null),
|
||||
),
|
||||
for (final pipeline in runFilterPipelines(controller))
|
||||
_singleChoice(
|
||||
pipeline.name,
|
||||
controller.pipelineId == pipeline.id,
|
||||
() => controller.setPipeline(pipeline.id),
|
||||
),
|
||||
_section(context, 'Time range'),
|
||||
for (final range in runTimeRanges)
|
||||
_singleChoice(
|
||||
range.$2,
|
||||
controller.timeRange == range.$1,
|
||||
() => controller.setTimeRange(range.$1),
|
||||
),
|
||||
_section(context, 'Trigger'),
|
||||
for (final schedule in runSchedules)
|
||||
_singleChoice(
|
||||
schedule.$2,
|
||||
controller.scheduled == schedule.$1,
|
||||
() => controller.setScheduled(schedule.$1),
|
||||
),
|
||||
if (runsHaveUnclassified(controller))
|
||||
const Padding(
|
||||
padding: EdgeInsets.fromLTRB(16, 4, 16, 0),
|
||||
child: Text(
|
||||
'Some records have no scheduling provenance; they stay '
|
||||
'unclassified.',
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,17 @@
|
||||
import '../../../ui/input/app_search_field.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../domain/run_models.dart';
|
||||
import '../../../ui/layout/app_sheet_header.dart';
|
||||
import '../../pipelines/pipeline_format.dart' show runStateLabel;
|
||||
import 'runs_controller.dart';
|
||||
import 'runs_filter_options.dart';
|
||||
import 'runs_filter_sheet.dart';
|
||||
|
||||
export 'runs_filter_sheet.dart' show showRunsFilterSheet;
|
||||
|
||||
const runsSortTitle = 'Sort runs';
|
||||
const runsSortDoneKey = ValueKey<String>('runs.sort.done');
|
||||
|
||||
/// The runs list's compact native filter/sort toolbar and applied-filter chips.
|
||||
///
|
||||
@@ -62,17 +69,20 @@ class RunsFilters extends StatelessWidget {
|
||||
applied.add((label: pipeline, clear: () => controller.setPipeline(null)));
|
||||
}
|
||||
for (final status in controller.statuses) {
|
||||
applied.add((label: status, clear: () => controller.setStatus(status)));
|
||||
applied.add((
|
||||
label: runStateLabel(status),
|
||||
clear: () => controller.setStatus(status),
|
||||
));
|
||||
}
|
||||
if (controller.timeRange != 'any_time') {
|
||||
applied.add((
|
||||
label: _timeRangeLabel(controller.timeRange),
|
||||
label: runTimeRangeLabel(controller.timeRange),
|
||||
clear: () => controller.setTimeRange('any_time'),
|
||||
));
|
||||
}
|
||||
if (controller.scheduled != 'any') {
|
||||
applied.add((
|
||||
label: _scheduleLabel(controller.scheduled),
|
||||
label: runScheduleLabel(controller.scheduled),
|
||||
clear: () => controller.setScheduled('any'),
|
||||
));
|
||||
}
|
||||
@@ -128,61 +138,6 @@ class RunsFilters extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
const _sorts = [
|
||||
('newest_first', 'Newest first'),
|
||||
('oldest_first', 'Oldest first'),
|
||||
('longest_duration', 'Longest duration'),
|
||||
('shortest_duration', 'Shortest duration'),
|
||||
('pipeline_name', 'Pipeline name'),
|
||||
('status', 'Status'),
|
||||
];
|
||||
const _schedules = [
|
||||
('any', 'Any trigger'),
|
||||
('scheduled', 'Scheduled runs'),
|
||||
('unscheduled', 'Not scheduled'),
|
||||
];
|
||||
const _timeRanges = [
|
||||
('any_time', 'Any time'),
|
||||
('today', 'Today'),
|
||||
('last_7_days', 'Last 7 days'),
|
||||
('last_30_days', 'Last 30 days'),
|
||||
];
|
||||
|
||||
List<({int id, String name})> _pipelines(RunsController controller) {
|
||||
final names = <int, String>{};
|
||||
final ids = <int>{};
|
||||
for (final run in controller.runs) {
|
||||
final id = run['pipeline_id'];
|
||||
if (id is! int) continue;
|
||||
ids.add(id);
|
||||
final name = '${run['name'] ?? ''}'.trim();
|
||||
if (name.isNotEmpty && !names.containsKey(id)) names[id] = name;
|
||||
}
|
||||
final options = ids
|
||||
.map((id) => (id: id, name: names[id] ?? 'Pipeline $id'))
|
||||
.toList();
|
||||
options.sort((a, b) {
|
||||
final nameOrder = a.name.toLowerCase().compareTo(b.name.toLowerCase());
|
||||
return nameOrder != 0 ? nameOrder : a.id.compareTo(b.id);
|
||||
});
|
||||
return options;
|
||||
}
|
||||
|
||||
bool _hasUnclassifiedRuns(RunsController controller) =>
|
||||
controller.runs.any((run) {
|
||||
final id = run['schedule_id'];
|
||||
return run['scheduled'] is! bool && !(id is num && id > 0);
|
||||
});
|
||||
|
||||
String _timeRangeLabel(String value) => _timeRanges
|
||||
.firstWhere((entry) => entry.$1 == value, orElse: () => _timeRanges.first)
|
||||
.$2;
|
||||
String _sortLabel(String value) =>
|
||||
_sorts.firstWhere((e) => e.$1 == value, orElse: () => _sorts.first).$2;
|
||||
String _scheduleLabel(String value) => _schedules
|
||||
.firstWhere((e) => e.$1 == value, orElse: () => _schedules.first)
|
||||
.$2;
|
||||
|
||||
/// The Runs list's app-bar actions: usage and charts, filter (with the search
|
||||
/// field inside) and sort, as icons.
|
||||
class RunsBarActions {
|
||||
@@ -252,7 +207,7 @@ class RunsBarActions {
|
||||
const ValueKey('runs.sort'),
|
||||
Icons.sort,
|
||||
CupertinoIcons.arrow_up_arrow_down,
|
||||
'Sort runs: ${_sortLabel(controller.sort)}',
|
||||
'Sort runs: ${runSortLabel(controller.sort)}',
|
||||
() => _chooseSort(context),
|
||||
),
|
||||
];
|
||||
@@ -265,10 +220,12 @@ class RunsBarActions {
|
||||
value = await showCupertinoModalPopup<String>(
|
||||
context: context,
|
||||
builder: (sheet) => CupertinoActionSheet(
|
||||
title: const Text('Sort runs'),
|
||||
title: const Text(runsSortTitle),
|
||||
actions: [
|
||||
for (final option in _sorts)
|
||||
for (final option in runSorts)
|
||||
CupertinoActionSheetAction(
|
||||
// The current order is the sheet's default (bold) action.
|
||||
isDefaultAction: controller.sort == option.$1,
|
||||
onPressed: () => Navigator.pop(sheet, option.$1),
|
||||
child: Text(
|
||||
'${controller.sort == option.$1 ? '✓ ' : ''}${option.$2}',
|
||||
@@ -286,18 +243,31 @@ class RunsBarActions {
|
||||
context: context,
|
||||
showDragHandle: true,
|
||||
builder: (sheet) => SafeArea(
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
const ListTile(title: Text('Sort runs')),
|
||||
for (final option in _sorts)
|
||||
ListTile(
|
||||
title: Text(option.$2),
|
||||
trailing: controller.sort == option.$1
|
||||
? const Icon(Icons.check)
|
||||
: null,
|
||||
onTap: () => Navigator.pop(sheet, option.$1),
|
||||
const AppSheetHeader(
|
||||
title: runsSortTitle,
|
||||
cupertino: false,
|
||||
doneKey: runsSortDoneKey,
|
||||
),
|
||||
Flexible(
|
||||
child: ListView(
|
||||
shrinkWrap: true,
|
||||
children: [
|
||||
for (final option in runSorts)
|
||||
ListTile(
|
||||
selected: controller.sort == option.$1,
|
||||
title: Text(option.$2),
|
||||
trailing: controller.sort == option.$1
|
||||
? const Icon(Icons.check)
|
||||
: null,
|
||||
onTap: () => Navigator.pop(sheet, option.$1),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -306,162 +276,3 @@ class RunsBarActions {
|
||||
if (value != null && value != controller.sort) controller.setSort(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// The filter sheet: the text filter first, then status, pipeline, time range
|
||||
/// and trigger, each choice applied as it is picked.
|
||||
Future<void> showRunsFilterSheet(
|
||||
BuildContext context,
|
||||
RunsController controller,
|
||||
) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final sheet = _RunsFilterSheet(controller: controller, cupertino: cupertino);
|
||||
if (cupertino) {
|
||||
return showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (_) => CupertinoPopupSurface(child: SafeArea(child: sheet)),
|
||||
);
|
||||
}
|
||||
return showModalBottomSheet<void>(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
showDragHandle: true,
|
||||
useSafeArea: true,
|
||||
builder: (_) => sheet,
|
||||
);
|
||||
}
|
||||
|
||||
class _RunsFilterSheet extends StatefulWidget {
|
||||
const _RunsFilterSheet({required this.controller, required this.cupertino});
|
||||
|
||||
final RunsController controller;
|
||||
final bool cupertino;
|
||||
|
||||
@override
|
||||
State<_RunsFilterSheet> createState() => _RunsFilterSheetState();
|
||||
}
|
||||
|
||||
class _RunsFilterSheetState extends State<_RunsFilterSheet> {
|
||||
late final TextEditingController _text = TextEditingController(
|
||||
text: widget.controller.query,
|
||||
);
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_text.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Widget _section(String title) => Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 4),
|
||||
child: Text(title, style: const TextStyle(fontWeight: FontWeight.w600)),
|
||||
);
|
||||
|
||||
Widget _choice(String label, bool checked, VoidCallback onTap) {
|
||||
if (widget.cupertino) {
|
||||
return CupertinoListTile(
|
||||
title: Text(label),
|
||||
trailing: checked ? const Icon(CupertinoIcons.check_mark) : null,
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
return CheckboxListTile(
|
||||
dense: true,
|
||||
title: Text(label),
|
||||
value: checked,
|
||||
onChanged: (_) => onTap(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final controller = widget.controller;
|
||||
final field = AppSearchField(
|
||||
fieldKey: const ValueKey('runs.filter.query'),
|
||||
controller: _text,
|
||||
cupertino: widget.cupertino,
|
||||
placeholder: 'Filter runs',
|
||||
onChanged: controller.setQuery,
|
||||
);
|
||||
return ListenableBuilder(
|
||||
listenable: controller,
|
||||
builder: (context, _) => ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.sizeOf(context).height * 0.85,
|
||||
),
|
||||
child: ListView(
|
||||
key: const ValueKey('runs.filter.sheet'),
|
||||
shrinkWrap: true,
|
||||
padding: const EdgeInsets.only(bottom: 16),
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||
child: field,
|
||||
),
|
||||
_section('Status'),
|
||||
for (final status in runStates)
|
||||
_choice(
|
||||
status,
|
||||
controller.statuses.contains(status),
|
||||
() => controller.setStatus(status),
|
||||
),
|
||||
_section('Pipeline'),
|
||||
_choice(
|
||||
'Any pipeline',
|
||||
controller.pipelineId == null,
|
||||
() => controller.setPipeline(null),
|
||||
),
|
||||
for (final pipeline in _pipelines(controller))
|
||||
_choice(
|
||||
pipeline.name,
|
||||
controller.pipelineId == pipeline.id,
|
||||
() => controller.setPipeline(pipeline.id),
|
||||
),
|
||||
_section('Time range'),
|
||||
for (final range in _timeRanges)
|
||||
_choice(
|
||||
range.$2,
|
||||
controller.timeRange == range.$1,
|
||||
() => controller.setTimeRange(range.$1),
|
||||
),
|
||||
_section('Trigger'),
|
||||
for (final schedule in _schedules)
|
||||
_choice(
|
||||
schedule.$2,
|
||||
controller.scheduled == schedule.$1,
|
||||
() => controller.setScheduled(schedule.$1),
|
||||
),
|
||||
if (_hasUnclassifiedRuns(controller))
|
||||
const Padding(
|
||||
padding: EdgeInsets.fromLTRB(16, 4, 16, 0),
|
||||
child: Text(
|
||||
'Some records have no scheduling provenance; they stay '
|
||||
'unclassified.',
|
||||
),
|
||||
),
|
||||
if (controller.activeFilterCount > 0 || controller.query.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
|
||||
child: widget.cupertino
|
||||
? CupertinoButton(
|
||||
onPressed: () {
|
||||
_text.clear();
|
||||
controller.setQuery('');
|
||||
controller.clearFilters();
|
||||
},
|
||||
child: const Text('Clear filters'),
|
||||
)
|
||||
: TextButton(
|
||||
onPressed: () {
|
||||
_text.clear();
|
||||
controller.setQuery('');
|
||||
controller.clearFilters();
|
||||
},
|
||||
child: const Text('Clear filters'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/status/run_status_icon.dart';
|
||||
import '../domain/run_models.dart';
|
||||
import '../../pipelines/pipeline_format.dart' show parseInstant;
|
||||
import '../../pipelines/pipeline_format.dart' show parseInstant, runStateLabel;
|
||||
import 'run_detail_content.dart';
|
||||
import 'runs_controller.dart';
|
||||
|
||||
@@ -72,10 +72,13 @@ class RunsStatsPage extends StatelessWidget {
|
||||
key: const ValueKey('runs.stats.page'),
|
||||
padding: withBarClearance(context, const EdgeInsets.all(16)),
|
||||
children: [
|
||||
Text('Usage', style: heading),
|
||||
const SizedBox(height: 8),
|
||||
// The bar already says Usage: the totals lead the page untitled.
|
||||
if (metrics.isEmpty)
|
||||
Text('No usage reported.', style: TextStyle(color: secondary))
|
||||
Text(
|
||||
'No usage has been reported for these runs.',
|
||||
key: const ValueKey('runs.stats.usage.empty'),
|
||||
style: TextStyle(color: secondary),
|
||||
)
|
||||
else
|
||||
Wrap(
|
||||
spacing: 24,
|
||||
@@ -124,11 +127,11 @@ class RunsStatsPage extends StatelessWidget {
|
||||
children: [
|
||||
RunStatusIcon(
|
||||
state: entry.key,
|
||||
label: entry.key,
|
||||
label: runStateLabel(entry.key),
|
||||
size: 16,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(child: Text(entry.key)),
|
||||
Expanded(child: Text(runStateLabel(entry.key))),
|
||||
Text('${entry.value}'),
|
||||
],
|
||||
),
|
||||
@@ -141,49 +144,14 @@ class RunsStatsPage extends StatelessWidget {
|
||||
const SizedBox(height: 24),
|
||||
Text('Runs in the last 7 days', style: heading),
|
||||
const SizedBox(height: 12),
|
||||
SizedBox(
|
||||
height: 140,
|
||||
child: Row(
|
||||
key: const ValueKey('runs.stats.days'),
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
for (final day in days)
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
'${day.count}',
|
||||
style: TextStyle(color: secondary),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Flexible(
|
||||
child: FractionallySizedBox(
|
||||
heightFactor: day.count == 0
|
||||
? 0.02
|
||||
: day.count /
|
||||
days.map((d) => d.count).reduce(math.max),
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(day.label, style: TextStyle(color: secondary)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (days.every((day) => day.count == 0))
|
||||
Text(
|
||||
'No runs started in the last 7 days.',
|
||||
key: const ValueKey('runs.stats.days.empty'),
|
||||
style: TextStyle(color: secondary),
|
||||
)
|
||||
else
|
||||
_DaysChart(days: days, cupertino: cupertino, secondary: secondary),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -231,3 +199,92 @@ class _PiePainter extends CustomPainter {
|
||||
@override
|
||||
bool shouldRepaint(_PiePainter oldDelegate) => true;
|
||||
}
|
||||
|
||||
/// Runs per day as bars over a baseline axis, each bar labelled with its
|
||||
/// count and its weekday underneath. Only drawn when some day has a run.
|
||||
class _DaysChart extends StatelessWidget {
|
||||
const _DaysChart({
|
||||
required this.days,
|
||||
required this.cupertino,
|
||||
required this.secondary,
|
||||
});
|
||||
|
||||
final List<({String label, int count})> days;
|
||||
final bool cupertino;
|
||||
final Color secondary;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final most = days.map((d) => d.count).reduce(math.max);
|
||||
final bar = cupertino
|
||||
? CupertinoTheme.of(context).primaryColor
|
||||
: Theme.of(context).colorScheme.primary;
|
||||
final axis = cupertino
|
||||
? CupertinoColors.separator.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.outlineVariant;
|
||||
return Column(
|
||||
key: const ValueKey('runs.stats.days'),
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(bottom: BorderSide(color: axis)),
|
||||
),
|
||||
child: SizedBox(
|
||||
height: 140,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
for (final day in days)
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
if (day.count > 0) ...[
|
||||
Text(
|
||||
'${day.count}',
|
||||
style: TextStyle(color: secondary),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Flexible(
|
||||
child: FractionallySizedBox(
|
||||
heightFactor: day.count / most,
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: bar,
|
||||
borderRadius: const BorderRadius.vertical(
|
||||
top: Radius.circular(4),
|
||||
),
|
||||
),
|
||||
child: const SizedBox.expand(),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
for (final day in days)
|
||||
Expanded(
|
||||
child: Text(
|
||||
day.label,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: secondary),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,10 @@ class SettingsController extends ChangeNotifier {
|
||||
_connection.kind == transport.ConnectionKind.connecting;
|
||||
|
||||
String get primaryActionLabel => connectionActive ? 'Disconnect' : 'Connect';
|
||||
String get secondaryActionLabel => connectionActive ? 'Connect' : 'Reconnect';
|
||||
|
||||
/// Connecting again to the URL in the field; while connected that is a
|
||||
/// reconnect, so it never reads `Connect` beside `Disconnect`.
|
||||
String get secondaryActionLabel => 'Reconnect';
|
||||
|
||||
List<String> get connectionLines => connectionCardLines(
|
||||
_connection,
|
||||
|
||||
@@ -151,9 +151,12 @@ class SettingsWorkspaceSection extends StatelessWidget {
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: <Widget>[
|
||||
if (usesCupertinoControls(context))
|
||||
CupertinoButton(
|
||||
// A tinted button keeps its shape when disabled, so an
|
||||
// unsaved-nothing state reads as a disabled button,
|
||||
// not as stray grey text.
|
||||
CupertinoButton.tinted(
|
||||
key: SettingsKeys.saveWorkspace,
|
||||
padding: EdgeInsets.zero,
|
||||
sizeStyle: CupertinoButtonSize.small,
|
||||
onPressed: save,
|
||||
child: const Text('Save workspace'),
|
||||
)
|
||||
|
||||
@@ -195,7 +195,10 @@ class _TemplatesScreenState extends State<TemplatesScreen> {
|
||||
onBack: _back,
|
||||
onCreate: () => _openCreate(selected),
|
||||
);
|
||||
final barTitle = selected == null ? null : templateBarTitle(selected);
|
||||
final framed = TemplatesFrame(
|
||||
title: barTitle?.title ?? templatesTitle,
|
||||
subtitle: barTitle?.subtitle,
|
||||
body: _withFailure(context, body),
|
||||
embedded: widget.embedded,
|
||||
canGoBack: selected != null,
|
||||
|
||||
@@ -5,6 +5,7 @@ import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../domain/template_entry.dart';
|
||||
import 'template_gallery.dart' show templatesColumn;
|
||||
|
||||
/// Browser wording for the gallery and the selected template, kept verbatim.
|
||||
const templateSourceLabel = 'Definition source';
|
||||
@@ -15,6 +16,17 @@ const templateDetailKey = ValueKey<String>('template-detail');
|
||||
const templateSourceKey = ValueKey<String>('template-source');
|
||||
const templateCreateActionKey = ValueKey<String>('template-create-action');
|
||||
const templateDetailBackKey = ValueKey<String>('template-detail-back');
|
||||
const templateKeyKey = ValueKey<String>('template-key');
|
||||
|
||||
/// What the bar's title pill shows for an open template: its name, and its
|
||||
/// description (when it has one) as the one-line subtitle.
|
||||
({String title, String? subtitle}) templateBarTitle(TemplateEntry entry) {
|
||||
final description = entry.description.trim();
|
||||
return (
|
||||
title: templateDetailName(entry),
|
||||
subtitle: description.isEmpty ? null : description,
|
||||
);
|
||||
}
|
||||
|
||||
/// A gallery card's name: a blank name is the explicit unnamed placeholder.
|
||||
String templateGalleryName(TemplateEntry entry) {
|
||||
@@ -52,64 +64,92 @@ class TemplateDetail extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
final muted = templateMutedStyle(context);
|
||||
final description = entry.description.trim();
|
||||
return ListView(
|
||||
key: templateDetailKey,
|
||||
padding: withBarClearance(context, const EdgeInsets.only(bottom: 24)),
|
||||
children: [
|
||||
if (showBack) _backRow(context, cupertino),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
_createButton(context, cupertino),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
templateDetailName(entry),
|
||||
style: templateTitleStyle(context),
|
||||
),
|
||||
if (entry.description.trim().isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Text(entry.description),
|
||||
templatesColumn(
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// With a bar above, its title pill carries the name and the
|
||||
// description; only a bar-less page names the template here.
|
||||
if (showBack) ...[
|
||||
Text(
|
||||
templateDetailName(entry),
|
||||
style: templateTitleStyle(context),
|
||||
),
|
||||
if (description.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Text(entry.description),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
],
|
||||
_createButton(cupertino),
|
||||
const SizedBox(height: 16),
|
||||
// The key and the schedule on one quiet line, not a
|
||||
// label/value document.
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 4,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
SelectableText(
|
||||
entry.key,
|
||||
key: templateKeyKey,
|
||||
semanticsLabel: 'Key ${entry.key}',
|
||||
style: muted,
|
||||
),
|
||||
if (entry.scheduled) ...[
|
||||
Text('·', style: muted),
|
||||
Text(templateIncludesScheduleLabel, style: muted),
|
||||
],
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text('Key', style: templateMutedStyle(context)),
|
||||
SelectableText(entry.key, style: templateBodyStyle(context)),
|
||||
if (entry.scheduled)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8),
|
||||
child: Text(templateIncludesScheduleLabel),
|
||||
const SizedBox(height: 20),
|
||||
Text(templateSourceLabel, style: templateSectionStyle(context)),
|
||||
const SizedBox(height: 8),
|
||||
// The server's source, byte-for-byte: no trim, re-indent or
|
||||
// re-encoding, so selecting it copies exactly what was
|
||||
// received.
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: SelectableText(
|
||||
entry.source,
|
||||
key: templateSourceKey,
|
||||
style: templateBodyStyle(context),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(templateSourceLabel, style: templateSectionStyle(context)),
|
||||
const SizedBox(height: 8),
|
||||
// The server's source, byte-for-byte: no trim, re-indent or
|
||||
// re-encoding, so selecting it copies exactly what was received.
|
||||
SelectableText(
|
||||
entry.source,
|
||||
key: templateSourceKey,
|
||||
style: templateBodyStyle(context),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _createButton(BuildContext context, bool cupertino) {
|
||||
/// A compact button at its own width: the page's one action, never a bar
|
||||
/// spanning a wide window.
|
||||
Widget _createButton(bool cupertino) {
|
||||
if (cupertino) {
|
||||
return CupertinoButton.filled(
|
||||
key: templateCreateActionKey,
|
||||
sizeStyle: CupertinoButtonSize.medium,
|
||||
onPressed: onCreate,
|
||||
child: const Text(templateCreateActionLabel),
|
||||
);
|
||||
}
|
||||
return FilledButton(
|
||||
return FilledButton.icon(
|
||||
key: templateCreateActionKey,
|
||||
onPressed: onCreate,
|
||||
child: const Text(templateCreateActionLabel),
|
||||
icon: const Icon(Icons.add),
|
||||
label: const Text(templateCreateActionLabel),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -160,7 +200,11 @@ TextStyle? templateBodyStyle(BuildContext context) {
|
||||
|
||||
TextStyle? templateMutedStyle(BuildContext context) {
|
||||
if (usesCupertinoHost(context)) {
|
||||
return CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
|
||||
// The list rows' secondary size, not the tab bar's 10pt caption.
|
||||
// SelectableText needs an explicit baseline when it inherits no style.
|
||||
return CupertinoTheme.of(context).textTheme.textStyle.copyWith(
|
||||
inherit: true,
|
||||
fontSize: 15,
|
||||
color: CupertinoColors.secondaryLabel.resolveFrom(context),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import '../../../ui/theme/app_theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
import '../../../ui/layout/app_list_avatar.dart';
|
||||
import '../../../ui/layout/app_list_row.dart';
|
||||
import '../domain/template_entry.dart';
|
||||
import 'template_detail.dart';
|
||||
import 'templates_failure.dart';
|
||||
@@ -16,8 +18,23 @@ const _loadingMessage = 'Loading templates…';
|
||||
const _emptyMessage = 'No templates are available on this server.';
|
||||
|
||||
Key templateRowKey(String key) => ValueKey<String>('template-row-$key');
|
||||
Key templateAvatarKey(String key) => ValueKey<String>('template-avatar-$key');
|
||||
|
||||
/// The gallery's truthful states and native catalogue rows.
|
||||
/// The widest the gallery and an open template grow on a wide window: the
|
||||
/// Settings column's reading width, so the page opened from Settings lines up
|
||||
/// with it.
|
||||
const double templatesContentMaxWidth = 720;
|
||||
|
||||
/// Caps [child] at [templatesContentMaxWidth], start-aligned under the bar.
|
||||
Widget templatesColumn(Widget child) => Align(
|
||||
alignment: AlignmentDirectional.topStart,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: templatesContentMaxWidth),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
|
||||
/// The gallery's truthful states and the app's shared list rows.
|
||||
///
|
||||
/// It owns no requests: loading, failure and the actual rows all come from the
|
||||
/// screen, so opening a row only selects an already-read template.
|
||||
@@ -44,9 +61,7 @@ class TemplateGallery extends StatelessWidget {
|
||||
final ValueChanged<String> onOpen;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => _body(context);
|
||||
|
||||
Widget _body(BuildContext context) {
|
||||
Widget build(BuildContext context) {
|
||||
if (!loaded) {
|
||||
if (error != null) {
|
||||
return TemplatesFailureState(
|
||||
@@ -58,9 +73,7 @@ class TemplateGallery extends StatelessWidget {
|
||||
return _loadingState(context);
|
||||
}
|
||||
if (templates.isEmpty) return _emptyState(context);
|
||||
return usesCupertinoHost(context)
|
||||
? _cupertinoList(context)
|
||||
: _materialList(context);
|
||||
return _list(context);
|
||||
}
|
||||
|
||||
Widget _loadingState(BuildContext context) {
|
||||
@@ -93,82 +106,62 @@ class TemplateGallery extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _materialList(BuildContext context) {
|
||||
return ListView.separated(
|
||||
Widget _list(BuildContext context) {
|
||||
final cupertino = usesCupertinoHost(context);
|
||||
// The rows scroll behind the bar and the floating tab bar.
|
||||
return ListView.builder(
|
||||
key: templatesGalleryKey,
|
||||
padding: withBarClearance(context, const EdgeInsets.only(bottom: 8)),
|
||||
itemCount: templates.length,
|
||||
separatorBuilder: (_, _) => const Divider(height: 1),
|
||||
itemBuilder: (context, index) {
|
||||
final entry = templates[index];
|
||||
return ListTile(
|
||||
key: templateRowKey(entry.key),
|
||||
title: Text(templateGalleryName(entry)),
|
||||
subtitle: _materialSubtitle(entry),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: () => onOpen(entry.key),
|
||||
return templatesColumn(
|
||||
AppListRow(
|
||||
key: templateRowKey(entry.key),
|
||||
cupertino: cupertino,
|
||||
divider: index < templates.length - 1,
|
||||
onTap: () => onOpen(entry.key),
|
||||
leading: ExcludeSemantics(
|
||||
child: AppListAvatar.initial(
|
||||
templateDetailName(entry),
|
||||
key: templateAvatarKey(entry.key),
|
||||
color: _avatarColor(context, entry.key, cupertino),
|
||||
),
|
||||
),
|
||||
title: Text(templateGalleryName(entry)),
|
||||
subtitle: _subtitle(entry),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertinoList(BuildContext context) {
|
||||
return ListView(
|
||||
key: templatesGalleryKey,
|
||||
children: [
|
||||
CupertinoListSection.insetGrouped(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
children: [
|
||||
for (final entry in templates)
|
||||
CupertinoListTile(
|
||||
key: templateRowKey(entry.key),
|
||||
title: _cupertinoText(templateGalleryName(entry)),
|
||||
subtitle: _cupertinoSubtitle(entry),
|
||||
trailing: const CupertinoListTileChevron(),
|
||||
onTap: () => onOpen(entry.key),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// The native tile is single-line by default. Let its content wrap at larger
|
||||
/// text sizes instead of ellipsizing a template's own name; the row grows
|
||||
/// with the content and nothing else about the tile is restyled.
|
||||
Widget _cupertinoText(String text) =>
|
||||
DefaultTextStyle.merge(maxLines: 3, child: Text(text));
|
||||
|
||||
Widget _materialSubtitle(TemplateEntry entry) {
|
||||
final description = entry.description.trim().isEmpty
|
||||
? null
|
||||
: Text(entry.description);
|
||||
final count = Text(_stageCountLabel(entry.key));
|
||||
if (description == null) return count;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [description, count],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _cupertinoSubtitle(TemplateEntry entry) {
|
||||
final description = entry.description.trim().isEmpty
|
||||
? null
|
||||
: _cupertinoText(entry.description);
|
||||
final count = _cupertinoText(_stageCountLabel(entry.key));
|
||||
if (description == null) return count;
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [description, count],
|
||||
);
|
||||
}
|
||||
|
||||
String _stageCountLabel(String key) {
|
||||
if (!stageCounts.containsKey(key) || stageCounts[key] == null) {
|
||||
return 'stage count unavailable';
|
||||
/// One of the theme's accents, picked by the template key so a row keeps
|
||||
/// its colour across reloads (the Pipelines list's palette).
|
||||
Color _avatarColor(BuildContext context, String key, 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 count = stageCounts[key]!;
|
||||
return '$count ${count == 1 ? 'stage' : 'stages'}';
|
||||
final hash = key.codeUnits.fold<int>(0, (sum, unit) => sum + unit);
|
||||
return colors[hash % colors.length];
|
||||
}
|
||||
|
||||
/// The description, then the stage count when the server could parse the
|
||||
/// source. An unknown count is left out rather than announced on every row.
|
||||
Widget? _subtitle(TemplateEntry entry) {
|
||||
final count = stageCounts[entry.key];
|
||||
final parts = [
|
||||
if (entry.description.trim().isNotEmpty) entry.description.trim(),
|
||||
if (count != null) '$count ${count == 1 ? 'stage' : 'stages'}',
|
||||
];
|
||||
return parts.isEmpty ? null : Text(parts.join(' · '));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import '../../../ui/theme/app_theme.dart';
|
||||
|
||||
const templatesRefreshKey = ValueKey<String>('templates-refresh');
|
||||
const templatesBackKey = ValueKey<String>('templates-back');
|
||||
const templatesTitle = 'Templates';
|
||||
|
||||
/// The screen's native chrome.
|
||||
///
|
||||
@@ -26,8 +27,14 @@ class TemplatesFrame extends StatelessWidget {
|
||||
required this.refreshing,
|
||||
required this.onBack,
|
||||
required this.onRefresh,
|
||||
this.title = templatesTitle,
|
||||
this.subtitle,
|
||||
});
|
||||
|
||||
/// The bar's title pill: `Templates` on the gallery, the open template's
|
||||
/// name (with its description as [subtitle]) on a detail.
|
||||
final String title;
|
||||
final String? subtitle;
|
||||
final Widget body;
|
||||
final bool embedded;
|
||||
final bool canGoBack;
|
||||
@@ -41,7 +48,8 @@ class TemplatesFrame extends StatelessWidget {
|
||||
if (embedded) {
|
||||
if (ShellBar.available(context)) {
|
||||
return ShellBar(
|
||||
title: 'Templates',
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
onBack: canGoBack ? onBack : null,
|
||||
actions: [_refreshButton()],
|
||||
child: body,
|
||||
@@ -70,14 +78,16 @@ class TemplatesFrame extends StatelessWidget {
|
||||
onPressed: onBack,
|
||||
)
|
||||
: null,
|
||||
title: 'Templates',
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
actions: [_refreshButton()],
|
||||
);
|
||||
// The body reaches the top edge and scrolls behind the bar.
|
||||
final page = SafeArea(top: false, bottom: false, child: body);
|
||||
if (cupertino) {
|
||||
return CupertinoPageScaffold(
|
||||
backgroundColor: AppColors.groupedBackground,
|
||||
// Plain list rows on the page background, like the other lists.
|
||||
backgroundColor: AppColors.background,
|
||||
navigationBar: bar,
|
||||
child: page,
|
||||
);
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../adaptive/host.dart';
|
||||
|
||||
/// The label of every sheet's close action.
|
||||
const appSheetDoneLabel = 'Done';
|
||||
|
||||
/// The app's one sheet header: the sheet's [title] at the start, then any
|
||||
/// extra [actions] (Clear all), then Done, which closes the sheet.
|
||||
///
|
||||
/// Material shows the title in `titleLarge` and a [TextButton]; Cupertino
|
||||
/// shows the navigation title style and a bold [CupertinoButton], like a
|
||||
/// modal's navigation bar. The title is a header that names the route, so a
|
||||
/// screen reader announces the sheet by it. Nothing has a fixed height and the
|
||||
/// title wraps at large text. Used by the Runs filter and sort sheets and the
|
||||
/// Needs you sheet, so every sheet closes the same way, not only by its drag
|
||||
/// handle.
|
||||
class AppSheetHeader extends StatelessWidget {
|
||||
const AppSheetHeader({
|
||||
super.key,
|
||||
required this.title,
|
||||
this.actions = const [],
|
||||
this.onDone,
|
||||
this.doneKey,
|
||||
this.cupertino,
|
||||
});
|
||||
|
||||
final String title;
|
||||
|
||||
/// Controls before Done, in the host's style.
|
||||
final List<Widget> actions;
|
||||
|
||||
/// Closes the sheet; the default pops the route the header is in.
|
||||
final VoidCallback? onDone;
|
||||
final Key? doneKey;
|
||||
|
||||
/// Overrides the host detection.
|
||||
final bool? cupertino;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = this.cupertino ?? usesCupertinoHost(context);
|
||||
final done = onDone ?? () => Navigator.of(context).maybePop();
|
||||
final titleStyle = cupertino
|
||||
? CupertinoTheme.of(context).textTheme.navTitleTextStyle
|
||||
: Theme.of(context).textTheme.titleLarge;
|
||||
final Widget doneButton = cupertino
|
||||
? CupertinoButton(
|
||||
key: doneKey,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
|
||||
onPressed: done,
|
||||
child: const Text(
|
||||
appSheetDoneLabel,
|
||||
style: TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
)
|
||||
: TextButton(
|
||||
key: doneKey,
|
||||
onPressed: done,
|
||||
child: const Text(appSheetDoneLabel),
|
||||
);
|
||||
return Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
cupertino ? 20 : 24,
|
||||
cupertino ? 8 : 0,
|
||||
8,
|
||||
4,
|
||||
),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final heading = Expanded(
|
||||
child: Semantics(
|
||||
header: true,
|
||||
namesRoute: true,
|
||||
child: Text(title, style: titleStyle),
|
||||
),
|
||||
);
|
||||
// A narrow sheet at large text moves the extra actions to a line
|
||||
// of their own under the title, so nothing is squeezed off.
|
||||
final narrow =
|
||||
constraints.maxWidth <
|
||||
MediaQuery.textScalerOf(context).scale(_wideHeaderWidth);
|
||||
if (actions.isEmpty || !narrow) {
|
||||
return Row(children: [heading, ...actions, doneButton]);
|
||||
}
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Row(children: [heading, doneButton]),
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerStart,
|
||||
child: Wrap(children: actions),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Below this width (scaled with the text) the extra actions wrap under the
|
||||
/// title.
|
||||
const double _wideHeaderWidth = 360;
|
||||
@@ -0,0 +1,117 @@
|
||||
# Templates, sheets, dialogs, Settings and artifact errors (review r2 D + H + L)
|
||||
|
||||
Fixes from the second style review (`/tmp/app-style-review-r2/report-summary.md`):
|
||||
P1-3, P2-1, P2-7, P2-10, P3-7, P3-8, P3-9, P3-10 and P3-12.
|
||||
|
||||
## Templates (P1-3, P2-1)
|
||||
|
||||
- Gallery (`features/templates/ui/template_gallery.dart`): the old
|
||||
`ListTile`/`CupertinoListTile` list is gone. Rows are `AppListRow`s with an
|
||||
`AppListAvatar.initial` (key `template-avatar-<key>`, a theme accent picked
|
||||
by the template key), the name as the bold title and one subtitle line: the
|
||||
description, then `N stages` only when the server parsed the source. The
|
||||
`stage count unavailable` line, chevrons and full-width dividers are gone.
|
||||
Row keys `template-row-<key>` are kept.
|
||||
- Width: `templatesContentMaxWidth` = 720 (the Settings column), start-aligned
|
||||
via `templatesColumn`, for the gallery and the detail.
|
||||
- Background: both Templates scaffolds (`TemplatesFrame` standalone and
|
||||
`application/templates_destination.dart`) use `AppColors.background` on
|
||||
Cupertino; the inset-grouped band is gone.
|
||||
- Detail: the bar's title pill shows the template name with its description
|
||||
as the subtitle (`templateBarTitle`; `TemplatesFrame.title/subtitle`, which
|
||||
publishes through `ShellBar`; the Templates destination passes the subtitle
|
||||
to its `SegmentedBar`). The body no longer repeats the name as a headline
|
||||
(only a bar-less embedded page still names it). Create is a compact button
|
||||
at its own width (Material `FilledButton.icon`, Cupertino medium filled),
|
||||
key `template-create-action` kept. The `Key / release` label/value pair is
|
||||
one muted line: the key (`template-key`, selectable, read as "Key …") and
|
||||
`· Includes a schedule`. The Cupertino muted style is now 15pt
|
||||
`secondaryLabel` instead of the 10pt tab caption.
|
||||
|
||||
## Sheets (P2-7, P3-9)
|
||||
|
||||
- `lib/ui/layout/app_sheet_header.dart` `AppSheetHeader`: title (route-naming
|
||||
header) + optional extra actions + Done (Material `TextButton`, Cupertino
|
||||
bold `CupertinoButton`). On a narrow sheet at large text the extra actions
|
||||
wrap under the title.
|
||||
- Used by the Runs filter sheet (key `runs.filter.done`; Clear filters moved
|
||||
to a header `Clear`, key `runs.filter.clear`, shown only when something is
|
||||
active), the Material Runs sort sheet (`runs.sort.done`) and both Needs you
|
||||
sheets (`attention-done`; Clear all stays as a Material header action and
|
||||
the Cupertino Clear-all group). The Cupertino sort stays a native action
|
||||
sheet with title and Cancel; the current order is its default action.
|
||||
- Filter sheet split out to `runs/ui/runs_filter_sheet.dart`; shared choices
|
||||
and labels in `runs_filter_options.dart`. Statuses read in sentence case
|
||||
(`runStateLabel`), also on applied chips and the usage legend. Status keeps
|
||||
checkboxes on Material (several may be picked); Pipeline, Time range and
|
||||
Trigger are check rows (`ListTile` with a trailing check and `selected`,
|
||||
in a mutually exclusive semantics group).
|
||||
- Not done: the chat "Chat information" sheet still says `Close`
|
||||
(`chat_thread_view.dart` belongs to the chat lane). It should adopt
|
||||
`AppSheetHeader` (Done) for full consistency.
|
||||
|
||||
## Dialogs and action sheets (P2-10, P3-12)
|
||||
|
||||
- Cupertino decision prompt: options are `DecisionOptionRow`s
|
||||
(`runs/actions/decision_option_row.dart`, key `human-decision-option-<o>`):
|
||||
label-coloured text, the target in secondary text, an empty circle until
|
||||
picked and a filled check circle when picked, hairline separators, the whole
|
||||
row tappable. Material keeps its radio list.
|
||||
- `RunMoreMenu` passes `sheetTitle: runMoreMenuTitle(run)` (title or pipeline,
|
||||
else `Run <id>`), so the Cupertino run action sheet is titled like the chat
|
||||
row sheet.
|
||||
|
||||
## Usage page (P3-7)
|
||||
|
||||
The body no longer starts with a `Usage` heading (the bar says it). No usage:
|
||||
"No usage has been reported for these runs." No run in the last 7 days:
|
||||
"No runs started in the last 7 days." instead of seven zero labels. Otherwise
|
||||
the chart draws bars over a baseline axis, counts only above days with runs.
|
||||
|
||||
## Settings (P3-8)
|
||||
|
||||
- `secondaryActionLabel` is always `Reconnect` (never `Connect` beside
|
||||
`Disconnect`); keys unchanged.
|
||||
- Notifications: `NotificationPermissionTile` is one compact row: a short
|
||||
state line (`Alerts are off` …), one short helper line and `Enable`
|
||||
(Material `FilledButton.tonal`, Cupertino small tinted; named "Enable
|
||||
notifications"). The browser's full sentence for the state is the row's
|
||||
semantics label. `NotificationPermissionView` gained `headline`/`helper`.
|
||||
- Cupertino `Save workspace` is a small tinted button, so disabled reads as a
|
||||
disabled button.
|
||||
|
||||
## Artifact viewer (P3-10)
|
||||
|
||||
`artifactPreviewFailureMessage` (`artifacts/domain/artifact_preview_failure.dart`)
|
||||
maps no-answer, 404/410, 401/403, 5xx and other statuses to plain sentences;
|
||||
exception text is never shown. The failure message carries a Retry button
|
||||
(`artifact-preview-retry`) that refetches (failures are not cached).
|
||||
|
||||
## Tests
|
||||
|
||||
New: `test/features/templates/ui/template_layout_test.dart` (720 cap, named
|
||||
bar, compact Create, 320 @2x), `test/features/runs/ui/runs_sheets_test.dart`
|
||||
(header/Done, Clear, check rows, sentence case, sort header, usage empty
|
||||
states and chart), `test/features/artifacts/domain/artifact_preview_failure_test.dart`,
|
||||
a Retry test in `artifact_viewer_page_test.dart`, decision option-row
|
||||
assertions in `decision_action_test.dart`, `runMoreMenuTitle` in
|
||||
`run_list_row_test.dart`, and the Reconnect assertion in
|
||||
`settings_screen_test.dart`. Updated for intentional changes: the template
|
||||
gallery screen and behind-bar tests, runs toolbar test (sentence case;
|
||||
`reveal` also ensures visibility), notification tile and wiring tests.
|
||||
|
||||
Full suite (after merging main bd370c99): 2150 passed. `flutter analyze` clean, `flutter build web` OK.
|
||||
|
||||
## Evidence
|
||||
|
||||
`/tmp/r3-c-evidence/`: web build of `tool/templates_wiring_probe_entry.dart`
|
||||
over `/tmp/wave2-e-scripts/fixture_server.mjs`, driven by
|
||||
`/tmp/wave2-e-scripts/shoot.mjs` (spec generator `/tmp/r3c-scripts/mkspec.py`).
|
||||
`{m,c}-{templates,tdetail,filter,sort,needsyou,usage,decide,settings}-{560,1200}-{light,dark}`
|
||||
(+ `-empty` decide before picking, `-top` Settings top), `c-runmenu-*`,
|
||||
`{m,c}-artifact-560-{light,dark}` (404 → friendly message + Retry). The fixture
|
||||
cannot validate sources, so stage counts are absent in the gallery captures.
|
||||
No device run: Android and iOS are unverified.
|
||||
|
||||
Known gap: the usage page body is not width-capped on wide windows (summary
|
||||
caps belong to batch K).
|
||||
@@ -13,7 +13,7 @@ import 'templates_wiring_test.dart' show openSettings, openTemplates, pumpApp;
|
||||
|
||||
/// The app-level Templates page: one bar (Back + Refresh), the gallery and an
|
||||
/// open template reach the top edge, start below the bar at rest and scroll
|
||||
/// behind it. Cupertino draws inset-grouped rows on the grouped background.
|
||||
/// behind it. Both hosts draw the shared list rows on the page background.
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
@@ -69,13 +69,14 @@ void main() {
|
||||
)
|
||||
.first,
|
||||
);
|
||||
expect(scaffold.backgroundColor, AppColors.groupedBackground);
|
||||
// Plain shared rows on the page background, like the other lists.
|
||||
expect(scaffold.backgroundColor, AppColors.background);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: gallery,
|
||||
matching: find.byType(CupertinoListSection),
|
||||
),
|
||||
findsOneWidget,
|
||||
findsNothing,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/artifacts/domain/artifact_preview_failure.dart';
|
||||
|
||||
void main() {
|
||||
test('fetch failures read as plain language, never raw errors', () {
|
||||
expect(
|
||||
artifactPreviewFailureMessage(),
|
||||
'The preview could not be loaded. Check the connection and try again.',
|
||||
);
|
||||
expect(
|
||||
artifactPreviewFailureMessage(status: 404),
|
||||
'This file is no longer on the server.',
|
||||
);
|
||||
expect(
|
||||
artifactPreviewFailureMessage(status: 403),
|
||||
'The server did not allow this file to be opened.',
|
||||
);
|
||||
expect(
|
||||
artifactPreviewFailureMessage(status: 502),
|
||||
'The server could not send this file right now.',
|
||||
);
|
||||
expect(
|
||||
artifactPreviewFailureMessage(status: 418),
|
||||
'The preview could not be loaded (status 418).',
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -12,6 +12,8 @@ import 'package:pipelines_app/features/artifacts/domain/artifact_groups.dart';
|
||||
import 'package:pipelines_app/features/artifacts/domain/artifact_record.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_external_open.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_gallery_page.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_content.dart'
|
||||
show artifactPreviewRetryKey;
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_fetch.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_viewer_page.dart';
|
||||
import 'package:pipelines_app/features/artifacts/ui/artifact_visit_list.dart';
|
||||
@@ -464,8 +466,39 @@ void main() {
|
||||
|
||||
pending.complete(ArtifactFetchResult(status: 404, bytes: Uint8List(0)));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('The server answered 404.'), findsOneWidget);
|
||||
expect(find.text('This file is no longer on the server.'), findsOneWidget);
|
||||
expect(find.textContaining('answered'), findsNothing);
|
||||
expect(find.byType(SelectableText), findsNothing);
|
||||
expect(find.byKey(artifactPreviewRetryKey), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Retry fetches a failed preview again', (tester) async {
|
||||
final text = recordedArtifact(
|
||||
'notes.txt',
|
||||
url: '/artifacts/1/1/notes.txt',
|
||||
contentType: 'text/plain',
|
||||
);
|
||||
final group = _group([text]);
|
||||
var calls = 0;
|
||||
await _pumpViewer(
|
||||
tester,
|
||||
groups: [group],
|
||||
selected: artifactVisitIdentity(group, text),
|
||||
fetch: (_) async {
|
||||
calls++;
|
||||
if (calls == 1) throw const ArtifactFetchException('network down');
|
||||
return ArtifactFetchResult(
|
||||
status: 200,
|
||||
bytes: Uint8List.fromList('hello'.codeUnits),
|
||||
);
|
||||
},
|
||||
);
|
||||
expect(find.byKey(artifactPreviewRetryKey), findsOneWidget);
|
||||
await tester.tap(find.byKey(artifactPreviewRetryKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(calls, 2);
|
||||
expect(find.byKey(artifactPreviewRetryKey), findsNothing);
|
||||
expect(find.text('hello'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('a network failure is reported instead of an empty preview', (
|
||||
@@ -483,8 +516,15 @@ void main() {
|
||||
selected: artifactVisitIdentity(group, text),
|
||||
fetch: (_) async => throw const ArtifactFetchException('network down'),
|
||||
);
|
||||
expect(find.textContaining('Could not load preview'), findsOneWidget);
|
||||
expect(find.textContaining('network down'), findsOneWidget);
|
||||
// A friendly line with Retry, never the raw exception text.
|
||||
expect(
|
||||
find.text(
|
||||
'The preview could not be loaded. Check the connection and try again.',
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.textContaining('network down'), findsNothing);
|
||||
expect(find.byKey(artifactPreviewRetryKey), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino draws the same text preview and controls', (
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:pipelines_app/features/attention/notify/notification_controller.
|
||||
import 'package:pipelines_app/features/attention/notify/notification_models.dart';
|
||||
import 'package:pipelines_app/features/attention/notify/notification_store.dart';
|
||||
import 'package:pipelines_app/features/attention/ui/needs_you_runs_heading.dart';
|
||||
import 'package:pipelines_app/features/attention/ui/notification_permission_tile.dart';
|
||||
import 'package:pipelines_app/features/settings/settings_notifications_section.dart';
|
||||
|
||||
import 'notification_test_support.dart';
|
||||
@@ -70,13 +71,13 @@ void main() {
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SettingsNotificationsSection(controller: notify),
|
||||
),
|
||||
home: Scaffold(body: SettingsNotificationsSection(controller: notify)),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.text(notificationRationale), findsOneWidget);
|
||||
// One compact row: the short state, not the long rationale paragraph.
|
||||
expect(find.byKey(notificationStateKey), findsOneWidget);
|
||||
expect(find.text(notificationRationale), findsNothing);
|
||||
|
||||
// A denied platform answer shows its own words and no Enable action.
|
||||
final denied = NotificationController(
|
||||
@@ -86,12 +87,11 @@ void main() {
|
||||
addTearDown(denied.dispose);
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: Scaffold(
|
||||
body: SettingsNotificationsSection(controller: denied),
|
||||
),
|
||||
home: Scaffold(body: SettingsNotificationsSection(controller: denied)),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
expect(find.text(notificationRationale), findsOneWidget);
|
||||
expect(find.byKey(notificationStateKey), findsOneWidget);
|
||||
expect(find.text(notificationRationale), findsNothing);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ void main() {
|
||||
for (final native in [false, true]) {
|
||||
final host = native ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets('$host shows the state\'s own honest copy', (tester) async {
|
||||
testWidgets('$host shows a compact row for each state', (tester) async {
|
||||
final cases = <NotificationPermissionState, String>{
|
||||
NotificationPermissionState.unsupported: notificationUnsupportedCopy,
|
||||
NotificationPermissionState.needsSecureContext:
|
||||
@@ -46,10 +46,15 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
_page(state: entry.key, cupertino: native, onRequest: _noop),
|
||||
);
|
||||
// The Settings section owns the heading; the tile is its body.
|
||||
final view = notificationPermissionView(entry.key);
|
||||
// The Settings section owns the heading; the tile is one short row.
|
||||
expect(find.text(notificationSectionTitle), findsNothing);
|
||||
expect(find.text(notificationRationale), findsOneWidget);
|
||||
expect(find.text(entry.value), findsOneWidget, reason: '${entry.key}');
|
||||
expect(find.text(notificationRationale), findsNothing);
|
||||
expect(find.text(view.headline), findsOneWidget);
|
||||
expect(find.text(view.helper), findsOneWidget);
|
||||
// The full honest sentence is what assistive technology reads.
|
||||
expect(view.body, entry.value);
|
||||
expect(find.bySemanticsLabel(entry.value), findsOneWidget);
|
||||
expect(
|
||||
find.byKey(notificationEnableKey),
|
||||
entry.key == NotificationPermissionState.notRequested
|
||||
@@ -70,8 +75,9 @@ void main() {
|
||||
cupertino: native,
|
||||
),
|
||||
);
|
||||
expect(find.text(notificationDefaultAskedCopy), findsOneWidget);
|
||||
expect(find.text(notificationDefaultCopy), findsNothing);
|
||||
expect(find.text('Alerts are still off'), findsOneWidget);
|
||||
expect(find.bySemanticsLabel(notificationDefaultAskedCopy), findsOne);
|
||||
expect(find.bySemanticsLabel(notificationDefaultCopy), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('$host Enable runs the explicit request', (tester) async {
|
||||
@@ -115,16 +121,19 @@ void main() {
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
|
||||
final rationale = tester.renderObject<RenderParagraph>(
|
||||
find.text(notificationRationale),
|
||||
final view = notificationPermissionView(
|
||||
NotificationPermissionState.notRequested,
|
||||
);
|
||||
final helper = tester.renderObject<RenderParagraph>(
|
||||
find.text(view.helper),
|
||||
);
|
||||
expect(
|
||||
rationale.size.width,
|
||||
helper.size.width,
|
||||
greaterThan(100),
|
||||
reason: 'the action must not squeeze the section copy',
|
||||
reason: 'the action must not squeeze the row copy',
|
||||
);
|
||||
final body = tester.renderObject<RenderParagraph>(
|
||||
find.text(notificationDefaultCopy),
|
||||
find.text(view.headline),
|
||||
);
|
||||
expect(body.didExceedMaxLines, isFalse);
|
||||
expect(find.byKey(notificationEnableKey), findsOneWidget);
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/decision_action.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/decision_option_row.dart';
|
||||
import 'package:pipelines_app/features/runs/actions/decision_wording.dart';
|
||||
|
||||
typedef _Handler = Future<JsonMap> Function(String type, JsonMap fields);
|
||||
@@ -194,9 +195,33 @@ void main() {
|
||||
decisionConfirmLabel,
|
||||
);
|
||||
expect(tester.widget<CupertinoDialogAction>(confirm).onPressed, isNull);
|
||||
// Options are check-list rows, not blue link buttons: an empty circle
|
||||
// until one is picked, then a filled check on that row only.
|
||||
final skip = find.byKey(decisionOptionKey('skip'));
|
||||
expect(skip, findsOneWidget);
|
||||
expect(
|
||||
find.ancestor(
|
||||
of: find.text('skip'),
|
||||
matching: find.byType(CupertinoButton),
|
||||
),
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.byIcon(CupertinoIcons.checkmark_circle_fill), findsNothing);
|
||||
expect(
|
||||
find.descendant(of: skip, matching: find.byIcon(CupertinoIcons.circle)),
|
||||
findsOneWidget,
|
||||
);
|
||||
await tester.tap(find.text('skip'));
|
||||
await tester.pump();
|
||||
expect(gateway.calls, isEmpty);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: skip,
|
||||
matching: find.byIcon(CupertinoIcons.checkmark_circle_fill),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byIcon(CupertinoIcons.checkmark_circle_fill), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text(decisionConfirmLabel));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@@ -84,6 +84,12 @@ void main() {
|
||||
expect(find.text('Pipeline unavailable · 2m 5s · 3 steps'), findsOneWidget);
|
||||
});
|
||||
|
||||
test('the run action sheet is titled with the run', () {
|
||||
expect(runMoreMenuTitle(_finished), 'Ship the release notes');
|
||||
expect(runMoreMenuTitle({'id': 5, 'name': 'nightly'}), 'nightly');
|
||||
expect(runMoreMenuTitle({'id': 5}), 'Run 5');
|
||||
});
|
||||
|
||||
testWidgets('gives a list action menu a per-run key', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
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';
|
||||
import 'package:pipelines_app/features/runs/data/runs_repository.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_controller.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_filter_sheet.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_filters.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/runs_list.dart';
|
||||
import 'package:pipelines_app/ui/layout/app_sheet_header.dart';
|
||||
|
||||
class _Gateway implements ApiGateway {
|
||||
final framesController = StreamController<JsonMap>.broadcast();
|
||||
JsonMap? reply;
|
||||
|
||||
@override
|
||||
Stream<JsonMap> get frames => framesController.stream;
|
||||
|
||||
@override
|
||||
Future<JsonMap> call(String type, [JsonMap fields = const {}]) async =>
|
||||
reply ?? {'runs': []};
|
||||
}
|
||||
|
||||
/// The Runs sheets share one header (title and Done), single-choice groups
|
||||
/// use check rows, statuses read in sentence case, and the usage page neither
|
||||
/// repeats its title nor draws a chart of zeros.
|
||||
void main() {
|
||||
late _Gateway gateway;
|
||||
late RunsController controller;
|
||||
|
||||
setUp(() {
|
||||
gateway = _Gateway();
|
||||
controller = RunsController(RunsRepository(gateway));
|
||||
});
|
||||
|
||||
tearDown(() async {
|
||||
controller.dispose();
|
||||
await gateway.framesController.close();
|
||||
});
|
||||
|
||||
Future<void> mount(
|
||||
WidgetTester tester, {
|
||||
required bool cupertino,
|
||||
String? createdAt,
|
||||
}) async {
|
||||
tester.view.physicalSize = const Size(800, 1400);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
final at = createdAt ?? DateTime.now().toIso8601String();
|
||||
gateway.reply = {
|
||||
'runs': [
|
||||
{
|
||||
'id': 1,
|
||||
'pipeline_id': 9,
|
||||
'name': 'Alpha',
|
||||
'status': 'running',
|
||||
'created_at': at,
|
||||
'scheduled': true,
|
||||
},
|
||||
],
|
||||
};
|
||||
await controller.load();
|
||||
final list = AnimatedBuilder(
|
||||
animation: controller,
|
||||
builder: (context, _) =>
|
||||
RunsList(controller: controller, onSelected: (_) {}),
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(home: CupertinoPageScaffold(child: list))
|
||||
: MaterialApp(home: Scaffold(body: list)),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets('$host filter sheet has a header whose Done closes it', (
|
||||
tester,
|
||||
) async {
|
||||
await mount(tester, cupertino: cupertino);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.filter')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(AppSheetHeader), findsOneWidget);
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byType(AppSheetHeader),
|
||||
matching: find.text(runsFilterTitle),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Queued'), findsOneWidget);
|
||||
expect(find.text('queued'), findsNothing);
|
||||
expect(find.byKey(runsFilterClearKey), findsNothing);
|
||||
|
||||
await tester.tap(find.text('Last 7 days'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(controller.timeRange, 'last_7_days');
|
||||
// An active filter offers Clear in the header.
|
||||
expect(find.byKey(runsFilterClearKey), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(runsFilterDoneKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const ValueKey('runs.filter.sheet')), findsNothing);
|
||||
// The applied chip reads in sentence case too.
|
||||
expect(find.textContaining('Last 7 days'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('Material single-choice groups are check rows, not checkboxes', (
|
||||
tester,
|
||||
) async {
|
||||
await mount(tester, cupertino: false);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.filter')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Seven statuses may be combined: those keep their checkboxes.
|
||||
expect(find.byType(CheckboxListTile), findsNWidgets(7));
|
||||
final anyTime = find.widgetWithText(ListTile, 'Any time');
|
||||
expect(anyTime, findsOneWidget);
|
||||
expect(
|
||||
find.descendant(of: anyTime, matching: find.byIcon(Icons.check)),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.descendant(of: anyTime, matching: find.byType(Checkbox)),
|
||||
findsNothing,
|
||||
);
|
||||
final today = find.widgetWithText(ListTile, 'Today');
|
||||
expect(
|
||||
find.descendant(of: today, matching: find.byIcon(Icons.check)),
|
||||
findsNothing,
|
||||
);
|
||||
expect(tester.widget<ListTile>(anyTime).selected, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('Material sort sheet has the same header', (tester) async {
|
||||
await mount(tester, cupertino: false);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.sort')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(runsSortTitle), findsOneWidget);
|
||||
await tester.tap(find.byKey(runsSortDoneKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(runsSortTitle), findsNothing);
|
||||
expect(controller.sort, 'newest_first');
|
||||
});
|
||||
|
||||
testWidgets('the usage page is honest when nothing was reported', (
|
||||
tester,
|
||||
) async {
|
||||
await mount(
|
||||
tester,
|
||||
cupertino: false,
|
||||
createdAt: DateTime(2020, 1, 1).toIso8601String(),
|
||||
);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.stats')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// The bar says Usage; the body does not repeat it.
|
||||
expect(find.text('Usage'), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('runs.stats.usage.empty')), findsOne);
|
||||
expect(find.byKey(const ValueKey('runs.stats.days')), findsNothing);
|
||||
expect(find.byKey(const ValueKey('runs.stats.days.empty')), findsOne);
|
||||
expect(find.text('Running'), findsOneWidget);
|
||||
expect(find.text('0'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('the 7-day chart shows bars over an axis when runs started', (
|
||||
tester,
|
||||
) async {
|
||||
await mount(tester, cupertino: true);
|
||||
await tester.tap(find.byKey(const ValueKey('runs.stats')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const ValueKey('runs.stats.days')), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('runs.stats.days.empty')), findsNothing);
|
||||
// Only the day with a run is labelled with its count.
|
||||
final days = find.byKey(const ValueKey('runs.stats.days'));
|
||||
expect(find.descendant(of: days, matching: find.text('1')), findsOne);
|
||||
expect(find.text('0'), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
@@ -70,18 +70,22 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Future<void> reveal(WidgetTester tester, Finder target) =>
|
||||
tester.scrollUntilVisible(
|
||||
target,
|
||||
80,
|
||||
// The sheet's own list, not the search field's inner scrollable.
|
||||
scrollable: find
|
||||
.descendant(
|
||||
of: find.byKey(const ValueKey('runs.filter.sheet')),
|
||||
matching: find.byType(Scrollable),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
Future<void> reveal(WidgetTester tester, Finder target) async {
|
||||
await tester.scrollUntilVisible(
|
||||
target,
|
||||
80,
|
||||
// The sheet's own list, not the search field's inner scrollable.
|
||||
scrollable: find
|
||||
.descendant(
|
||||
of: find.byKey(const ValueKey('runs.filter.sheet')),
|
||||
matching: find.byType(Scrollable),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
// Built is not on screen: bring the row fully inside the sheet.
|
||||
await tester.ensureVisible(target);
|
||||
await tester.pumpAndSettle();
|
||||
}
|
||||
|
||||
Future<void> closeSheet(WidgetTester tester) async {
|
||||
await tester.tapAt(const Offset(4, 4));
|
||||
@@ -148,7 +152,7 @@ void main() {
|
||||
await tester.tap(find.byKey(const ValueKey('runs.filter')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoSearchTextField), findsOneWidget);
|
||||
final failed = find.widgetWithText(CupertinoListTile, 'failed');
|
||||
final failed = find.widgetWithText(CupertinoListTile, 'Failed');
|
||||
await reveal(tester, failed);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(failed);
|
||||
@@ -156,7 +160,7 @@ void main() {
|
||||
expect(controller.statuses, {'failed'});
|
||||
await closeSheet(tester);
|
||||
|
||||
final failedChip = find.widgetWithText(CupertinoButton, 'failed');
|
||||
final failedChip = find.widgetWithText(CupertinoButton, 'Failed');
|
||||
expect(failedChip, findsOneWidget);
|
||||
expect(find.text('Alpha'), findsNothing);
|
||||
await tester.tap(failedChip);
|
||||
|
||||
@@ -154,6 +154,15 @@ void main() {
|
||||
expect(find.text('Server time 2026-10-21T12:00:00Z'), findsOneWidget);
|
||||
expect(find.byKey(SettingsKeys.disconnect), findsOneWidget);
|
||||
expect(find.byKey(SettingsKeys.connect), findsOneWidget);
|
||||
// Beside Disconnect, the second action reconnects; it never says Connect.
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byKey(SettingsKeys.connect),
|
||||
matching: find.text('Reconnect'),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Connect'), findsNothing);
|
||||
// The only other request is the ntfy settings load, queued behind ping.
|
||||
_answerNtfySettings(factory.last);
|
||||
await tester.pump();
|
||||
|
||||
@@ -6,6 +6,9 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/templates/screen.dart';
|
||||
import 'package:pipelines_app/features/templates/ui/template_detail.dart';
|
||||
import 'package:pipelines_app/features/templates/ui/template_gallery.dart'
|
||||
show templateAvatarKey;
|
||||
import 'package:pipelines_app/ui/layout/app_list_row.dart';
|
||||
|
||||
import '../data/template_test_support.dart' show source;
|
||||
import 'template_gallery_test_support.dart';
|
||||
@@ -31,15 +34,19 @@ void main() {
|
||||
|
||||
expect(find.byKey(templatesGalleryKey), findsOneWidget);
|
||||
expect(find.text('Release workflow'), findsOneWidget);
|
||||
expect(find.text('Ship a version'), findsOneWidget);
|
||||
expect(find.text('2 stages'), findsNWidgets(2));
|
||||
// One subtitle line: the description, then the parsed stage count.
|
||||
expect(find.text('Ship a version · 2 stages'), findsOneWidget);
|
||||
expect(find.text('No display name · 2 stages'), findsOneWidget);
|
||||
expect(find.text('(unnamed template)'), findsOneWidget);
|
||||
expect(find.byKey(templatesLoadingKey), findsNothing);
|
||||
// The app's shared rows with an initial avatar; no chevrons or tiles.
|
||||
expect(find.byType(AppListRow), findsNWidgets(2));
|
||||
expect(find.byKey(templateAvatarKey('release')), findsOneWidget);
|
||||
expect(find.byType(ListTile), findsNothing);
|
||||
expect(find.byIcon(Icons.chevron_right), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('stage count is unavailable when server parsing refuses', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('an unknown stage count is left out of the row', (tester) async {
|
||||
final gateway =
|
||||
GalleryGateway((type, fields) async => templatesReply(galleryTemplates))
|
||||
..validationHandler = (type, fields) async {
|
||||
@@ -48,8 +55,9 @@ void main() {
|
||||
|
||||
await pumpGallery(tester, gateway);
|
||||
|
||||
expect(find.text('stage count unavailable'), findsNWidgets(2));
|
||||
expect(find.text('0 stages'), findsNothing);
|
||||
expect(find.textContaining('stage count'), findsNothing);
|
||||
expect(find.textContaining('stages'), findsNothing);
|
||||
expect(find.text('Ship a version'), findsOneWidget);
|
||||
expect(gateway.callsOf('validate'), hasLength(2));
|
||||
expect(
|
||||
gateway.callsOf('validate').first.fields['source'],
|
||||
@@ -162,9 +170,20 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byKey(templateDetailKey), findsOneWidget);
|
||||
// The bar's title pill names the template; the body does not repeat it.
|
||||
final bar = find.byType(SegmentedBar);
|
||||
expect(
|
||||
find.descendant(of: bar, matching: find.text('Release workflow')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
find.descendant(of: bar, matching: find.text('Ship a version')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Release workflow'), findsOneWidget);
|
||||
expect(find.text('Ship a version'), findsOneWidget);
|
||||
expect(find.text('Key'), findsOneWidget);
|
||||
expect(find.text('Key'), findsNothing);
|
||||
expect(find.byKey(templateKeyKey), findsOneWidget);
|
||||
expect(find.text('Includes a schedule'), findsOneWidget);
|
||||
expect(find.text(templateSourceLabel), findsOneWidget);
|
||||
expect(selectableSource(source), findsOneWidget);
|
||||
@@ -230,7 +249,8 @@ void main() {
|
||||
);
|
||||
await pumpGallery(tester, gateway, cupertino: true);
|
||||
|
||||
expect(find.byType(CupertinoListTile), findsNWidgets(2));
|
||||
expect(find.byType(AppListRow), findsNWidgets(2));
|
||||
expect(find.byType(CupertinoListTile), findsNothing);
|
||||
expect(find.byType(Scaffold), findsNothing);
|
||||
await tester.tap(find.byKey(templateRowKey('release')));
|
||||
await tester.pumpAndSettle();
|
||||
@@ -247,7 +267,7 @@ void main() {
|
||||
|
||||
await tester.tap(find.byKey(templatesBackKey));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoListTile), findsNWidgets(2));
|
||||
expect(find.byType(AppListRow), findsNWidgets(2));
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/templates/screen.dart';
|
||||
import 'package:pipelines_app/features/templates/ui/template_gallery.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
||||
|
||||
import '../data/template_test_support.dart' show source;
|
||||
import 'template_gallery_test_support.dart';
|
||||
|
||||
/// The gallery and an open template on a wide window: the column stops at the
|
||||
/// Settings reading width, start-aligned; the bar names the open template and
|
||||
/// the Create action is a compact button, not a full-width bar.
|
||||
void main() {
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets('$host: rows and detail are capped at 720 on a wide window', (
|
||||
tester,
|
||||
) async {
|
||||
final gateway = GalleryGateway(
|
||||
(type, fields) async => templatesReply(galleryTemplates),
|
||||
);
|
||||
await pumpGallery(
|
||||
tester,
|
||||
gateway,
|
||||
cupertino: cupertino,
|
||||
size: const Size(1200, 800),
|
||||
);
|
||||
|
||||
final row = tester.getRect(find.byKey(templateRowKey('release')));
|
||||
expect(row.left, 0);
|
||||
expect(row.width, templatesContentMaxWidth);
|
||||
expect(find.text('Templates'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.byKey(templateRowKey('release')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final bar = find.byType(SegmentedBar);
|
||||
expect(
|
||||
find.descendant(of: bar, matching: find.text('Release workflow')),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Templates'), findsNothing);
|
||||
|
||||
final create = tester.getRect(find.byKey(templateCreateActionKey));
|
||||
expect(create.left, 16);
|
||||
// Its own width, not stretched across the 688 content column.
|
||||
expect(create.width, lessThan(templatesContentMaxWidth - 32));
|
||||
final body = tester.getRect(selectableSource(source));
|
||||
expect(body.right, lessThanOrEqualTo(templatesContentMaxWidth));
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('$host: the detail fits 320 at 2x text', (tester) async {
|
||||
final gateway = GalleryGateway(
|
||||
(type, fields) async => templatesReply(galleryTemplates),
|
||||
);
|
||||
await pumpGallery(
|
||||
tester,
|
||||
gateway,
|
||||
cupertino: cupertino,
|
||||
size: const Size(320, 800),
|
||||
textScale: 2,
|
||||
);
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.tap(find.byKey(templateRowKey('release')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(templateCreateActionKey), findsOneWidget);
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user