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/destination.dart';
import '../../shell/detail_page.dart'; import '../../shell/detail_page.dart';
import '../../shell/list_detail.dart'; import '../../shell/list_detail.dart';
import '../../ui/adaptive/floating_bar_layout.dart';
import '../../ui/adaptive/host.dart'; import '../../ui/adaptive/host.dart';
import 'dart:async'; import 'dart:async';
@@ -242,19 +241,17 @@ class _ChatScreenState extends State<ChatScreen> {
? const SizedBox.shrink() ? const SizedBox.shrink()
: _thread(selected, () => Navigator.of(context).maybePop()), : _thread(selected, () => Navigator.of(context).maybePop()),
); );
// The shell's body now reaches the top edge; until the session list pads // The session list pads its first row by the bar's height itself, so it
// itself by the bar (owned by the chat lane), it keeps starting below it. // scrolls behind the shell's floating bar like the other lists.
final list = BelowTopBar( final list = ChatSessionsScreen(
child: ChatSessionsScreen( gateway: widget.gateway,
gateway: widget.gateway, embedded: true,
embedded: true, syncToken: widget.syncToken,
syncToken: widget.syncToken, controller: _sessions,
controller: _sessions, onOpen: _open,
onOpen: _open, onSessions: _adoptRows,
onSessions: _adoptRows, activeSessionId: selected,
activeSessionId: selected, publishShellBar: true,
publishShellBar: true,
),
); );
if (!beside) return list; if (!beside) return list;
return ListDetailPanes( return ListDetailPanes(
@@ -5,6 +5,7 @@ import '../../../../core/api_gateway.dart';
import '../../domain/chat_sessions.dart'; import '../../domain/chat_sessions.dart';
import 'chat_adaptive.dart'; import 'chat_adaptive.dart';
import 'session_row_style.dart'; import 'session_row_style.dart';
import '../../../../ui/layout/app_overflow_menu.dart';
enum SessionAction { star, rename, close, reopen, hide } enum SessionAction { star, rename, close, reopen, hide }
@@ -29,54 +30,19 @@ class SessionActionsButton extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final label = sessionActionsLabel(session, duplicateTitles); return AppOverflowMenu<SessionAction>(
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) { cupertino: chatControlsStyleOf(context) == ChatControlsStyle.cupertino,
// Its own node, so the row's merged label never swallows the button. label: sessionActionsLabel(session, duplicateTitles),
return Semantics( sheetTitle: chatSessionTitle(session),
container: true, actions: [
label: label, for (final item in _items(session))
button: true, AppMenuAction(value: item.action, label: item.label),
child: CupertinoButton( ],
padding: EdgeInsets.zero, onSelected: (_, action) => onSelected(action),
onPressed: () => _showSheet(context),
child: const Icon(CupertinoIcons.ellipsis),
),
);
}
return PopupMenuButton<SessionAction>(
tooltip: label,
onSelected: onSelected,
itemBuilder: (context) => _menuItems(session),
); );
} }
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) { List<({SessionAction action, String label})> _items(JsonMap session) {
final isClosed = session['closed_at'] != null; final isClosed = session['closed_at'] != null;
return [ return [
@@ -1,5 +1,4 @@
import '../../../../ui/layout/collapsible_list_section.dart'; import '../../../../ui/layout/collapsible_list_section.dart';
import '../../../../ui/theme/app_theme.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import '../../../../core/api_gateway.dart'; import '../../../../core/api_gateway.dart';
@@ -8,7 +7,6 @@ import 'chat_adaptive.dart';
import 'chat_sessions_body.dart'; import 'chat_sessions_body.dart';
import 'session_actions.dart'; import 'session_actions.dart';
import 'session_row_content.dart'; import 'session_row_content.dart';
import 'session_row_style.dart';
import '../../../../ui/adaptive/floating_bar_layout.dart'; import '../../../../ui/adaptive/floating_bar_layout.dart';
class CupertinoSessionList extends StatelessWidget { class CupertinoSessionList extends StatelessWidget {
@@ -76,43 +74,45 @@ class CupertinoSessionList extends StatelessWidget {
count: section.sessions.length, count: section.sessions.length,
initiallyOpen: section.title != 'Closed', initiallyOpen: section.title != 'Closed',
children: [ children: [
for (final group in groups) for (final group in groups) ...[
CupertinoListSection.insetGrouped( if (groups.length > 1)
backgroundColor: AppColors.groupedBackground, _DirectoryHeader(
header: groups.length > 1 group.directory.isEmpty ? 'No directory' : group.directory,
? Text( ),
group.directory.isEmpty for (var i = 0; i < group.sessions.length; i++)
? 'No directory' ..._row(
: group.directory, group.sessions[i],
) divider: i < group.sessions.length - 1,
: null, ),
children: [ ],
for (final session in group.sessions) ..._row(session),
],
),
], ],
), ),
]; ];
} }
/// The tile plus its refusal. `CupertinoListTile` forces its subtitle to one /// The row plus its refusal, the server's words in their own full-width
/// ellipsised line, so the server's words go in their own full-width row /// row under it.
/// inside the same native card. List<Widget> _row(JsonMap session, {required bool divider}) {
List<Widget> _row(JsonMap session) {
final id = '${session['id'] ?? ''}'; final id = '${session['id'] ?? ''}';
final error = errorFor(id); final error = errorFor(id);
return [ return [
_CupertinoSessionRow( ChatSessionRow(
session: session, session: session,
selected: id == activeSessionId, selected: id == activeSessionId,
duplicateTitles: duplicateTitles, duplicateTitles: duplicateTitles,
unseen: isUnseen(session), unseen: isUnseen(session),
// A refusal below the row separates it instead.
divider: divider && error == null,
onOpen: onOpen, onOpen: onOpen,
onRename: onRename, onAction: (action) => _dispatch(
onClose: onClose, action,
onReopen: onReopen, session,
onStar: onStar, onStar: onStar,
onHide: onHide, onRename: onRename,
onClose: onClose,
onReopen: onReopen,
onHide: onHide,
),
), ),
if (error != null) if (error != null)
ChatRowError( ChatRowError(
@@ -124,101 +124,50 @@ class CupertinoSessionList extends StatelessWidget {
} }
} }
class _CupertinoSessionRow extends StatelessWidget { /// Routes a row's menu choice to the list's callbacks.
const _CupertinoSessionRow({ void _dispatch(
required this.session, SessionAction action,
required this.selected, JsonMap session, {
required this.duplicateTitles, required ValueChanged<JsonMap> onStar,
required this.unseen, required ValueChanged<JsonMap> onRename,
required this.onOpen, required ValueChanged<JsonMap> onClose,
required this.onRename, required ValueChanged<JsonMap> onReopen,
required this.onClose, required ValueChanged<JsonMap> onHide,
required this.onReopen, }) {
required this.onStar, switch (action) {
required this.onHide, 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; /// A directory's name above its chats, like a grouped table's header.
final bool selected; class _DirectoryHeader extends StatelessWidget {
final Set<String> duplicateTitles; const _DirectoryHeader(this.directory);
final bool unseen;
final ValueChanged<JsonMap> onOpen; final String directory;
final ValueChanged<JsonMap> onRename;
final ValueChanged<JsonMap> onClose;
final ValueChanged<JsonMap> onReopen;
final ValueChanged<JsonMap> onStar;
final ValueChanged<JsonMap> onHide;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final id = '${session['id'] ?? ''}'; final style = CupertinoTheme.of(context).textTheme.textStyle.copyWith(
final closed = chatSessionRowStatus(session, unseen: false) == 'Closed'; fontSize: 13,
// A contact-list row, the same pieces as the Material row. The grouped color: CupertinoColors.secondaryLabel.resolveFrom(context),
// list owns the separators and the tile its native text styles; the );
// leading slot is widened to hold the avatar. return Padding(
// A narrow pane (a wide window's list beside its detail, or its opening padding: const EdgeInsetsDirectional.fromSTEB(16, 16, 16, 6),
// animation) drops the avatar and tightens the tile's insets, so the child: Text(
// menu stays reachable and the title keeps some width. directory,
return LayoutBuilder( style: style,
builder: (context, constraints) { maxLines: 1,
final avatar = constraints.maxWidth >= _avatarMinWidth; overflow: TextOverflow.ellipsis,
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),
),
);
},
); );
} }
/// 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 'chat_sessions_body.dart';
import 'session_actions.dart'; import 'session_actions.dart';
import 'session_row_content.dart'; import 'session_row_content.dart';
import 'session_row_style.dart';
class MaterialSessionList extends StatelessWidget { class MaterialSessionList extends StatelessWidget {
const MaterialSessionList({ const MaterialSessionList({
@@ -83,35 +82,38 @@ class MaterialSessionList extends StatelessWidget {
style: heading.title.copyWith(fontWeight: FontWeight.w600), style: heading.title.copyWith(fontWeight: FontWeight.w600),
), ),
), ),
// Material's native list separator between rows in a group, the // Inset dividers between the rows of a group; the group header
// counterpart of the inset group's hairline on Cupertino. The group // owns the boundary between directories.
// header still owns the boundary between directories. for (var i = 0; i < group.sessions.length; i++)
for (var i = 0; i < group.sessions.length; i++) ...[ ..._row(group.sessions[i], divider: i < group.sessions.length - 1),
if (i > 0) const Divider(height: 1),
..._row(group.sessions[i]),
],
], ],
], ],
); );
} }
/// 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). /// 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 id = '${session['id'] ?? ''}';
final error = errorFor(id); final error = errorFor(id);
return [ return [
_MaterialSessionRow( ChatSessionRow(
session: session, session: session,
selected: id == activeSessionId, selected: id == activeSessionId,
duplicateTitles: duplicateTitles, duplicateTitles: duplicateTitles,
unseen: isUnseen(session), unseen: isUnseen(session),
// A refusal below the row separates it instead.
divider: divider && error == null,
onOpen: onOpen, onOpen: onOpen,
onRename: onRename, onAction: (action) => _dispatch(
onClose: onClose, action,
onReopen: onReopen, session,
onStar: onStar, onStar: onStar,
onHide: onHide, onRename: onRename,
onClose: onClose,
onReopen: onReopen,
onHide: onHide,
),
), ),
if (error != null) if (error != null)
ChatRowError( ChatRowError(
@@ -123,99 +125,26 @@ class MaterialSessionList extends StatelessWidget {
} }
} }
class _MaterialSessionRow extends StatelessWidget { /// Routes a row's menu choice to the list's callbacks.
const _MaterialSessionRow({ void _dispatch(
required this.session, SessionAction action,
required this.selected, JsonMap session, {
required this.duplicateTitles, required ValueChanged<JsonMap> onStar,
required this.unseen, required ValueChanged<JsonMap> onRename,
required this.onOpen, required ValueChanged<JsonMap> onClose,
required this.onRename, required ValueChanged<JsonMap> onReopen,
required this.onClose, required ValueChanged<JsonMap> onHide,
required this.onReopen, }) {
required this.onStar, switch (action) {
required this.onHide, case SessionAction.star:
}); onStar(session);
case SessionAction.rename:
final JsonMap session; onRename(session);
final bool selected; case SessionAction.close:
final Set<String> duplicateTitles; onClose(session);
final bool unseen; case SessionAction.reopen:
final ValueChanged<JsonMap> onOpen; onReopen(session);
final ValueChanged<JsonMap> onRename; case SessionAction.hide:
final ValueChanged<JsonMap> onClose; onHide(session);
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);
}
} }
} }
@@ -2,12 +2,134 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../../core/api_gateway.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 'chat_adaptive.dart';
import 'session_actions.dart';
import 'session_harness_icon.dart'; import 'session_harness_icon.dart';
import 'session_row_style.dart';
/// Row pieces shared by the Material and Cupertino chat lists. Each list puts /// One chat in the list, in the app's shared row on both hosts: the harness
/// them in its native tile's slots: the avatar leads, the title line and the /// avatar, the title with its recency, one muted line, and the actions menu.
/// subtitle line fill the text column, and the actions menu trails. ///
/// 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 /// 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 /// running chat carries a small activity badge on the avatar's corner instead
@@ -43,26 +165,18 @@ class ChatSessionAvatar extends StatelessWidget {
: scheme.surfaceContainerHighest; : scheme.surfaceContainerHighest;
mark = selected ? scheme.onPrimaryContainer : scheme.onSurfaceVariant; mark = selected ? scheme.onPrimaryContainer : scheme.onSurfaceVariant;
} }
final avatar = CircleAvatar( return AppListAvatar(
backgroundColor: fill, 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), 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/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -138,21 +139,9 @@ class PipelineListPanel extends StatelessWidget {
if (empty == null) return _withoutRows(header, const SizedBox.shrink()); if (empty == null) return _withoutRows(header, const SizedBox.shrink());
return _withoutRows(header, _empty(context, empty)); return _withoutRows(header, _empty(context, empty));
} }
// A list pane beside a detail can be very narrow (a 640px window leaves return _list(context, header, items);
// 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);
},
);
} }
static const double _compactRowWidth = 220;
Widget _centered(BuildContext context, List<String> messages) { Widget _centered(BuildContext context, List<String> messages) {
return Center( return Center(
child: Padding( 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, BuildContext context,
List<Widget> header, List<Widget> header,
List<PipelineSummary> items, { List<PipelineSummary> items,
required bool compact, ) {
}) {
final now = DateTime.now(); final now = DateTime.now();
final cupertino = useCupertinoControls(context);
// The default padding is the media padding: the controls start below the // The default padding is the media padding: the controls start below the
// top bar and the last row clears the floating tab bar. // top bar and the last row clears the floating tab bar.
return ListView.separated( return ListView.builder(
key: const Key('pipeline-list'), key: const Key('pipeline-list'),
itemCount: header.length + items.length, itemCount: header.length + items.length,
separatorBuilder: (context, index) => index < header.length
? const SizedBox.shrink()
: const Divider(height: 1),
itemBuilder: (context, index) { itemBuilder: (context, index) {
if (index < header.length) return header[index]; if (index < header.length) return header[index];
final pipeline = items[index - header.length]; 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}'), key: Key('pipeline-row-${pipeline.id}'),
cupertino: cupertino,
selected: controller.selectedId == pipeline.id, selected: controller.selectedId == pipeline.id,
selectedTileColor: Theme.of(context).colorScheme.secondaryContainer, divider: index < header.length + items.length - 1,
selectedColor: Theme.of(context).colorScheme.onSecondaryContainer,
onTap: () => onTap: () =>
controller.openPipeline(pipeline.id, version: pipeline.version), controller.openPipeline(pipeline.id, version: pipeline.version),
contentPadding: const EdgeInsets.symmetric( leading: _pipelineIdentityIcon(context, pipeline, cupertino),
horizontal: kPipelineListInset, title: Text(pipeline.displayName),
), time: badge?.ranAgo,
visualDensity: VisualDensity.compact, subtitleLeading: badge == null
leading: compact ? null : _pipelineIdentityIcon(context, pipeline), ? null
title: _rowTitle(context, pipeline, now: now, compact: compact), : AppListStatusDot(
subtitle: _rowMetadata(context, pipeline, now, compact: compact), key: Key('pipeline-status-${pipeline.id}'),
trailing: compact ? null : const Icon(Icons.chevron_right), 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( /// The row's one muted subtitle: stage count and schedules.
BuildContext context, String _rowMetadata(PipelineSummary pipeline) {
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);
final schedules = switch (pipeline.scheduleState) { final schedules = switch (pipeline.scheduleState) {
PipelineScheduleState.scheduled => pipeline.scheduleLabel, PipelineScheduleState.scheduled => pipeline.scheduleLabel,
PipelineScheduleState.unscheduled => '0 schedules', PipelineScheduleState.unscheduled => '0 schedules',
PipelineScheduleState.unclassified => '', PipelineScheduleState.unclassified => '',
}; };
final what = [ return [
pipelineStageSummary(pipeline), pipelineStageSummary(pipeline),
if (schedules.isNotEmpty) schedules, if (schedules.isNotEmpty) schedules,
].join(' · '); ].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) { TextStyle? _mutedStyle(BuildContext context) {
@@ -416,27 +261,31 @@ class PipelineListPanel extends StatelessWidget {
); );
} }
Widget _pipelineIdentityIcon(BuildContext context, PipelineSummary pipeline) { /// The pipeline's initial on a tint picked from its id, so neighbouring
final scheme = Theme.of(context).colorScheme; /// pipelines are told apart at a glance.
final colors = [scheme.primary, scheme.secondary, scheme.tertiary]; Widget _pipelineIdentityIcon(
final color = colors[pipeline.id.abs() % colors.length]; BuildContext context,
final name = pipeline.displayName.trimLeft(); PipelineSummary pipeline,
final initial = name.isEmpty bool cupertino,
? '?' ) {
: String.fromCharCode(name.runes.first).toUpperCase(); 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( return Semantics(
label: 'Pipeline ${pipeline.displayName}', label: 'Pipeline ${pipeline.displayName}',
child: ExcludeSemantics( child: ExcludeSemantics(
child: Container( child: AppListAvatar.initial(
pipeline.displayName,
key: Key('pipeline-avatar-${pipeline.id}'), key: Key('pipeline-avatar-${pipeline.id}'),
width: 40, color: colors[pipeline.id.abs() % colors.length],
height: 40,
alignment: Alignment.center,
decoration: BoxDecoration(
color: color.withValues(alpha: 0.14),
shape: BoxShape.circle,
),
child: Text(initial, style: TextStyle(color: color)),
), ),
), ),
); );
+10 -46
View File
@@ -1,6 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../ui/layout/app_overflow_menu.dart';
import '../../../core/api_gateway.dart'; import '../../../core/api_gateway.dart';
import '../../schedules/ui/run/schedule_run_action.dart'; import '../../schedules/ui/run/schedule_run_action.dart';
import '../actions/retry_action.dart'; import '../actions/retry_action.dart';
@@ -93,51 +94,14 @@ class _RunMoreMenuState extends State<RunMoreMenu> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final items = _items; return AppOverflowMenu<_RunMoreItem>(
if (items.isEmpty) return const SizedBox.shrink(); key: widget.menuKey,
if (!widget.cupertino) { cupertino: widget.cupertino,
return PopupMenuButton<_RunMoreItem>( actions: [
key: widget.menuKey, for (final (item, label) in _items)
icon: const Icon(Icons.more_vert), AppMenuAction(key: _keyOf(item), value: item, label: label),
tooltip: 'More actions', ],
onSelected: (item) => _pick(context, item), onSelected: _pick,
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),
),
); );
} }
} }
+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/layout/section_heading.dart';
import '../../../ui/motion/motion.dart'; import '../../../ui/motion/motion.dart';
import 'package:flutter/cupertino.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( return Arrival(
id: '${entry.run!['id']}', 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']; final id = run['id'];
return RunListRow( return RunListRow(
run: run, run: run,
divider: divider,
selected: id == controller.selectedRunId, selected: id == controller.selectedRunId,
now: DateTime.now(), now: DateTime.now(),
onTap: id is num ? () => onSelected(id) : null, 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 /// One run in the list: a status avatar, title/time, and one muted fact
/// line. Its detail retains the full timestamp, path, and other diagnostics. /// line in the app's shared row. Its detail retains the full timestamp,
/// path, and other diagnostics.
class RunListRow extends StatelessWidget { class RunListRow extends StatelessWidget {
/// The narrowest row that still shows its own actions menu.
static const double _menuMinRowWidth = 280;
const RunListRow({ const RunListRow({
super.key, super.key,
required this.run, required this.run,
required this.now, required this.now,
this.selected = false, this.selected = false,
this.divider = true,
this.onTap, this.onTap,
this.gateway, this.gateway,
this.onRunChanged, this.onRunChanged,
@@ -296,6 +301,9 @@ class RunListRow extends StatelessWidget {
final JsonMap run; final JsonMap run;
final DateTime now; final DateTime now;
final bool selected; 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 VoidCallback? onTap;
final ApiGateway? gateway; final ApiGateway? gateway;
final ValueChanged<JsonMap>? onRunChanged; final ValueChanged<JsonMap>? onRunChanged;
@@ -319,22 +327,6 @@ class RunListRow extends StatelessWidget {
: pipeline.isEmpty : pipeline.isEmpty
? 'Pipeline unavailable' ? 'Pipeline unavailable'
: pipeline; : 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 scheduled = run['scheduled'] == true;
final subtitle = [ final subtitle = [
?pipelineLabel, ?pipelineLabel,
@@ -342,164 +334,41 @@ class RunListRow extends StatelessWidget {
?facts.duration, ?facts.duration,
?facts.progress, ?facts.progress,
].join(' · '); ].join(' · ');
final relativeTime = formatRanAgo('${run['created_at'] ?? ''}', now); // A narrow pane keeps the decision facts: the pipeline, and progress
Widget body(bool withMenu, bool compact) => Row( // while executing (duration only when there is no pipeline to show).
crossAxisAlignment: CrossAxisAlignment.start, final compactSubtitle = [
children: [ ?pipelineLabel,
Padding( if (scheduled) 'Scheduled',
padding: const EdgeInsetsDirectional.only(end: 12), if (run['executing'] == true && facts.progress != null) facts.progress!,
child: _RunStatusAvatar( if (pipelineLabel == null && facts.duration != null) facts.duration!,
state: runStateOf(run['status']), ].join(' · ');
label: runStatusLabel(run), final state = runStateOf(run['status']);
), return AppListRow(
), key: ValueKey('run-row-$id'),
Expanded( cupertino: cupertino,
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(
selected: selected, selected: selected,
button: onTap != null, divider: divider,
child: cupertino onTap: onTap,
? CupertinoButton( leading: AppListAvatar(
key: ValueKey('run-row-$id'), foreground: runStatusColor(state).resolveFrom(context),
color: selected child: RunStatusIcon(state: state, label: runStatusLabel(run)),
? 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,
), ),
alignment: Alignment.center, title: Text(title),
child: RunStatusIcon(state: state, label: label), 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'; if (visible != total) return '$visible of $total schedules';
return total == 1 ? '1 schedule' : '$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/cupertino.dart';
import 'package:flutter/material.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 '../../domain/saved_schedule.dart';
import 'schedule_list_format.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 { class ScheduleListRow extends StatelessWidget {
const ScheduleListRow({ const ScheduleListRow({
super.key, super.key,
required this.schedule, required this.schedule,
required this.cupertino, required this.cupertino,
required this.onOpen, required this.onOpen,
this.divider = true,
}); });
final SavedSchedule schedule; final SavedSchedule schedule;
final bool cupertino; final bool cupertino;
final VoidCallback onOpen; final VoidCallback onOpen;
final bool divider;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final content = Padding( return AppListRow(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), cupertino: cupertino,
child: Row( divider: divider,
crossAxisAlignment: CrossAxisAlignment.start, onTap: onOpen,
children: [ leading: ScheduleAvatar(schedule: schedule, cupertino: cupertino),
Expanded(child: _details(context)), title: Text(scheduleDisplayName(schedule)),
const SizedBox(width: 8), time: scheduleNextDueShort(schedule),
Icon( subtitle: Text(
cupertino ? CupertinoIcons.chevron_right : Icons.chevron_right, '${scheduleTimerValue(schedule)} · '
color: _secondaryColor(context), '${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) { /// A schedule's leading clock: green while enabled, grey while paused. The
final prompt = schedule.prompt; /// state is also a word on the row (its time reads `Paused`), so colour is
return Column( /// never the only signal.
crossAxisAlignment: CrossAxisAlignment.start, class ScheduleAvatar extends StatelessWidget {
children: [ const ScheduleAvatar({
Row( super.key,
crossAxisAlignment: CrossAxisAlignment.start, required this.schedule,
children: [ required this.cupertino,
Expanded( });
child: Text(
scheduleDisplayName(schedule), final SavedSchedule schedule;
style: _titleStyle(context), final bool cupertino;
),
), @override
const SizedBox(width: 8), Widget build(BuildContext context) {
Text(scheduleStatusLabel(schedule), style: _statusStyle(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) { Widget _list(BuildContext context) {
final schedules = controller.visibleSchedules; final schedules = controller.visibleSchedules;
return ListView.separated( return ListView.builder(
key: scheduleListKey, key: scheduleListKey,
controller: scrollController, controller: scrollController,
padding: const EdgeInsets.only(top: 4, bottom: 24), padding: const EdgeInsets.only(top: 4, bottom: 24),
itemCount: schedules.length, itemCount: schedules.length,
separatorBuilder: (context, index) =>
cupertino ? _cupertinoSeparator(context) : const Divider(height: 1),
itemBuilder: (context, index) { itemBuilder: (context, index) {
final schedule = schedules[index]; final schedule = schedules[index];
return ScheduleListRow( return ScheduleListRow(
@@ -91,17 +89,13 @@ class SchedulesListView extends StatelessWidget {
), ),
schedule: schedule, schedule: schedule,
cupertino: cupertino, cupertino: cupertino,
divider: index < schedules.length - 1,
onOpen: () => onOpen(schedule), onOpen: () => onOpen(schedule),
); );
}, },
); );
} }
Widget _cupertinoSeparator(BuildContext context) => Container(
height: 1 / MediaQuery.devicePixelRatioOf(context),
color: CupertinoColors.separator.resolveFrom(context),
);
Widget _loadingState(BuildContext context) { Widget _loadingState(BuildContext context) {
return Center( return Center(
child: Semantics( child: Semantics(
@@ -73,11 +73,12 @@ class SchedulePipelineListBody extends StatelessWidget {
style: schedulePipelineMutedStyle(context), style: schedulePipelineMutedStyle(context),
), ),
), ),
for (var index = 0; index < schedules.length; index++) ...[ for (var index = 0; index < schedules.length; index++)
_row(context, schedules[index]), _row(
if (index < schedules.length - 1) context,
schedulePipelineSeparator(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; final id = schedule.id;
return SchedulePipelineRow( return SchedulePipelineRow(
schedule: schedule, schedule: schedule,
divider: divider,
busy: id != null && busyRows.contains(id), busy: id != null && busyRows.contains(id),
error: id == null ? null : rowErrors[id], error: id == null ? null : rowErrors[id],
onEdit: () => onEdit(schedule), onEdit: () => onEdit(schedule),
@@ -1,15 +1,21 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../../ui/adaptive/host.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 '../../domain/saved_schedule.dart';
import '../list/schedule_list_format.dart'; import '../list/schedule_list_format.dart';
import '../list/schedule_list_row.dart';
import 'schedule_pipeline_styles.dart'; import 'schedule_pipeline_styles.dart';
import 'schedule_pipeline_wording.dart'; import 'schedule_pipeline_wording.dart';
/// One saved schedule in the pipeline Summary: name, state, pinned version and enum _ScheduleAction { edit, toggle, delete }
/// timer words, the recorded due time, and its Edit/Pause-Enable/Delete actions.
/// 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 { class SchedulePipelineRow extends StatelessWidget {
const SchedulePipelineRow({ const SchedulePipelineRow({
super.key, super.key,
@@ -19,6 +25,7 @@ class SchedulePipelineRow extends StatelessWidget {
required this.onToggle, required this.onToggle,
required this.onDelete, required this.onDelete,
this.error, this.error,
this.divider = false,
}); });
final SavedSchedule schedule; final SavedSchedule schedule;
@@ -27,199 +34,74 @@ class SchedulePipelineRow extends StatelessWidget {
final VoidCallback onEdit; final VoidCallback onEdit;
final VoidCallback onToggle; final VoidCallback onToggle;
final VoidCallback onDelete; final VoidCallback onDelete;
final bool divider;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final id = schedule.id; 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 cupertino = usesCupertinoHost(context);
final color = enabled final row = AppListRow(
? (cupertino cupertino: cupertino,
? CupertinoColors.systemGreen.resolveFrom(context) divider: divider && error == null,
: Colors.green.shade700) onTap: busy ? null : onEdit,
: (cupertino leading: ScheduleAvatar(schedule: schedule, cupertino: cupertino),
? CupertinoColors.secondaryLabel.resolveFrom(context) title: Text(scheduleDisplayName(schedule)),
: Theme.of(context).colorScheme.onSurfaceVariant); time: scheduleNextDueShort(schedule),
return DecoratedBox( subtitle: Text(
decoration: ShapeDecoration( '${schedulePinnedVersionValue(schedule)} · '
color: color.withValues(alpha: 0.14), '${scheduleRuleSummary(schedule)}',
shape: const StadiumBorder(),
), ),
child: Padding( // A narrow Summary still needs a way to pause or delete.
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2), keepMenuWhenCompact: true,
child: Text( menu: AppOverflowMenu<_ScheduleAction>(
enabled ? 'Enabled' : 'Paused', key: scheduleRowMenuKey(id),
style: TextStyle( cupertino: cupertino,
color: color, enabled: !busy,
fontWeight: FontWeight.w700, label: 'Schedule actions for ${scheduleDisplayName(schedule)}',
fontSize: 12, 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(),
},
), ),
); );
} return Column(
} key: scheduleRowKey(id),
crossAxisAlignment: CrossAxisAlignment.stretch,
/// 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,
children: [ children: [
Icon(cupertino ? cupertinoIcon : icon, size: 16, color: muted?.color), row,
const SizedBox(width: 4), if (error case final text?)
Text('$label ', style: muted?.copyWith(fontWeight: FontWeight.w700)), Padding(
Flexible(child: Text(value, style: muted)), 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 ? CupertinoTheme.of(context).textTheme.navTitleTextStyle
: Theme.of(context).textTheme.titleMedium; : 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) { TextStyle? schedulePipelineMutedStyle(BuildContext context) {
if (usesCupertinoHost(context)) { if (usesCupertinoHost(context)) {
return CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith( return CupertinoTheme.of(context).textTheme.tabLabelTextStyle.copyWith(
@@ -59,13 +54,3 @@ Widget schedulePipelineTextButton(
} }
return TextButton(key: key, onPressed: onPressed, child: Text(label)); 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> scheduleRowKey(int? id) =>
ValueKey<String>('schedule-pipeline-row-${id ?? 'unknown'}'); 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> scheduleRowEditKey(int? id) =>
ValueKey<String>('schedule-pipeline-edit-${id ?? 'unknown'}'); ValueKey<String>('schedule-pipeline-edit-${id ?? 'unknown'}');
ValueKey<String> scheduleRowToggleKey(int? id) => ValueKey<String> scheduleRowToggleKey(int? id) =>
@@ -2,11 +2,10 @@ import 'package:flutter/cupertino.dart';
import '../../../core/api_gateway.dart'; import '../../../core/api_gateway.dart';
import '../domain/search_controller.dart'; import '../domain/search_controller.dart';
import '../domain/search_row.dart'; import 'search_result_row.dart';
import 'search_result_view.dart';
import 'search_layout.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 /// rows in one scroll view that runs behind the top bar, with standard
/// activity and retry controls. /// activity and retry controls.
class CupertinoSearchBody extends StatelessWidget { class CupertinoSearchBody extends StatelessWidget {
@@ -61,22 +60,14 @@ class CupertinoSearchBody extends StatelessWidget {
]; ];
case SearchBodyKind.results: case SearchBodyKind.results:
return [ return [
SliverToBoxAdapter( SliverList.builder(
child: CupertinoListSection.insetGrouped( itemCount: controller.shownResults.length,
// The section sits on the page's own background (the shell's itemBuilder: (context, index) => SearchResultRow(
// is not the grouped one), so it takes the bar pills' grey hit: controller.shownResults[index],
// rather than a white card framed by a grey band. query: query,
backgroundColor: const Color(0x00000000), onOpen: onOpen,
decoration: BoxDecoration( cupertino: true,
color: CupertinoColors.systemGrey6.resolveFrom(context), divider: index < controller.shownResults.length - 1,
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),
],
), ),
), ),
]; ];
@@ -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 { class _CupertinoSearching extends StatelessWidget {
const _CupertinoSearching(); const _CupertinoSearching();
@@ -2,8 +2,7 @@ import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart'; import '../../../core/api_gateway.dart';
import '../domain/search_controller.dart'; import '../domain/search_controller.dart';
import '../domain/search_row.dart'; import 'search_result_row.dart';
import 'search_result_view.dart';
import 'search_layout.dart'; import 'search_layout.dart';
/// The Material search view: an optional status header and a flat native /// The Material search view: an optional status header and a flat native
@@ -54,10 +53,13 @@ class MaterialSearchBody extends StatelessWidget {
return [ return [
SliverList.builder( SliverList.builder(
itemCount: controller.shownResults.length, itemCount: controller.shownResults.length,
itemBuilder: (context, index) { itemBuilder: (context, index) => SearchResultRow(
final hit = controller.shownResults[index]; hit: controller.shownResults[index],
return _MaterialResult(hit: hit, query: query, onOpen: onOpen); query: query,
}, onOpen: onOpen,
cupertino: false,
divider: index < controller.shownResults.length - 1,
),
), ),
]; ];
case SearchBodyKind.empty: 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 { class _Searching extends StatelessWidget {
const _Searching(); 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 'package:flutter/material.dart';
import '../../../core/api_gateway.dart'; import '../../../core/api_gateway.dart';
import '../../../core/transport/pipelines_client.dart' import '../../../core/transport/pipelines_client.dart'
show configuredGatewayEndpoint; 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_kind.dart';
import '../../artifacts/domain/artifact_record.dart'; import '../../artifacts/domain/artifact_record.dart';
import '../../artifacts/ui/artifact_tile.dart'; import '../../artifacts/ui/artifact_tile.dart';
import '../../artifacts/ui/artifact_viewer_fetch.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 /// 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. /// 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 null;
} }
return ClipRRect( return ClipRRect(
borderRadius: BorderRadius.circular(6), borderRadius: BorderRadius.circular(8),
child: SizedBox.square( child: SizedBox.square(
dimension: 44, dimension: kAppListAvatarSize,
child: ArtifactThumbnail( child: ArtifactThumbnail(
key: ValueKey('search.thumbnail.${hit['target']}'), key: ValueKey('search.thumbnail.${hit['target']}'),
artifact: record, artifact: record,
@@ -213,45 +109,14 @@ Widget? searchArtifactActions(BuildContext context, JsonMap hit) {
} }
} }
const labels = { return AppOverflowMenu<_ArtifactOpen>(
_ArtifactOpen.stage: 'Open stage', key: ValueKey('search.actions.${hit['target']}'),
_ArtifactOpen.run: 'Open run', label: 'Open…',
_ArtifactOpen.pipeline: 'Open pipeline', actions: const [
}; AppMenuAction(value: _ArtifactOpen.stage, label: 'Open stage'),
final key = ValueKey('search.actions.${hit['target']}'); AppMenuAction(value: _ArtifactOpen.run, label: 'Open run'),
if (usesCupertinoHost(context)) { AppMenuAction(value: _ArtifactOpen.pipeline, label: 'Open pipeline'),
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)),
], ],
onSelected: (_, choice) => pick(choice),
); );
} }
+132
View File
@@ -0,0 +1,132 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../adaptive/host.dart';
/// The leading circle every list row uses, as large as a native contact
/// avatar ([CircleAvatar]'s default).
const double kAppListAvatarSize = 40;
/// A list row's leading identity: an icon or an initial on a tinted circle,
/// with an optional corner badge (a chat's activity indicator).
///
/// [foreground] colours the icon/initial; the circle is [background], or the
/// foreground at 14% when omitted, so a status colour reads as a soft tint.
class AppListAvatar extends StatelessWidget {
const AppListAvatar({
super.key,
required this.child,
this.foreground,
this.background,
this.badge,
});
/// The first character of [name] (or `?`), large and bold enough to read
/// at a glance in the circle.
factory AppListAvatar.initial(
String name, {
Key? key,
required Color color,
Widget? badge,
}) {
final trimmed = name.trimLeft();
final initial = trimmed.isEmpty
? '?'
: String.fromCharCode(trimmed.runes.first).toUpperCase();
return AppListAvatar(
key: key,
foreground: color,
badge: badge,
child: Text(initial),
);
}
final Widget child;
final Color? foreground;
final Color? background;
final Widget? badge;
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
final mark =
foreground ??
(cupertino
? CupertinoColors.secondaryLabel.resolveFrom(context)
: Theme.of(context).colorScheme.onSurfaceVariant);
final fill =
background ??
(foreground == null
? (cupertino
? CupertinoColors.systemGrey5.resolveFrom(context)
: Theme.of(context).colorScheme.surfaceContainerHighest)
: mark.withValues(alpha: 0.14));
final initialStyle =
(cupertino
? CupertinoTheme.of(context).textTheme.textStyle
: Theme.of(context).textTheme.titleMedium ?? const TextStyle())
.copyWith(
color: mark,
fontSize: 18,
fontWeight: FontWeight.w700,
height: 1,
);
final circle = SizedBox.square(
dimension: kAppListAvatarSize,
child: DecoratedBox(
decoration: BoxDecoration(color: fill, shape: BoxShape.circle),
child: Center(
// The glyph is identity, not reading text: it scales down to stay
// inside the circle under large text instead of overflowing it.
child: Padding(
padding: const EdgeInsets.all(8),
child: FittedBox(
fit: BoxFit.scaleDown,
child: IconTheme.merge(
data: IconThemeData(color: mark, size: 22),
child: DefaultTextStyle(style: initialStyle, child: child),
),
),
),
),
),
);
if (badge == null) return circle;
return Stack(
clipBehavior: Clip.none,
children: [
circle,
PositionedDirectional(end: -2, bottom: -2, child: badge!),
],
);
}
}
/// A small coloured dot that leads a row's subtitle (a latest-run state) or
/// trails it (unread). It follows text scaling and carries its own label.
class AppListStatusDot extends StatelessWidget {
const AppListStatusDot({
super.key,
required this.color,
this.semanticLabel,
this.size = 8,
});
final Color color;
final String? semanticLabel;
final double size;
@override
Widget build(BuildContext context) {
final dimension = MediaQuery.textScalerOf(context).scale(size);
final dot = DecoratedBox(
decoration: BoxDecoration(color: color, shape: BoxShape.circle),
child: SizedBox.square(dimension: dimension),
);
if (semanticLabel == null) return ExcludeSemantics(child: dot);
return Semantics(
label: semanticLabel,
child: ExcludeSemantics(child: dot),
);
}
}
+333
View File
@@ -0,0 +1,333 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../adaptive/host.dart';
import 'app_list_avatar.dart';
/// Below this row width (a list pane squeezed beside its detail) a row is
/// compact: no avatar, no time and (by default) no menu, so the title keeps
/// the width and a tap on the row never lands on a second control.
const double kAppListRowCompactWidth = 280;
/// The rows' horizontal inset and the gap after the avatar.
const double kAppListRowInset = 16;
const double _avatarGap = 12;
/// Keys on a row's highlight surface and inset divider, for tests.
const appListRowSurfaceKey = ValueKey<String>('app-list-row-surface');
const appListRowDividerKey = ValueKey<String>('app-list-row-divider');
/// The app's one list row (runs, pipelines, chats, search results,
/// schedules), on both hosts.
///
/// Layout: [leading] (an [AppListAvatar]), then a bold one-line [title] with
/// the [time] at its trailing edge, then one muted [subtitle] line (with an
/// optional [subtitleLeading] dot/prefix and [subtitleTrailing] mark), then
/// the optional [menu] (an `AppOverflowMenu`). An inset hairline [divider]
/// under the text column separates rows. Nothing has a fixed height: the row
/// grows with text scaling and every line ellipsises.
///
/// [selected] paints the open row (Material `secondaryContainer`, Cupertino
/// `tertiarySystemFill`); [emphasized] marks unread/attention (a heavier
/// title and an accent time). Material rows ripple; Cupertino rows highlight
/// while pressed, like a native table cell.
class AppListRow extends StatelessWidget {
const AppListRow({
super.key,
required this.title,
this.leading,
this.time,
this.subtitle,
this.compactSubtitle,
this.subtitleLeading,
this.subtitleTrailing,
this.menu,
this.onTap,
this.tapKey,
this.selected = false,
this.emphasized = false,
this.divider = true,
this.keepMenuWhenCompact = false,
this.compactWidth = kAppListRowCompactWidth,
this.cupertino,
});
final Widget title;
final Widget? leading;
final String? time;
final Widget? subtitle;
/// Replaces [subtitle] in a compact row, which has less room for facts.
final Widget? compactSubtitle;
final Widget? subtitleLeading;
final Widget? subtitleTrailing;
final Widget? menu;
final VoidCallback? onTap;
/// Placed on the tap target ([InkWell] / [GestureDetector]).
final Key? tapKey;
final bool selected;
final bool emphasized;
final bool divider;
/// Keeps the menu in a compact row when the list has no other way to reach
/// the row's actions.
final bool keepMenuWhenCompact;
final double compactWidth;
/// Overrides the host detection (some features pick a style per platform).
final bool? cupertino;
/// The open row's fill on each host.
static Color selectedColor(BuildContext context, {required bool cupertino}) =>
cupertino
? CupertinoColors.tertiarySystemFill.resolveFrom(context)
: Theme.of(context).colorScheme.secondaryContainer;
@override
Widget build(BuildContext context) {
final cupertino = this.cupertino ?? usesCupertinoHost(context);
final styles = _RowStyles.of(
context,
cupertino: cupertino,
selected: selected,
emphasized: emphasized,
);
return Semantics(
container: true,
selected: selected,
button: onTap != null,
child: LayoutBuilder(
builder: (context, constraints) {
final compact = constraints.maxWidth < compactWidth;
final showLeading = leading != null && !compact;
final showMenu = menu != null && (!compact || keepMenuWhenCompact);
final start = compact ? 12.0 : kAppListRowInset;
final content = Padding(
padding: EdgeInsetsDirectional.only(
start: start,
end: showMenu ? 4 : kAppListRowInset,
top: 10,
bottom: 10,
),
child: Row(
children: [
if (showLeading)
Padding(
padding: const EdgeInsetsDirectional.only(end: _avatarGap),
child: leading,
),
Expanded(child: _text(styles, compact)),
if (showMenu)
Padding(
padding: const EdgeInsetsDirectional.only(start: 4),
child: menu,
),
],
),
);
final surface = cupertino
? _CupertinoRowSurface(
tapKey: tapKey,
onTap: onTap,
selected: selected,
child: content,
)
: Material(
key: appListRowSurfaceKey,
color: selected
? selectedColor(context, cupertino: false)
: Colors.transparent,
child: InkWell(key: tapKey, onTap: onTap, child: content),
);
if (!divider) return surface;
final textStart =
start + (showLeading ? kAppListAvatarSize + _avatarGap : 0);
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
surface,
Padding(
padding: EdgeInsetsDirectional.only(start: textStart),
child: SizedBox(
key: appListRowDividerKey,
height: cupertino
? 1 / MediaQuery.devicePixelRatioOf(context)
: 1,
child: ColoredBox(color: styles.divider),
),
),
],
);
},
),
);
}
Widget _text(_RowStyles styles, bool compact) {
final line = compact ? (compactSubtitle ?? subtitle) : subtitle;
final titleLine = LayoutBuilder(
// The time keeps at most 40% of the line, so very large text in a
// narrow row ellipsises instead of overflowing.
builder: (context, constraints) => Row(
children: [
Expanded(
child: DefaultTextStyle(
style: styles.title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
child: title,
),
),
if (!compact && time != null && time!.isNotEmpty)
ConstrainedBox(
constraints: BoxConstraints(maxWidth: constraints.maxWidth * 0.4),
child: Padding(
padding: const EdgeInsetsDirectional.only(start: 8),
child: Text(
time!,
style: styles.time,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
),
],
),
);
if (line == null && subtitleLeading == null && subtitleTrailing == null) {
return titleLine;
}
return Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
titleLine,
const SizedBox(height: 2),
Row(
children: [
if (subtitleLeading != null)
Padding(
padding: const EdgeInsetsDirectional.only(end: 6),
child: subtitleLeading,
),
Expanded(
child: DefaultTextStyle(
style: styles.subtitle,
maxLines: 1,
overflow: TextOverflow.ellipsis,
child: line ?? const SizedBox.shrink(),
),
),
if (subtitleTrailing != null)
Padding(
padding: const EdgeInsetsDirectional.only(start: 8),
child: subtitleTrailing,
),
],
),
],
);
}
}
/// The row's text styles, from the host's own type scale.
class _RowStyles {
const _RowStyles(this.title, this.subtitle, this.time, this.divider);
factory _RowStyles.of(
BuildContext context, {
required bool cupertino,
required bool selected,
required bool emphasized,
}) {
final weight = emphasized ? FontWeight.w700 : FontWeight.w600;
if (cupertino) {
final theme = CupertinoTheme.of(context);
final base = theme.textTheme.textStyle;
final muted = CupertinoColors.secondaryLabel.resolveFrom(context);
final small = base.copyWith(fontSize: 15, color: muted);
return _RowStyles(
base.copyWith(fontWeight: weight, letterSpacing: 0),
small,
small.copyWith(
color: emphasized ? theme.primaryColor : muted,
fontWeight: emphasized ? FontWeight.w600 : null,
),
CupertinoColors.separator.resolveFrom(context),
);
}
final theme = Theme.of(context);
final scheme = theme.colorScheme;
final text = theme.textTheme;
final muted = scheme.onSurfaceVariant;
return _RowStyles(
(text.titleMedium ?? const TextStyle()).copyWith(
fontWeight: weight,
letterSpacing: 0,
color: selected ? scheme.onSecondaryContainer : scheme.onSurface,
),
(text.bodyMedium ?? const TextStyle()).copyWith(color: muted),
(text.bodySmall ?? const TextStyle()).copyWith(
color: emphasized ? scheme.primary : muted,
fontWeight: emphasized ? FontWeight.w600 : null,
),
scheme.outlineVariant,
);
}
final TextStyle title;
final TextStyle subtitle;
final TextStyle time;
final Color divider;
}
/// A Cupertino table cell: highlights while pressed, tinted while selected.
class _CupertinoRowSurface extends StatefulWidget {
const _CupertinoRowSurface({
required this.tapKey,
required this.onTap,
required this.selected,
required this.child,
});
final Key? tapKey;
final VoidCallback? onTap;
final bool selected;
final Widget child;
@override
State<_CupertinoRowSurface> createState() => _CupertinoRowSurfaceState();
}
class _CupertinoRowSurfaceState extends State<_CupertinoRowSurface> {
bool _pressed = false;
void _press(bool value) {
if (_pressed != value) setState(() => _pressed = value);
}
@override
Widget build(BuildContext context) {
final color = _pressed
? CupertinoColors.systemGrey4.resolveFrom(context)
: widget.selected
? AppListRow.selectedColor(context, cupertino: true)
: const Color(0x00000000);
final enabled = widget.onTap != null;
return GestureDetector(
key: widget.tapKey,
behavior: HitTestBehavior.opaque,
onTap: widget.onTap,
onTapDown: enabled ? (_) => _press(true) : null,
onTapUp: enabled ? (_) => _press(false) : null,
onTapCancel: enabled ? () => _press(false) : null,
child: ColoredBox(
key: appListRowSurfaceKey,
color: color,
child: widget.child,
),
);
}
}
+118
View File
@@ -0,0 +1,118 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../adaptive/host.dart';
/// One choice in an [AppOverflowMenu].
class AppMenuAction<T> {
const AppMenuAction({
required this.value,
required this.label,
this.key,
this.destructive = false,
});
final T value;
final String label;
/// Placed on the menu item (Material) or the sheet action (Cupertino), so a
/// test finds the same item on both hosts.
final Key? key;
/// Shown in the destructive colour on Cupertino's action sheet.
final bool destructive;
}
/// The app's one row/header overflow control: the host's "more" icon that
/// opens the row's secondary actions.
///
/// Material shows a [PopupMenuButton] with [Icons.more_vert]; Cupertino shows
/// a [CupertinoButton] with [CupertinoIcons.ellipsis] that opens a
/// [CupertinoActionSheet] (with Cancel). Every list row and the run header use
/// this, so the overflow icon reads the same everywhere on a host.
class AppOverflowMenu<T> extends StatelessWidget {
const AppOverflowMenu({
super.key,
required this.actions,
required this.onSelected,
this.label = 'More actions',
this.sheetTitle,
this.enabled = true,
this.cupertino,
});
final List<AppMenuAction<T>> actions;
/// Called with the picked value once the menu or sheet has closed.
final void Function(BuildContext context, T value) onSelected;
/// Tooltip (Material) and accessible label (both hosts).
final String label;
/// The Cupertino sheet's title, usually the row's name.
final String? sheetTitle;
final bool enabled;
/// Overrides the host detection (some features pick a style per platform).
final bool? cupertino;
@override
Widget build(BuildContext context) {
if (actions.isEmpty) return const SizedBox.shrink();
if (!(cupertino ?? usesCupertinoHost(context))) {
return PopupMenuButton<T>(
icon: const Icon(Icons.more_vert),
tooltip: label,
enabled: enabled,
onSelected: (value) => onSelected(context, value),
itemBuilder: (_) => [
for (final action in actions)
PopupMenuItem<T>(
key: action.key,
value: action.value,
child: Text(action.label),
),
],
);
}
// Its own node, so a row's merged label never swallows the button.
return Semantics(
container: true,
button: true,
enabled: enabled,
label: label,
excludeSemantics: true,
child: CupertinoButton(
padding: EdgeInsets.zero,
minimumSize: const Size.square(kMinInteractiveDimensionCupertino),
onPressed: enabled ? () => _showSheet(context) : null,
child: const Icon(CupertinoIcons.ellipsis),
),
);
}
Future<void> _showSheet(BuildContext context) async {
final picked = await showCupertinoModalPopup<T>(
context: context,
builder: (sheet) => CupertinoActionSheet(
title: sheetTitle == null ? null : Text(sheetTitle!),
actions: [
for (final action in actions)
CupertinoActionSheetAction(
key: action.key,
isDestructiveAction: action.destructive,
onPressed: () => Navigator.of(sheet).pop(action.value),
child: Text(action.label),
),
],
cancelButton: CupertinoActionSheetAction(
isDefaultAction: true,
onPressed: () => Navigator.of(sheet).pop(),
child: const Text('Cancel'),
),
),
);
if (picked != null && context.mounted) onSelected(context, picked);
}
}
+130
View File
@@ -0,0 +1,130 @@
# One shared list row (style review batch 3: F6, F8 results, F16)
Before this change Runs, Pipelines, Chat, Search results and Schedules each drew
rows differently (see `/tmp/app-style-review/report.md`). They now all use one
component, on both hosts.
## Shared pieces (`lib/ui/layout/`)
- `app_list_row.dart`, `AppListRow`: the leading slot, then a bold one-line
`title` with `time` on the same line (the time takes at most 40% of the
line), then one muted `subtitle` line with an optional `subtitleLeading`
(status dot) and `subtitleTrailing` (unread dot), then an optional `menu`.
- Styles come from the host's type scale. Material: title `titleMedium` w600
(letter spacing 0), subtitle `bodyMedium`, time `bodySmall`, all in
`onSurfaceVariant`. Cupertino: title `textStyle` w600, subtitle and time
15pt `secondaryLabel`.
- `selected`: Material `secondaryContainer` (title in
`onSecondaryContainer`), Cupertino `tertiarySystemFill`.
`AppListRow.selectedColor` gives the fill. Semantics are a container with
`selected` and `button`.
- `emphasized` (unread or attention): w700 title, accent time in w600.
- Tapping: Material uses `InkWell` on a `Material` surface. Cupertino uses a
`GestureDetector` that highlights `systemGrey4` while pressed, like a table
cell, and fades nothing. `tapKey` goes on the tap target.
- `divider` (default true): a hairline inset to the start of the text column.
Cupertino uses `separator` at 1 physical pixel; Material uses
`outlineVariant` at 1. Lists turn it off for the last row of a group.
- Compact mode: when the row is narrower than `kAppListRowCompactWidth`
(280), it drops the avatar, the time and the menu, and shows
`compactSubtitle` if one is given. `keepMenuWhenCompact` keeps the menu
(chat, pipeline schedules).
- No fixed heights. Padding is 16 horizontal and 10 vertical. At 2x text in
a 320px row everything ellipsises without overflowing.
- Test keys: `appListRowSurfaceKey` and `appListRowDividerKey`.
- `app_list_avatar.dart`
- `AppListAvatar` is a 40px circle (the `CircleAvatar` default) holding an
icon (22) or text. The circle is filled with the foreground at 14%, or a
neutral fill when there is no foreground. An optional corner `badge` is
supported. The glyph scales down to stay inside the circle at large text.
- `AppListAvatar.initial` shows the first letter in 18pt w700. It replaces
the pipelines initial that used to read as an empty circle.
- `AppListStatusDot` is a small dot that follows text scaling and can carry a
semantics label.
- `app_overflow_menu.dart`: `AppOverflowMenu<T>` and `AppMenuAction` give the
app one overflow control. Material uses a `PopupMenuButton` with
`Icons.more_vert`. Cupertino uses a `CupertinoButton` with
`CupertinoIcons.ellipsis` that opens a `CupertinoActionSheet` with Cancel.
Item keys sit on the popup items or sheet actions on both hosts. Used by the
run menu (list rows and the run detail header), chat rows, search artifact
hits and pipeline schedule rows.
## Migrated
- Runs (`runs/ui/runs_list.dart`): `RunListRow` is a thin `AppListRow`. Its
leading slot is the status avatar. Rows are separated by inset dividers,
with no divider before a day heading. The key `run-row-<id>` is now on the
row. `run-list-more-menu-<id>` and the menu item keys are unchanged.
`run-row-surface-<id>` is gone; use `appListRowSurfaceKey`. The run detail's
menu uses the same control, so its Cupertino icon changed from
`ellipsis_circle` to `ellipsis`.
- Pipelines (`pipelines/widgets/pipeline_list_panel.dart`): one list for both
hosts. The Cupertino inset-grouped section and the full-width Material
dividers are gone, and so is the chevron. The legible initial avatar keeps
the key `pipeline-avatar-<id>`. The latest-run dot is now
`AppListStatusDot`, keeping `pipeline-status-<id>`. Compact rows show the
latest state word. The compact threshold moved from 220 to 280.
- Chat (`chat/ui/sessions/session_row_content.dart` `ChatSessionRow`, used by
both `session_list_material.dart` and `session_list_cupertino.dart`): the
separate Material `ListTile` and Cupertino `CupertinoListTile` rows are gone.
The Cupertino list no longer uses inset groups; a directory header is now a
small grey label. All keys are kept: `chat-row-<id>`, `chat-actions-<id>`,
`chat-row-unread`, `chat-row-working` and `chat-row-starred`. Titles are now
w600, or w700 when unread (they were w500/w700). The menu stays when compact.
- Chat in the shell (`chat/screen.dart`): the `BelowTopBar` wrapper is
removed. The list pads itself by the bar height (Material through default
`ListView` padding, Cupertino explicitly), so it scrolls behind the bar like
the other lists.
- Search (`search/ui/search_result_row.dart` `SearchResultRow`, used by both
bodies): the leading slot is the kind icon in an avatar, or the image
thumbnail, now 40px. The recency is the time. The line starts with the kind
in bold ("Field · …"), then shows the snippet with the match in bold.
`SearchKindTag`, the two-line title and the Cupertino inset group are gone.
Artifact hits keep `search.actions.<target>` and the tooltip "Open…".
- Schedules list (`schedules/ui/list/schedule_list_row.dart`): the six-line
block is now two lines. The clock avatar is green when enabled and grey when
paused, and also carries the status as its semantics label. The time is
`scheduleNextDueShort` ("22 Oct 09:00" or "Paused"). The line shows the
timer and the pipeline/version. The prompt, workspace, timezone and exact
due time are left to the editor the row opens. The list stays read-only and
has no menu: its tests require no Edit/Pause/Delete, and the list controller
has no mutations.
- Pipeline Summary schedules (`schedules/ui/pipeline/schedule_pipeline_row.dart`):
the same two lines, with the line "v2 · Every 24h · mon · Europe/London".
The inline Edit, Pause/Enable and Delete text buttons moved into an overflow
menu under a new key, `scheduleRowMenuKey(id)`. The item keys
`scheduleRowEditKey`, `scheduleRowToggleKey` and `scheduleRowDeleteKey` are
kept, and Delete is destructive. A busy row disables its menu and tap. A tap
on the row edits it. A refusal appears under the row with
`scheduleRowErrorKey`.
## Tests
- New: `test/ui/layout/app_list_row_test.dart` covers both hosts. It checks
the layout order, inset divider, tap, menu icon and items, the selected and
emphasised styles, compact mode, `keepMenuWhenCompact`, 320px at 2x in light
and dark, and the initial avatar.
- Updated for intentional changes: `list_detail_consistency_test`,
`pipelines_destination_test`, `chat_list_detail_test`,
`chat_active_selection_test`, `chat_session_row_layout_test`,
`chat_session_row_material_test`, `pipeline_list_composition_test` (inset
divider and legible avatar), `pipelines_adaptive_test`,
`pipelines_screen_test`, `pipeline_summary_schedules_test`,
`schedules_layout_test`, `schedule_pipeline_section_test` (actions open
through the menu) and `search_bar_layout_test`.
## Evidence
The captures are in `/tmp/wave2-d-evidence/`. They were taken with headless
Chrome using the reviewer's driver (a copy pointed at this worktree's tool
directory). The sources were:
- `lib/main.dart` over the runs and pipelines fixture servers;
- the new `tool/app_host_probe_entry.dart`, which is the same composition with
`?host=cupertino`;
- `tool/chat_sessions_probe_entry.dart`, `tool/schedules_list_probe_app.dart`,
`tool/schedule_pipeline_probe_app.dart` and
`tool/search_selection_probe_entry.dart`.
The captures were taken at 560 and 1200, in light and dark, on Material and
Cupertino. There was no device run, so Android and iOS are unverified.
@@ -3,6 +3,7 @@ import 'dart:ui' show Tristate;
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:pipelines_app/features/chat/screen.dart'; import 'package:pipelines_app/features/chat/screen.dart';
import 'package:pipelines_app/features/pipelines/screen.dart'; import 'package:pipelines_app/features/pipelines/screen.dart';
@@ -175,39 +176,24 @@ void main() {
selected, selected,
reason: '$destination: $rowKey after opening $key', reason: '$destination: $rowKey after opening $key',
); );
// Every list uses the shared row and its highlight.
final context = tester.element(row); final context = tester.element(row);
if (cupertino) { expect(tester.widget<AppListRow>(row).selected, selected);
final color = destination == 'Runs' final surface = find.descendant(
? tester.widget<CupertinoButton>(row).color of: row,
: tester.widget<CupertinoListTile>(row).backgroundColor; matching: find.byKey(appListRowSurfaceKey),
expect( );
color, expect(
selected cupertino
? CupertinoColors.tertiarySystemFill.resolveFrom( ? tester.widget<ColoredBox>(surface).color
context, : tester.widget<Material>(surface).color,
) selected
: isNull, ? AppListRow.selectedColor(
); context,
} else if (destination == 'Runs') { cupertino: cupertino,
final id = rowKey.split('-').last;
expect(
tester
.widget<Material>(
find.byKey(ValueKey('run-row-surface-$id')),
) )
.color, : const Color(0x00000000),
selected );
? Theme.of(context).colorScheme.secondaryContainer
: Colors.transparent,
);
} else {
final tile = tester.widget<ListTile>(row);
expect(tile.selected, selected);
expect(
tile.selectedTileColor,
Theme.of(context).colorScheme.secondaryContainer,
);
}
} }
} }
if (destination == 'Chat') { if (destination == 'Chat') {
@@ -2,6 +2,7 @@ import 'dart:convert';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'package:pipelines_app/application/app_session.dart'; import 'package:pipelines_app/application/app_session.dart';
import 'package:pipelines_app/application/pipelines_destination.dart'; import 'package:pipelines_app/application/pipelines_destination.dart';
import 'package:pipelines_app/application/server_endpoint.dart'; import 'package:pipelines_app/application/server_endpoint.dart';
@@ -202,7 +203,9 @@ void main() {
await tester.pump(); await tester.pump();
expect(find.text('hash-alpha'), findsOneWidget); expect(find.text('hash-alpha'), findsOneWidget);
expect( expect(
tester.widget<ListTile>(find.byKey(const Key('pipeline-row-1'))).selected, tester
.widget<AppListRow>(find.byKey(const Key('pipeline-row-1')))
.selected,
isTrue, isTrue,
); );
@@ -229,7 +232,9 @@ void main() {
expect(find.text('Reconnecting to Pipelines…'), findsNothing); expect(find.text('Reconnecting to Pipelines…'), findsNothing);
expect(find.text('hash-alpha'), findsOneWidget); expect(find.text('hash-alpha'), findsOneWidget);
expect( expect(
tester.widget<ListTile>(find.byKey(const Key('pipeline-row-1'))).selected, tester
.widget<AppListRow>(find.byKey(const Key('pipeline-row-1')))
.selected,
isTrue, isTrue,
reason: 'A reconnect must not remount the screen or drop the selection.', reason: 'A reconnect must not remount the screen or drop the selection.',
); );
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart'; import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'package:pipelines_app/core/api_gateway.dart'; import 'package:pipelines_app/core/api_gateway.dart';
@@ -53,7 +54,7 @@ void main() {
await _pumpShell(tester, size); await _pumpShell(tester, size);
expect(find.text('Select a chat to open it here.'), findsOneWidget); expect(find.text('Select a chat to open it here.'), findsOneWidget);
expect( expect(
tester.widget<ListTile>(find.byKey(const Key('chat-row-a'))).selected, tester.widget<AppListRow>(find.byKey(const Key('chat-row-a'))).selected,
isFalse, isFalse,
); );
@@ -66,11 +67,11 @@ void main() {
expect(find.byKey(const ValueKey('chat-thread-a')), findsOneWidget); expect(find.byKey(const ValueKey('chat-thread-a')), findsOneWidget);
expect(find.text('Second chat'), findsOneWidget); expect(find.text('Second chat'), findsOneWidget);
expect( expect(
tester.widget<ListTile>(find.byKey(const Key('chat-row-a'))).selected, tester.widget<AppListRow>(find.byKey(const Key('chat-row-a'))).selected,
isTrue, isTrue,
); );
expect( expect(
tester.widget<ListTile>(find.byKey(const Key('chat-row-b'))).selected, tester.widget<AppListRow>(find.byKey(const Key('chat-row-b'))).selected,
isFalse, isFalse,
); );
// The shell bar keeps the list's controls; the pane bar has the chat's // The shell bar keeps the list's controls; the pane bar has the chat's
@@ -91,11 +92,11 @@ void main() {
expect(find.byKey(const ValueKey('chat-thread-a')), findsNothing); expect(find.byKey(const ValueKey('chat-thread-a')), findsNothing);
expect(find.byKey(const ValueKey('chat-thread-b')), findsOneWidget); expect(find.byKey(const ValueKey('chat-thread-b')), findsOneWidget);
expect( expect(
tester.widget<ListTile>(find.byKey(const Key('chat-row-a'))).selected, tester.widget<AppListRow>(find.byKey(const Key('chat-row-a'))).selected,
isFalse, isFalse,
); );
expect( expect(
tester.widget<ListTile>(find.byKey(const Key('chat-row-b'))).selected, tester.widget<AppListRow>(find.byKey(const Key('chat-row-b'))).selected,
isTrue, isTrue,
); );
expect(navigator.canPop(), isFalse); expect(navigator.canPop(), isFalse);
@@ -123,7 +124,7 @@ void main() {
await tester.pageBack(); await tester.pageBack();
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect( expect(
tester.widget<ListTile>(find.byKey(const Key('chat-row-a'))).selected, tester.widget<AppListRow>(find.byKey(const Key('chat-row-a'))).selected,
isFalse, isFalse,
); );
@@ -3,6 +3,7 @@ import 'dart:ui' show Tristate;
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_screen.dart'; import 'package:pipelines_app/features/chat/ui/sessions/chat_sessions_screen.dart';
import 'chat_test_harness.dart'; import 'chat_test_harness.dart';
@@ -59,24 +60,23 @@ void main() {
Tristate.isTrue, Tristate.isTrue,
active, active,
); );
if (cupertino) { expect(tester.widget<AppListRow>(row).selected, active);
final tile = tester.widget<CupertinoListTile>(row); final surface = find.descendant(
expect( of: row,
tile.backgroundColor, matching: find.byKey(appListRowSurfaceKey),
active );
? CupertinoColors.tertiarySystemFill.resolveFrom( final color = cupertino
tester.element(row), ? tester.widget<ColoredBox>(surface).color
) : tester.widget<Material>(surface).color;
: isNull, expect(
); color,
} else { active
final tile = tester.widget<ListTile>(row); ? AppListRow.selectedColor(
expect(tile.selected, active); tester.element(row),
expect( cupertino: cupertino,
tile.selectedTileColor, )
Theme.of(tester.element(row)).colorScheme.secondaryContainer, : const Color(0x00000000),
); );
}
} }
expectRow('a', true); expectRow('a', true);
@@ -1,12 +1,13 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'package:pipelines_app/core/api_gateway.dart'; import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_list_cupertino.dart'; import 'package:pipelines_app/features/chat/ui/sessions/session_list_cupertino.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_row_content.dart'; import 'package:pipelines_app/features/chat/ui/sessions/session_row_content.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_row_style.dart'; import 'package:pipelines_app/features/chat/ui/sessions/session_row_style.dart';
/// A grouped Cupertino list, the host the web client runs on macOS/iOS. /// The Cupertino list, the host the web client runs on macOS/iOS.
Future<void> _pumpRows( Future<void> _pumpRows(
WidgetTester tester, WidgetTester tester,
List<JsonMap> sessions, { List<JsonMap> sessions, {
@@ -193,7 +194,7 @@ void main() {
// Unread is bold with an accent time and dot; read rows are not. // Unread is bold with an accent time and dot; read rows are not.
expect(_styleOf(tester, 'Unread chat').fontWeight, FontWeight.w700); expect(_styleOf(tester, 'Unread chat').fontWeight, FontWeight.w700);
expect(_styleOf(tester, 'Read chat').fontWeight, FontWeight.w500); expect(_styleOf(tester, 'Read chat').fontWeight, FontWeight.w600);
expect(find.byKey(const Key('chat-row-unread')), findsOneWidget); expect(find.byKey(const Key('chat-row-unread')), findsOneWidget);
final accent = CupertinoTheme.of( final accent = CupertinoTheme.of(
tester.element(find.text('5 min ago')), tester.element(find.text('5 min ago')),
@@ -216,10 +217,10 @@ void main() {
), ),
findsOneWidget, findsOneWidget,
); );
expect(find.byType(CupertinoListTile), findsNWidgets(2)); expect(find.byType(AppListRow), findsNWidgets(2));
expect( expect(
tester.getTopLeft(find.byKey(const Key('chat-row-s2'))).dy, tester.getTopLeft(find.byKey(const Key('chat-row-s2'))).dy,
greaterThan( greaterThanOrEqualTo(
tester.getBottomLeft(find.byKey(const Key('chat-row-s1'))).dy, tester.getBottomLeft(find.byKey(const Key('chat-row-s1'))).dy,
), ),
); );
@@ -1,12 +1,13 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'package:pipelines_app/core/api_gateway.dart'; import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_list_material.dart'; import 'package:pipelines_app/features/chat/ui/sessions/session_list_material.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_row_content.dart'; import 'package:pipelines_app/features/chat/ui/sessions/session_row_content.dart';
import 'expand_closed.dart'; import 'expand_closed.dart';
/// The Android host: a Material grouped list with its native separators. /// The Android host: the Material list with the shared row's dividers.
Future<void> _pumpRows( Future<void> _pumpRows(
WidgetTester tester, WidgetTester tester,
List<JsonMap> sessions, { List<JsonMap> sessions, {
@@ -107,11 +108,16 @@ void main() {
findsOneWidget, findsOneWidget,
); );
// Native Material separators sit between rows, not around the group. // One inset divider between the rows, none after the last; it starts
expect(find.byType(Divider), findsOneWidget); // under the text, not at the edge.
expect(find.byKey(appListRowDividerKey), findsOneWidget);
expect(
tester.getTopLeft(find.byKey(appListRowDividerKey)).dx,
closeTo(title.left, 1),
);
expect( expect(
tester.getTopLeft(find.byKey(const Key('chat-row-s2'))).dy, tester.getTopLeft(find.byKey(const Key('chat-row-s2'))).dy,
greaterThan( greaterThanOrEqualTo(
tester.getBottomLeft(find.byKey(const Key('chat-row-s1'))).dy, tester.getBottomLeft(find.byKey(const Key('chat-row-s1'))).dy,
), ),
); );
@@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'package:pipelines_app/features/pipelines/screen.dart'; import 'package:pipelines_app/features/pipelines/screen.dart';
import 'package:pipelines_app/shell/detail_page.dart'; import 'package:pipelines_app/shell/detail_page.dart';
@@ -24,17 +25,32 @@ void main() {
// Filter and sort are app-bar actions; no toolbar row without a filter. // Filter and sort are app-bar actions; no toolbar row without a filter.
expect(find.byKey(const Key('pipeline-toolbar')), findsNothing); expect(find.byKey(const Key('pipeline-toolbar')), findsNothing);
// Each pipeline has a deterministic tinted initial rather than one generic // Each pipeline has a deterministic tinted initial rather than one generic
// flow icon, while the title follows native ListTile spacing. // flow icon, while the title follows the shared row's spacing.
expect(find.byKey(const Key('pipeline-avatar-1')), findsOneWidget); expect(find.byKey(const Key('pipeline-avatar-1')), findsOneWidget);
expect( expect(
tester.getTopLeft(find.text('Alpha review')).dx, tester.getTopLeft(find.text('Alpha review')).dx,
greaterThan(listLeft), greaterThan(listLeft),
); );
// Inset dividers between rows, none after the last.
expect( expect(
find.descendant(of: list, matching: find.byType(Divider)), find.descendant(of: list, matching: find.byKey(appListRowDividerKey)),
findsNWidgets(fixture.summaries.length - 1), findsNWidgets(fixture.summaries.length - 1),
); );
// The divider starts under the title, not at the list edge.
expect(
tester.getTopLeft(find.byKey(appListRowDividerKey).first).dx,
closeTo(tester.getTopLeft(find.text('Alpha review')).dx, 1),
);
// The initial is legible: a 40px circle with a large glyph.
final avatar = find.byKey(const Key('pipeline-avatar-1'));
expect(tester.getSize(avatar), const Size.square(40));
expect(
tester
.getSize(find.descendant(of: avatar, matching: find.text('A')))
.height,
greaterThanOrEqualTo(14),
);
// The title's trailing time and the one muted facts line replace the old // The title's trailing time and the one muted facts line replace the old
// version/id, run metadata, and graph stack. // version/id, run metadata, and graph stack.
@@ -196,7 +212,7 @@ void main() {
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
}); });
testWidgets('Cupertino keeps native tiles with the same row identity', ( testWidgets('Cupertino keeps the shared row with the same row identity', (
tester, tester,
) async { ) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS; debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
@@ -211,7 +227,12 @@ void main() {
); );
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.byType(CupertinoListTile), findsWidgets); expect(
tester
.widget<AppListRow>(find.byKey(const Key('pipeline-row-1')))
.cupertino,
isTrue,
);
expect(find.text('2 stages · 1 schedule'), findsOneWidget); expect(find.text('2 stages · 1 schedule'), findsOneWidget);
expect(find.textContaining('v2 · #'), findsNothing); expect(find.textContaining('v2 · #'), findsNothing);
expect(find.byKey(const Key('pipeline-avatar-1')), findsOneWidget); expect(find.byKey(const Key('pipeline-avatar-1')), findsOneWidget);
@@ -61,13 +61,18 @@ void main() {
expect(find.text('Schedules (1)'), findsOneWidget); expect(find.text('Schedules (1)'), findsOneWidget);
expect(find.text('Research batteries'), findsOneWidget); expect(find.text('Research batteries'), findsOneWidget);
expect( expect(
find.text('Every 24h · mon, wed · Europe/London'), find.text('v3 · Every 24h · mon, wed · Europe/London'),
findsOneWidget, findsOneWidget,
); );
expect(find.byKey(scheduleAddKey), findsOneWidget); expect(find.byKey(scheduleAddKey), findsOneWidget);
// Edit, Pause and Delete are the row's overflow menu.
await tester.tap(find.byKey(scheduleRowMenuKey(8)));
await tester.pumpAndSettle();
expect(find.byKey(scheduleRowEditKey(8)), findsOneWidget); expect(find.byKey(scheduleRowEditKey(8)), findsOneWidget);
expect(find.byKey(scheduleRowToggleKey(8)), findsOneWidget); expect(find.byKey(scheduleRowToggleKey(8)), findsOneWidget);
expect(find.byKey(scheduleRowDeleteKey(8)), findsOneWidget); expect(find.byKey(scheduleRowDeleteKey(8)), findsOneWidget);
await tester.tapAt(const Offset(4, 4));
await tester.pumpAndSettle();
expect(gateway.callsOf('list_schedules').single.fields, {'pipeline_id': 1}); expect(gateway.callsOf('list_schedules').single.fields, {'pipeline_id': 1});
await tester.tap(find.text('Source')); await tester.tap(find.text('Source'));
@@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import '../../native_back.dart'; import '../../native_back.dart';
import 'package:pipelines_app/features/graph/widgets/definition_graph_view.dart'; import 'package:pipelines_app/features/graph/widgets/definition_graph_view.dart';
import 'package:pipelines_app/features/pipelines/pipeline_repository.dart'; import 'package:pipelines_app/features/pipelines/pipeline_repository.dart';
@@ -122,7 +123,13 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.byType(CupertinoPageScaffold), findsOneWidget); expect(find.byType(CupertinoPageScaffold), findsOneWidget);
expect(find.byType(CupertinoListTile), findsWidgets); // The shared list row, in its Cupertino form.
expect(
tester
.widget<AppListRow>(find.byKey(const Key('pipeline-row-1')))
.cupertino,
isTrue,
);
expect(find.byType(CupertinoActionSheet), findsNothing); expect(find.byType(CupertinoActionSheet), findsNothing);
await tester.tap(find.byKey(const Key('pipeline-row-1'))); await tester.tap(find.byKey(const Key('pipeline-row-1')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
@@ -2,6 +2,7 @@ import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'package:pipelines_app/features/pipelines/ui/run_pipeline_wording.dart'; import 'package:pipelines_app/features/pipelines/ui/run_pipeline_wording.dart';
import 'package:pipelines_app/core/api_gateway.dart'; import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/pipelines/screen.dart'; import 'package:pipelines_app/features/pipelines/screen.dart';
@@ -129,7 +130,7 @@ void main() {
await tester.tap(find.byTooltip('Refresh')); await tester.tap(find.byTooltip('Refresh'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
final row = tester.widget<ListTile>( final row = tester.widget<AppListRow>(
find.byKey(const Key('pipeline-row-1')), find.byKey(const Key('pipeline-row-1')),
); );
expect(row.selected, isTrue); expect(row.selected, isTrue);
@@ -30,16 +30,15 @@ void main() {
expect(find.text('2 schedules'), findsOneWidget); expect(find.text('2 schedules'), findsOneWidget);
expect(find.textContaining('not pipeline definitions'), findsOneWidget); expect(find.textContaining('not pipeline definitions'), findsOneWidget);
// Two lines per row: the name with its next run, then the timer
// and pinned pipeline version. The editor holds the rest.
expect(find.text('Research batteries'), findsOneWidget); expect(find.text('Research batteries'), findsOneWidget);
expect(find.text('Find battery chemistry sources'), findsOneWidget); expect(find.text('22 Oct 09:00'), findsOneWidget);
expect(find.text('Pipeline 4 · v2'), findsOneWidget);
expect(find.text('Workspace: /srv/research'), findsOneWidget);
expect(find.text('Timer: Every 24h · mon, wed'), findsOneWidget);
expect(find.text('Timezone: Europe/London'), findsOneWidget);
expect( expect(
find.text('Next due: 2026-10-22 09:00 (your local time)'), find.text('Every 24h · mon, wed · Pipeline 4 · v2'),
findsOneWidget, findsOneWidget,
); );
expect(find.text('Find battery chemistry sources'), findsNothing);
await tester.scrollUntilVisible( await tester.scrollUntilVisible(
find.text('Nightly report'), find.text('Nightly report'),
@@ -50,11 +49,8 @@ void main() {
), ),
); );
expect(find.text('Nightly report'), findsOneWidget); expect(find.text('Nightly report'), findsOneWidget);
expect(find.text('Pipeline 7 · v5'), findsOneWidget); expect(find.text('10:00, 18:30 · Pipeline 7 · v5'), findsOneWidget);
expect(find.text('Workspace: /srv/reports'), findsOneWidget); expect(find.text('Paused'), findsOneWidget);
expect(find.text('Timer: 10:00, 18:30'), findsOneWidget);
expect(find.text('Timezone: Server timezone'), findsOneWidget);
expect(find.text('Next due: Paused'), findsOneWidget);
if (cupertino) { if (cupertino) {
expect(find.byType(CupertinoSearchTextField), findsOneWidget); expect(find.byType(CupertinoSearchTextField), findsOneWidget);
@@ -18,6 +18,20 @@ Future<void> _tapSave(WidgetTester tester) async {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
} }
/// Edit, Pause/Enable and Delete live in the row's overflow menu.
Future<void> _openMenu(WidgetTester tester, int id) async {
await tester.ensureVisible(find.byKey(scheduleRowMenuKey(id)));
await tester.pumpAndSettle();
await tester.tap(find.byKey(scheduleRowMenuKey(id)));
await tester.pumpAndSettle();
}
Future<void> _pick(WidgetTester tester, Key item, int id) async {
await _openMenu(tester, id);
await tester.tap(find.byKey(item));
await tester.pumpAndSettle();
}
void main() { void main() {
testWidgets('lists this pipeline schedules with server values and states', ( testWidgets('lists this pipeline schedules with server values and states', (
tester, tester,
@@ -46,21 +60,24 @@ void main() {
expect(find.text('Schedules (2)'), findsOneWidget); expect(find.text('Schedules (2)'), findsOneWidget);
expect(find.text('Research batteries'), findsOneWidget); expect(find.text('Research batteries'), findsOneWidget);
// Two lines: the name with its next run, then version and timer words.
expect( expect(
find.text('Every 24h · mon, wed · Europe/London'), find.text('v2 · Every 24h · mon, wed · Europe/London'),
findsOneWidget, findsOneWidget,
); );
expect(find.text('Paused'), findsWidgets);
expect(find.text('Nightly report'), findsOneWidget); expect(find.text('Nightly report'), findsOneWidget);
expect( expect(find.text('v5 · 10:00, 18:30 · Server timezone'), findsOneWidget);
find.text('10:00, 18:30 · Server timezone'), expect(find.bySemanticsLabel(RegExp('Enabled')), findsOneWidget);
findsOneWidget, expect(find.bySemanticsLabel(RegExp('Paused')), findsOneWidget);
); expect(find.text('Paused'), findsOneWidget);
expect(find.text('Enabled'), findsOneWidget); // The prompt and the inline text buttons are gone from the row.
expect(find.text('Paused'), findsWidgets); expect(find.text('Edit'), findsNothing);
expect(find.text('Paused'), findsWidgets); expect(find.byKey(scheduleRowMenuKey(8)), findsOneWidget);
expect(find.byKey(scheduleRowEditKey(8)), findsOneWidget); await _openMenu(tester, 9);
expect(find.byKey(scheduleRowEditKey(9)), findsOneWidget);
expect(find.byKey(scheduleRowToggleKey(9)), findsOneWidget); expect(find.byKey(scheduleRowToggleKey(9)), findsOneWidget);
expect(find.text('Enable'), findsOneWidget);
expect(find.byKey(scheduleRowDeleteKey(9)), findsOneWidget);
expect(gateway.calls.map((call) => call.type), ['list_schedules']); expect(gateway.calls.map((call) => call.type), ['list_schedules']);
expect(gateway.calls.single.fields, {'pipeline_id': 4}); expect(gateway.calls.single.fields, {'pipeline_id': 4});
}); });
@@ -187,7 +204,7 @@ void main() {
}); });
await pumpScheduleSection(tester, gateway: gateway); await pumpScheduleSection(tester, gateway: gateway);
await tester.tap(find.byKey(scheduleRowEditKey(8))); await _pick(tester, scheduleRowEditKey(8), 8);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect( expect(
tester tester
@@ -238,14 +255,14 @@ void main() {
}); });
await pumpScheduleSection(tester, gateway: gateway); await pumpScheduleSection(tester, gateway: gateway);
await tester.tap(find.byKey(scheduleRowToggleKey(8))); await _pick(tester, scheduleRowToggleKey(8), 8);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
final call = gateway.callsOf('save_schedule').single; final call = gateway.callsOf('save_schedule').single;
expect(call.fields.containsKey('request_key'), isFalse); expect(call.fields.containsKey('request_key'), isFalse);
expect(call.fields['schedule'], {...original, 'enabled': false}); expect(call.fields['schedule'], {...original, 'enabled': false});
expect(find.text('Paused'), findsWidgets); expect(find.text('Paused'), findsOneWidget);
expect(find.text('Paused'), findsWidgets); await _openMenu(tester, 8);
expect(find.byKey(scheduleRowToggleKey(8)), findsOneWidget); expect(find.byKey(scheduleRowToggleKey(8)), findsOneWidget);
expect(find.text('Enable'), findsOneWidget); expect(find.text('Enable'), findsOneWidget);
expect(gateway.calls.map((call) => call.type), [ expect(gateway.calls.map((call) => call.type), [
@@ -264,11 +281,12 @@ void main() {
}); });
await pumpScheduleSection(tester, gateway: gateway); await pumpScheduleSection(tester, gateway: gateway);
await tester.tap(find.byKey(scheduleRowToggleKey(8))); await _pick(tester, scheduleRowToggleKey(8), 8);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.byKey(scheduleRowErrorKey(8)), findsOneWidget); expect(find.byKey(scheduleRowErrorKey(8)), findsOneWidget);
expect(find.text('conflict: revision 3 is stale'), findsOneWidget); expect(find.text('conflict: revision 3 is stale'), findsOneWidget);
await _openMenu(tester, 8);
expect(find.text('Pause'), findsOneWidget); expect(find.text('Pause'), findsOneWidget);
expect(gateway.callsOf('list_schedules'), hasLength(1)); expect(gateway.callsOf('list_schedules'), hasLength(1));
}); });
@@ -291,7 +309,7 @@ void main() {
}); });
await pumpScheduleSection(tester, gateway: gateway); await pumpScheduleSection(tester, gateway: gateway);
await tester.tap(find.byKey(scheduleRowDeleteKey(8))); await _pick(tester, scheduleRowDeleteKey(8), 8);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('Delete Research batteries?'), findsOneWidget); expect(find.text('Delete Research batteries?'), findsOneWidget);
expect( expect(
@@ -304,7 +322,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(gateway.callsOf('delete_schedule'), isEmpty); expect(gateway.callsOf('delete_schedule'), isEmpty);
await tester.tap(find.byKey(scheduleRowDeleteKey(8))); await _pick(tester, scheduleRowDeleteKey(8), 8);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.byKey(scheduleDeleteConfirmKey)); await tester.tap(find.byKey(scheduleDeleteConfirmKey));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
@@ -333,7 +351,7 @@ void main() {
}); });
await pumpScheduleSection(tester, gateway: gateway); await pumpScheduleSection(tester, gateway: gateway);
await tester.tap(find.byKey(scheduleRowDeleteKey(8))); await _pick(tester, scheduleRowDeleteKey(8), 8);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.tap(find.byKey(scheduleDeleteConfirmKey)); await tester.tap(find.byKey(scheduleDeleteConfirmKey));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
@@ -392,10 +410,10 @@ void main() {
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
expect(find.byKey(scheduleAddKey), findsOneWidget); expect(find.byKey(scheduleAddKey), findsOneWidget);
await tester.ensureVisible(find.byKey(scheduleRowDeleteKey(8))); await _openMenu(tester, 8);
await tester.pumpAndSettle();
expect(find.byKey(scheduleRowEditKey(8)), findsOneWidget); expect(find.byKey(scheduleRowEditKey(8)), findsOneWidget);
expect(find.byKey(scheduleRowToggleKey(8)), findsOneWidget); expect(find.byKey(scheduleRowToggleKey(8)), findsOneWidget);
expect(find.byKey(scheduleRowDeleteKey(8)), findsOneWidget);
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
} }
}); });
@@ -5,7 +5,7 @@ import 'package:pipelines_app/features/search/search_screen.dart';
import 'package:pipelines_app/features/search/ui/search_bar_controls.dart'; import 'package:pipelines_app/features/search/ui/search_bar_controls.dart';
import 'package:pipelines_app/features/search/ui/search_bounds_note.dart'; import 'package:pipelines_app/features/search/ui/search_bounds_note.dart';
import 'package:pipelines_app/features/search/ui/search_layout.dart'; import 'package:pipelines_app/features/search/ui/search_layout.dart';
import 'package:pipelines_app/features/search/ui/search_result_view.dart'; import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'; import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
import 'search_screen_test.dart' import 'search_screen_test.dart'
@@ -95,7 +95,7 @@ void main() {
expect(find.textContaining('Results truncated'), findsOneWidget); expect(find.textContaining('Results truncated'), findsOneWidget);
}); });
testWidgets('$host: rows show a bold title, a kind tag and one line', ( testWidgets('$host: rows are the shared row: title, kind-led line', (
tester, tester,
) async { ) async {
_size(tester, 390); _size(tester, 390);
@@ -110,8 +110,10 @@ void main() {
final row = find.byKey(const ValueKey('search.result.run:11:4:output')); final row = find.byKey(const ValueKey('search.result.run:11:4:output'));
expect(row, findsOneWidget); expect(row, findsOneWidget);
expect(tester.widget<AppListRow>(row).cupertino, cupertino);
// The kind leads the one muted line, before the snippet.
expect( expect(
find.descendant(of: row, matching: find.byType(SearchKindTag)), find.descendant(of: row, matching: find.textContaining('Field · ')),
findsOneWidget, findsOneWidget,
); );
expect( expect(
+281
View File
@@ -0,0 +1,281 @@
import 'dart:ui' show Tristate;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/layout/app_list_avatar.dart';
import 'package:pipelines_app/ui/layout/app_list_row.dart';
import 'package:pipelines_app/ui/layout/app_overflow_menu.dart';
const _longTitle = 'A row title long enough that it must ellipsise somewhere';
const _longLine = 'a muted line of facts that is far too long for one line';
Widget _host(bool cupertino, Widget child, {Brightness? brightness}) {
final body = ListView(children: [child]);
return cupertino
? CupertinoApp(
theme: CupertinoThemeData(brightness: brightness),
home: CupertinoPageScaffold(child: body),
)
: MaterialApp(
theme: ThemeData(brightness: brightness ?? Brightness.light),
home: Scaffold(body: body),
);
}
void _size(WidgetTester tester, double width, {double textScale = 1}) {
tester.view.physicalSize = Size(width, 800);
tester.view.devicePixelRatio = 1;
tester.platformDispatcher.textScaleFactorTestValue = textScale;
addTearDown(tester.view.reset);
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
}
AppListRow _row({
String title = 'Fixture run',
String? time = '9d ago',
bool selected = false,
bool emphasized = false,
bool divider = true,
VoidCallback? onTap,
void Function(String)? onPicked,
}) => AppListRow(
key: const Key('row'),
selected: selected,
emphasized: emphasized,
divider: divider,
onTap: onTap ?? () {},
leading: const AppListAvatar(
key: Key('avatar'),
child: Icon(Icons.play_arrow),
),
title: Text(title),
time: time,
subtitle: const Text('pipeline · 2 stages'),
compactSubtitle: const Text('Running'),
subtitleLeading: const AppListStatusDot(
key: Key('dot'),
color: Color(0xFF00AA00),
semanticLabel: 'Running',
),
menu: AppOverflowMenu<String>(
key: const Key('menu'),
sheetTitle: title,
actions: const [
AppMenuAction(key: Key('menu-rename'), value: 'rename', label: 'Rename'),
AppMenuAction(
key: Key('menu-delete'),
value: 'delete',
label: 'Delete',
destructive: true,
),
],
onSelected: (_, value) => onPicked?.call(value),
),
);
TextStyle _paint(WidgetTester tester, String text) =>
tester.renderObject<RenderParagraph>(find.textContaining(text)).text.style!;
void main() {
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host: avatar, title with time, one line, menu, divider', (
tester,
) async {
_size(tester, 560);
var taps = 0;
String? picked;
await tester.pumpWidget(
_host(
cupertino,
_row(onTap: () => taps++, onPicked: (value) => picked = value),
),
);
final avatar = tester.getRect(find.byKey(const Key('avatar')));
final title = tester.getRect(find.text('Fixture run'));
final time = tester.getRect(find.text('9d ago'));
final line = tester.getRect(find.text('pipeline · 2 stages'));
final menu = tester.getRect(find.byKey(const Key('menu')));
expect(avatar.size, const Size.square(kAppListAvatarSize));
expect(avatar.right, lessThanOrEqualTo(title.left));
expect(time.left, greaterThan(title.right - 1));
expect(time.center.dy, closeTo(title.center.dy, 3));
expect(line.top, greaterThanOrEqualTo(title.bottom - 1));
expect(menu.left, greaterThanOrEqualTo(time.right));
expect(find.byKey(const Key('dot')), findsOneWidget);
// The title is bold, the line muted and smaller.
expect(_paint(tester, 'Fixture run').fontWeight, FontWeight.w600);
expect(
_paint(tester, 'pipeline').fontSize!,
lessThan(_paint(tester, 'Fixture run').fontSize!),
);
// The inset divider starts under the text column.
final divider = tester.getRect(find.byKey(appListRowDividerKey));
expect(divider.left, closeTo(title.left, 1));
await tester.tap(find.text('Fixture run'));
await tester.pumpAndSettle();
expect(taps, 1);
// One overflow icon per host; the menu items keep their keys.
expect(
find.descendant(
of: find.byKey(const Key('menu')),
matching: find.byIcon(
cupertino ? CupertinoIcons.ellipsis : Icons.more_vert,
),
),
findsOneWidget,
);
await tester.tap(find.byKey(const Key('menu')));
await tester.pumpAndSettle();
expect(taps, 1, reason: 'the menu is its own control');
if (cupertino) {
expect(find.byType(CupertinoActionSheet), findsOneWidget);
expect(find.text('Cancel'), findsOneWidget);
} else {
expect(find.byType(PopupMenuItem<String>), findsNWidgets(2));
}
await tester.tap(find.byKey(const Key('menu-delete')));
await tester.pumpAndSettle();
expect(picked, 'delete');
});
testWidgets('$host: selected and emphasised rows', (tester) async {
_size(tester, 560);
await tester.pumpWidget(
_host(cupertino, _row(selected: true, emphasized: true)),
);
final row = find.byKey(const Key('row'));
expect(
tester.getSemantics(row).flagsCollection.isSelected,
Tristate.isTrue,
);
final surface = find.descendant(
of: row,
matching: find.byKey(appListRowSurfaceKey),
);
final context = tester.element(row);
expect(
cupertino
? tester.widget<ColoredBox>(surface).color
: tester.widget<Material>(surface).color,
AppListRow.selectedColor(context, cupertino: cupertino),
);
final accent = cupertino
? CupertinoTheme.of(context).primaryColor
: Theme.of(context).colorScheme.primary;
expect(_paint(tester, 'Fixture run').fontWeight, FontWeight.w700);
expect(_paint(tester, '9d ago').color, accent);
await tester.pumpWidget(_host(cupertino, _row()));
expect(
cupertino
? tester.widget<ColoredBox>(surface).color
: tester.widget<Material>(surface).color,
const Color(0x00000000),
);
expect(_paint(tester, '9d ago').color, isNot(accent));
});
testWidgets('$host: a narrow pane drops the avatar, time and menu', (
tester,
) async {
_size(tester, 240);
await tester.pumpWidget(_host(cupertino, _row()));
expect(find.byKey(const Key('avatar')), findsNothing);
expect(find.text('9d ago'), findsNothing);
expect(find.byKey(const Key('menu')), findsNothing);
expect(find.text('Running'), findsOneWidget);
expect(find.text('pipeline · 2 stages'), findsNothing);
expect(tester.takeException(), isNull);
});
testWidgets('$host: keepMenuWhenCompact keeps the menu', (tester) async {
_size(tester, 240);
await tester.pumpWidget(
_host(
cupertino,
AppListRow(
keepMenuWhenCompact: true,
title: const Text('Chat'),
menu: AppOverflowMenu<int>(
key: const Key('menu'),
actions: const [AppMenuAction(value: 1, label: 'Star')],
onSelected: (_, _) {},
),
),
),
);
expect(find.byKey(const Key('menu')), findsOneWidget);
});
for (final brightness in Brightness.values) {
testWidgets('$host ${brightness.name}: 320px at 2x text ellipsises '
'without overflow', (tester) async {
_size(tester, 320, textScale: 2);
await tester.pumpWidget(
_host(
cupertino,
brightness: brightness,
AppListRow(
key: const Key('row'),
onTap: () {},
leading: const AppListAvatar(
key: Key('avatar'),
child: Text('P'),
),
title: const Text(_longTitle),
time: '12 days ago',
subtitle: const Text(_longLine),
menu: AppOverflowMenu<int>(
key: const Key('menu'),
actions: const [AppMenuAction(value: 1, label: 'Star')],
onSelected: (_, _) {},
),
),
),
);
expect(tester.takeException(), isNull);
final title = tester.renderObject<RenderParagraph>(
find.text(_longTitle),
);
expect(title.maxLines, 1);
expect(title.didExceedMaxLines, isTrue);
final line = tester.renderObject<RenderParagraph>(find.text(_longLine));
expect(line.maxLines, 1);
expect(line.didExceedMaxLines, isTrue);
final row = tester.getRect(find.byKey(const Key('row')));
expect(
tester.getRect(find.text('12 days ago')).right,
lessThanOrEqualTo(row.right),
);
// The avatar keeps its size; its glyph scales down inside it.
expect(
tester.getSize(find.byKey(const Key('avatar'))),
const Size.square(kAppListAvatarSize),
);
expect(find.byKey(const Key('menu')), findsOneWidget);
});
}
}
testWidgets('the initial avatar reads the first letter, upper case', (
tester,
) async {
await tester.pumpWidget(
MaterialApp(
home: Center(
child: AppListAvatar.initial(' beta flow', color: Colors.teal),
),
),
);
expect(find.text('B'), findsOneWidget);
expect(_paint(tester, 'B').fontSize, 18);
expect(_paint(tester, 'B').fontWeight, FontWeight.w700);
});
}
+26
View File
@@ -0,0 +1,26 @@
// The normal application composition with an explicit host, for browser
// captures of the Cupertino app (the web build is Material by design, see
// `prefersCupertino`).
//
// Build and capture (from app/):
// flutter build web --target tool/app_host_probe_entry.dart \
// -o build/probe-app-host
// serve it with the runs or pipelines fixture server
// (`tool/runs_probe_server.mjs`, `tool/pipelines_wiring_probe_server.mjs`)
// and open `/runs?host=cupertino`; without `host=cupertino` it is Material.
//
// It connects only to the page's own origin, like the web app.
import 'package:flutter/widgets.dart';
import 'package:pipelines_app/application/app_url_strategy.dart';
import 'package:pipelines_app/application/pipelines_app.dart';
import 'package:pipelines_app/application/server_endpoint.dart';
void main() {
useAppUrlStrategy();
runApp(
PipelinesApp(
server: ServerEndpoint.resolve(base: Uri.base, web: true),
cupertino: Uri.base.queryParameters['host'] == 'cupertino',
),
);
}