Files
alan 04ba81e0ea Remove Cupertino chat cleanup leftovers
Keep chat and folder-picker UI on the Material path by removing obsolete Cupertino imports, icon metadata, flags, and alternate control handling while preserving existing behavior and focused test coverage.
2026-11-11 20:06:37 +00:00

125 lines
3.6 KiB
Dart

import 'package:flutter/material.dart';
import '../domain/chat_task_metadata.dart';
import '../../../ui/text/monospace.dart';
Color taskSecondary(BuildContext context) =>
Theme.of(context).colorScheme.onSurfaceVariant;
TextStyle taskHeading(BuildContext context) =>
Theme.of(context).textTheme.titleMedium ?? const TextStyle();
String taskDisplayTitle(Map<String, dynamic> shell) =>
taskText(shell, 'description') ??
taskText(shell, 'command') ??
'Background process';
String? taskKindLabel(Map<String, dynamic> shell) {
final value = taskText(shell, 'task_type');
return value == null
? null
: '${value[0].toUpperCase()}${value.substring(1).replaceAll('_', ' ')}';
}
String _comparable(String value) => value
.trim()
.toLowerCase()
.replaceFirst(RegExp(r'^(agent|shell):\s*'), '')
.replaceAll(RegExp(r'\s+'), ' ');
bool sameTaskText(String a, String b) => _comparable(a) == _comparable(b);
/// Progress is useful only when it contributes a fact beyond the title/command.
String? distinctTaskProgress(Map<String, dynamic> shell) {
final progress = taskText(shell, 'progress');
if (progress == null) return null;
return [
taskDisplayTitle(shell),
taskText(shell, 'description'),
taskText(shell, 'command'),
].whereType<String>().any((value) => sameTaskText(progress, value))
? null
: progress;
}
String formatTaskCount(int count) {
final digits = '$count';
return [
for (var end = digits.length; end > 0; end -= 3)
digits.substring((end - 3).clamp(0, digits.length), end),
].reversed.join(',');
}
String formatTaskDate(BuildContext context, DateTime time) {
final material = Localizations.of<MaterialLocalizations>(
context,
MaterialLocalizations,
);
final monthYear =
material?.formatMonthYear(time) ?? '${time.month}/${time.year}';
return '${time.day} $monthYear · ${time.hour.toString().padLeft(2, '0')}:${time.minute.toString().padLeft(2, '0')}';
}
/// A Material filled card; callers supply content that grows with text scaling.
class ChatTaskSurface extends StatelessWidget {
const ChatTaskSurface({
super.key,
required this.child,
this.padding = const EdgeInsets.all(16),
});
final Widget child;
final EdgeInsetsGeometry padding;
@override
Widget build(BuildContext context) => Card.filled(
margin: EdgeInsets.zero,
child: Padding(padding: padding, child: child),
);
}
class ChatTaskFact extends StatelessWidget {
const ChatTaskFact({
super.key,
required this.icon,
required this.label,
required this.value,
this.monospace = false,
});
final IconData icon;
final String label;
final String value;
final bool monospace;
@override
Widget build(BuildContext context) => Row(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(top: 2),
child: Icon(icon, size: 18, color: taskSecondary(context)),
),
const SizedBox(width: 8),
Flexible(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
label,
style: TextStyle(color: taskSecondary(context), fontSize: 12),
),
const SizedBox(height: 2),
Text(
value,
style: taskHeading(
context,
).copyWith(fontFamily: monospace ? appMonospaceFamily : null),
),
],
),
),
],
);
}