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/text_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/new_views/app_style/app_color.dart';

import '../../../../views/pages/user/ppm/ppm_details_page.dart';
import '../../../../views/widgets/requests/request_status.dart';

class PpmItemView extends StatelessWidget {
  final RequestsDetails request;
  final bool showShadow;

  const PpmItemView(this.request, {Key key, this.showShadow = true}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            StatusLabel(
              label: request.priority,
              textColor: AppColor.getRequestStatusTextColorByName(context, request.priority),
              backgroundColor: AppColor.getRequestStatusColorByName(context, request.priority),
            ),
            8.width,
            StatusLabel(
              label: request.status,
              textColor: AppColor.getRequestStatusTextColorByName(context, request.status),
              backgroundColor: AppColor.getRequestStatusColorByName(context, request.status),
            ),
            1.width.expanded,
            Text(
              request.date?.toServiceRequestCardFormat ?? "",
              textAlign: TextAlign.end,
              style: AppTextStyles.tinyFont.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
            ),
          ],
        ),
        8.height,
        context.translation.ppmRequest.heading5(context),
        8.height,
        '${context.translation.assetNumber}:  ${request.assetNo}'.bodyText(context),
        '${context.translation.assetSN}: ${request.assetSN}'.bodyText(context),
        '${context.translation.code}: ${request.code}'.bodyText(context),
        //'${context.translation.requestNo}: ${request.requestNo}'.bodyText(context),
        16.height,
        Row(
          mainAxisSize: MainAxisSize.min,
          children: [
            Text(
              context.translation.viewDetails,
              style: AppTextStyles.bodyText.copyWith(color: AppColor.blueStatus(context)),
            ),
            4.width,
            Icon(Icons.arrow_forward, color: AppColor.blueStatus(context), size: 14)
          ],
        ),
      ],
    ).toShadowContainer(context, showShadow: showShadow).onPress(() {
      Navigator.of(context).push(MaterialPageRoute(builder: (_) => PpmDetailsPage(request: request)));
    });
  }
}
