import 'package:cs_resources/theme/app_colors_theme.dart';
import 'package:domain/entity/visitor_page_entity.dart';
import 'package:flutter/material.dart';
import 'package:shared/utils/util.dart';
import 'package:widgets/ext/ex_widget.dart';
import 'package:widgets/my_text_view.dart';

class VisitorItem extends StatelessWidget {
  final int index;
  final VisitorPageList item;

  const VisitorItem({
    required this.index,
    required this.item,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: const EdgeInsets.only(left: 15, right: 15, top: 5, bottom: 5),
      padding: const EdgeInsets.symmetric(vertical: 19, horizontal: 18.5),
      decoration: BoxDecoration(
        color: context.appColors.whiteBG,
        borderRadius: BorderRadius.circular(6.0), // 圆角
        boxShadow: [
          BoxShadow(
            color: context.appColors.itemBGShadow, // 阴影颜色
            offset: const Offset(0, 3), // 阴影的偏移量
            blurRadius: 8.0, // 模糊半径
            spreadRadius: 3.0, // 扩散半径
          ),
        ],
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          //姓名
          MyTextView(
            item.name ?? "",
            fontSize: 16,
            marginBottom: 5,
            textColor: context.appColors.textBlack,
            isFontMedium: true,
          ),

          //电话/身份证
          Row(
            children: [
              MyTextView(
                item.phone ?? "",
                fontSize: 14,
                textColor: context.appColors.textBlack,
                isFontRegular: true,
              ),
              const Spacer(),
              MyTextView(
                Utils.maskString(item.nric ?? ""),
                fontSize: 14,
                textColor: context.appColors.textBlack,
                isFontRegular: true,
              ),
            ],
          ),

          //车牌号/访问日期
          Row(
            children: [
              MyTextView(
                item.vehicleNumber ?? "",
                fontSize: 14,
                textColor: context.appColors.textBlack,
                isFontRegular: true,
              ),
              const Spacer(),
              MyTextView(
                item.createdAt ?? "",
                fontSize: 14,
                textColor: context.appColors.textBlack,
                isFontRegular: true,
              ),
            ],
          ).marginOnly(top: 5),

          //备注
          MyTextView(
            item.note ?? "",
            fontSize: 14,
            marginTop: 6,
            textColor: context.appColors.textDarkGray,
            isFontRegular: true,
            fontWeight: FontWeight.w500,
          ),
        ],
      ),
    );
  }
}
