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

part of '../task_timeline_card.dart';

/// Private implementation type for `_ExpandedCardContent` in this library.
/// It keeps supporting state and behavior scoped to the owning file so the public API stays focused on the scheduler concepts that callers use directly.
class _ExpandedCardContent extends StatelessWidget {
  /// Creates a `_ExpandedCardContent` 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 _ExpandedCardContent({
    required this.card,
    required this.colors,
    required this.metrics,
    required this.onStatusPressed,
  });

  /// 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 `colors` value for this object.
  /// This field is part of the explicit state that downstream scheduling, persistence, or UI code reads when composing behavior.
  final _CardColors colors;

  /// 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 `onStatusPressed` 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? onStatusPressed;

  /// 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 Row(
      children: [
        if (card.visualKind != TaskVisualKind.freeSlot) ...[
          _StatusRing(
            card: card,
            color: colors.accent,
            metrics: metrics,
            onPressed: card.canToggleCompletion ? onStatusPressed : null,
          ),
          SizedBox(width: metrics.statusGap),
        ],
        Expanded(
          child: Padding(
            padding: EdgeInsets.only(
              right: card.showPastTaskPushButton
                  ? metrics.expandedPushTrailingReserve
                  : metrics.expandedTrailingReserve,
            ),
            child: _CardText(
              card: card,
              color: colors.accent,
              metrics: metrics,
            ),
          ),
        ),
      ],
    );
  }
}
