import 'package:flutter/material.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/int_extensions.dart';
import 'package:test_sa/extensions/string_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';

import '../../../extensions/text_extensions.dart';
import '../../../models/new_models/gas_refill_model.dart';
import '../../../new_views/app_style/app_color.dart';
import '../requests/request_status.dart';

class GasRefillItem extends StatelessWidget {
  final int index;
  final GasRefillModel item;
  final Function(GasRefillModel) onPressed;

  const GasRefillItem({Key? key,required this.item,required this.onPressed,required this.index}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            // StatusLabel(
            //   label: item.priority,
            //   textColor: AppColor.getRequestStatusTextColorByName(context, item.priority),
            //   backgroundColor: AppColor.getRequestStatusColorByName(context, item.priority),
            // ),
            StatusLabel(
              label: item.status!.name,
              textColor: AppColor.getRequestStatusTextColor(context, item.status!.value!),
              backgroundColor: AppColor.getRequestStatusColor(context, item.status!.value!),
            ),
            1.width.expanded,
            Text(item.startDate != null ? item.startDate!.toServiceRequestCardFormat : "",
                textAlign: TextAlign.end, style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : const Color(0xFF3B3D4A))),
          ],
        ),
        8.height,
        context.translation.gasRefillRequest.heading5(context),
        '${context.translation.gasType}: ${item.gazRefillDetails![0].gasType!.name}'.bodyText(context),
        '${context.translation.site}: ${item.site!.name}'.bodyText(context),
        8.height,
        Row(
          mainAxisSize: MainAxisSize.min,
          children: [
            Text(
              context.translation.viewDetails,
              style: AppTextStyles.bodyText.copyWith(color: const Color(0xFF4A8DB7)),
            ),
            4.width,
            const Icon(
              Icons.arrow_forward,
              color: Color(0xFF4A8DB7),
              size: 14,
            )
          ],
        ).onPress(() => onPressed(item)),
        // Row(
        //   children: [
        //     Expanded(
        //       child: Column(
        //         crossAxisAlignment: CrossAxisAlignment.start,
        //         children: [
        //           Text(
        //             item.title ?? "-----",
        //             style: Theme.of(context).textTheme.titleLarge.copyWith(color: onItemColor, fontSize: 16, fontWeight: FontWeight.bold),
        //           ),
        //           Row(
        //             children: [
        //               Expanded(
        //                 child: Text(
        //                   subtitle.hospital,
        //                   style: Theme.of(context).textTheme.titleSmall.copyWith(
        //                         color: onItemColor,
        //                       ),
        //                 ),
        //               ),
        //               if (item.clientName != null)
        //                 Text(
        //                   item.clientName,
        //                   style: Theme.of(context).textTheme.titleSmall.copyWith(
        //                         color: onItemColor,
        //                       ),
        //                 ),
        //             ],
        //           ),
        //           Divider(color: onItemColor),
        //           Row(
        //             children: [
        //               Expanded(
        //                 child: Text(subtitle.status, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
        //               ),
        //               if (item.status?.id != null) StatusLabel(label: item.status.name, color: AColors.getGasStatusColor(item.status.id)),
        //             ],
        //           ),
        //           if (item?.expectedDate != null) Divider(color: onItemColor),
        //           if (item?.expectedDate != null)
        //             Row(
        //               mainAxisAlignment: MainAxisAlignment.spaceBetween,
        //               children: [
        //                 Text("Expected Date", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
        //                 Text(item.expectedDate.toIso8601String().split("T").first, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
        //               ],
        //             ),
        //           if (item?.details?.isNotEmpty ?? false) Divider(color: onItemColor),
        //           Row(
        //             mainAxisAlignment: MainAxisAlignment.spaceBetween,
        //             crossAxisAlignment: CrossAxisAlignment.start,
        //             children: [
        //               if (item?.details?.isNotEmpty ?? false) Text("Gas Type", style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor)),
        //               Column(
        //                 crossAxisAlignment: CrossAxisAlignment.end,
        //                 children: item.details
        //                     .map(
        //                       (gas) => gas?.type?.name?.isNotEmpty ?? false
        //                           ? Text(gas?.type?.name, style: Theme.of(context).textTheme.titleSmall.copyWith(color: onItemColor))
        //                           : const SizedBox.shrink(),
        //                     )
        //                     .toList(),
        //               )
        //             ],
        //           ),
        //         ],
        //       ),
        //     ),
        //   ],
        // ),
      ],
    ).toShadowContainer(context).paddingOnly(bottom: 8);
  }
}
