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

/// Renders Task Timeline Card pieces for the FocusFlow Flutter timeline.
library;

import 'dart:async';
import 'dart:math' as math;

import 'package:flutter/material.dart';
import 'package:scheduler_core/scheduler_core.dart' show logger;

import '../../models/today_screen_models.dart';
import '../../theme/focus_flow_tokens.dart';
import '../status_circle_button.dart';
import 'difficulty_bars.dart';
import 'reward_icon.dart';

part 'task_card/card_colors.dart';
part 'task_card/card_metrics.dart';
part 'task_card/card_text.dart';
part 'task_card/compact_card_text.dart';
part 'task_card/expanded_card_content.dart';
part 'task_card/no_op_icon.dart';
part 'task_card/quick_actions.dart';
part 'task_card/status_ring.dart';
part 'task_card/task_timeline_card_state.dart';
part 'task_card/trailing_controls.dart';

/// Interactive card that renders a scheduled task on the compact timeline.
class TaskTimelineCard extends StatefulWidget {
  /// Creates a task timeline card.
  const TaskTimelineCard({
    required this.card,
    required this.onTap,
    this.onStatusPressed,
    this.onPushToNext,
    this.onPushToTomorrow,
    this.onPushToBacklog,
    super.key,
  });

  /// Card model to render.
  final TimelineCardModel card;

  /// Callback invoked when the card is tapped.
  final VoidCallback onTap;

  /// Callback invoked when the left status control is clicked.
  final VoidCallback? onStatusPressed;

  /// Callback invoked when the card requests Push to next.
  final Future<void> Function(TimelineCardModel card)? onPushToNext;

  /// Callback invoked when the card requests Push to tomorrow.
  final Future<void> Function(TimelineCardModel card)? onPushToTomorrow;

  /// Callback invoked when the card requests Push to backlog.
  final Future<void> Function(TimelineCardModel card)? onPushToBacklog;

  /// Creates the mutable state object used by this stateful widget.
  /// Flutter calls this once for each mounted widget instance before lifecycle callbacks and builds begin.
  @override
  State<TaskTimelineCard> createState() => _TaskTimelineCardState();
}
