import 'package:cs_resources/constants/color_constants.dart';
import 'package:domain/entity/response/staff_detail_s_g_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 StaffDetailSGEntity? detail;
  final void Function() onRemarkAction;

  const StaffDetailWidget({
    super.key,
    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".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(
                "${"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(
                "${"Reviews".tr}:",
                textColor: ColorConstants.textGrayAECAE5,
                fontSize: 14,
                isFontRegular: true,
              ),
              MyTextView(
                "${detail?.reviews?.avgScore.toString() ?? "-"} (${detail?.reviews?.count ?? "0"} Reviews)",
                marginLeft: 5,
                textColor: ColorConstants.textGreen0AC074,
                fontSize: 14,
                onClick: onRemarkAction,
                isFontMedium: true,
                textDecoration: TextDecoration.underline,
                decorationColor: ColorConstants.textGreen0AC074,
                decorationThickness: 2.0,
                decorationStyle: TextDecorationStyle.solid,
              ).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, bottom: 26),
        ],
      ),
    );
  }
}
