getTaskStatusColor function

Color getTaskStatusColor(
  1. BuildContext context,
  2. TaskStatus status, {
  3. bool isIdle = false,
  4. bool awaitingApproval = false,
  5. bool hasError = false,
  6. bool shutdownRequested = false,
})

Returns the appropriate semantic color for a task based on status and state flags.

Implementation

Color getTaskStatusColor(
  BuildContext context,
  TaskStatus status, {
  bool isIdle = false,
  bool awaitingApproval = false,
  bool hasError = false,
  bool shutdownRequested = false,
}) {
  final theme = Theme.of(context);
  if (hasError) return theme.colorScheme.error;
  if (awaitingApproval) return Colors.orange;
  if (shutdownRequested) return Colors.orange;
  if (isIdle) return theme.colorScheme.onSurface.withValues(alpha: 0.5);
  if (status == TaskStatus.completed) return Colors.green;
  if (status == TaskStatus.failed) return theme.colorScheme.error;
  if (status == TaskStatus.killed) return Colors.orange;
  return theme.colorScheme.onSurface.withValues(alpha: 0.5);
}