import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:generp/screens/notifierExports.dart';
import 'package:generp/Utils/app_colors.dart';
import 'package:generp/Utils/commonWidgets.dart';
import 'package:generp/screens/CheckInScreen.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';

class AttendanceScreen extends StatefulWidget {
  const AttendanceScreen({super.key});

  @override
  State<AttendanceScreen> createState() => _AttendanceScreenState();
}

class _AttendanceScreenState extends State<AttendanceScreen> {
  var att_provider;
  var homeProvider;

  @override
  void initState() {
    super.initState();
    homeProvider = Provider.of<HomescreenNotifier>(context, listen: false);
    WidgetsBinding.instance.addPostFrameCallback((_) {
      att_provider = Provider.of<AttendanceNotifier>(context, listen: false);
      att_provider.getAttendanceList(homeProvider, context);
      att_provider.init(homeProvider, context);
    });
  }

  @override
  Widget build(BuildContext context) {
    return Consumer<AttendanceNotifier>(
      builder: (context, attendance, index) {
        final timeString =
            attendance.attendanceHistory.firstOrNull?['check_in_time']
                .toString() ??
            "";
        final match = RegExp(
          r'^(\d{1,2}:\d{2})(am|pm)$',
          caseSensitive: false,
        ).firstMatch(timeString.replaceAll(' ', '').toLowerCase());

        final timeString2 =
            attendance.attendanceHistory.firstOrNull?['check_out_time']
                .toString() ??
            "";
        final match2 = RegExp(
          r'^(\d{1,2}:\d{2})(am|pm)$',
          caseSensitive: false,
        ).firstMatch(timeString2.replaceAll(' ', '').toLowerCase());

        String formattedTime = match?.group(1) ?? "-";
        String period = match?.group(2)?.toUpperCase() ?? "";

        String formattedTime2 = match2?.group(1) ?? "-";
        String period2 = match2?.group(2)?.toUpperCase() ?? "";

        print(attendance.attendanceHistory.firstOrNull);

        final dateArrayList = attendance.dateArrayList;
        final penalityArrayList = attendance.penalityArrayList;
        var selectedIndex = attendance.selectedIndex;

        // Calculate the custom period: 26th of previous month to 25th of current month
        final startDate = DateTime(
          attendance.month.year,
          attendance.month.month - 1,
          26,
        );
        final endDate = DateTime(
          attendance.month.year,
          attendance.month.month,
          25,
        );
        final daysInPeriod = endDate.difference(startDate).inDays + 1;
        final startingIndex =
            startDate.weekday % 7; // 0 for Sunday, 1 for Monday, etc.
        final currentDate = DateTime.now();

        // Format the month label (e.g., "Mar - Apr 2025")
        final prevMonthName = DateFormat(
          'MMM',
        ).format(DateTime(attendance.month.year, attendance.month.month - 1));
        final currentMonthName = DateFormat('MMM').format(attendance.month);
        final year = DateFormat('yyyy').format(attendance.month);
        // final monthLabel =
        //     prevMonthName == currentMonthName
        //         ? '$currentMonthName $year'
        //         : '$prevMonthName - $currentMonthName $year';
        final monthLabel ='$currentMonthName $year';

        return RefreshIndicator.adaptive(
          color: AppColors.app_blue,

          onRefresh: () async {
            await Future.delayed(const Duration(milliseconds: 600));
            attendance.getAttendanceList(homeProvider, context);
            attendance.init(homeProvider, context);
            attendance.loadAttendanceDetails(homeProvider, context);
          },
          child: WillPopScope(
            onWillPop: () => onBackPressed(context),
            child: Scaffold(
              resizeToAvoidBottomInset: true,
              backgroundColor: AppColors.scaffold_bg_color,
              appBar: appbar(context, "Attendance"),
              body: SafeArea(
                child: Container(
                  child: SingleChildScrollView(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Container(
                          margin: EdgeInsets.only(top: 15, bottom: 15),
                          decoration: BoxDecoration(
                            color: Colors.white,
                            borderRadius: BorderRadius.circular(16),
                          ),
                          child: Column(
                            crossAxisAlignment: CrossAxisAlignment.start,
                            children: [
                              Container(
                                padding: EdgeInsets.only(
                                  left: 15,
                                  right: 10,
                                  top: 15,
                                ),
                                child: Row(
                                  children: [
                                    Expanded(child: Text("Check-in")),
                                    Expanded(child: Text("Check-out")),
                                  ],
                                ),
                              ),
                              SizedBox(
                                child: Row(
                                  children: [
                                    Expanded(
                                      child: Container(
                                        padding: EdgeInsets.symmetric(
                                          horizontal: 10,
                                          vertical: 15,
                                        ),
                                        margin: EdgeInsets.symmetric(
                                          horizontal: 10,
                                          vertical: 15,
                                        ),
                                        decoration: BoxDecoration(
                                          color: Color(0xFFF3EDFF),
                                          borderRadius: BorderRadius.circular(
                                            16,
                                          ),
                                        ),
                                        child: Column(
                                          crossAxisAlignment:
                                              CrossAxisAlignment.start,
                                          children: [
                                            RichText(
                                              text: TextSpan(
                                                children: [
                                                  TextSpan(
                                                    text: formattedTime,
                                                    style: TextStyle(
                                                      color:formattedTime!="-"?Color(0xFF493272): Color(0xFFED3424),
                                                      fontFamily:
                                                          "JakartaRegular",
                                                      fontSize: 30,
                                                    ),
                                                  ),
                                                  TextSpan(
                                                    text: period,
                                                    style: TextStyle(
                                                      color:period!="-"?Color(0xFF493272): Color(0xFFED3424),
                                                      fontFamily:
                                                          "JakartaRegular",
                                                    ),
                                                  ),
                                                ],
                                              ),
                                            ),
                                            Text(
                                              "${attendance.attendanceHistory.firstOrNull?['check_in_location']}",
                                              style: TextStyle(
                                                color: Color(0xFF818181),
                                              ),
                                            ),
                                          ],
                                        ),
                                      ),
                                    ),
                                    Expanded(
                                      child: Container(
                                        padding: EdgeInsets.symmetric(
                                          horizontal: 10,
                                          vertical: 15,
                                        ),
                                        margin: EdgeInsets.symmetric(
                                          horizontal: 10,
                                          vertical: 15,
                                        ),
                                        decoration: BoxDecoration(
                                          color: Color(0xFFF3EDFF),
                                          borderRadius: BorderRadius.circular(
                                            16,
                                          ),
                                        ),
                                        child: Column(
                                          crossAxisAlignment:
                                              CrossAxisAlignment.start,
                                          children: [
                                            RichText(
                                              text: TextSpan(
                                                children: [
                                                  TextSpan(
                                                    text: formattedTime2,
                                                    style: TextStyle(
                                                      color:formattedTime2!="-"?Color(0xFF493272): Color(0xFFED3424),
                                                      fontFamily:
                                                          "JakartaRegular",
                                                      fontSize: 30,
                                                    ),
                                                  ),
                                                  TextSpan(
                                                    text: period2,
                                                    style: TextStyle(
                                                      color:period2!="-"?Color(0xFF493272): Color(0xFFED3424),
                                                      fontFamily:
                                                          "JakartaRegular",
                                                    ),
                                                  ),
                                                ],
                                              ),
                                            ),
                                            Text(
                                              "${attendance.attendanceHistory.firstOrNull?['check_out_location']}",
                                              style: TextStyle(
                                                color: Color(0xFF818181),
                                              ),
                                            ),
                                          ],
                                        ),
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                            ],
                          ),
                        ),
                        Container(
                          padding: EdgeInsets.symmetric(
                            horizontal: 10,
                            vertical: 10,
                          ),
                          child: Text(
                            "Attendance Details",
                            style: TextStyle(
                              fontFamily: "JakartaSemiBold",
                              fontSize: 14,
                              color: Color(0xFF818181),
                            ),
                          ),
                        ),
                        Container(
                          padding: EdgeInsets.symmetric(
                            horizontal: 10,
                            vertical: 10,
                          ),
                          decoration: BoxDecoration(
                            color: Colors.white,
                            borderRadius: BorderRadius.circular(16),
                          ),
                          child: GridView.builder(
                            itemCount: 4,
                            shrinkWrap: true,
                            physics: NeverScrollableScrollPhysics(),
                            gridDelegate:
                                SliverGridDelegateWithFixedCrossAxisCount(
                                  crossAxisCount: 2,
                                  crossAxisSpacing: 10,
                                  mainAxisSpacing: 10,
                                  childAspectRatio: 20 / 10,
                                ),
                            itemBuilder: (context, index) {
                              final numbers = [
                                attendance.presentDays,
                                attendance.absentDays,
                                attendance.holidays,
                                attendance.latePenalties,
                              ];
                              final names = [
                                "Present Days",
                                "Absent Days",
                                "Holidays",
                                "Late Points",
                              ];
                              final colors = [
                                0xFFE7FFE5,
                                0xFFFFEFEF,
                                0xFFF3EDFF,
                                0xFFFFF6F0,
                              ];
                              final textcolors = [
                                0xFF0D9C00,
                                0xFFFF0000,
                                0xFF493272,
                                0xFF91481B,
                              ];
                              return Container(
                                padding: EdgeInsets.symmetric(horizontal: 13),
                                decoration: BoxDecoration(
                                  color: Color(colors[index]),
                                  borderRadius: BorderRadius.circular(12),
                                ),
                                child: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  mainAxisAlignment: MainAxisAlignment.center,
                                  children: [
                                    Text(
                                      numbers[index].toString(),
                                      style: TextStyle(
                                        fontSize: 30,
                                        fontFamily: "JakartaMedium",
                                        color: Color(textcolors[index]),
                                      ),
                                    ),
                                    Text(
                                      names[index],
                                      style: TextStyle(
                                        color: Color(0xFF818181),
                                      ),
                                    ),
                                  ],
                                ),
                              );
                            },
                          ),
                        ),

                        ///calendar
                        Container(
                          // padding: EdgeInsets.symmetric(horizontal: 10,vertical: 5),
                          margin: EdgeInsets.symmetric(
                            horizontal: 10,
                            vertical: 5,
                          ),
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(16),
                            color: Colors.white,
                          ),
                          child: Column(
                            children: [
                              Padding(
                                padding: const EdgeInsets.fromLTRB(
                                  30,
                                  10,
                                  30,
                                  0,
                                ),
                                child: Container(
                                  child: Row(
                                    mainAxisAlignment:
                                        MainAxisAlignment.spaceBetween,
                                    children: [
                                      SizedBox(
                                        child: Row(
                                          children: [
                                            GestureDetector(
                                              onTap: () {
                                                attendance.setPreviousMonth(
                                                  homeProvider,
                                                  context,
                                                );
                                              },
                                              child: SvgPicture.asset(
                                                "assets/svg/arrow_left.svg",
                                              ),
                                            ),
                                            Text(
                                              monthLabel,
                                              style: TextStyle(
                                                overflow: TextOverflow.ellipsis,
                                                fontFamily: "JakartaMedium",
                                                color: Color(0xFF2D2D2D),
                                              ),
                                            ),
                                            GestureDetector(
                                              onTap: () {
                                                attendance.setNextMonth(
                                                  homeProvider,
                                                  context,
                                                );
                                              },
                                              child: SvgPicture.asset(
                                                "assets/svg/arrow_right_new.svg",
                                              ),
                                            ),
                                          ],
                                        ),
                                      ),

                                      InkResponse(
                                        onTap: () {
                                          _showInfoBottomSheet(context);
                                        },
                                        child: SizedBox(
                                          width: 20,
                                          height: 20,
                                          child: SvgPicture.asset(
                                            "assets/svg/ic_info_new.svg",
                                            width: 20,
                                            height: 20,
                                          ),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                              SizedBox(height: 5),
                              Padding(
                                padding: const EdgeInsets.fromLTRB(8, 10, 8, 0),
                                child: Container(
                                  child: Row(
                                    children: [
                                      for (
                                        var i = 0;
                                        i <
                                            [
                                              'S',
                                              'M',
                                              'T',
                                              'W',
                                              'T',
                                              'F',
                                              'S',
                                            ].length;
                                        i++
                                      )
                                        Expanded(
                                          child: Text(
                                            [
                                              'S',
                                              'M',
                                              'T',
                                              'W',
                                              'T',
                                              'F',
                                              'S',
                                            ][i],
                                            textAlign: TextAlign.center,
                                            style: TextStyle(
                                              overflow: TextOverflow.ellipsis,
                                              color:
                                                  i == 0
                                                      ? Color(0xFFFF0000)
                                                      : AppColors.semi_black,
                                            ),
                                          ),
                                        ),
                                    ],
                                  ),
                                ),
                              ),

                              Padding(
                                padding: const EdgeInsets.fromLTRB(0, 0, 0, 10),
                                child: Container(
                                  child: GridView.builder(
                                    itemCount: daysInPeriod + startingIndex,
                                    gridDelegate:
                                        SliverGridDelegateWithFixedCrossAxisCount(
                                          crossAxisCount: 7,
                                          crossAxisSpacing: 2,
                                          mainAxisSpacing: 1,
                                          childAspectRatio: (255 / 245),
                                        ),
                                    padding: const EdgeInsets.fromLTRB(
                                      0,
                                      0,
                                      0,
                                      0,
                                    ),
                                    shrinkWrap: true,
                                    physics: NeverScrollableScrollPhysics(),
                                    itemBuilder: (context, index) {
                                      if (index < startingIndex) {
                                        return SizedBox.shrink();
                                      }

                                      final dayIndex = index - startingIndex;
                                      final currentDateInPeriod = startDate.add(
                                        Duration(days: dayIndex),
                                      );
                                      final currentDay =
                                          currentDateInPeriod.day;
                                      final isFutureDate = currentDateInPeriod
                                          .isAfter(currentDate);

                                      // Find matching date in dateArrayList
                                      Map<String, dynamic>? dateMap;
                                      try {
                                        dateMap = dateArrayList[dayIndex];
                                      } catch (e) {
                                        dateMap = {};
                                      }

                                      // Find matching penalty
                                      Map<String, dynamic>? penaltyMap;
                                      try {
                                        penaltyMap =
                                            penalityArrayList[dayIndex];
                                      } catch (e) {
                                        penaltyMap = {};
                                      }

                                      String? dateColor =
                                          dateMap.isNotEmpty
                                              ? dateMap.values.first
                                              : null;
                                      String? penaltyKey =
                                          penaltyMap.isNotEmpty
                                              ? penaltyMap.keys.first
                                              : null;
                                      int? datePenalty =
                                          penaltyMap.isNotEmpty
                                              ? penaltyMap.values.first
                                              : 0;

                                      // Determine if this is the current day
                                      final isCurrentDay =
                                          currentDateInPeriod.day ==
                                              currentDate.day &&
                                          currentDateInPeriod.month ==
                                              currentDate.month &&
                                          currentDateInPeriod.year ==
                                              currentDate.year;

                                      return InkWell(
                                        onTap:
                                            isFutureDate
                                                ? null
                                                : () {
                                                  selectedIndex = index;
                                                  if (penaltyKey != null) {
                                                    attendance
                                                        .dateWiseAttendance(
                                                          homeProvider,
                                                          penaltyKey,
                                                          context,
                                                        );
                                                  }
                                                  attendance.selectedDate =
                                                      currentDay.toString();
                                                  _showAttDetailsBottomSheet(
                                                    context,
                                                  );
                                                },
                                        child: Card(
                                          elevation: 0,
                                          child: Column(
                                            children: [
                                              // Row(
                                              //   mainAxisAlignment:
                                              //       MainAxisAlignment.center,
                                              //   children: [
                                              //     Text(
                                              //        "($datePenalty)",
                                              //       style: TextStyle(
                                              //         fontWeight: FontWeight.w400,
                                              //         color: Colors.black,
                                              //         fontSize: 5
                                              //       ),
                                              //     ),
                                              //   ],
                                              // ),
                                              Center(
                                                child: Container(
                                                  decoration: BoxDecoration(
                                                    shape: BoxShape.circle,
                                                    border: Border.all(
                                                      color:
                                                          (isCurrentDay ||
                                                                  (selectedIndex ==
                                                                      index))
                                                              ? Color(
                                                                0xFF1487C9,
                                                              )
                                                              : Colors
                                                                  .transparent,
                                                    ),
                                                    color:
                                                        isFutureDate
                                                            ? Colors.transparent
                                                            : (isCurrentDay ||
                                                                (selectedIndex ==
                                                                    index))
                                                            ? Color(0xFFFFFFFF)
                                                            : dateColor == 'g'
                                                            ? Color(
                                                              0xFF6B3A02,
                                                            ).withAlpha(50)
                                                            : dateColor == 'r'
                                                            ? Color(
                                                              0xFFFF0000,
                                                            ).withAlpha(50)
                                                            : dateColor == 'b'
                                                            ? Color(
                                                              0xFF493272,
                                                            ).withAlpha(50)
                                                            : dateColor == 'br'
                                                            ? Color(0xFFFFE8D0)
                                                            : dateColor == 'y'
                                                            ? Color(0xFFFFF9B2)
                                                            : Colors
                                                                .transparent,
                                                  ),
                                                  child: Center(
                                                    child: Text(
                                                      currentDay.toString(),
                                                      style: TextStyle(
                                                        fontSize: 14,
                                                        fontWeight:
                                                            FontWeight.w400,
                                                        color:
                                                            isFutureDate
                                                                ? AppColors
                                                                    .semi_black
                                                                : (isCurrentDay ||
                                                                    (selectedIndex ==
                                                                        index))
                                                                ? Color(
                                                                  0xFF2D2D2D,
                                                                )
                                                                : dateColor ==
                                                                    'g'
                                                                ? Color(
                                                                  0xFF6B3A02,
                                                                )
                                                                : dateColor ==
                                                                    'r'
                                                                ? Color(
                                                                  0xFFFF0000,
                                                                )
                                                                : dateColor ==
                                                                    'b'
                                                                ? Color(
                                                                  0xFF493272,
                                                                )
                                                                : dateColor ==
                                                                    'br'
                                                                ? Color(
                                                                  0xFF6B3A02,
                                                                )
                                                                : dateColor ==
                                                                    'y'
                                                                ? Color(
                                                                  0xFF605C00,
                                                                )
                                                                : Colors
                                                                    .transparent,
                                                      ),
                                                    ),
                                                  ),
                                                ),
                                              ),
                                            ],
                                          ),
                                        ),
                                      );
                                    },
                                  ),
                                ),
                              ),
                            ],
                          ),
                        ),
                        SizedBox(height: 70),
                      ],
                    ),
                  ),
                ),
              ),
              floatingActionButton:
                  attendance.attendanceStatus == 0 ||
                          attendance.attendanceStatus == 1
                      ? Align(
                        alignment: Alignment.bottomCenter,
                        child: InkWell(
                          onTap: () async {
                            var res = await Navigator.push(
                              context,
                              MaterialPageRoute(
                                builder:
                                    (context) => CheckInOutScreen(
                                      getAttendanceStatus:
                                          attendance.attendanceStatus,
                                    ),
                              ),

                            );
                            if (res == true) {
                              attendance.getAttendanceList(
                                homeProvider,
                                context,
                              );
                              attendance.init(homeProvider, context);
                              attendance.loadAttendanceDetails(
                                homeProvider,
                                context,
                              );
                            }

                            var f = FocusScope.of(context);
                            if (!f.hasPrimaryFocus) {
                              f.unfocus();
                            }
                          },
                          child: Container(
                            alignment: Alignment.bottomCenter,
                            height: 45,
                            margin: EdgeInsets.symmetric(horizontal: 10),
                            width: MediaQuery.of(context).size.width,
                            decoration: BoxDecoration(
                              color: AppColors.app_blue,
                              borderRadius: BorderRadius.circular(15.0),
                            ),
                            child: Center(
                              child: Text(
                                attendance.attendanceStatus == 0
                                    ? "Check In"
                                    : "Check Out",
                                textAlign: TextAlign.center,
                                style: TextStyle(
                                  fontSize: 16,
                                  color: Colors.white,
                                  fontFamily: "JakartaMedium",
                                ),
                              ),
                            ),
                          ),
                        ),
                      )
                      : SizedBox(height: 0),
              floatingActionButtonLocation:
                  FloatingActionButtonLocation.centerFloat,
            ),
          ),
        );
      },
    );
  }

  Future<void> _showInfoBottomSheet(BuildContext context) {
    return showModalBottomSheet(
      useSafeArea: true,
      isDismissible: true,
      isScrollControlled: true,
      showDragHandle: true,

      enableDrag: true,
      context: context,
      builder: (context) {
        return StatefulBuilder(
          builder: (context, setState) {
            return SafeArea(
              child: Container(
                margin: EdgeInsets.only(
                  bottom: 15,
                  left: 15,
                  right: 15,
                  top: 15,
                ),
                padding: EdgeInsets.only(
                  bottom: MediaQuery.of(context).viewInsets.bottom,
                ),

                child: SingleChildScrollView(
                  child: Column(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text(
                            "Indicators Info",
                            style: TextStyle(
                              color: AppColors.app_blue,
                              fontFamily: "JakartaSemiBold",
                              fontSize: 16,
                            ),
                          ),
                          SizedBox(height: 15),
                          GridView.builder(
                            gridDelegate:
                                SliverGridDelegateWithFixedCrossAxisCount(
                                  crossAxisCount: 3,
                                  crossAxisSpacing: 0,
                                  mainAxisExtent: 40,
                                  mainAxisSpacing: 10,
                                  childAspectRatio: 6 / 1,
                                ),
                            physics: NeverScrollableScrollPhysics(),
                            shrinkWrap: true,
                            itemCount: 5,

                            itemBuilder: (context, index) {
                              final colors = [
                                Color(0xFF493272).withAlpha(50),
                                Color(0xFF6B3A02).withAlpha(50),
                                Color(0xFFFF0000).withAlpha(50),
                                Color(0xFFFFE8D0),
                                Color(0xFFFFF9B2),
                              ];
                              final text_colors = [
                                Color(0xFF493272),
                                Color(0xFF6B3A02),
                                Color(0xFFFF0000),
                                Color(0xFF6B3A02),
                                Color(0xFF605C00),
                              ];
                              final text_subs = ["24", "7", "13", "17", "2"];
                              final text = [
                                "Holiday",
                                "Present",
                                "Absent",
                                "Half Day",
                                "Not Checked Out",
                              ];
                              return Row(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: [
                                  Expanded(
                                    flex:1,
                                    child: Container(
                                      width: 18,
                                      height: 18,
                                      decoration: BoxDecoration(
                                        shape: BoxShape.circle,
                                        color: colors[index],
                                      ),
                                      child: Center(
                                        child: Text(
                                          text_subs[index],
                                          style: TextStyle(
                                            color: text_colors[index],
                                            fontSize: 10,
                                          ),
                                        ),
                                      ),
                                    ),
                                  ),
                                  SizedBox(width: 5),
                                  Expanded(
                                    flex:4,
                                    child: Text(
                                      text[index],
                                      maxLines: 2,
                                      overflow:TextOverflow.ellipsis,
                                      style: TextStyle(
                                        fontSize: 14,
                                        color: Colors.black,
                                      ),
                                    ),
                                  ),
                                ],
                              );
                            },
                          ),
                        ],
                      ),
                    ],
                  ),
                ),
              ),
            );
          },
        );
      },
    );
  }

  Future<void> _showAttDetailsBottomSheet(BuildContext context) {
    return showModalBottomSheet(
      useSafeArea: true,
      isDismissible: true,
      isScrollControlled: true,
      showDragHandle: true,

      enableDrag: true,
      context: context,
      builder: (context) {
        return StatefulBuilder(
          builder: (context, setState) {
            return Consumer<AttendanceNotifier>(
              builder: (context, provider, child) {
                return SafeArea(
                  child: Container(
                    margin: EdgeInsets.only(
                      bottom: 15,
                      left: 15,
                      right: 15,
                      top: 15,
                    ),
                    padding: EdgeInsets.only(
                      bottom: MediaQuery.of(context).viewInsets.bottom,
                    ),

                    child: SingleChildScrollView(
                      child: Column(
                        mainAxisSize: MainAxisSize.min,
                        children: [
                          Row(
                            children: [
                              Column(
                                crossAxisAlignment: CrossAxisAlignment.start,
                                children: [
                                  Text(
                                    "Attendance Info",
                                    style: TextStyle(
                                      color: AppColors.app_blue,
                                      fontFamily: "JakartaSemiBold",
                                      fontSize: 16,
                                    ),
                                  ),
                                  Text(
                                    provider.date,
                                    style: TextStyle(
                                      color: Color(0xFF818181),
                                      fontSize: 12,
                                    ),
                                  ),
                                ],
                              ),
                              Spacer(),
                              Container(
                                padding: EdgeInsets.symmetric(
                                  horizontal: 10,
                                  vertical: 10,
                                ),
                                decoration: BoxDecoration(
                                  color: Color(0xFFFFF6F0),
                                  borderRadius: BorderRadius.circular(12),
                                ),
                                child: Row(
                                  children: [
                                    Text(
                                      "Late Points ",
                                      style: TextStyle(
                                        fontFamily: "JakartaMedium",
                                      ),
                                    ),
                                    Text(
                                      provider.penalties,
                                      style: TextStyle(
                                        color: Color(0xFF91481B),
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                            ],
                          ),
                          Padding(
                            padding: EdgeInsets.symmetric(horizontal: 5),
                            child: Divider(
                              color: Color(0xFFD7D7D7),
                              thickness: 0.5,
                            ),
                          ),
                          SizedBox(height: 15),
                          ...List.generate(4, (j) {
                            final values = [
                              "Check-in Time",
                              "Check-in Location",
                              "Check-out Time",
                              "Check-out Location",
                            ];
                            final subvalues = [
                              (provider.intime),
                              (provider.inlocation),
                              (provider.outtime),
                              (provider.outlocation),
                            ];
                            return SizedBox(
                              height: 35,
                              child: Row(
                                children: [
                                  Expanded(
                                    child: Text(
                                      values[j],
                                      style: TextStyle(
                                        fontFamily: "JakartaMedium",
                                        color: AppColors.semi_black,
                                      ),
                                    ),
                                  ),
                                  Expanded(
                                    child: Text(
                                      subvalues[j],
                                      style: TextStyle(
                                        color: Color(0xFF818181),
                                      ),
                                    ),
                                  ),
                                ],
                              ),
                            );
                          }),
                        ],
                      ),
                    ),
                  ),
                );
              },
            );
          },
        );
      },
    );
  }
}
