import 'package:flutter/material.dart';

class PlantRowHorizontalSpace extends StatelessWidget {
  final List<double> plantingPositions;

  const PlantRowHorizontalSpace({
    Key? key,
    required this.plantingPositions,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        _buildCross(),
        ...plantingPositions
            .map((position) => _buildPlantingPosition(position)),
      ],
    );
  }

  Widget _buildCross() {
    return Container(
      margin: const EdgeInsets.all(5),
      height: 50,
      width: 100,
      decoration: BoxDecoration(
        color: Colors.brown,
        borderRadius: BorderRadius.circular(8),
      ),
      child: const Center(),
    );
  }

  Widget _buildPlantingPosition(double position) {
    return Container(
      margin: const EdgeInsets.all(5),
      height: 50,
      width: 160,
      decoration: BoxDecoration(
        color: Colors.brown,
        borderRadius: BorderRadius.circular(8),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Image.asset(
            'lib/assets/layout/width-64.png',
            height: 32,
            width: 32,
          ),
          Text(
            '${position.toStringAsFixed(2)} m',
            style: const TextStyle(color: Colors.white),
          ),
        ],
      ),
    );
  }
}
