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

part of '../task_selection_modal.dart';

/// Private implementation type for `_HeaderMetricIcons` in this library.
/// It keeps task effort and reward metadata near the modal close action.
class _HeaderMetricIcons extends StatelessWidget {
  /// Creates a `_HeaderMetricIcons` 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 _HeaderMetricIcons({required this.card});

  /// 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;

  /// 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 Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        _HeaderMetricIcon(
          tooltip: card.effortLabel == 'Effort not set'
              ? 'Not Set'
              : card.effortLabel,
          child: DifficultyBars(
            difficulty: card.difficultyIconToken,
            color: FocusFlowTokens.restPurple,
            size: const Size(28, 16),
          ),
        ),
        const SizedBox(height: 8),
        _HeaderMetricIcon(
          tooltip: card.rewardLabel == 'Reward not set'
              ? 'Not Set'
              : card.rewardLabel,
          child: const RewardIcon(
            color: FocusFlowTokens.accentMagenta,
            size: 18,
          ),
        ),
      ],
    );
  }
}

/// Private implementation type for `_HeaderMetricIcon` in this library.
/// It keeps metric tooltips scoped to icon-only modal affordances.
class _HeaderMetricIcon extends StatelessWidget {
  /// Creates a `_HeaderMetricIcon` 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 _HeaderMetricIcon({required this.tooltip, required this.child});

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

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

  /// 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 Tooltip(
      message: tooltip,
      child: SizedBox.square(dimension: 28, child: Center(child: child)),
    );
  }
}
