b6aa820378
Keep the Material-only chat conversation implementation while preserving public Cupertino parameters for downstream compatibility. Narrow the matching tests to the Material path.
179 lines
5.8 KiB
Dart
179 lines
5.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import '../../../core/api_gateway.dart';
|
|
import '../domain/chat_shells.dart';
|
|
import '../domain/chat_task_metadata.dart';
|
|
import 'chat_task_metadata_view.dart';
|
|
import 'chat_task_presentation.dart';
|
|
|
|
/// One scan-friendly task card; only the explicit Details control loads output.
|
|
class ChatBackgroundTaskCard extends StatelessWidget {
|
|
const ChatBackgroundTaskCard({
|
|
super.key,
|
|
required this.shell,
|
|
required this.now,
|
|
required this.selected,
|
|
required this.onDetails,
|
|
this.detail,
|
|
});
|
|
final JsonMap shell;
|
|
final DateTime now;
|
|
final bool selected;
|
|
final VoidCallback onDetails;
|
|
final Widget? detail;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final kind = taskKindLabel(shell);
|
|
final agent = '${shell['task_type'] ?? ''}'.contains('agent');
|
|
final progress = distinctTaskProgress(shell);
|
|
final elapsed = taskElapsed(shell, now);
|
|
final accent = Theme.of(context).colorScheme.primary;
|
|
final status = DecoratedBox(
|
|
decoration: BoxDecoration(
|
|
color: Theme.of(context).colorScheme.secondaryContainer,
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Icon(Icons.play_arrow_rounded, size: 14, color: accent),
|
|
const SizedBox(width: 4),
|
|
Flexible(
|
|
child: Text(
|
|
'Running',
|
|
style: Theme.of(context).textTheme.labelMedium?.copyWith(
|
|
color: Theme.of(context).colorScheme.onSecondaryContainer,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
final details = Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Flexible(child: Text(selected ? 'Hide details' : 'Details')),
|
|
const SizedBox(width: 4),
|
|
Icon(selected ? Icons.expand_less : Icons.expand_more, size: 18),
|
|
],
|
|
);
|
|
return ChatTaskSurface(
|
|
key: ValueKey('chat-bg-task-card-${shellIdOf(shell)}'),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
CircleAvatar(
|
|
backgroundColor: Theme.of(context).colorScheme.primaryContainer,
|
|
child: Icon(
|
|
agent ? Icons.smart_toy_outlined : Icons.terminal,
|
|
color: accent,
|
|
),
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
if (kind != null)
|
|
Text(
|
|
kind,
|
|
style: TextStyle(
|
|
color: taskSecondary(context),
|
|
fontSize: 12,
|
|
),
|
|
),
|
|
Text(
|
|
taskDisplayTitle(shell),
|
|
style: taskHeading(context),
|
|
maxLines: selected ? null : 2,
|
|
overflow: selected
|
|
? TextOverflow.clip
|
|
: TextOverflow.ellipsis,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 16),
|
|
Wrap(
|
|
alignment: WrapAlignment.spaceBetween,
|
|
crossAxisAlignment: WrapCrossAlignment.center,
|
|
spacing: 16,
|
|
runSpacing: 8,
|
|
children: [
|
|
status,
|
|
if (elapsed != null)
|
|
Semantics(
|
|
label: 'Elapsed ${taskDuration(elapsed)}',
|
|
child: Text(
|
|
taskDuration(elapsed),
|
|
style: Theme.of(context).textTheme.headlineSmall,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
const SizedBox(height: 20),
|
|
ChatTaskMetadataView(shell: shell, now: now),
|
|
if (progress != null) ...[
|
|
const SizedBox(height: 16),
|
|
DecoratedBox(
|
|
decoration: BoxDecoration(
|
|
color: Theme.of(context).colorScheme.surfaceContainerLowest,
|
|
borderRadius: BorderRadius.circular(8),
|
|
),
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(12),
|
|
child: Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Icon(
|
|
Icons.notes_rounded,
|
|
size: 18,
|
|
color: taskSecondary(context),
|
|
),
|
|
const SizedBox(width: 8),
|
|
Expanded(
|
|
child: Text(
|
|
progress,
|
|
maxLines: selected ? null : 2,
|
|
overflow: selected
|
|
? TextOverflow.clip
|
|
: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
Align(
|
|
alignment: AlignmentDirectional.centerEnd,
|
|
child: Semantics(
|
|
expanded: selected,
|
|
child: TextButton(
|
|
key: ValueKey('chat-bg-task-${shellIdOf(shell)}'),
|
|
onPressed: onDetails,
|
|
child: details,
|
|
),
|
|
),
|
|
),
|
|
if (detail != null) ...[
|
|
const Divider(),
|
|
const SizedBox(height: 12),
|
|
detail!,
|
|
],
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|