import 'package:cs_resources/constants/color_constants.dart';
import 'package:domain/entity/response/agency_table_entity.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:plugin_basic/basic_export.dart';
import 'package:widgets/ext/ex_widget.dart';
import 'package:widgets/my_button.dart';
import 'package:widgets/my_text_view.dart';

/*
 * 列表Item
 */
class AgencyItem extends StatelessWidget {
  final int index;
  final AgencyTableRows item;
  final VoidCallback? onDeleteAction;
  final VoidCallback? onDetailAction;
  final VoidCallback? onEditAction;

  AgencyItem({
    required this.index,
    required this.item,
    this.onDeleteAction,
    this.onDetailAction,
    this.onEditAction,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.symmetric(vertical: 23, horizontal: 21),
      margin: const EdgeInsets.only(left: 15, right: 15, top: 5, bottom: 5),
      decoration: BoxDecoration(
        color: const Color(0xFF4DCFF6).withOpacity(0.2), // 设置背景颜色和不透明度
        borderRadius: BorderRadius.circular(5), // 设置圆角
      ),
      child: Column(
        mainAxisSize: MainAxisSize.max,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [


          // 中介商名称
          Row(
            mainAxisSize: MainAxisSize.max,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              MyTextView(
                "${"Agency Name".tr}:",
                isFontRegular: true,
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
              ),

              //文本
              MyTextView(
                item.agencyName ?? "-",
                marginLeft: 5,
                isFontMedium: true,
                textColor: ColorConstants.textYellowFFBB1B,
                fontSize: 14,
                textDecoration: TextDecoration.underline,
                decorationColor: ColorConstants.textYellowFFBB1B,
                // 可选，设置下划线的颜色
                decorationThickness: 2.0,
                // 可选，设置下划线的粗细
                decorationStyle: TextDecorationStyle.solid, // 可选，设置下划线的样式
              ).expanded(),
            ],
          ),

          // 编码
          Row(
            mainAxisSize: MainAxisSize.max,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              MyTextView(
                "${"ACRA NO".tr}:",
                isFontRegular: true,
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
              ),

              //文本
              MyTextView(
                item.uenNo ?? "-",
                marginLeft: 5,
                isFontRegular: true,
                textColor: Colors.white,
                fontSize: 14,
              ).expanded(),
            ],
          ).marginOnly(top: 12),

          // 负责人
          Row(
            mainAxisSize: MainAxisSize.max,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              MyTextView(
                "${"Person in Charge".tr}:",
                isFontRegular: true,
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
              ),

              //文本
              MyTextView(
                item.contactPerson ?? "-",
                marginLeft: 5,
                isFontRegular: true,
                textColor: Colors.white,
                fontSize: 14,
              ).expanded(),
            ],
          ).marginOnly(top: 12),

          // 邮箱
          Row(
            mainAxisSize: MainAxisSize.max,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              MyTextView(
                "${"Contact Email".tr}:",
                isFontRegular: true,
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
              ),

              //文本
              MyTextView(
                item.contactEmail ?? "-",
                marginLeft: 5,
                isFontRegular: true,
                textColor: Colors.white,
                fontSize: 14,
              ).expanded(),
            ],
          ).marginOnly(top: 12),

          // 电话
          Row(
            mainAxisSize: MainAxisSize.max,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              MyTextView(
                "${"Contact No".tr}:",
                isFontRegular: true,
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
              ),

              //文本
              MyTextView(
                item.contactNo ?? "-",
                marginLeft: 5,
                isFontRegular: true,
                textColor: Colors.white,
                fontSize: 14,
              ).expanded(),
            ],
          ).marginOnly(top: 12),


          // 状态
          Row(
            mainAxisSize: MainAxisSize.max,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              MyTextView(
                "Status:".tr,
                isFontRegular: true,
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
              ),

              //状态
              MyTextView(
                "1" == item.status
                    ? "No Register".tr
                    : "2" == item.status
                    ? "Active".tr
                    : "3" == item.status
                    ? "Inactive".tr
                    : "-",
                marginLeft: 5,
                isFontRegular: true,
                textColor: "1" == item.status
                    ? ColorConstants.textRedFF6262
                    : "2" == item.status
                    ? ColorConstants.textBlue5CEEFF
                    : "3" == item.status
                    ? ColorConstants.textYellowFFBB1B
                    : ColorConstants.white,
                fontSize: 14,
              ).expanded(),
            ],
          ).marginOnly(top: 12),

          //按钮组
          Visibility(
            visible: true,
            child: Row(
              mainAxisSize: MainAxisSize.max,
              mainAxisAlignment: MainAxisAlignment.end,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [

                //Edit按钮
                Visibility(
                  visible: true,
                  child: MyButton(
                    onPressed: () {
                      FocusScope.of(context).unfocus();
                      onEditAction?.call();
                    },
                    text: "Edit".tr,
                    textColor: ColorConstants.white,
                    backgroundColor: ColorConstants.textGreen0AC074,
                    radius: 17.25,
                    minWidth: 60,
                    minHeight: 35,
                  ).marginOnly(left: 12),
                ),

                //Delete按钮
                Visibility(
                  visible: true,
                  child: MyButton(
                    onPressed: () {
                      FocusScope.of(context).unfocus();
                      onDeleteAction?.call();
                    },
                    text: "Delete".tr,
                    textColor: ColorConstants.white,
                    backgroundColor: ColorConstants.textRedFF6262,
                    radius: 17.25,
                    minWidth: 60,
                    minHeight: 35,
                  ).marginOnly(left: 12),
                ),

              ],
            ).marginOnly(top: 15, bottom: 2),
          ),
        ],
      ),
    );
  }
}
