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/string_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/modules/asset_inventory_module/pages/asset_inventory_page.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/modules/asset_delivery_module/pages/asset_delivery_page.dart';
import 'package:test_sa/views/widgets/item_views/info_header_widget.dart';
import 'package:test_sa/views/widgets/requests/request_status.dart';
import 'package:test_sa/views/widgets/item_views/info_text_widget.dart';

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

  const AssetDeliveryItemView({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: [
          InfoHeaderWidget(requestData?.typeTransaction ?? 'Asset Delivery'),
          InfoTextWidget(label: 'PO Internal'.addTranslation, value: requestData?.poInternal ?? '-'),
          InfoTextWidget(label: 'PO External'.addTranslation, value: requestData?.poExternal ?? '-', showArrow: true),
          // infoWidget(label: 'No of Sites'.addTranslation, value: requestData?.numberOfSites != null ? requestData?.numberOfSites.toString() : '-', context: context),
        ],
      ).toShadowContainer(context, withShadow: showShadow).onPress(() async {
        Navigator.of(context).push(MaterialPageRoute(
            builder: (_) => AssetDeliveryPage(
                  requestId: requestData!.id!,
                  poInternal: requestData?.poInternal,
                  poExternal: requestData?.poExternal,
                )));
      });
    }
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      spacing: 1,
      children: [
        InfoHeaderWidget(requestDetails?.nameOfType ?? 'Asset Delivery'),
        InfoTextWidget(label: 'PO Internal'.addTranslation, value: requestDetails?.poInternal ?? '-'),
        InfoTextWidget(label: 'PO External'.addTranslation, value: requestDetails?.poExternal ?? '-', showArrow: true),
      ],
    ).toShadowContainer(context, withShadow: showShadow).onPress(() async {
      Navigator.of(context).push(MaterialPageRoute(
          builder: (_) => AssetDeliveryPage(
                requestId: requestDetails!.id!,
                poInternal: requestDetails?.poInternal,
                poExternal: requestDetails?.poExternal,
              )));
    });
  }
}
