import 'package:cs_resources/constants/color_constants.dart';
import 'package:domain/entity/response/staff_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 StaffDetailEntity? 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?.avatar,
              width: 100,
              height: 100,
            ),
          )).onTap(() {
            if (Utils.isNotEmpty(detail?.avatar)) {
              ImagePreviewEngine.singleImagePreview(context, detail!.avatar!, heroTag: '112cc8a34e13');
            }
          }).marginOnly(top: 25, bottom: 15),

          //姓名
          Row(
            mainAxisSize: MainAxisSize.max,
            children: [
              MyTextView(
                "Name:".tr,
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
                isFontRegular: true,
              ),
              MyTextView(
                detail?.name ?? "-",
                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(
                "DOB:",
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
                isFontRegular: true,
              ),
              MyTextView(
                detail?.dob ?? "-",
                marginLeft: 5,
                textColor: ColorConstants.white,
                fontSize: 14,
                isFontMedium: true,
              ).expanded(),
            ],
          ).marginOnly(left: 22, right: 22, top: 10),

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

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

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

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

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

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

          //紧急联系人
          Row(
            mainAxisSize: MainAxisSize.max,
            children: [
              MyTextView(
                "Emergency Name:",
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
                isFontRegular: true,
              ),
              MyTextView(
                detail?.emerName ?? "-",
                marginLeft: 5,
                textColor: ColorConstants.white,
                fontSize: 14,
                isFontMedium: true,
              ).expanded(),
            ],
          ).marginOnly(left: 22, right: 22, top: 10),

          //紧急联系人电话
          Row(
            mainAxisSize: MainAxisSize.max,
            children: [
              MyTextView(
                "Emergency Phone:",
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
                isFontRegular: true,
              ),
              MyTextView(
                detail?.emerPhone ?? "-",
                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?.remRate.toString() ?? "-"} (${detail?.remNum.toString() ?? "0"} Reviews)",
                marginLeft: 5,
                textColor: ColorConstants.textGreen0AC074,
                fontSize: 14,
                onClick: onRemarkAction,
                isFontMedium: true,
              ).expanded(),
            ],
          ).marginOnly(left: 22, right: 22, top: 10, bottom: 26),

        ],
      ),
    );
  }
}
