import 'package:cs_resources/constants/color_constants.dart';
import 'package:domain/entity/response/staff_detail_entity.dart';
import 'package:domain/entity/response/t_h_employee_detail_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:plugin_platform/engine/image/image_preview.dart';
import 'package:shared/utils/util.dart';
import 'package:widgets/ext/ex_widget.dart';
import 'package:widgets/my_load_image.dart';
import 'package:widgets/my_text_view.dart';

/*
 * 员工的信息
 */
class StaffDetailWidget extends StatelessWidget {
  final THEmployeeDetailEntity? detail;
  final void Function() onRemarkAction;

  StaffDetailWidget({
    required this.detail,
    required this.onRemarkAction,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.only(left: 15, right: 15, top: 5, bottom: 10),
      decoration: BoxDecoration(
        color: const Color(0xFF4DCFF6).withOpacity(0.2), // 设置背景颜色和不透明度
        borderRadius: BorderRadius.circular(5), // 设置圆角
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          //头像
          Center(
              child: Hero(
            tag: '112cc8a34e13',
            child: MyLoadImage(
              detail?.icon ?? "",
              width: 100,
              height: 100,
            ),
          )).onTap(() {
            if (Utils.isNotEmpty(detail?.icon)) {
              ImagePreviewEngine.singleImagePreview(context, detail!.icon!, heroTag: '112cc8a34e13');
            }
          }).marginOnly(top: 25, bottom: 15),

          //姓名
          Row(
            mainAxisSize: MainAxisSize.max,
            children: [
              MyTextView(
                "Name:".tr,
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
                isFontRegular: true,
              ),
              MyTextView(
                detail?.workerName ?? "-",
                marginLeft: 5,
                textColor: ColorConstants.white,
                fontSize: 14,
                isFontMedium: true,
              ).expanded(),
            ],
          ).marginOnly(left: 22, right: 22),

          //性别
          Row(
            mainAxisSize: MainAxisSize.max,
            children: [
              MyTextView(
                "${"Gender".tr}:",
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
                isFontRegular: true,
              ),
              MyTextView(
                detail?.sex ?? "-",
                marginLeft: 5,
                textColor: ColorConstants.white,
                fontSize: 14,
                isFontMedium: true,
              ).expanded(),
            ],
          ).marginOnly(left: 22, right: 22, top: 10),

          //电话
          Row(
            mainAxisSize: MainAxisSize.max,
            children: [
              MyTextView(
                "Mobile:",
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
                isFontRegular: true,
              ),
              MyTextView(
                detail?.staff?.mobile ?? "-",
                marginLeft: 5,
                textColor: ColorConstants.white,
                fontSize: 14,
                isFontMedium: true,
              ).expanded(),
            ],
          ).marginOnly(left: 22, right: 22, top: 10),

          //身份证
          Row(
            mainAxisSize: MainAxisSize.max,
            children: [
              MyTextView(
                "${"ID Card No.".tr}:",
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
                isFontRegular: true,
              ),
              MyTextView(
                detail?.staff?.nric ?? "-",
                marginLeft: 5,
                textColor: ColorConstants.white,
                fontSize: 14,
                isFontMedium: true,
              ).expanded(),
            ],
          ).marginOnly(left: 22, right: 22, top: 10),

          //评分
          Row(
            mainAxisSize: MainAxisSize.max,
            children: [
              MyTextView(
                "${"Reviews".tr}:",
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
                isFontRegular: true,
              ),
              MyTextView(
                "${detail?.reviews?.avgScore ?? "-"} (${detail?.reviews?.count ?? "0"} Reviews)",
                marginLeft: 5,
                textColor: ColorConstants.textGreen0AC074,
                fontSize: 14,
                onClick: onRemarkAction,
                isFontMedium: true,
              ).expanded(),
            ],
          ).marginOnly(left: 22, right: 22, top: 10),

          //时薪
          Row(
            mainAxisSize: MainAxisSize.max,
            children: [
              MyTextView(
                "${"Hourly Rate".tr}:",
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
                isFontRegular: true,
              ),
              MyTextView(
                detail?.hourlyRate ?? "-",
                marginLeft: 5,
                textColor: ColorConstants.white,
                fontSize: 14,
                isFontMedium: true,
              ).expanded(),
            ],
          ).marginOnly(left: 22, right: 22, top: 10),

          //Typhoid
          Row(
            mainAxisSize: MainAxisSize.max,
            children: [
              MyTextView(
                "Typhoid:",
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
                isFontRegular: true,
              ),
              MyTextView(
                detail?.staff?.typhoidDate ?? "-",
                marginLeft: 5,
                textColor: ColorConstants.white,
                fontSize: 14,
                isFontMedium: true,
              ).expanded(),
            ],
          ).marginOnly(left: 22, right: 22, top: 10),

          //Food hy
          Row(
            mainAxisSize: MainAxisSize.max,
            children: [
              MyTextView(
                "Food hy:",
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
                isFontRegular: true,
              ),
              MyTextView(
                detail?.staff?.foodHygiene ?? "-",
                marginLeft: 5,
                textColor: ColorConstants.white,
                fontSize: 14,
                isFontMedium: true,
              ).expanded(),
            ],
          ).marginOnly(left: 22, right: 22, top: 10),

          //Criminal check:
          Row(
            mainAxisSize: MainAxisSize.max,
            children: [
              MyTextView(
                "Criminal check:",
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
                isFontRegular: true,
              ),
              MyTextView(
                Utils.isNotEmpty(detail?.staff?.criminalFile) ? "criminal check file" : "",
                marginLeft: 5,
                textColor: ColorConstants.textYellowFFBB1B,
                textDecoration: TextDecoration.underline,
                decorationColor: ColorConstants.textYellowFFBB1B,
                decorationThickness: 2.0,
                decorationStyle: TextDecorationStyle.solid,
                fontSize: 14,
                onClick: () {
                  if (Utils.isNotEmpty(detail?.staff?.criminalFile)) {
                    ImagePreviewEngine.singleImagePreview(context, detail!.staff!.criminalFile!);
                  }
                },
                isFontMedium: true,
              ).expanded(),
            ],
          ).marginOnly(left: 22, right: 22, top: 10),

          //Criminal check time:
          Row(
            mainAxisSize: MainAxisSize.max,
            children: [
              MyTextView(
                "Criminal check time:",
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
                isFontRegular: true,
              ),
              MyTextView(
                detail?.staff?.criminalDate ?? "-",
                marginLeft: 5,
                textColor: ColorConstants.white,
                fontSize: 14,
                isFontMedium: true,
              ).expanded(),
            ],
          ).marginOnly(left: 22, right: 22, top: 10),

          //紧急联系人电话
          Row(
            mainAxisSize: MainAxisSize.max,
            children: [
              MyTextView(
                "Clothing Size: ",
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
                isFontRegular: true,
              ),
              MyTextView(
                detail?.clothingSize ?? "-",
                isFontMedium: true,
                textColor: ColorConstants.textYellowFFBB1B,
                fontSize: 14,
                marginLeft: 5,
                marginRight: 5,
                textDecoration: TextDecoration.underline,
                decorationColor: ColorConstants.textYellowFFBB1B,
                // 可选，设置下划线的颜色
                decorationThickness: 2.0,
                // 可选，设置下划线的粗细
                decorationStyle: TextDecorationStyle.solid,
              ).expanded(),
            ],
          ).marginOnly(left: 22, right: 22, top: 10, bottom: 26),
        ],
      ),
    );
  }
}
