import 'package:absensi_sas/app/constant.dart';
import 'package:absensi_sas/model/approval_model.dart';
import 'package:absensi_sas/screen/approval/widget/approval_card_status_widget.dart';
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/material.dart';

class ApprovalCardPresensi extends StatelessWidget {
  const ApprovalCardPresensi(
      {super.key, required this.data, required this.onTap});
  final ApprovalModel data;
  final Function onTap;

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(
          bottom: Constant.getActualYPhone(context: context, y: 20)),
      child: InkWell(
        customBorder: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(16),
        ),
        splashColor: Constant.bgOrange,
        // hoverColor: Colors.red,
        overlayColor: MaterialStatePropertyAll(Constant.bgOrange),

        onTap: () {
          onTap(data.typeID);
        },
        child: Ink(
            decoration: BoxDecoration(boxShadow: [
              BoxShadow(
                color: Colors.grey.withOpacity(0.12),
                offset: Offset(0.0, 10), //(x,y)
                blurRadius: 4.0,
              ),
              BoxShadow(
                color: Colors.grey.withOpacity(0.2),
                offset: Offset(0.0, 0), //(x,y)
                blurRadius: 2.0,
              ),
            ], color: Colors.white, borderRadius: BorderRadius.circular(16)),
            child: Column(
              children: [
                Container(
                  padding: EdgeInsets.symmetric(
                      horizontal:
                          Constant.getActualXPhone(context: context, x: 20),
                      vertical:
                          Constant.getActualYPhone(context: context, y: 16)),
                  child: Column(
                    children: [
                      Row(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Text(
                            data.name ?? "",
                            style: Constant.body_16(context: context),
                          ),
                          Container(
                            decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(8),
                                color: Constant.bgBlue),
                            padding: EdgeInsets.symmetric(
                                horizontal: Constant.getActualXPhone(
                                    context: context, x: 8),
                                vertical: Constant.getActualYPhone(
                                    context: context, y: 1)),
                            child: Text(
                              data.typename ?? "",
                              style: Constant.body_12(context: context)
                                  .copyWith(color: Constant.primaryBlue),
                            ),
                          )
                        ],
                      ),
                      SizedBox(
                        height:
                            Constant.getActualYPhone(context: context, y: 8),
                      ),
                      Row(
                        children: [
                          Row(
                            children: [
                              Icon(
                                EvaIcons.calendar,
                                color: Constant.primaryOrange,
                                size: 14,
                              ),
                              SizedBox(
                                width: Constant.getActualXPhone(
                                    context: context, x: 8),
                              ),
                              Text(
                                data.date ?? "",
                                style: Constant.titleH2_400_14(context: context)
                                    .copyWith(color: Constant.textDarkGrey),
                              )
                            ],
                          ),
                          SizedBox(
                            width: Constant.getActualXPhone(
                                context: context, x: 20),
                          ),
                          Row(
                            children: [
                              Icon(
                                EvaIcons.clock,
                                color: Constant.primaryOrange,
                                size: 14,
                              ),
                              SizedBox(
                                width: Constant.getActualXPhone(
                                    context: context, x: 8),
                              ),
                              Text(
                                data.time ?? "",
                                style: Constant.titleH2_400_14(context: context)
                                    .copyWith(color: Constant.textDarkGrey),
                              )
                            ],
                          ),
                          SizedBox(
                            width: Constant.getActualXPhone(
                                context: context, x: 20),
                          ),
                          Row(
                            children: [
                              Image.asset(
                                'images/finger_tap_orange_botnav.png',
                                width: Constant.getActualXPhone(
                                    context: context, x: 14),
                              ),
                              SizedBox(
                                width: Constant.getActualXPhone(
                                    context: context, x: 8),
                              ),
                              Text(
                                data.presensiTypeName ?? "",
                                style: Constant.titleH2_400_14(context: context)
                                    .copyWith(color: Constant.textDarkGrey),
                              )
                            ],
                          ),
                        ],
                      ),
                      SizedBox(
                        height:
                            Constant.getActualYPhone(context: context, y: 8),
                      ),
                      Row(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Icon(
                            EvaIcons.pin,
                            color: Constant.primaryOrange,
                            size: 14,
                          ),
                          SizedBox(
                            width: Constant.getActualXPhone(
                                context: context, x: 8),
                          ),
                          Flexible(
                            child: Text(
                              data.address ?? "",
                              style: Constant.titleH2_400_14(context: context)
                                  .copyWith(color: Constant.textDarkGrey),
                            ),
                          )
                        ],
                      ),
                      if (data.statusID == "1" || data.statusID == "2")
                        SizedBox(
                          height:
                              Constant.getActualYPhone(context: context, y: 20),
                        ),
                      if (data.statusID == "1" || data.statusID == "2")
                        Row(
                          children: List.generate(
                              1000 ~/ 10,
                              (index) => Expanded(
                                    child: Container(
                                      color: index % 2 == 0
                                          ? Colors.transparent
                                          : Constant.textLightGrey
                                              .withOpacity(0.24),
                                      height: 1,
                                    ),
                                  )),
                        ),
                    ],
                  ),
                ),
                AprrovalCardStatusWidget(
                  statusID: data.statusID ?? "",
                  statusName: data.statusName ?? "",
                )
              ],
            )),
      ),
    );
  }
}
