import 'package:flutter/material.dart';
import 'package:test_sa/extensions/context_extension.dart';
import 'package:test_sa/extensions/text_extensions.dart';
import 'package:test_sa/extensions/widget_extensions.dart';
import 'package:test_sa/modules/asset_delivery_module/models/delivery_line_model.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/views/widgets/item_views/info_text_widget.dart';

class AssetDeliveryLineCard extends StatelessWidget {
  DeliveryLineModel deliveryLineModel;
  bool isViewOnly;
  VoidCallback? editPress;
  bool isTechnical;

  AssetDeliveryLineCard({
    super.key,
    required this.isViewOnly,
    required this.deliveryLineModel,
    this.isTechnical = false,
    this.editPress,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        //need to check this @waseem.
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            InfoTextWidget(label: "Item Category", value: deliveryLineModel.itemCategory ?? '-'),
            if (!isViewOnly)
              'edit_icon'.toSvgAsset(width: 24, height: 24, color: AppColor.icon2Color(context)).onPress(() {
                if (editPress != null) {
                  editPress!();
                }
              }),
          ],
        ),
        InfoTextWidget(label: "Item No", value: deliveryLineModel.itemNumber ?? '-'),
        InfoTextWidget(label: "Item Description", value: deliveryLineModel.itemDescription ?? '-'),
        InfoTextWidget(label: "Quantity", value: deliveryLineModel.qty?.toString() ?? '-'),
        if (!isTechnical) ...[
          InfoTextWidget(label: "Remaining Quantity", value: deliveryLineModel.remainingQty?.toString() ?? '-'),
          InfoTextWidget(label: "Quantity of this Delivery", value: deliveryLineModel.usingQtyInThisDelivery?.toString() ?? '-'),
        ],
        InfoTextWidget(label: "Measure Unit", value: deliveryLineModel.unitOfMeasure?.toString() ?? '-'),
        InfoTextWidget(label: "Unit price", value: deliveryLineModel.unitPrice?.toString() ?? '-'),
        InfoTextWidget(label: "Line Type", value: deliveryLineModel.lineType?.toString() ?? '-'),
        InfoTextWidget(label: "Total", value: deliveryLineModel.total?.toString() ?? '-'),
      ],
    ).toShadowContainer(context);
  }
}
