import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:gap/gap.dart';
import 'package:tanami_app/core/styles/app_color.dart';
import 'package:tanami_app/core/styles/app_images.dart';
import 'package:tanami_app/shared/components/text_widget.dart';

import '../../../../../core/routes/route_name.dart';
import '../../../../../core/routes/routes.dart';

Widget academyCard(dynamic data) {
  return Padding(
    padding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 16.0),
    child: GestureDetector(
      onTap: () {
        goRouter.pushNamed(RouteName.academyDetails);
      },
      child: Container(
        height: 140.h,
        width: double.infinity,
        decoration: BoxDecoration(
          color: AppColor.plainWhite,
          borderRadius: const BorderRadius.all(Radius.circular(20.0)),
          boxShadow: [
            BoxShadow(
              color: AppColor.plainBlack.withOpacity(0.15),
              spreadRadius: 2,
              blurRadius: 10,
              offset: const Offset(0, 3), // changes position of shadow
            ),
          ],
        ),
        child: Row(
          children: [
            Container(
              height: 140.h,
              width: 164.w,
              decoration: const BoxDecoration(
                color: AppColor.academyCardBgColor,
                borderRadius: BorderRadius.all(
                  Radius.circular(20.0),
                ),
              ),
              child: Stack(
                children: [
                  ClipRRect(
                    borderRadius: const BorderRadius.only(
                      topLeft: Radius.circular(20.0),
                      bottomLeft: Radius.circular(20.0),
                    ),
                    child: Image.asset(
                      data['img_path'],
                      fit: BoxFit.cover,
                      height: double.infinity,
                      alignment: Alignment.topCenter,
                    ),
                  ),
                  Positioned(
                    bottom: 0.0,
                    child: ClipRRect(
                      borderRadius: const BorderRadius.only(
                        bottomLeft: Radius.circular(20.0),
                      ),
                      child: Image.asset(
                        AppImages.academyCardOverlay,
                      ),
                    ),
                  ),
                  Positioned(
                    bottom: 8.0, left: 12.0,
                    // alignment: Alignment.bottomLeft,
                    child: Row(
                      children: [
                        Image.asset(
                          AppImages.videoIcon,
                          height: 15.sp,
                        ),
                        Gap(
                          5.w,
                        ),
                        TextWidget().text12W700(
                          '${data['videos']} videos',
                          clr: AppColor.academyCardTextColor,
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
            Expanded(
              child: Padding(
                padding: const EdgeInsets.symmetric(
                    vertical: 20.0, horizontal: 16.0),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    TextWidget().text13W500(
                      data['date'],
                      clr: AppColor.academyCardTextColor,
                    ),
                    Gap(
                      4.h,
                    ),
                    TextWidget().text17W600(
                      data['title'],
                      clr: AppColor.plainBlack,
                    ),
                    Gap(
                      12.h,
                    ),
                    Expanded(
                      //  width: 158.w,
                      child: TextWidget().text14W400(
                        data['desc'],
                        maxLine: 2,
                        txtOverflow: TextOverflow.fade,
                        txtAlign: TextAlign.start,
                        clr: AppColor.academyCardTextColor,
                      ),
                    ),
                  ],
                ),
              ),
            )
          ],
        ),
      ),
    ),
  );
}
