import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:test_sa/controllers/api_routes/urls.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/modules/asset_inventory_module/models/asset_inventory_model.dart';
import 'package:test_sa/new_views/app_style/app_color.dart';
import 'package:test_sa/views/widgets/loaders/image_loader.dart';

class AssetDetailCardView extends StatelessWidget {
  AssetInventoryModel assetInventoryModel;
  VoidCallback onDeletePress;
  bool canDelete;

  AssetDetailCardView({
    super.key,
    required this.assetInventoryModel,
    required this.onDeletePress,
    this.canDelete = false,
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Row(
          children: [
            Text(
              context.translation.assetInformation,
              style: AppTextStyles.heading4.copyWith(color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
            ).expanded,
            if (canDelete)
              'delete_icon'.toSvgAsset().onPress(() {
                onDeletePress();
              }),
          ],
        ),
        8.height,
        Text(
          'Inventory Date: ${assetInventoryModel.transactionDate?.toServiceRequestDetailsFormat ?? '-'}',
          style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
        ),
        Text(
          '${context.translation.assetNumber}: ${assetInventoryModel.assetNumber ?? '-'}',
          style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
        ),
        Text(
          '${context.translation.assetName}: ${assetInventoryModel.assetName ?? '-'}',
          style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
        ),
        Text(
          '${context.translation.serialNo}: ${assetInventoryModel.serialNo ?? '-'}',
          style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
        ),
        Text(
          '${context.translation.manufacture}: ${assetInventoryModel.manufacturer ?? ''}',
          style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
        ),
        Text(
          '${context.translation.model}: ${assetInventoryModel.model ?? ''}',
          style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
        ),
        Text(
          '${context.translation.site}: ${assetInventoryModel.siteName ?? ''}',
          style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
        ),
        Text(
          '${context.translation.building}: ${assetInventoryModel.buildingName ?? ''}',
          style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
        ),
        Text(
          '${context.translation.floor}: ${assetInventoryModel.floorName ?? ''}',
          style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
        ),
        Text(
          '${context.translation.department}: ${assetInventoryModel.departmentName ?? ''}',
          style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
        ),
        Text(
          '${context.translation.supplier}: ${assetInventoryModel.supplierName ?? ''}',
          style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
        ),
        Text(
          '${'Classifications'.addTranslation}: ${assetInventoryModel.status ?? ''}',
          style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
        ),
        Text(
          '${'Remarks'.addTranslation}: ${assetInventoryModel.remarks ?? ''}',
          style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral120),
        ),
      ],
    ).toShadowContainer(context, borderRadius: 20, padding: 12);
  }
}
//TODO old code.
// Container(
//   decoration: BoxDecoration(color: AppColor.neutral100, borderRadius: BorderRadius.circular(15)),
//   height: 115.toScreenHeight,
//   width: 115.toScreenWidth,
//   margin: const EdgeInsets.only(top: 8),
//   child: assetInventoryModel.photo != null && assetInventoryModel.photo!.isNotEmpty
//       ? ClipRRect(
//           borderRadius: BorderRadius.circular(8),
//           child: ImageLoader(
//             url: URLs.getFileUrl(assetInventoryModel.photo),
//             boxFit: BoxFit.cover,
//             height: 48,
//             width: 48,
//           ))
//       : 'image_placeholder'.toSvgAsset().center,
// )
