import 'package:flutter/material.dart';

import '../../../../entities/beet_row.dart';
import '../../../../entities/plant.dart';
import '../../../../entities/plant_in_row.dart';
import '../../../../repositories/beet.repositories.dart';
import 'plant_drop.dart';
import 'plant_element.dart';
import 'space/plant_row_space.dart';

class PlantRow extends StatelessWidget {
  final Function(Plant) onPlantDropped;
  final Function(PlantInRow) onPlantRemove;
  final bool showSpaceRequirement;
  final double verticalSpace;
  final BeetRow row;
  final bool showImages;
  final BeetRepository beetRepository;
  final DateTime date;

  const PlantRow(
      {Key? key,
      required this.row,
      required this.verticalSpace,
      required this.onPlantDropped,
      required this.showSpaceRequirement,
      required this.beetRepository,
      required this.onPlantRemove,
      required this.showImages,
      required this.date})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Row(children: [
      if (showSpaceRequirement && row.plants.isNotEmpty)
        PlantRowSpace(verticalSpace: verticalSpace),
      for (PlantInRow plant in row.plants)
        PlantElement(
            showImages: showImages,
            onRemovePlant: onPlantRemove,
            plant: plant,
            beetRepository: beetRepository,
            date: date),
      PlantDrop(
          showSpaceRequirement: showSpaceRequirement,
          onPlantDropped: onPlantDropped)
    ]);
  }
}
