// ignore_for_file: public_member_api_docs, sort_constructors_first
import 'package:farm_tpf/utils/helpers.dart';
import 'package:flutter/material.dart';

import 'package:farm_tpf/presentation/screens/codes/models/stamp.dart';

import '../../../../custom_model/TbCropDTO.dart';
import '../../../../themes/app_colors.dart';
import '../../../../themes/styles_text.dart';
import 'package:farm_tpf/utils/formatter.dart';

class ItemPlot extends StatelessWidget {
  final TbCropDTO item;
  final Function onPressed;
  ItemPlot({
    Key? key,
    required this.item,
    required this.onPressed,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    var startDate = item.startDate?.format_DDMMYY().toString() ?? '';
    var area = item.areaM2?.formatNumtoStringDecimal().toString() ?? '';
    var backgroundColor;
    switch (item.status) {
      case "STATUS_ARE_ACTIVE":
        backgroundColor = Colors.white;
        break;
      case "STATUS_FINISHED":
        backgroundColor = AppColors.primary1;
        break;
      default:
        backgroundColor = Colors.white;
    }
    return GestureDetector(
      onTap: () {
        onPressed();
      },
      child: Container(
        padding: EdgeInsets.symmetric(vertical: 12, horizontal: 8),
        margin: EdgeInsets.symmetric(vertical: 4, horizontal: 8),
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(10),
          border: Border.all(
            color: Colors.grey.shade200,
            width: 1,
          ),
          color: backgroundColor,
        ),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              "${item.code ?? ''} - ${item.suppliesName ?? ''}",
              style: StylesText.body4,
            ),
            const SizedBox(
              height: 8,
            ),
            Text(
              '$startDate - $area m\u00B2',
              style: StylesText.body6,
            ),
          ],
        ),
      ),
    );
  }
}
