ui: one row height and one trailing line in the sidebar, and a dsh-Go activity cap
- The project header is a ListTile now, like a session row: both are 72 high (title + subtitle). A Material 3 list tile ends at 24, so the band's 8px inset gets 16 more, putting the project + and the session ⋮ on one line (a widget test asserts both the heights and the x centres). - The running status is a full-width stadium like dsh-Go's activity strip: title and current-step summary on the left, a tabular m:ss clock on the right, translucent surface, 36 minimum height. The spinner inside is gone; the cap's top edge is where the future input-box pet will perch. - 0.3.20 (320).
This commit is contained in:
1 parent
6ced914757
commit
73af9d851b
6 files changed
+200
-132
No files matched your search
@@ -1380,57 +1380,72 @@ class _ChatScreenState extends State<ChatScreen> {
|
||||
if (start <= 0) return '';
|
||||
final secs =
|
||||
((DateTime.now().millisecondsSinceEpoch - start) / 1000).round();
|
||||
if (secs <= 0) return '';
|
||||
if (secs < 60) return '$secs 秒';
|
||||
if (secs <= 0) return '0:00';
|
||||
return '${secs ~/ 60}:${(secs % 60).toString().padLeft(2, '0')}';
|
||||
}
|
||||
|
||||
/// dsh-Go's activity strip: the current step and its clock, above the input.
|
||||
/// dsh-Go's activity cap: a stadium above the input with the current step
|
||||
/// on the left and its clock on the right. Its top edge is where the
|
||||
/// input-box pet will later perch.
|
||||
Widget _activityStrip() {
|
||||
final theme = Theme.of(context);
|
||||
final scheme = theme.colorScheme;
|
||||
final act = _activity();
|
||||
final elapsed = _elapsedSince(_runningStart());
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(14, 2, 14, 2),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 13,
|
||||
height: 13,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 1.7,
|
||||
color: scheme.primary,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text.rich(
|
||||
TextSpan(children: [
|
||||
TextSpan(
|
||||
text: act.title,
|
||||
style: TextStyle(
|
||||
fontSize: 12.5,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: scheme.onSurface,
|
||||
// The same 8px side margin as the composer, so the two capsules agree.
|
||||
padding: const EdgeInsets.fromLTRB(8, 4, 8, 4),
|
||||
child: Container(
|
||||
constraints: const BoxConstraints(minHeight: 36),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 6),
|
||||
decoration: ShapeDecoration(
|
||||
color: scheme.surfaceContainerHighest.withValues(alpha: 0.7),
|
||||
shape: const StadiumBorder(),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
act.title,
|
||||
style: theme.textTheme.labelMedium?.copyWith(
|
||||
fontSize: 13,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: scheme.onSurface,
|
||||
),
|
||||
),
|
||||
if (act.detail.isNotEmpty) ...[
|
||||
const SizedBox(width: 6),
|
||||
Flexible(
|
||||
child: Text(
|
||||
act.detail,
|
||||
maxLines: 1,
|
||||
softWrap: false,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
fontSize: 12,
|
||||
color: scheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
if (elapsed.isNotEmpty) ...[
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
elapsed,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: theme.hintColor,
|
||||
fontFeatures: const [FontFeature.tabularFigures()],
|
||||
),
|
||||
if (act.detail.isNotEmpty)
|
||||
TextSpan(
|
||||
text: ' · ${act.detail}',
|
||||
style: TextStyle(fontSize: 12, color: theme.hintColor),
|
||||
),
|
||||
if (elapsed.isNotEmpty)
|
||||
TextSpan(
|
||||
text: ' · $elapsed',
|
||||
style: TextStyle(fontSize: 12, color: theme.hintColor),
|
||||
),
|
||||
]),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -298,16 +298,58 @@ class _SessionListPaneState extends State<SessionListPane> {
|
||||
Widget _groupHeader(_SessionGroup group, {required bool collapsed}) {
|
||||
final theme = Theme.of(context);
|
||||
final scheme = theme.colorScheme;
|
||||
final radius = BorderRadius.circular(10);
|
||||
// A tinted band, at least a session row's height: a project reads as a
|
||||
// section, not as another row.
|
||||
// A ListTile with a title and a subtitle has the session rows' height and
|
||||
// trailing slot; only the tinted band and the folder mark it as a project.
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(8, 10, 8, 2),
|
||||
padding: const EdgeInsets.fromLTRB(8, 8, 8, 2),
|
||||
child: Material(
|
||||
color: scheme.surfaceContainerHighest.withValues(alpha: 0.5),
|
||||
borderRadius: radius,
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: InkWell(
|
||||
child: ListTile(
|
||||
// The band already insets by 8. A Material 3 list tile ends at 24
|
||||
// (start 16), so 16 here makes the + line up with the session
|
||||
// rows' ⋮.
|
||||
contentPadding: const EdgeInsets.only(left: 8, right: 16),
|
||||
leading: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(collapsed ? Icons.chevron_right : Icons.expand_more,
|
||||
size: 18, color: scheme.onSurfaceVariant),
|
||||
const SizedBox(width: 2),
|
||||
Icon(Icons.folder_outlined, size: 16, color: scheme.primary),
|
||||
],
|
||||
),
|
||||
title: Text(
|
||||
group.label.isEmpty ? '未命名项目' : group.label,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: scheme.onSurface,
|
||||
),
|
||||
),
|
||||
subtitle: group.path.isEmpty
|
||||
? null
|
||||
: Text(
|
||||
group.path,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 11.5, color: theme.hintColor),
|
||||
),
|
||||
// A fixed 48 slot, like the session rows' menu: both keys then sit
|
||||
// on the same vertical line.
|
||||
trailing: SizedBox(
|
||||
width: 48,
|
||||
height: 48,
|
||||
child: IconButton(
|
||||
icon: const Icon(Icons.add, size: 20),
|
||||
padding: EdgeInsets.zero,
|
||||
tooltip: '在此项目新会话',
|
||||
onPressed: () => _newSession(directory: group.path),
|
||||
),
|
||||
),
|
||||
onTap: () => setState(() {
|
||||
if (collapsed) {
|
||||
_collapsed.remove(group.key);
|
||||
@@ -315,56 +357,6 @@ class _SessionListPaneState extends State<SessionListPane> {
|
||||
_collapsed.add(group.key);
|
||||
}
|
||||
}),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(minHeight: 56),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(10, 10, 4, 10),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(collapsed ? Icons.chevron_right : Icons.expand_more,
|
||||
size: 18, color: scheme.onSurfaceVariant),
|
||||
const SizedBox(width: 6),
|
||||
Icon(Icons.folder_outlined,
|
||||
size: 16, color: scheme.primary),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
group.label.isEmpty ? '未命名项目' : group.label,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 13.5,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: scheme.onSurface),
|
||||
),
|
||||
if (group.path.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 2),
|
||||
child: Text(
|
||||
group.path,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
fontSize: 11, color: theme.hintColor),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.add, size: 18),
|
||||
tooltip: '在此项目新会话',
|
||||
visualDensity: VisualDensity.compact,
|
||||
onPressed: () => _newSession(directory: group.path),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -565,42 +557,47 @@ class _SessionListPaneState extends State<SessionListPane> {
|
||||
}
|
||||
|
||||
Widget _menu(Session session, {required bool archived}) {
|
||||
return PopupMenuButton<String>(
|
||||
icon: const Icon(Icons.more_vert, size: 18),
|
||||
onSelected: (value) {
|
||||
switch (value) {
|
||||
case 'rename':
|
||||
_rename(session);
|
||||
break;
|
||||
case 'pin':
|
||||
_app.togglePin(session);
|
||||
break;
|
||||
case 'archive':
|
||||
_archive(session, archived);
|
||||
break;
|
||||
case 'delete':
|
||||
_confirmDelete(session);
|
||||
break;
|
||||
case 'copy':
|
||||
Clipboard.setData(ClipboardData(text: session.id));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('已复制会话 ID')));
|
||||
break;
|
||||
}
|
||||
},
|
||||
itemBuilder: (_) => [
|
||||
if (!archived) ...[
|
||||
const PopupMenuItem(value: 'rename', child: Text('重命名')),
|
||||
// The same 48 slot as the project header's +, so the keys line up.
|
||||
return SizedBox(
|
||||
width: 48,
|
||||
height: 48,
|
||||
child: PopupMenuButton<String>(
|
||||
icon: const Icon(Icons.more_vert, size: 18),
|
||||
onSelected: (value) {
|
||||
switch (value) {
|
||||
case 'rename':
|
||||
_rename(session);
|
||||
break;
|
||||
case 'pin':
|
||||
_app.togglePin(session);
|
||||
break;
|
||||
case 'archive':
|
||||
_archive(session, archived);
|
||||
break;
|
||||
case 'delete':
|
||||
_confirmDelete(session);
|
||||
break;
|
||||
case 'copy':
|
||||
Clipboard.setData(ClipboardData(text: session.id));
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('已复制会话 ID')));
|
||||
break;
|
||||
}
|
||||
},
|
||||
itemBuilder: (_) => [
|
||||
if (!archived) ...[
|
||||
const PopupMenuItem(value: 'rename', child: Text('重命名')),
|
||||
PopupMenuItem(
|
||||
value: 'pin',
|
||||
child: Text(session.isPinned ? '取消置顶' : '置顶')),
|
||||
],
|
||||
PopupMenuItem(
|
||||
value: 'pin',
|
||||
child: Text(session.isPinned ? '取消置顶' : '置顶')),
|
||||
value: 'archive',
|
||||
child: Text(archived ? '取消归档' : '归档')),
|
||||
const PopupMenuItem(value: 'delete', child: Text('删除')),
|
||||
const PopupMenuItem(value: 'copy', child: Text('复制会话 ID')),
|
||||
],
|
||||
PopupMenuItem(
|
||||
value: 'archive',
|
||||
child: Text(archived ? '取消归档' : '归档')),
|
||||
const PopupMenuItem(value: 'delete', child: Text('删除')),
|
||||
const PopupMenuItem(value: 'copy', child: Text('复制会话 ID')),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user