import 'package:flutter/material.dart';
import 'package:habo/model/habit_data.dart';
import 'package:habo/model/category.dart';

/// Habit is a StatefulWidget wrapper around HabitData.
/// It manages the UI state for a single habit card.
class Habit extends StatefulWidget {
  final HabitData habitData;

  Habit({
    super.key,
    required this.habitData,
  });

  set setId(int id) {
    habitData.id = id;
  }

  factory Habit.fromJson(Map<String, dynamic> json) {
    return Habit(
      habitData: HabitData.fromJson(json),
    );
  }

  Map<String, dynamic> toJson() {
    final data = habitData.toJson();
    data['categories'] = habitData.categories.map((c) => c.toJson()).toList();
    return data;
  }

  @override
  State<Habit> createState() => _HabitState();
}

class _HabitState extends State<Habit> {
  DateTime? _selectedDate;
  bool _isExpanded = false;

  DateTime get selectedDate => _selectedDate ?? DateTime.now();
  set selectedDate(DateTime date) {
    _selectedDate = date;
  }

  bool get isExpanded => _isExpanded;
  set isExpanded(bool value) {
    _isExpanded = value;
  }

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}
