// SPDX-FileCopyrightText: 2026 FocusFlow contributors
// SPDX-License-Identifier: AGPL-3.0-only

part of '../task_timeline_card.dart';

/// Private implementation type for `_StatusRing` in this library.
/// It adapts timeline card sizing and labels to the shared status-circle button.
class _StatusRing extends StatelessWidget {
  /// Creates a `_StatusRing` instance with the values required by its invariants.
  /// Callers should pass already-normalized scheduler data because validation and defaulting belong at the model or service boundary, not in arbitrary UI code.
  const _StatusRing({
    required this.card,
    required this.color,
    required this.metrics,
    this.onPressed,
  });

  /// Stores the `card` value for this object.
  /// This field is part of the explicit state that downstream scheduling, persistence, or UI code reads when composing behavior.
  final TimelineCardModel card;

  /// Stores the `color` value for this object.
  /// This field is part of the explicit state that downstream scheduling, persistence, or UI code reads when composing behavior.
  final Color color;

  /// Stores the `metrics` value for this object.
  /// This field is part of the explicit state that downstream scheduling, persistence, or UI code reads when composing behavior.
  final _CardMetrics metrics;

  /// Stores the `onPressed` value for this object.
  /// This field is part of the explicit state that downstream scheduling, persistence, or UI code reads when composing behavior.
  final VoidCallback? onPressed;

  /// Builds the widget subtree for this component.
  /// The method translates the current widget configuration and state into Flutter UI without mutating scheduler domain data.
  @override
  Widget build(BuildContext context) {
    return StatusCircleButton(
      circleKey: ValueKey('${card.id}-status'),
      color: color,
      checkColor: FocusFlowTokens.appBackground,
      isCompleted: card.isCompleted,
      size: metrics.statusRingSize,
      borderWidth: metrics.statusBorderWidth,
      iconSize: metrics.statusIconSize,
      semanticLabel: card.isCompleted
          ? 'Mark ${card.title} not done'
          : 'Mark ${card.title} complete',
      onPressed: onPressed,
    );
  }
}
