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:absensi_sas/screen/approval/widget/approval_dialog_confirmation.dart';
import 'package:absensi_sas/widget/custom_button_approval.dart';
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/material.dart';
import 'package:iconify_flutter/iconify_flutter.dart';
import 'package:iconify_flutter/icons/heroicons.dart';

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

  @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,
        overlayColor: MaterialStatePropertyAll(Constant.bgOrange),
        onTap: () {
          print("tapped");
        },
        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.bgSecondaryBlue),
                            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.secondaryBlue),
                            ),
                          )
                        ],
                      ),
                      SizedBox(
                        height:
                            Constant.getActualYPhone(context: context, y: 8),
                      ),
                      Row(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Icon(
                            EvaIcons.calendar,
                            color: Constant.textOrange,
                            size: 14,
                          ),
                          SizedBox(
                            width: Constant.getActualXPhone(
                                context: context, x: 8),
                          ),
                          Flexible(
                            child: Text(
                              data.date ?? "",
                              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(
                          // ,
                          //   color: Constant.textOrange,
                          //   size: 14,
                          // ),
                          Iconify(
                            Heroicons.chat_bubble_bottom_center_text_solid,
                            color: Constant.textOrange,
                            size: 14,
                          ),
                          SizedBox(
                            width: Constant.getActualXPhone(
                                context: context, x: 8),
                          ),

                          Flexible(
                            child: Text(
                              data.reasonDescription ?? '',
                              style: Constant.titleH2_400_14(context: context)
                                  .copyWith(color: Constant.textDarkGrey),
                            ),
                          ),
                        ],
                      ),
                      SizedBox(
                        height:
                            Constant.getActualYPhone(context: context, y: 20),
                      ),
                      Row(
                        children: List.generate(
                            1000 ~/ 10,
                            (index) => Expanded(
                                  child: Container(
                                    color: index % 2 == 0
                                        ? Colors.transparent
                                        : Constant.textLightGrey
                                            .withOpacity(0.24),
                                    height: 1,
                                  ),
                                )),
                      ),
                      if (data.statusID != "1" && data.statusID != "2")
                        SizedBox(
                          height:
                              Constant.getActualYPhone(context: context, y: 20),
                        ),
                      if (data.statusID != "1" && data.statusID != "2")
                        Row(
                          children: [
                            Expanded(
                              child: CustomButtonWhite(
                                  btnText: "Reject",
                                  onPressed: () {
                                    ApprovalDialogConfirmation(
                                        context: context,
                                        confirmFunc: () {},
                                        textInformation: "Menolak ",
                                        staffName: data.name ?? "",
                                        typename: data.typename ?? "");
                                  }),
                            ),
                            SizedBox(
                              width: Constant.getActualXPhone(
                                  context: context, x: 24),
                            ),
                            Expanded(
                              child: CustomButtonOrange(
                                  btnText: "Approve",
                                  onPressed: () {
                                    ApprovalDialogConfirmation(
                                        context: context,
                                        confirmFunc: () {},
                                        textInformation: "Menyetujui ",
                                        staffName: data.name ?? "",
                                        typename: data.typename ?? "");
                                  }),
                            ),
                          ],
                        ),
                    ],
                  ),
                ),
                AprrovalCardStatusWidget(
                  statusID: data.statusID ?? "",
                  statusName: data.statusName ?? '',
                )
              ],
            )),
      ),
    );
  }
}
