You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.0KB

  1. // ignore_for_file: public_member_api_docs, sort_constructors_first
  2. import 'package:farm_tpf/utils/helpers.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:farm_tpf/presentation/screens/codes/models/stamp.dart';
  5. import '../../../../custom_model/TbCropDTO.dart';
  6. import '../../../../themes/app_colors.dart';
  7. import '../../../../themes/styles_text.dart';
  8. import 'package:farm_tpf/utils/formatter.dart';
  9. class ItemPlot extends StatelessWidget {
  10. final TbCropDTO item;
  11. final Function onPressed;
  12. ItemPlot({
  13. Key? key,
  14. required this.item,
  15. required this.onPressed,
  16. }) : super(key: key);
  17. @override
  18. Widget build(BuildContext context) {
  19. var startDate = item.startDate?.format_DDMMYY().toString() ?? '';
  20. var area = item.areaM2?.formatNumtoStringDecimal().toString() ?? '';
  21. var backgroundColor;
  22. switch (item.status) {
  23. case "STATUS_ARE_ACTIVE":
  24. backgroundColor = Colors.white;
  25. break;
  26. case "STATUS_FINISHED":
  27. backgroundColor = AppColors.primary1;
  28. break;
  29. default:
  30. backgroundColor = Colors.white;
  31. }
  32. return GestureDetector(
  33. onTap: () {
  34. onPressed();
  35. },
  36. child: Container(
  37. padding: EdgeInsets.symmetric(vertical: 12, horizontal: 8),
  38. margin: EdgeInsets.symmetric(vertical: 4, horizontal: 8),
  39. decoration: BoxDecoration(
  40. borderRadius: BorderRadius.circular(10),
  41. border: Border.all(
  42. color: Colors.grey.shade200,
  43. width: 1,
  44. ),
  45. color: backgroundColor,
  46. ),
  47. child: Column(
  48. crossAxisAlignment: CrossAxisAlignment.start,
  49. children: [
  50. Text(
  51. "${item.code ?? ''} - ${item.suppliesName ?? ''}",
  52. style: StylesText.body4,
  53. ),
  54. const SizedBox(
  55. height: 8,
  56. ),
  57. Text(
  58. '$startDate - $area m\u00B2',
  59. style: StylesText.body6,
  60. ),
  61. ],
  62. ),
  63. ),
  64. );
  65. }
  66. }