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/widget_extensions.dart';
import 'package:test_sa/models/all_requests_and_count_model.dart';
import 'package:test_sa/models/new_models/dashboard_detail.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/views/widgets/item_views/info_date_widget.dart';
import 'package:test_sa/views/widgets/item_views/info_header_widget.dart';
import 'package:test_sa/views/widgets/item_views/info_text_widget.dart';
import 'package:test_sa/views/widgets/requests/request_status.dart';

import 'traf_request_detail_page.dart';

class TrafRequestItemView extends StatelessWidget {
  final Data? requestData;
  final RequestsDetails? requestDetails;
  final bool showShadow;

  const TrafRequestItemView({Key? key, this.requestData, this.requestDetails, this.showShadow = true}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    if (requestData != null) {
      return Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              // StatusLabel(
              //   label: requestData!.priorityName!,
              //   textColor: AppColor.getRequestStatusTextColorByName(context, requestData!.priorityName!),
              //   backgroundColor: AppColor.getRequestStatusColorByName(context, requestData!.priorityName!),
              // ),
              // 8.width,
              StatusLabel(
                label: requestData!.statusName!,
                textColor: AppColor.getRequestStatusTextColorByName(context, requestData!.statusName!),
                backgroundColor: AppColor.getRequestStatusColorByName(context, requestData!.statusName!),
              ),
              1.width.expanded,
              InfoDateWidget(requestData!.transactionDate ?? ""),
            ],
          ),
          InfoHeaderWidget(requestData?.typeTransaction ?? "Assessment of Need & Technology"),
          InfoTextWidget(label: context.translation.requestType, value: requestData?.requestTypeName),
          InfoTextWidget(label: "Request No", value: requestData?.requestNo, showArrow: true),
        ],
      ).toShadowContainer(context, withShadow: showShadow).onPress(() async {
        Navigator.push(context, MaterialPageRoute(builder: (context) => TrafRequestDetailPage(trafId: requestData!.id!)));
      });
    }
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      spacing: 1,
      children: [
        Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            // StatusLabel(
            //   label: requestDetails!.priority!,
            //   textColor: AppColor.getRequestStatusTextColorByName(context, requestDetails?.priority!),
            //   backgroundColor: AppColor.getRequestStatusColorByName(context, requestDetails?.priority!),
            // ),
            // 8.width,
            StatusLabel(
              label: requestDetails!.status!,
              textColor: AppColor.getRequestStatusTextColorByName(context, requestDetails?.status!),
              backgroundColor: AppColor.getRequestStatusColorByName(context, requestDetails?.status!),
            ),
            1.width.expanded,
            InfoDateWidget(requestDetails!.date ?? ""),
          ],
        ),
        InfoHeaderWidget(requestDetails?.nameOfType ?? "Assessment of Need & Technology"),
        InfoTextWidget(label: context.translation.requestType, value: requestDetails!.requestType),
        InfoTextWidget(label: "Request No", value: requestDetails!.requestNo),
        InfoTextWidget(label: context.translation.site, value: requestDetails!.site, showEmptyValue: true, showArrow: true),
      ],
    ).toShadowContainer(context, withShadow: showShadow).onPress(() async {
      Navigator.push(context, MaterialPageRoute(builder: (context) => TrafRequestDetailPage(trafId: requestDetails!.id!)));
    });
  }
}
