import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:krow/features/profile/schedule/domain/entities/day_shedule.dart';
import 'package:krow/features/profile/schedule/domain/bloc/schedule_bloc.dart';
import 'package:krow/features/profile/schedule/presentation/widgets/calendar_data_detail_setting_widget.dart';
import 'package:krow/features/profile/schedule/presentation/widgets/calendar_legend_widget.dart';

class CalendarFooterWidget extends StatelessWidget {
  const CalendarFooterWidget({
    super.key,
    required this.selectedDates,
    required this.existedSlots,
  });

  final List<DateTime> selectedDates;
  final List<DaySchedule> existedSlots;

  @override
  Widget build(BuildContext context) {
    return BlocSelector<ScheduleBloc, ScheduleState, bool>(
      selector: (state) => state.isScheduleAddMode,
      builder: (context, isInScheduleAddMode) {
        return AnimatedCrossFade(
          duration: Durations.short4,
          crossFadeState: isInScheduleAddMode
              ? CrossFadeState.showSecond
              : CrossFadeState.showFirst,
          firstChild: CalendarLegendWidget(
            selectedDates: selectedDates,
            existedSlots: existedSlots,
          ),
          secondChild: CalendarDataDetailSettingWidget(
            selectedDate: selectedDates.firstOrNull,
          ),
        );
      },
    );
  }
}
