Share one list row across runs, pipelines, chat, search and schedules

AppListRow (Material + Cupertino) with avatar, bold title and trailing
time, one muted line, one overflow menu style, inset dividers, selected
and emphasised states and a compact mode. Pipelines get a legible initial
avatar, schedule rows shrink to two lines with Edit/Pause/Delete in an
overflow menu, and the shell chat list scrolls behind the bar.
This commit is contained in:
2026-10-31 04:15:01 +00:00
parent 6ab8551348
commit 3c56db37fd
38 changed files with 1841 additions and 1520 deletions
+11 -14
View File
@@ -1,7 +1,6 @@
import '../../shell/destination.dart';
import '../../shell/detail_page.dart';
import '../../shell/list_detail.dart';
import '../../ui/adaptive/floating_bar_layout.dart';
import '../../ui/adaptive/host.dart';
import 'dart:async';
@@ -242,19 +241,17 @@ class _ChatScreenState extends State<ChatScreen> {
? const SizedBox.shrink()
: _thread(selected, () => Navigator.of(context).maybePop()),
);
// The shell's body now reaches the top edge; until the session list pads
// itself by the bar (owned by the chat lane), it keeps starting below it.
final list = BelowTopBar(
child: ChatSessionsScreen(
gateway: widget.gateway,
embedded: true,
syncToken: widget.syncToken,
controller: _sessions,
onOpen: _open,
onSessions: _adoptRows,
activeSessionId: selected,
publishShellBar: true,
),
// The session list pads its first row by the bar's height itself, so it
// scrolls behind the shell's floating bar like the other lists.
final list = ChatSessionsScreen(
gateway: widget.gateway,
embedded: true,
syncToken: widget.syncToken,
controller: _sessions,
onOpen: _open,
onSessions: _adoptRows,
activeSessionId: selected,
publishShellBar: true,
);
if (!beside) return list;
return ListDetailPanes(
@@ -5,6 +5,7 @@ import '../../../../core/api_gateway.dart';
import '../../domain/chat_sessions.dart';
import 'chat_adaptive.dart';
import 'session_row_style.dart';
import '../../../../ui/layout/app_overflow_menu.dart';
enum SessionAction { star, rename, close, reopen, hide }
@@ -29,54 +30,19 @@ class SessionActionsButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
final label = sessionActionsLabel(session, duplicateTitles);
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
// Its own node, so the row's merged label never swallows the button.
return Semantics(
container: true,
label: label,
button: true,
child: CupertinoButton(
padding: EdgeInsets.zero,
onPressed: () => _showSheet(context),
child: const Icon(CupertinoIcons.ellipsis),
),
);
}
return PopupMenuButton<SessionAction>(
tooltip: label,
onSelected: onSelected,
itemBuilder: (context) => _menuItems(session),
return AppOverflowMenu<SessionAction>(
cupertino: chatControlsStyleOf(context) == ChatControlsStyle.cupertino,
label: sessionActionsLabel(session, duplicateTitles),
sheetTitle: chatSessionTitle(session),
actions: [
for (final item in _items(session))
AppMenuAction(value: item.action, label: item.label),
],
onSelected: (_, action) => onSelected(action),
);
}
Future<void> _showSheet(BuildContext context) async {
final action = await showCupertinoModalPopup<SessionAction>(
context: context,
builder: (sheetContext) => CupertinoActionSheet(
title: Text(chatSessionTitle(session)),
actions: [
for (final item in _items(session))
CupertinoActionSheetAction(
onPressed: () => Navigator.pop(sheetContext, item.action),
child: Text(item.label),
),
],
cancelButton: CupertinoActionSheetAction(
onPressed: () => Navigator.pop(sheetContext),
child: const Text('Cancel'),
),
),
);
if (action != null && context.mounted) onSelected(action);
}
}
List<PopupMenuEntry<SessionAction>> _menuItems(JsonMap session) => [
for (final item in _items(session))
PopupMenuItem(value: item.action, child: Text(item.label)),
];
List<({SessionAction action, String label})> _items(JsonMap session) {
final isClosed = session['closed_at'] != null;
return [
@@ -1,5 +1,4 @@
import '../../../../ui/layout/collapsible_list_section.dart';
import '../../../../ui/theme/app_theme.dart';
import 'package:flutter/cupertino.dart';
import '../../../../core/api_gateway.dart';
@@ -8,7 +7,6 @@ import 'chat_adaptive.dart';
import 'chat_sessions_body.dart';
import 'session_actions.dart';
import 'session_row_content.dart';
import 'session_row_style.dart';
import '../../../../ui/adaptive/floating_bar_layout.dart';
class CupertinoSessionList extends StatelessWidget {
@@ -76,43 +74,45 @@ class CupertinoSessionList extends StatelessWidget {
count: section.sessions.length,
initiallyOpen: section.title != 'Closed',
children: [
for (final group in groups)
CupertinoListSection.insetGrouped(
backgroundColor: AppColors.groupedBackground,
header: groups.length > 1
? Text(
group.directory.isEmpty
? 'No directory'
: group.directory,
)
: null,
children: [
for (final session in group.sessions) ..._row(session),
],
),
for (final group in groups) ...[
if (groups.length > 1)
_DirectoryHeader(
group.directory.isEmpty ? 'No directory' : group.directory,
),
for (var i = 0; i < group.sessions.length; i++)
..._row(
group.sessions[i],
divider: i < group.sessions.length - 1,
),
],
],
),
];
}
/// The tile plus its refusal. `CupertinoListTile` forces its subtitle to one
/// ellipsised line, so the server's words go in their own full-width row
/// inside the same native card.
List<Widget> _row(JsonMap session) {
/// The row plus its refusal, the server's words in their own full-width
/// row under it.
List<Widget> _row(JsonMap session, {required bool divider}) {
final id = '${session['id'] ?? ''}';
final error = errorFor(id);
return [
_CupertinoSessionRow(
ChatSessionRow(
session: session,
selected: id == activeSessionId,
duplicateTitles: duplicateTitles,
unseen: isUnseen(session),
// A refusal below the row separates it instead.
divider: divider && error == null,
onOpen: onOpen,
onRename: onRename,
onClose: onClose,
onReopen: onReopen,
onStar: onStar,
onHide: onHide,
onAction: (action) => _dispatch(
action,
session,
onStar: onStar,
onRename: onRename,
onClose: onClose,
onReopen: onReopen,
onHide: onHide,
),
),
if (error != null)
ChatRowError(
@@ -124,101 +124,50 @@ class CupertinoSessionList extends StatelessWidget {
}
}
class _CupertinoSessionRow extends StatelessWidget {
const _CupertinoSessionRow({
required this.session,
required this.selected,
required this.duplicateTitles,
required this.unseen,
required this.onOpen,
required this.onRename,
required this.onClose,
required this.onReopen,
required this.onStar,
required this.onHide,
});
/// Routes a row's menu choice to the list's callbacks.
void _dispatch(
SessionAction action,
JsonMap session, {
required ValueChanged<JsonMap> onStar,
required ValueChanged<JsonMap> onRename,
required ValueChanged<JsonMap> onClose,
required ValueChanged<JsonMap> onReopen,
required ValueChanged<JsonMap> onHide,
}) {
switch (action) {
case SessionAction.star:
onStar(session);
case SessionAction.rename:
onRename(session);
case SessionAction.close:
onClose(session);
case SessionAction.reopen:
onReopen(session);
case SessionAction.hide:
onHide(session);
}
}
final JsonMap session;
final bool selected;
final Set<String> duplicateTitles;
final bool unseen;
final ValueChanged<JsonMap> onOpen;
final ValueChanged<JsonMap> onRename;
final ValueChanged<JsonMap> onClose;
final ValueChanged<JsonMap> onReopen;
final ValueChanged<JsonMap> onStar;
final ValueChanged<JsonMap> onHide;
/// A directory's name above its chats, like a grouped table's header.
class _DirectoryHeader extends StatelessWidget {
const _DirectoryHeader(this.directory);
final String directory;
@override
Widget build(BuildContext context) {
final id = '${session['id'] ?? ''}';
final closed = chatSessionRowStatus(session, unseen: false) == 'Closed';
// A contact-list row, the same pieces as the Material row. The grouped
// list owns the separators and the tile its native text styles; the
// leading slot is widened to hold the avatar.
// A narrow pane (a wide window's list beside its detail, or its opening
// animation) drops the avatar and tightens the tile's insets, so the
// menu stays reachable and the title keeps some width.
return LayoutBuilder(
builder: (context, constraints) {
final avatar = constraints.maxWidth >= _avatarMinWidth;
return Semantics(
selected: selected,
child: CupertinoListTile(
key: Key('chat-row-$id'),
backgroundColor: selected
? CupertinoColors.tertiarySystemFill.resolveFrom(context)
: null,
padding: avatar
? null
: const EdgeInsetsDirectional.only(start: 8, end: 4),
leadingSize: avatar ? 40 : 28,
leading: avatar
? ChatSessionAvatar(
session: session,
running: session['running'] == true && !unseen,
selected: selected,
)
: null,
title: ChatSessionTitleLine(
title: chatSessionTitle(session),
recency: relativeChatSessionTime(session['updated_at']),
unread: unseen && !closed,
starred: session['starred'] == true,
),
subtitle: ChatSessionSubtitleLine(
text: chatSessionSubtitle(session),
unread: unseen && !closed,
closed: closed,
),
trailing: SessionActionsButton(
key: Key('chat-actions-$id'),
session: session,
duplicateTitles: duplicateTitles,
onSelected: _select,
),
onTap: () => onOpen(session),
),
);
},
final style = CupertinoTheme.of(context).textTheme.textStyle.copyWith(
fontSize: 13,
color: CupertinoColors.secondaryLabel.resolveFrom(context),
);
return Padding(
padding: const EdgeInsetsDirectional.fromSTEB(16, 16, 16, 6),
child: Text(
directory,
style: style,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
);
}
/// The tile width below which the row is compact: no avatar, tight insets.
static const double _avatarMinWidth = 240;
void _select(SessionAction action) {
switch (action) {
case SessionAction.star:
onStar(session);
case SessionAction.rename:
onRename(session);
case SessionAction.close:
onClose(session);
case SessionAction.reopen:
onReopen(session);
case SessionAction.hide:
onHide(session);
}
}
}
@@ -8,7 +8,6 @@ import 'chat_adaptive.dart';
import 'chat_sessions_body.dart';
import 'session_actions.dart';
import 'session_row_content.dart';
import 'session_row_style.dart';
class MaterialSessionList extends StatelessWidget {
const MaterialSessionList({
@@ -83,35 +82,38 @@ class MaterialSessionList extends StatelessWidget {
style: heading.title.copyWith(fontWeight: FontWeight.w600),
),
),
// Material's native list separator between rows in a group, the
// counterpart of the inset group's hairline on Cupertino. The group
// header still owns the boundary between directories.
for (var i = 0; i < group.sessions.length; i++) ...[
if (i > 0) const Divider(height: 1),
..._row(group.sessions[i]),
],
// Inset dividers between the rows of a group; the group header
// owns the boundary between directories.
for (var i = 0; i < group.sessions.length; i++)
..._row(group.sessions[i], divider: i < group.sessions.length - 1),
],
],
);
}
/// The tile plus its refusal at full width (a long sentence in `subtitle`
/// The row plus its refusal at full width (a long sentence in a subtitle
/// made the row taller than the viewport at 320px with 2x text).
List<Widget> _row(JsonMap session) {
List<Widget> _row(JsonMap session, {required bool divider}) {
final id = '${session['id'] ?? ''}';
final error = errorFor(id);
return [
_MaterialSessionRow(
ChatSessionRow(
session: session,
selected: id == activeSessionId,
duplicateTitles: duplicateTitles,
unseen: isUnseen(session),
// A refusal below the row separates it instead.
divider: divider && error == null,
onOpen: onOpen,
onRename: onRename,
onClose: onClose,
onReopen: onReopen,
onStar: onStar,
onHide: onHide,
onAction: (action) => _dispatch(
action,
session,
onStar: onStar,
onRename: onRename,
onClose: onClose,
onReopen: onReopen,
onHide: onHide,
),
),
if (error != null)
ChatRowError(
@@ -123,99 +125,26 @@ class MaterialSessionList extends StatelessWidget {
}
}
class _MaterialSessionRow extends StatelessWidget {
const _MaterialSessionRow({
required this.session,
required this.selected,
required this.duplicateTitles,
required this.unseen,
required this.onOpen,
required this.onRename,
required this.onClose,
required this.onReopen,
required this.onStar,
required this.onHide,
});
final JsonMap session;
final bool selected;
final Set<String> duplicateTitles;
final bool unseen;
final ValueChanged<JsonMap> onOpen;
final ValueChanged<JsonMap> onRename;
final ValueChanged<JsonMap> onClose;
final ValueChanged<JsonMap> onReopen;
final ValueChanged<JsonMap> onStar;
final ValueChanged<JsonMap> onHide;
@override
Widget build(BuildContext context) {
final id = '${session['id'] ?? ''}';
final theme = Theme.of(context);
final closed = chatSessionRowStatus(session, unseen: false) == 'Closed';
// A contact-list row, the same pieces as the Cupertino row: the harness
// avatar, the title with its time, one muted line, and the actions menu.
// ListTile asserts when its trailing control leaves the title no width.
// A narrow pane (a wide window's list beside its detail, or its opening
// animation) drops the avatar and tightens the tile's insets, so the
// menu stays reachable and the title keeps some width.
return LayoutBuilder(
builder: (context, constraints) {
final narrow = constraints.maxWidth < _avatarMinWidth;
return ListTile(
key: Key('chat-row-$id'),
selected: selected,
selectedTileColor: theme.colorScheme.secondaryContainer,
selectedColor: theme.colorScheme.onSecondaryContainer,
contentPadding: narrow
? const EdgeInsetsDirectional.only(start: 8)
: null,
horizontalTitleGap: narrow ? 4 : null,
leading: narrow
? null
: ChatSessionAvatar(
session: session,
running: session['running'] == true && !unseen,
selected: selected,
),
title: ChatSessionTitleLine(
title: chatSessionTitle(session),
recency: relativeChatSessionTime(session['updated_at']),
unread: unseen && !closed,
starred: session['starred'] == true,
),
subtitle: ChatSessionSubtitleLine(
text: chatSessionSubtitle(session),
unread: unseen && !closed,
closed: closed,
),
trailing: SessionActionsButton(
key: Key('chat-actions-$id'),
session: session,
duplicateTitles: duplicateTitles,
onSelected: _select,
),
onTap: () => onOpen(session),
);
},
);
}
/// The tile width below which the row is compact: no avatar, tight insets.
static const double _avatarMinWidth = 240;
void _select(SessionAction action) {
switch (action) {
case SessionAction.star:
onStar(session);
case SessionAction.rename:
onRename(session);
case SessionAction.close:
onClose(session);
case SessionAction.reopen:
onReopen(session);
case SessionAction.hide:
onHide(session);
}
/// Routes a row's menu choice to the list's callbacks.
void _dispatch(
SessionAction action,
JsonMap session, {
required ValueChanged<JsonMap> onStar,
required ValueChanged<JsonMap> onRename,
required ValueChanged<JsonMap> onClose,
required ValueChanged<JsonMap> onReopen,
required ValueChanged<JsonMap> onHide,
}) {
switch (action) {
case SessionAction.star:
onStar(session);
case SessionAction.rename:
onRename(session);
case SessionAction.close:
onClose(session);
case SessionAction.reopen:
onReopen(session);
case SessionAction.hide:
onHide(session);
}
}
@@ -2,12 +2,134 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../../core/api_gateway.dart';
import '../../../../ui/layout/app_list_avatar.dart';
import '../../../../ui/layout/app_list_row.dart';
import '../../domain/chat_sessions.dart';
import 'chat_adaptive.dart';
import 'session_actions.dart';
import 'session_harness_icon.dart';
import 'session_row_style.dart';
/// Row pieces shared by the Material and Cupertino chat lists. Each list puts
/// them in its native tile's slots: the avatar leads, the title line and the
/// subtitle line fill the text column, and the actions menu trails.
/// One chat in the list, in the app's shared row on both hosts: the harness
/// avatar, the title with its recency, one muted line, and the actions menu.
///
/// An unread chat is emphasised (heavier title, accent time) with an accent
/// dot ending its line; a starred chat shows a small star after its title; a
/// running chat carries an activity badge on its avatar. A narrow pane drops
/// the avatar and time but keeps the menu, the list's only way to its actions.
class ChatSessionRow extends StatelessWidget {
const ChatSessionRow({
super.key,
required this.session,
required this.onOpen,
required this.onAction,
this.selected = false,
this.unseen = false,
this.divider = true,
this.duplicateTitles = const {},
});
final JsonMap session;
final ValueChanged<JsonMap> onOpen;
final ValueChanged<SessionAction> onAction;
final bool selected;
final bool unseen;
final bool divider;
final Set<String> duplicateTitles;
@override
Widget build(BuildContext context) {
final id = '${session['id'] ?? ''}';
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
final closed = chatSessionRowStatus(session, unseen: false) == 'Closed';
final unread = unseen && !closed;
final accent = cupertino
? CupertinoTheme.of(context).primaryColor
: Theme.of(context).colorScheme.primary;
final text = chatSessionSubtitle(session);
return AppListRow(
key: Key('chat-row-$id'),
cupertino: cupertino,
selected: selected,
emphasized: unread,
divider: divider,
keepMenuWhenCompact: true,
onTap: () => onOpen(session),
leading: ChatSessionAvatar(
session: session,
running: session['running'] == true && !unseen,
selected: selected,
),
// The star rides in the title's own text, so a narrow row ellipsises
// them together.
title: Text.rich(
TextSpan(
text: chatSessionTitle(session),
children: [
if (session['starred'] == true)
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: Padding(
padding: const EdgeInsetsDirectional.only(start: 4),
child: _Star(cupertino: cupertino, color: accent),
),
),
],
),
),
time: relativeChatSessionTime(session['updated_at']),
// `Closed` leads the line of a closed chat, then the model and folder.
subtitle: Text.rich(
TextSpan(
children: [
if (closed)
const TextSpan(
text: 'Closed',
style: TextStyle(fontWeight: FontWeight.w600),
),
if (closed && text.isNotEmpty) const TextSpan(text: ' · '),
TextSpan(text: text),
],
),
),
subtitleTrailing: unread
? AppListStatusDot(
key: const Key('chat-row-unread'),
color: accent,
semanticLabel: 'New',
size: 10,
)
: null,
menu: SessionActionsButton(
key: Key('chat-actions-$id'),
session: session,
duplicateTitles: duplicateTitles,
onSelected: onAction,
),
);
}
}
/// As tall as the title's text, so it follows text scaling.
class _Star extends StatelessWidget {
const _Star({required this.cupertino, required this.color});
final bool cupertino;
final Color color;
@override
Widget build(BuildContext context) {
final size = DefaultTextStyle.of(context).style.fontSize ?? 14;
return Icon(
cupertino ? CupertinoIcons.star_fill : Icons.star,
key: const Key('chat-row-starred'),
size: MediaQuery.textScalerOf(context).scale(size),
color: color,
semanticLabel: 'Starred',
);
}
}
/// The chat's harness mark in a filled circle, like a contact avatar. A
/// running chat carries a small activity badge on the avatar's corner instead
@@ -43,26 +165,18 @@ class ChatSessionAvatar extends StatelessWidget {
: scheme.surfaceContainerHighest;
mark = selected ? scheme.onPrimaryContainer : scheme.onSurfaceVariant;
}
final avatar = CircleAvatar(
backgroundColor: fill,
return AppListAvatar(
foreground: mark,
background: fill,
badge: running
? Semantics(
key: const Key('chat-row-working'),
label: 'Chat is working',
child: _WorkingBadge(cupertino: cupertino),
)
: null,
child: SessionHarnessIcon(session: session, color: mark),
);
if (!running) return avatar;
return Stack(
clipBehavior: Clip.none,
children: [
avatar,
PositionedDirectional(
end: -2,
bottom: -2,
child: Semantics(
key: const Key('chat-row-working'),
label: 'Chat is working',
child: _WorkingBadge(cupertino: cupertino),
),
),
],
);
}
}
@@ -90,152 +204,3 @@ class _WorkingBadge extends StatelessWidget {
);
}
}
/// The title with its recency at the trailing edge. An unread chat's title is
/// bold and its time takes the accent, so it stands out at a glance; a starred
/// chat shows a small star after its title.
class ChatSessionTitleLine extends StatelessWidget {
const ChatSessionTitleLine({
super.key,
required this.title,
required this.recency,
this.unread = false,
this.starred = false,
});
final String title;
final String recency;
final bool unread;
final bool starred;
@override
Widget build(BuildContext context) {
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
final accent = cupertino
? CupertinoTheme.of(context).primaryColor
: Theme.of(context).colorScheme.primary;
final secondary = cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
final timeStyle =
(cupertino
? CupertinoTheme.of(context).textTheme.tabLabelTextStyle
: Theme.of(context).textTheme.bodySmall)
?.copyWith(
color: unread ? accent : secondary,
fontWeight: unread ? FontWeight.w600 : null,
);
final star = Icon(
cupertino ? CupertinoIcons.star_fill : Icons.star,
key: const Key('chat-row-starred'),
// As tall as the title's text, so it follows text scaling.
size: DefaultTextStyle.of(context).style.fontSize,
color: accent,
semanticLabel: 'Starred',
);
// The star rides in the title's own text, so a narrow row ellipsises
// them together; the time keeps at most about half the line.
return LayoutBuilder(
builder: (context, constraints) => Row(
children: [
Expanded(
child: Text.rich(
TextSpan(
text: title,
children: [
if (starred)
WidgetSpan(
alignment: PlaceholderAlignment.middle,
child: Padding(
padding: const EdgeInsetsDirectional.only(start: 4),
child: star,
),
),
],
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontWeight: unread ? FontWeight.w700 : FontWeight.w500,
),
),
),
if (recency.isNotEmpty)
ConstrainedBox(
constraints: BoxConstraints(maxWidth: constraints.maxWidth / 2),
child: Padding(
padding: const EdgeInsetsDirectional.only(start: 8),
child: Text(
recency,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: timeStyle,
),
),
),
],
),
);
}
}
/// One muted line: `Closed` first when the chat is closed, then the model and
/// folder, with an accent dot at the end while the chat has unread content.
class ChatSessionSubtitleLine extends StatelessWidget {
const ChatSessionSubtitleLine({
super.key,
required this.text,
this.unread = false,
this.closed = false,
});
final String text;
final bool unread;
final bool closed;
@override
Widget build(BuildContext context) {
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
final accent = cupertino
? CupertinoTheme.of(context).primaryColor
: Theme.of(context).colorScheme.primary;
return Row(
children: [
Expanded(
child: Text.rich(
TextSpan(
children: [
if (closed)
const TextSpan(
text: 'Closed',
style: TextStyle(fontWeight: FontWeight.w600),
),
if (closed && text.isNotEmpty) const TextSpan(text: ' · '),
TextSpan(text: text),
],
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
if (unread)
Padding(
padding: const EdgeInsetsDirectional.only(start: 8),
child: Semantics(
key: const Key('chat-row-unread'),
label: 'New',
child: DecoratedBox(
decoration: BoxDecoration(
color: accent,
shape: BoxShape.circle,
),
child: const SizedBox.square(dimension: 10),
),
),
),
],
);
}
}
@@ -1,4 +1,5 @@
import '../../../ui/theme/app_theme.dart';
import '../../../ui/layout/app_list_avatar.dart';
import '../../../ui/layout/app_list_row.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@@ -138,21 +139,9 @@ class PipelineListPanel extends StatelessWidget {
if (empty == null) return _withoutRows(header, const SizedBox.shrink());
return _withoutRows(header, _empty(context, empty));
}
// A list pane beside a detail can be very narrow (a 640px window leaves
// it ~130px): there the rows drop the identity icon and chevron so the
// name keeps the width.
return LayoutBuilder(
builder: (context, constraints) {
final compact = constraints.maxWidth < _compactRowWidth;
return useCupertinoControls(context)
? _cupertinoList(context, header, items, compact: compact)
: _materialList(context, header, items, compact: compact);
},
);
return _list(context, header, items);
}
static const double _compactRowWidth = 220;
Widget _centered(BuildContext context, List<String> messages) {
return Center(
child: Padding(
@@ -195,213 +184,69 @@ class PipelineListPanel extends StatelessWidget {
);
}
Widget _materialList(
/// The rows in the app's shared list row. A list pane beside a detail can
/// be very narrow (a 640px window leaves it ~130px): there a row drops its
/// avatar and time so the name keeps the width.
Widget _list(
BuildContext context,
List<Widget> header,
List<PipelineSummary> items, {
required bool compact,
}) {
List<PipelineSummary> items,
) {
final now = DateTime.now();
final cupertino = useCupertinoControls(context);
// The default padding is the media padding: the controls start below the
// top bar and the last row clears the floating tab bar.
return ListView.separated(
return ListView.builder(
key: const Key('pipeline-list'),
itemCount: header.length + items.length,
separatorBuilder: (context, index) => index < header.length
? const SizedBox.shrink()
: const Divider(height: 1),
itemBuilder: (context, index) {
if (index < header.length) return header[index];
final pipeline = items[index - header.length];
return ListTile(
final run = controller.runsLoaded
? controller.latestRuns[pipeline.id]
: null;
final badge = run == null ? null : runBadge(run, now);
return AppListRow(
key: Key('pipeline-row-${pipeline.id}'),
cupertino: cupertino,
selected: controller.selectedId == pipeline.id,
selectedTileColor: Theme.of(context).colorScheme.secondaryContainer,
selectedColor: Theme.of(context).colorScheme.onSecondaryContainer,
divider: index < header.length + items.length - 1,
onTap: () =>
controller.openPipeline(pipeline.id, version: pipeline.version),
contentPadding: const EdgeInsets.symmetric(
horizontal: kPipelineListInset,
),
visualDensity: VisualDensity.compact,
leading: compact ? null : _pipelineIdentityIcon(context, pipeline),
title: _rowTitle(context, pipeline, now: now, compact: compact),
subtitle: _rowMetadata(context, pipeline, now, compact: compact),
trailing: compact ? null : const Icon(Icons.chevron_right),
leading: _pipelineIdentityIcon(context, pipeline, cupertino),
title: Text(pipeline.displayName),
time: badge?.ranAgo,
subtitleLeading: badge == null
? null
: AppListStatusDot(
key: Key('pipeline-status-${pipeline.id}'),
color: runStatusColor(badge.state).resolveFrom(context),
semanticLabel: runStateLabel(badge.state),
),
subtitle: Text(_rowMetadata(pipeline)),
// A narrow pane keeps the latest state, the useful decision signal;
// stage counts, schedules and version live in the detail instead.
// Do not turn an in-flight or failed run-history read into a false
// no-runs claim: the line stays blank until history is known.
compactSubtitle: badge == null
? const SizedBox.shrink()
: Text(runStateLabel(badge.state)),
);
},
);
}
Widget _cupertinoList(
BuildContext context,
List<Widget> header,
List<PipelineSummary> items, {
required bool compact,
}) {
final now = DateTime.now();
return ListView(
key: const Key('pipeline-list'),
children: [
...header,
CupertinoListSection.insetGrouped(
backgroundColor: AppColors.groupedBackground,
children: [
for (final pipeline in items)
Semantics(
selected: controller.selectedId == pipeline.id,
child: CupertinoListTile(
key: Key('pipeline-row-${pipeline.id}'),
backgroundColor: controller.selectedId == pipeline.id
? CupertinoColors.tertiarySystemFill.resolveFrom(context)
: null,
leading: compact
? null
: _pipelineIdentityIcon(context, pipeline),
title: _rowTitle(
context,
pipeline,
now: now,
compact: compact,
),
subtitle: _rowMetadata(
context,
pipeline,
now,
compact: compact,
),
trailing: compact ? null : const CupertinoListTileChevron(),
onTap: () => controller.openPipeline(
pipeline.id,
version: pipeline.version,
),
),
),
],
),
],
);
}
/// The row's title line: its name and, when known, its latest run's age.
/// A narrow split pane keeps the name alone; the detail preserves identity.
Widget _rowTitle(
BuildContext context,
PipelineSummary pipeline, {
required DateTime now,
required bool compact,
}) {
final muted = _mutedStyle(context);
if (compact) {
return Text(
pipeline.displayName,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(fontWeight: FontWeight.w600),
);
}
final run = controller.runsLoaded
? controller.latestRuns[pipeline.id]
: null;
final ranAgo = run == null ? null : runBadge(run, now).ranAgo;
return Row(
children: [
Expanded(
child: Text(
pipeline.displayName,
maxLines: 1,
overflow: TextOverflow.ellipsis,
// Weight only: the native tile owns size and the selected colour.
style: const TextStyle(fontWeight: FontWeight.w600),
),
),
if (ranAgo != null) ...[
const SizedBox(width: 8),
Text(ranAgo, style: muted, maxLines: 1),
],
],
);
}
/// The row's one muted subtitle: latest-run state, stage count, and schedules.
Widget _rowMetadata(
BuildContext context,
PipelineSummary pipeline,
DateTime now, {
required bool compact,
}) {
final style = _mutedStyle(context);
/// The row's one muted subtitle: stage count and schedules.
String _rowMetadata(PipelineSummary pipeline) {
final schedules = switch (pipeline.scheduleState) {
PipelineScheduleState.scheduled => pipeline.scheduleLabel,
PipelineScheduleState.unscheduled => '0 schedules',
PipelineScheduleState.unclassified => '',
};
final what = [
return [
pipelineStageSummary(pipeline),
if (schedules.isNotEmpty) schedules,
].join(' · ');
final run = controller.runsLoaded
? controller.latestRuns[pipeline.id]
: null;
final badge = run == null ? null : runBadge(run, now);
// A 640px window can leave this pane about 130px wide. At that size the
// latest state is the useful decision signal; stage counts, timestamps,
// graph cues and version live in the selected pipeline's detail instead.
if (compact) {
// Do not turn an in-flight or failed run-history read into a false
// no-runs claim. The normal row also stays blank until history is known.
if (badge == null) return const SizedBox.shrink();
return Semantics(
label: runStateLabel(badge.state),
child: Row(
children: [
RunStatusIcon(
state: badge.state,
label: runStateLabel(badge.state),
size: 14,
),
const SizedBox(width: 4),
Expanded(
child: Text(
runStateLabel(badge.state),
style: style,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
],
),
);
}
return Row(
children: [
if (badge != null) ...[
Semantics(
label: runStateLabel(badge.state),
child: ExcludeSemantics(
child: Container(
key: Key('pipeline-status-${pipeline.id}'),
width: 8,
height: 8,
decoration: BoxDecoration(
color: runStatusColor(badge.state).resolveFrom(context),
shape: BoxShape.circle,
),
),
),
),
const SizedBox(width: 6),
],
Expanded(
child: Text(
what,
style: style,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
],
);
}
TextStyle? _mutedStyle(BuildContext context) {
@@ -416,27 +261,31 @@ class PipelineListPanel extends StatelessWidget {
);
}
Widget _pipelineIdentityIcon(BuildContext context, PipelineSummary pipeline) {
final scheme = Theme.of(context).colorScheme;
final colors = [scheme.primary, scheme.secondary, scheme.tertiary];
final color = colors[pipeline.id.abs() % colors.length];
final name = pipeline.displayName.trimLeft();
final initial = name.isEmpty
? '?'
: String.fromCharCode(name.runes.first).toUpperCase();
/// The pipeline's initial on a tint picked from its id, so neighbouring
/// pipelines are told apart at a glance.
Widget _pipelineIdentityIcon(
BuildContext context,
PipelineSummary pipeline,
bool cupertino,
) {
final List<Color> colors;
if (cupertino) {
colors = [
CupertinoTheme.of(context).primaryColor,
CupertinoColors.systemIndigo.resolveFrom(context),
CupertinoColors.systemTeal.resolveFrom(context),
];
} else {
final scheme = Theme.of(context).colorScheme;
colors = [scheme.primary, scheme.secondary, scheme.tertiary];
}
return Semantics(
label: 'Pipeline ${pipeline.displayName}',
child: ExcludeSemantics(
child: Container(
child: AppListAvatar.initial(
pipeline.displayName,
key: Key('pipeline-avatar-${pipeline.id}'),
width: 40,
height: 40,
alignment: Alignment.center,
decoration: BoxDecoration(
color: color.withValues(alpha: 0.14),
shape: BoxShape.circle,
),
child: Text(initial, style: TextStyle(color: color)),
color: colors[pipeline.id.abs() % colors.length],
),
),
);
+10 -46
View File
@@ -1,6 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/layout/app_overflow_menu.dart';
import '../../../core/api_gateway.dart';
import '../../schedules/ui/run/schedule_run_action.dart';
import '../actions/retry_action.dart';
@@ -93,51 +94,14 @@ class _RunMoreMenuState extends State<RunMoreMenu> {
@override
Widget build(BuildContext context) {
final items = _items;
if (items.isEmpty) return const SizedBox.shrink();
if (!widget.cupertino) {
return PopupMenuButton<_RunMoreItem>(
key: widget.menuKey,
icon: const Icon(Icons.more_vert),
tooltip: 'More actions',
onSelected: (item) => _pick(context, item),
itemBuilder: (_) => [
for (final (item, label) in items)
PopupMenuItem(key: _keyOf(item), value: item, child: Text(label)),
],
);
}
return Semantics(
button: true,
label: 'More actions',
excludeSemantics: true,
child: CupertinoButton(
key: widget.menuKey,
padding: EdgeInsets.zero,
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
onPressed: () async {
final picked = await showCupertinoModalPopup<_RunMoreItem>(
context: context,
builder: (sheet) => CupertinoActionSheet(
actions: [
for (final (item, label) in items)
CupertinoActionSheetAction(
key: _keyOf(item),
onPressed: () => Navigator.of(sheet).pop(item),
child: Text(label),
),
],
cancelButton: CupertinoActionSheetAction(
isDefaultAction: true,
onPressed: () => Navigator.of(sheet).pop(),
child: const Text('Cancel'),
),
),
);
if (picked != null && context.mounted) _pick(context, picked);
},
child: const Icon(CupertinoIcons.ellipsis_circle),
),
return AppOverflowMenu<_RunMoreItem>(
key: widget.menuKey,
cupertino: widget.cupertino,
actions: [
for (final (item, label) in _items)
AppMenuAction(key: _keyOf(item), value: item, label: label),
],
onSelected: _pick,
);
}
}
+48 -179
View File
@@ -1,3 +1,5 @@
import '../../../ui/layout/app_list_avatar.dart';
import '../../../ui/layout/app_list_row.dart';
import '../../../ui/layout/section_heading.dart';
import '../../../ui/motion/motion.dart';
import 'package:flutter/cupertino.dart';
@@ -177,9 +179,12 @@ class RunsList extends StatelessWidget {
),
);
}
// The last run of a day (before the next heading) has no divider.
final next = index - header.length + 1;
final last = next >= entries.length || entries[next].run == null;
return Arrival(
id: '${entry.run!['id']}',
child: _runTile(context, entry.run!),
child: _runTile(context, entry.run!, divider: !last),
);
},
);
@@ -262,10 +267,11 @@ class RunsList extends StatelessWidget {
),
);
Widget _runTile(BuildContext context, JsonMap run) {
Widget _runTile(BuildContext context, JsonMap run, {bool divider = true}) {
final id = run['id'];
return RunListRow(
run: run,
divider: divider,
selected: id == controller.selectedRunId,
now: DateTime.now(),
onTap: id is num ? () => onSelected(id) : null,
@@ -276,17 +282,16 @@ class RunsList extends StatelessWidget {
}
}
/// One run in the list, with a status avatar, title/time, and one muted fact
/// line. Its detail retains the full timestamp, path, and other diagnostics.
/// One run in the list: a status avatar, title/time, and one muted fact
/// line in the app's shared row. Its detail retains the full timestamp,
/// path, and other diagnostics.
class RunListRow extends StatelessWidget {
/// The narrowest row that still shows its own actions menu.
static const double _menuMinRowWidth = 280;
const RunListRow({
super.key,
required this.run,
required this.now,
this.selected = false,
this.divider = true,
this.onTap,
this.gateway,
this.onRunChanged,
@@ -296,6 +301,9 @@ class RunListRow extends StatelessWidget {
final JsonMap run;
final DateTime now;
final bool selected;
/// False for the last row before a day heading or the end of the list.
final bool divider;
final VoidCallback? onTap;
final ApiGateway? gateway;
final ValueChanged<JsonMap>? onRunChanged;
@@ -319,22 +327,6 @@ class RunListRow extends StatelessWidget {
: pipeline.isEmpty
? 'Pipeline unavailable'
: pipeline;
final secondary = cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
final nativeStyle = cupertino
? CupertinoTheme.of(context).textTheme.textStyle
: Theme.of(context).textTheme.bodyMedium ?? const TextStyle();
final base = !cupertino && selected
? nativeStyle.copyWith(
color: Theme.of(context).colorScheme.onSecondaryContainer,
)
: nativeStyle;
final titleStyle = base.copyWith(fontWeight: FontWeight.w600);
final small = base.copyWith(
color: secondary,
fontSize: (base.fontSize ?? 14) - 1,
);
final scheduled = run['scheduled'] == true;
final subtitle = [
?pipelineLabel,
@@ -342,164 +334,41 @@ class RunListRow extends StatelessWidget {
?facts.duration,
?facts.progress,
].join(' · ');
final relativeTime = formatRanAgo('${run['created_at'] ?? ''}', now);
Widget body(bool withMenu, bool compact) => Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsetsDirectional.only(end: 12),
child: _RunStatusAvatar(
state: runStateOf(run['status']),
label: runStatusLabel(run),
),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: compact
? [
Text(
title,
style: titleStyle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
const SizedBox(height: 2),
Text(
// The stored pipeline name is a fallback when the API
// has no human-readable pipeline title. Avoid repeating
// it if it already supplies the row title.
[
?pipelineLabel,
if (scheduled) 'Scheduled',
if (run['executing'] == true && facts.progress != null)
facts.progress!,
if (pipelineLabel == null && facts.duration != null)
facts.duration!,
].join(' · '),
style: small,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
]
: [
// The time keeps at most 40% of the line, so very large
// text in a narrow row ellipsises instead of overflowing.
LayoutBuilder(
builder: (context, constraints) => Row(
children: [
Expanded(
child: Text(
title,
style: titleStyle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
if (relativeTime != null)
ConstrainedBox(
constraints: BoxConstraints(
maxWidth: constraints.maxWidth * 0.4,
),
child: Padding(
padding: const EdgeInsetsDirectional.only(
start: 8,
),
child: Text(
relativeTime,
style: small,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
),
],
),
),
const SizedBox(height: 2),
Text(
subtitle,
style: small,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
),
if (withMenu &&
gateway != null &&
onRunChanged != null &&
showRunMoreMenu(run))
RunMoreMenu(
run: run,
gateway: gateway!,
onRunChanged: onRunChanged!,
onRunOpened: onRunOpened,
cupertino: cupertino,
menuKey: ValueKey('run-list-more-menu-$id'),
),
],
);
// A narrow list pane beside the open run leaves the row no room for a
// second control (a tap on its centre would land on the menu); the open
// run's detail beside it carries the same menu.
final padded = Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
child: LayoutBuilder(
builder: (context, constraints) {
final compact = constraints.maxWidth < _menuMinRowWidth;
return body(!compact, compact);
},
),
);
return Semantics(
// A narrow pane keeps the decision facts: the pipeline, and progress
// while executing (duration only when there is no pipeline to show).
final compactSubtitle = [
?pipelineLabel,
if (scheduled) 'Scheduled',
if (run['executing'] == true && facts.progress != null) facts.progress!,
if (pipelineLabel == null && facts.duration != null) facts.duration!,
].join(' · ');
final state = runStateOf(run['status']);
return AppListRow(
key: ValueKey('run-row-$id'),
cupertino: cupertino,
selected: selected,
button: onTap != null,
child: cupertino
? CupertinoButton(
key: ValueKey('run-row-$id'),
color: selected
? CupertinoColors.tertiarySystemFill.resolveFrom(context)
: null,
padding: EdgeInsets.zero,
minimumSize: Size.zero,
pressedOpacity: 0.6,
onPressed: onTap,
child: DefaultTextStyle(style: base, child: padded),
)
: Material(
key: ValueKey('run-row-surface-$id'),
color: selected
? Theme.of(context).colorScheme.secondaryContainer
: Colors.transparent,
child: InkWell(
key: ValueKey('run-row-$id'),
onTap: onTap,
child: padded,
),
),
);
}
}
class _RunStatusAvatar extends StatelessWidget {
const _RunStatusAvatar({required this.state, required this.label});
final String state;
final String label;
@override
Widget build(BuildContext context) {
final color = runStatusColor(state).resolveFrom(context);
return Container(
width: 36,
height: 36,
decoration: BoxDecoration(
color: color.withValues(alpha: 0.14),
shape: BoxShape.circle,
divider: divider,
onTap: onTap,
leading: AppListAvatar(
foreground: runStatusColor(state).resolveFrom(context),
child: RunStatusIcon(state: state, label: runStatusLabel(run)),
),
alignment: Alignment.center,
child: RunStatusIcon(state: state, label: label),
title: Text(title),
time: formatRanAgo('${run['created_at'] ?? ''}', now),
subtitle: Text(subtitle),
compactSubtitle: Text(compactSubtitle),
// A narrow list pane beside the open run leaves the row no room for a
// second control; the open run's detail beside it carries the same menu.
menu: gateway != null && onRunChanged != null && showRunMoreMenu(run)
? RunMoreMenu(
run: run,
gateway: gateway!,
onRunChanged: onRunChanged!,
onRunOpened: onRunOpened,
cupertino: cupertino,
menuKey: ValueKey('run-list-more-menu-$id'),
)
: null,
);
}
}
@@ -90,3 +90,32 @@ String scheduleCountLabel(int visible, int total) {
if (visible != total) return '$visible of $total schedules';
return total == 1 ? '1 schedule' : '$total schedules';
}
/// A row's short next-run word for its title line: `Paused`, `Not
/// scheduled`, `Next time unavailable`, or the local time as `22 Oct 09:00`.
String scheduleNextDueShort(SavedSchedule schedule) {
if (!schedule.enabled) return 'Paused';
final value = schedule.nextDue;
if (value.isEmpty) return 'Not scheduled';
final date = DateTime.tryParse(value);
if (date == null) return 'Next time unavailable';
final local = date.toLocal();
String two(int part) => part.toString().padLeft(2, '0');
return '${local.day} ${_shortMonths[local.month - 1]} '
'${two(local.hour)}:${two(local.minute)}';
}
const _shortMonths = [
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec',
];
@@ -1,109 +1,74 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../../ui/layout/app_list_avatar.dart';
import '../../../../ui/layout/app_list_row.dart';
import '../../domain/saved_schedule.dart';
import 'schedule_list_format.dart';
/// One tappable saved-schedule row with the server's actual values.
/// One tappable saved schedule in the app's shared row: a clock avatar (tinted
/// while enabled), the name with its next run (or `Paused`), and one muted
/// line with the timer and the pinned pipeline version. The editor it opens
/// shows the prompt, workspace, timezone and exact due time.
class ScheduleListRow extends StatelessWidget {
const ScheduleListRow({
super.key,
required this.schedule,
required this.cupertino,
required this.onOpen,
this.divider = true,
});
final SavedSchedule schedule;
final bool cupertino;
final VoidCallback onOpen;
final bool divider;
@override
Widget build(BuildContext context) {
final content = Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(child: _details(context)),
const SizedBox(width: 8),
Icon(
cupertino ? CupertinoIcons.chevron_right : Icons.chevron_right,
color: _secondaryColor(context),
),
],
return AppListRow(
cupertino: cupertino,
divider: divider,
onTap: onOpen,
leading: ScheduleAvatar(schedule: schedule, cupertino: cupertino),
title: Text(scheduleDisplayName(schedule)),
time: scheduleNextDueShort(schedule),
subtitle: Text(
'${scheduleTimerValue(schedule)} · '
'${schedulePipelineVersionValue(schedule)}',
),
);
if (cupertino) {
return CupertinoButton(
padding: EdgeInsets.zero,
alignment: Alignment.centerLeft,
onPressed: onOpen,
child: content,
);
}
return InkWell(onTap: onOpen, child: content);
}
}
Widget _details(BuildContext context) {
final prompt = schedule.prompt;
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Text(
scheduleDisplayName(schedule),
style: _titleStyle(context),
),
),
const SizedBox(width: 8),
Text(scheduleStatusLabel(schedule), style: _statusStyle(context)),
],
/// A schedule's leading clock: green while enabled, grey while paused. The
/// state is also a word on the row (its time reads `Paused`), so colour is
/// never the only signal.
class ScheduleAvatar extends StatelessWidget {
const ScheduleAvatar({
super.key,
required this.schedule,
required this.cupertino,
});
final SavedSchedule schedule;
final bool cupertino;
@override
Widget build(BuildContext context) {
final Color? enabled = schedule.enabled
? (cupertino
? CupertinoColors.systemGreen.resolveFrom(context)
: Colors.green.shade700)
: null;
return Semantics(
label: scheduleStatusLabel(schedule),
child: ExcludeSemantics(
child: AppListAvatar(
foreground: enabled,
child: Icon(cupertino ? CupertinoIcons.clock : Icons.schedule),
),
if (prompt.isNotEmpty) ...[
const SizedBox(height: 4),
Text(prompt, style: _bodyStyle(context)),
],
const SizedBox(height: 6),
_meta(context, schedulePipelineVersionValue(schedule)),
_meta(context, 'Workspace: ${scheduleWorkspaceValue(schedule)}'),
_meta(context, 'Timer: ${scheduleTimerValue(schedule)}'),
_meta(context, 'Timezone: ${scheduleTimezoneValue(schedule)}'),
_meta(context, 'Next due: ${scheduleNextDueValue(schedule)}'),
],
),
);
}
Widget _meta(BuildContext context, String value) =>
Text(value, style: _metaStyle(context));
TextStyle? _titleStyle(BuildContext context) => cupertino
? CupertinoTheme.of(context).textTheme.navTitleTextStyle
: Theme.of(context).textTheme.titleMedium;
TextStyle? _bodyStyle(BuildContext context) =>
cupertino ? CupertinoTheme.of(context).textTheme.textStyle : null;
TextStyle? _metaStyle(BuildContext context) => cupertino
? CupertinoTheme.of(
context,
).textTheme.tabLabelTextStyle.copyWith(color: _secondaryColor(context))
: Theme.of(
context,
).textTheme.bodySmall?.copyWith(color: _secondaryColor(context));
TextStyle? _statusStyle(BuildContext context) =>
_metaStyle(context)?.copyWith(color: _statusColor(context));
Color _secondaryColor(BuildContext context) => cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
Color _statusColor(BuildContext context) => schedule.enabled
? (cupertino
? CupertinoTheme.of(context).primaryColor
: Theme.of(context).colorScheme.primary)
: _secondaryColor(context);
}
@@ -76,13 +76,11 @@ class SchedulesListView extends StatelessWidget {
Widget _list(BuildContext context) {
final schedules = controller.visibleSchedules;
return ListView.separated(
return ListView.builder(
key: scheduleListKey,
controller: scrollController,
padding: const EdgeInsets.only(top: 4, bottom: 24),
itemCount: schedules.length,
separatorBuilder: (context, index) =>
cupertino ? _cupertinoSeparator(context) : const Divider(height: 1),
itemBuilder: (context, index) {
final schedule = schedules[index];
return ScheduleListRow(
@@ -91,17 +89,13 @@ class SchedulesListView extends StatelessWidget {
),
schedule: schedule,
cupertino: cupertino,
divider: index < schedules.length - 1,
onOpen: () => onOpen(schedule),
);
},
);
}
Widget _cupertinoSeparator(BuildContext context) => Container(
height: 1 / MediaQuery.devicePixelRatioOf(context),
color: CupertinoColors.separator.resolveFrom(context),
);
Widget _loadingState(BuildContext context) {
return Center(
child: Semantics(
@@ -73,11 +73,12 @@ class SchedulePipelineListBody extends StatelessWidget {
style: schedulePipelineMutedStyle(context),
),
),
for (var index = 0; index < schedules.length; index++) ...[
_row(context, schedules[index]),
if (index < schedules.length - 1)
schedulePipelineSeparator(context),
],
for (var index = 0; index < schedules.length; index++)
_row(
context,
schedules[index],
divider: index < schedules.length - 1,
),
],
),
);
@@ -115,10 +116,15 @@ class SchedulePipelineListBody extends StatelessWidget {
);
}
Widget _row(BuildContext context, SavedSchedule schedule) {
Widget _row(
BuildContext context,
SavedSchedule schedule, {
required bool divider,
}) {
final id = schedule.id;
return SchedulePipelineRow(
schedule: schedule,
divider: divider,
busy: id != null && busyRows.contains(id),
error: id == null ? null : rowErrors[id],
onEdit: () => onEdit(schedule),
@@ -1,15 +1,21 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../../ui/adaptive/host.dart';
import '../../../../ui/layout/app_list_row.dart';
import '../../../../ui/layout/app_overflow_menu.dart';
import '../../domain/saved_schedule.dart';
import '../list/schedule_list_format.dart';
import '../list/schedule_list_row.dart';
import 'schedule_pipeline_styles.dart';
import 'schedule_pipeline_wording.dart';
/// One saved schedule in the pipeline Summary: name, state, pinned version and
/// timer words, the recorded due time, and its Edit/Pause-Enable/Delete actions.
enum _ScheduleAction { edit, toggle, delete }
/// One saved schedule in the pipeline Summary, in the app's shared row: the
/// clock avatar, the name with its next run (or `Paused`), one muted line with
/// the pinned version and timer words, and an overflow menu with Edit,
/// Pause/Enable and Delete. A tap on the row edits it; a refused action's
/// message sits under the row.
class SchedulePipelineRow extends StatelessWidget {
const SchedulePipelineRow({
super.key,
@@ -19,6 +25,7 @@ class SchedulePipelineRow extends StatelessWidget {
required this.onToggle,
required this.onDelete,
this.error,
this.divider = false,
});
final SavedSchedule schedule;
@@ -27,199 +34,74 @@ class SchedulePipelineRow extends StatelessWidget {
final VoidCallback onEdit;
final VoidCallback onToggle;
final VoidCallback onDelete;
final bool divider;
@override
Widget build(BuildContext context) {
final id = schedule.id;
final body = schedulePipelineBodyStyle(context);
final title = body?.copyWith(fontWeight: FontWeight.w700);
return Padding(
key: scheduleRowKey(id),
padding: const EdgeInsets.fromLTRB(16, 12, 16, 8),
child: Semantics(
container: true,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// The name, bold, with its state as a coloured pill.
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
child: Text(scheduleDisplayName(schedule), style: title),
),
const SizedBox(width: 8),
_StatusPill(enabled: schedule.enabled),
],
),
const SizedBox(height: 8),
// Labelled facts several to a line: when, which version, next.
Wrap(
spacing: 16,
runSpacing: 6,
children: [
_Fact(
icon: Icons.schedule,
cupertinoIcon: CupertinoIcons.clock,
label: 'When',
value: scheduleRuleSummary(schedule),
),
_Fact(
icon: Icons.push_pin_outlined,
cupertinoIcon: CupertinoIcons.pin,
label: 'Version',
value: schedulePinnedVersionValue(schedule),
),
_Fact(
icon: Icons.event_outlined,
cupertinoIcon: CupertinoIcons.calendar,
label: 'Next',
value: scheduleNextDueValue(schedule),
),
],
),
if (schedule.prompt.isNotEmpty) ...[
const SizedBox(height: 8),
// The prompt it sends, as a quote under the facts.
_Quote(text: schedule.prompt, style: body),
],
const SizedBox(height: 4),
Wrap(
spacing: 8,
runSpacing: 4,
children: [
schedulePipelineTextButton(
context,
key: scheduleRowEditKey(id),
label: scheduleEditLabel,
onPressed: busy ? null : onEdit,
),
schedulePipelineTextButton(
context,
key: scheduleRowToggleKey(id),
label: schedule.enabled
? schedulePauseLabel
: scheduleEnableLabel,
onPressed: busy ? null : onToggle,
),
schedulePipelineTextButton(
context,
key: scheduleRowDeleteKey(id),
label: scheduleDeleteLabel,
onPressed: busy ? null : onDelete,
),
],
),
if (error case final text?)
Padding(
padding: const EdgeInsets.only(top: 4),
child: Semantics(
liveRegion: true,
child: Text(
text,
key: scheduleRowErrorKey(id),
style: schedulePipelineErrorStyle(context),
),
),
),
],
),
),
);
}
}
/// Enabled (green) or Paused (grey).
class _StatusPill extends StatelessWidget {
const _StatusPill({required this.enabled});
final bool enabled;
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final color = enabled
? (cupertino
? CupertinoColors.systemGreen.resolveFrom(context)
: Colors.green.shade700)
: (cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant);
return DecoratedBox(
decoration: ShapeDecoration(
color: color.withValues(alpha: 0.14),
shape: const StadiumBorder(),
final row = AppListRow(
cupertino: cupertino,
divider: divider && error == null,
onTap: busy ? null : onEdit,
leading: ScheduleAvatar(schedule: schedule, cupertino: cupertino),
title: Text(scheduleDisplayName(schedule)),
time: scheduleNextDueShort(schedule),
subtitle: Text(
'${schedulePinnedVersionValue(schedule)} · '
'${scheduleRuleSummary(schedule)}',
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
child: Text(
enabled ? 'Enabled' : 'Paused',
style: TextStyle(
color: color,
fontWeight: FontWeight.w700,
fontSize: 12,
// A narrow Summary still needs a way to pause or delete.
keepMenuWhenCompact: true,
menu: AppOverflowMenu<_ScheduleAction>(
key: scheduleRowMenuKey(id),
cupertino: cupertino,
enabled: !busy,
label: 'Schedule actions for ${scheduleDisplayName(schedule)}',
sheetTitle: scheduleDisplayName(schedule),
actions: [
AppMenuAction(
key: scheduleRowEditKey(id),
value: _ScheduleAction.edit,
label: scheduleEditLabel,
),
),
AppMenuAction(
key: scheduleRowToggleKey(id),
value: _ScheduleAction.toggle,
label: schedule.enabled ? schedulePauseLabel : scheduleEnableLabel,
),
AppMenuAction(
key: scheduleRowDeleteKey(id),
value: _ScheduleAction.delete,
label: scheduleDeleteLabel,
destructive: true,
),
],
onSelected: (_, action) => switch (action) {
_ScheduleAction.edit => onEdit(),
_ScheduleAction.toggle => onToggle(),
_ScheduleAction.delete => onDelete(),
},
),
);
}
}
/// One labelled fact: an icon, a bold label and its value.
class _Fact extends StatelessWidget {
const _Fact({
required this.icon,
required this.cupertinoIcon,
required this.label,
required this.value,
});
final IconData icon;
final IconData cupertinoIcon;
final String label;
final String value;
@override
Widget build(BuildContext context) {
final muted = schedulePipelineMutedStyle(context);
final cupertino = usesCupertinoHost(context);
return Row(
mainAxisSize: MainAxisSize.min,
return Column(
key: scheduleRowKey(id),
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Icon(cupertino ? cupertinoIcon : icon, size: 16, color: muted?.color),
const SizedBox(width: 4),
Text('$label ', style: muted?.copyWith(fontWeight: FontWeight.w700)),
Flexible(child: Text(value, style: muted)),
row,
if (error case final text?)
Padding(
padding: const EdgeInsets.fromLTRB(16, 0, 16, 8),
child: Semantics(
liveRegion: true,
child: Text(
text,
key: scheduleRowErrorKey(id),
style: schedulePipelineErrorStyle(context),
),
),
),
],
);
}
}
/// The schedule's prompt as a quote: a side bar and up to three lines.
class _Quote extends StatelessWidget {
const _Quote({required this.text, required this.style});
final String text;
final TextStyle? style;
@override
Widget build(BuildContext context) {
final line = usesCupertinoHost(context)
? CupertinoColors.separator.resolveFrom(context)
: Theme.of(context).colorScheme.outlineVariant;
return DecoratedBox(
decoration: BoxDecoration(
border: Border(left: BorderSide(color: line, width: 3)),
),
child: Padding(
padding: const EdgeInsetsDirectional.only(start: 10),
child: Text(
text,
maxLines: 3,
overflow: TextOverflow.ellipsis,
style: style,
),
),
);
}
}
@@ -10,11 +10,6 @@ TextStyle? schedulePipelineHeadingStyle(BuildContext context) =>
? CupertinoTheme.of(context).textTheme.navTitleTextStyle
: Theme.of(context).textTheme.titleMedium;
TextStyle? schedulePipelineBodyStyle(BuildContext context) =>
usesCupertinoHost(context)
? CupertinoTheme.of(context).textTheme.textStyle
: Theme.of(context).textTheme.bodyLarge;
TextStyle? schedulePipelineMutedStyle(BuildContext context) {
if (usesCupertinoHost(context)) {
return CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
@@ -59,13 +54,3 @@ Widget schedulePipelineTextButton(
}
return TextButton(key: key, onPressed: onPressed, child: Text(label));
}
Widget schedulePipelineSeparator(BuildContext context) {
if (usesCupertinoHost(context)) {
return Container(
height: 1 / MediaQuery.devicePixelRatioOf(context),
color: CupertinoColors.separator.resolveFrom(context),
);
}
return const Divider(height: 1);
}
@@ -32,6 +32,10 @@ const scheduleDeleteErrorKey = ValueKey<String>('schedule-delete-error');
ValueKey<String> scheduleRowKey(int? id) =>
ValueKey<String>('schedule-pipeline-row-${id ?? 'unknown'}');
/// The row's overflow menu, which holds Edit, Pause/Enable and Delete.
ValueKey<String> scheduleRowMenuKey(int? id) =>
ValueKey<String>('schedule-pipeline-menu-${id ?? 'unknown'}');
ValueKey<String> scheduleRowEditKey(int? id) =>
ValueKey<String>('schedule-pipeline-edit-${id ?? 'unknown'}');
ValueKey<String> scheduleRowToggleKey(int? id) =>
@@ -2,11 +2,10 @@ import 'package:flutter/cupertino.dart';
import '../../../core/api_gateway.dart';
import '../domain/search_controller.dart';
import '../domain/search_row.dart';
import 'search_result_view.dart';
import 'search_result_row.dart';
import 'search_layout.dart';
/// The Cupertino search view: an optional status header and inset-grouped
/// The Cupertino search view: an optional status header and the shared list
/// rows in one scroll view that runs behind the top bar, with standard
/// activity and retry controls.
class CupertinoSearchBody extends StatelessWidget {
@@ -61,22 +60,14 @@ class CupertinoSearchBody extends StatelessWidget {
];
case SearchBodyKind.results:
return [
SliverToBoxAdapter(
child: CupertinoListSection.insetGrouped(
// The section sits on the page's own background (the shell's
// is not the grouped one), so it takes the bar pills' grey
// rather than a white card framed by a grey band.
backgroundColor: const Color(0x00000000),
decoration: BoxDecoration(
color: CupertinoColors.systemGrey6.resolveFrom(context),
borderRadius: const BorderRadius.all(Radius.circular(10)),
),
// The column already keeps the bar's inset.
margin: const EdgeInsets.symmetric(vertical: 8),
children: [
for (final hit in controller.shownResults)
_CupertinoResult(hit: hit, query: query, onOpen: onOpen),
],
SliverList.builder(
itemCount: controller.shownResults.length,
itemBuilder: (context, index) => SearchResultRow(
hit: controller.shownResults[index],
query: query,
onOpen: onOpen,
cupertino: true,
divider: index < controller.shownResults.length - 1,
),
),
];
@@ -99,34 +90,6 @@ class CupertinoSearchBody extends StatelessWidget {
}
}
class _CupertinoResult extends StatelessWidget {
const _CupertinoResult({
required this.hit,
required this.query,
required this.onOpen,
});
final JsonMap hit;
final String query;
final ValueChanged<JsonMap> onOpen;
@override
Widget build(BuildContext context) {
final row = searchRowView(hit, query);
return CupertinoListTile(
key: ValueKey('search.result.${hit['target']}'),
leading:
searchArtifactThumbnail(context, hit) ??
Icon(searchCupertinoIcon('${hit['kind'] ?? ''}')),
leadingSize: 44,
trailing: searchArtifactActions(context, hit),
title: searchRowTitle(context, row),
subtitle: searchRowLine(context, row),
onTap: row.openable ? () => onOpen(hit) : null,
);
}
}
class _CupertinoSearching extends StatelessWidget {
const _CupertinoSearching();
@@ -2,8 +2,7 @@ import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../domain/search_controller.dart';
import '../domain/search_row.dart';
import 'search_result_view.dart';
import 'search_result_row.dart';
import 'search_layout.dart';
/// The Material search view: an optional status header and a flat native
@@ -54,10 +53,13 @@ class MaterialSearchBody extends StatelessWidget {
return [
SliverList.builder(
itemCount: controller.shownResults.length,
itemBuilder: (context, index) {
final hit = controller.shownResults[index];
return _MaterialResult(hit: hit, query: query, onOpen: onOpen);
},
itemBuilder: (context, index) => SearchResultRow(
hit: controller.shownResults[index],
query: query,
onOpen: onOpen,
cupertino: false,
divider: index < controller.shownResults.length - 1,
),
),
];
case SearchBodyKind.empty:
@@ -79,33 +81,6 @@ class MaterialSearchBody extends StatelessWidget {
}
}
class _MaterialResult extends StatelessWidget {
const _MaterialResult({
required this.hit,
required this.query,
required this.onOpen,
});
final JsonMap hit;
final String query;
final ValueChanged<JsonMap> onOpen;
@override
Widget build(BuildContext context) {
final row = searchRowView(hit, query);
return ListTile(
key: ValueKey('search.result.${hit['target']}'),
leading:
searchArtifactThumbnail(context, hit) ??
Icon(searchMaterialIcon('${hit['kind'] ?? ''}')),
trailing: searchArtifactActions(context, hit),
title: searchRowTitle(context, row),
subtitle: searchRowLine(context, row),
onTap: row.openable ? () => onOpen(hit) : null,
);
}
}
class _Searching extends StatelessWidget {
const _Searching();
@@ -0,0 +1,96 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/layout/app_list_avatar.dart';
import '../../../ui/layout/app_list_row.dart';
import '../domain/search_row.dart';
import 'search_result_view.dart';
/// One search hit in the app's shared row: the kind's icon (or an image
/// artifact's picture), the title with its recency, and one muted line that
/// names the kind and then shows the snippet (its first query occurrence
/// emphasised by weight, never by parsing server text as markup) or, without
/// one, the kind's own facts. An artifact hit's open choices are its menu.
class SearchResultRow extends StatelessWidget {
const SearchResultRow({
super.key,
required this.hit,
required this.query,
required this.onOpen,
required this.cupertino,
this.divider = true,
});
final JsonMap hit;
final String query;
final ValueChanged<JsonMap> onOpen;
final bool cupertino;
final bool divider;
@override
Widget build(BuildContext context) {
final row = searchRowView(hit, query);
final kind = '${hit['kind'] ?? ''}';
return AppListRow(
key: ValueKey('search.result.${hit['target']}'),
cupertino: cupertino,
divider: divider,
onTap: row.openable ? () => onOpen(hit) : null,
leading:
searchArtifactThumbnail(context, hit) ??
AppListAvatar(
child: Icon(
cupertino ? searchCupertinoIcon(kind) : searchMaterialIcon(kind),
),
),
title: Text(row.title),
time: row.recency,
subtitle: Text.rich(_line(row)),
menu: searchArtifactActions(context, hit),
);
}
TextSpan _line(SearchRowView row) {
final snippet = row.snippet;
return TextSpan(
children: [
TextSpan(
text: row.kindLabel,
style: const TextStyle(fontWeight: FontWeight.w600),
),
const TextSpan(text: ' · '),
if (snippet == null)
TextSpan(text: row.secondary)
else
for (final span in row.snippetSpans)
TextSpan(
text: span.text,
style: span.matched
? const TextStyle(fontWeight: FontWeight.bold)
: null,
),
],
);
}
}
IconData searchMaterialIcon(String kind) => switch (kind) {
'pipeline' => Icons.account_tree_outlined,
'version' => Icons.layers_outlined,
'run' => Icons.play_circle_outline,
'step' => Icons.arrow_forward,
'field' => Icons.notes,
'artifact' => Icons.attach_file,
_ => Icons.help_outline,
};
IconData searchCupertinoIcon(String kind) => switch (kind) {
'pipeline' => CupertinoIcons.arrow_branch,
'version' => CupertinoIcons.square_stack_3d_up,
'run' => CupertinoIcons.play_circle,
'step' => CupertinoIcons.arrow_right,
'field' => CupertinoIcons.doc_text,
'artifact' => CupertinoIcons.paperclip,
_ => CupertinoIcons.question_circle,
};
@@ -1,118 +1,14 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../core/transport/pipelines_client.dart'
show configuredGatewayEndpoint;
import '../../../ui/adaptive/host.dart';
import '../../../ui/layout/app_list_avatar.dart';
import '../../../ui/layout/app_overflow_menu.dart';
import '../../artifacts/domain/artifact_kind.dart';
import '../../artifacts/domain/artifact_record.dart';
import '../../artifacts/ui/artifact_tile.dart';
import '../../artifacts/ui/artifact_viewer_fetch.dart';
import '../domain/search_row.dart';
/// A row's title line: the bold title and, at its trailing edge, a small tag
/// naming the kind.
Widget searchRowTitle(BuildContext context, SearchRowView row) => Row(
crossAxisAlignment: CrossAxisAlignment.start,
spacing: 8,
children: [
Expanded(
child: Text(
row.title,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: const TextStyle(fontWeight: FontWeight.w600),
),
),
SearchKindTag(label: row.kindLabel),
],
);
/// A row's one muted line: recency, then the snippet (its first query
/// occurrence emphasised by weight, never by parsing server text as markup)
/// or, without one, the kind's own facts.
Widget searchRowLine(BuildContext context, SearchRowView row) {
final snippet = row.snippet;
final lead = row.recency == null ? '' : '${row.recency} · ';
final spans = <InlineSpan>[
if (snippet == null)
TextSpan(text: '$lead${row.secondary}')
else ...[
if (lead.isNotEmpty) TextSpan(text: lead),
for (final span in row.snippetSpans)
TextSpan(
text: span.text,
style: span.matched
? const TextStyle(fontWeight: FontWeight.bold)
: null,
),
],
];
return Text.rich(
TextSpan(children: spans),
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: _muted(context)),
);
}
Color _muted(BuildContext context) => usesCupertinoHost(context)
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant;
/// The result's kind as a small tinted capsule.
class SearchKindTag extends StatelessWidget {
const SearchKindTag({super.key, required this.label});
final String label;
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final Color fill;
final TextStyle? style;
if (cupertino) {
fill = CupertinoColors.tertiarySystemFill.resolveFrom(context);
style = CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
color: CupertinoColors.secondaryLabel.resolveFrom(context),
);
} else {
final theme = Theme.of(context);
fill = theme.colorScheme.surfaceContainerHighest;
style = theme.textTheme.labelSmall?.copyWith(
color: theme.colorScheme.onSurfaceVariant,
);
}
return DecoratedBox(
decoration: ShapeDecoration(color: fill, shape: const StadiumBorder()),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
child: Text(label, style: style),
),
);
}
}
IconData searchMaterialIcon(String kind) => switch (kind) {
'pipeline' => Icons.account_tree_outlined,
'version' => Icons.layers_outlined,
'run' => Icons.play_circle_outline,
'step' => Icons.arrow_forward,
'field' => Icons.notes,
'artifact' => Icons.attach_file,
_ => Icons.help_outline,
};
IconData searchCupertinoIcon(String kind) => switch (kind) {
'pipeline' => CupertinoIcons.arrow_branch,
'version' => CupertinoIcons.square_stack_3d_up,
'run' => CupertinoIcons.play_circle,
'step' => CupertinoIcons.arrow_right,
'field' => CupertinoIcons.doc_text,
'artifact' => CupertinoIcons.paperclip,
_ => CupertinoIcons.question_circle,
};
/// What artifact hits need from the screen: the app's gateway (to resolve a
/// thumbnail and look up a run's pipeline) and the screen's opener.
@@ -152,9 +48,9 @@ Widget? searchArtifactThumbnail(BuildContext context, JsonMap hit) {
return null;
}
return ClipRRect(
borderRadius: BorderRadius.circular(6),
borderRadius: BorderRadius.circular(8),
child: SizedBox.square(
dimension: 44,
dimension: kAppListAvatarSize,
child: ArtifactThumbnail(
key: ValueKey('search.thumbnail.${hit['target']}'),
artifact: record,
@@ -213,45 +109,14 @@ Widget? searchArtifactActions(BuildContext context, JsonMap hit) {
}
}
const labels = {
_ArtifactOpen.stage: 'Open stage',
_ArtifactOpen.run: 'Open run',
_ArtifactOpen.pipeline: 'Open pipeline',
};
final key = ValueKey('search.actions.${hit['target']}');
if (usesCupertinoHost(context)) {
return CupertinoButton(
key: key,
padding: EdgeInsets.zero,
onPressed: () async {
final choice = await showCupertinoModalPopup<_ArtifactOpen>(
context: context,
builder: (sheet) => CupertinoActionSheet(
actions: [
for (final entry in labels.entries)
CupertinoActionSheetAction(
onPressed: () => Navigator.pop(sheet, entry.key),
child: Text(entry.value),
),
],
cancelButton: CupertinoActionSheetAction(
onPressed: () => Navigator.pop(sheet),
child: const Text('Cancel'),
),
),
);
if (choice != null) await pick(choice);
},
child: const Icon(CupertinoIcons.ellipsis_circle),
);
}
return PopupMenuButton<_ArtifactOpen>(
key: key,
tooltip: 'Open…',
onSelected: pick,
itemBuilder: (_) => [
for (final entry in labels.entries)
PopupMenuItem(value: entry.key, child: Text(entry.value)),
return AppOverflowMenu<_ArtifactOpen>(
key: ValueKey('search.actions.${hit['target']}'),
label: 'Open…',
actions: const [
AppMenuAction(value: _ArtifactOpen.stage, label: 'Open stage'),
AppMenuAction(value: _ArtifactOpen.run, label: 'Open run'),
AppMenuAction(value: _ArtifactOpen.pipeline, label: 'Open pipeline'),
],
onSelected: (_, choice) => pick(choice),
);
}