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/utils/date_time_formatter/date_time_formatter.dart';
import 'package:tanami_app/features/MainScreens/Invest/domain/model/available_io_model.dart';

import '../../../../../core/styles/app_images.dart';
import '../../../../../core/styles/app_text.dart';
import '../../../../../core/utils/language/localizations_delegate.dart';
import '../../../../../shared/components/text_widget.dart';

class InvestDetailsSection extends StatelessWidget {
  final Rows availableIOModel;
  const InvestDetailsSection({super.key, required this.availableIOModel});

  @override
  Widget build(BuildContext context) {
    var localizations = AppLocalizations.of(context);
    return Column(
      children: [
        Container(
          color: AppColor.plainWhite,
          child: Padding(
            padding: const EdgeInsets.only(
              left: 20.0,
              right: 20,
              top: 10,
              bottom: 20,
            ),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    TextWidget().text17W700(
                      availableIOModel.investmentNameEnglish!,
                      clr: AppColor.plainBlack,
                    ),
                    Container(
                      height: 28,
                      padding: const EdgeInsets.symmetric(
                          horizontal: 12, vertical: 6),
                      decoration: ShapeDecoration(
                        color: const Color(0xFFE4F5E9),
                        shape: RoundedRectangleBorder(
                            borderRadius: BorderRadius.circular(4)),
                      ),
                      child: Center(
                          child: TextWidget().text11W700(
                        availableIOModel.investmentType!.investmentTypeName!,
                        clr: AppColor.selectedItemColor,
                      )),
                    )
                  ],
                ),
                Gap(10.h),
                Container(
                  padding: const EdgeInsets.symmetric(
                      horizontal: 12.0, vertical: 5.0),
                  decoration: BoxDecoration(
                    color: Colors.white,
                    border: Border.all(color: const Color(0xFFE4F5E9)),
                    borderRadius: BorderRadius.circular(14.0),
                  ),
                  child: Row(
                    mainAxisSize: MainAxisSize.min,
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: [
                      Image.asset(
                        AppImages.portfolioClock,
                        height: 20.h,
                      ),
                      Gap(
                        5.w,
                      ),
                      TextWidget().text12W700(
                        "${localizations.translate(AppText.closingDateText)}: ",
                        clr: AppColor.plainBlack,
                      ),
                      TextWidget().text12W500(
                        DateTimeFormatter()
                            .formatDate(availableIOModel.closingDate!),
                        clr: AppColor.plainBlack,
                      ),
                    ],
                  ),
                ),
                Gap(
                  10.h,
                ),
                TextWidget().text22W900("USD ${availableIOModel.goalAmount!}",
                    clr: AppColor.investTextColor),
                const Gap(8.0),
                LinearProgressIndicator(
                  value: (double.parse(availableIOModel.amountInvested!) /
                      double.parse(availableIOModel.goalAmount!)),
                  borderRadius: BorderRadius.circular(2),
                  minHeight: 8.0,
                  backgroundColor: AppColor.txtBorderColor,
                  valueColor: const AlwaysStoppedAnimation<Color>(
                      AppColor.investTextColor),
                ),
                const Gap(8.0),
                TextWidget().text11W700(
                    "${(double.parse(availableIOModel.amountInvested!) / double.parse(availableIOModel.goalAmount!)) * 100}% ${localizations.translate(AppText.fundedText)}",
                    clr: AppColor.portoflioCardTextColor),
                const Gap(8.0),
                TextWidget().text14W400(
                  availableIOModel.descriptionEnglish!,
                  clr: Colors.grey,
                  txtAlign: TextAlign.start,
                  maxLine: 2,
                )
              ],
            ),
          ),
        ),
        Padding(
          padding: const EdgeInsets.only(left: 12.0, right: 12, bottom: 12.0),
          child: Container(
            decoration: BoxDecoration(
                color: const Color(0xFFE4F5E9),
                borderRadius: BorderRadius.circular(22)),
            child: Padding(
              padding:
                  const EdgeInsets.symmetric(horizontal: 20.0, vertical: 16.0),
              child: Column(
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      SizedBox(
                        width: 150.w,
                        child: TextWidget().text14W500(
                          "${localizations.translate(AppText.sponsorNameText)}:",
                          clr: AppColor.portoflioCardTextColor,
                          txtAlign: TextAlign.start,
                        ),
                      ),
                      TextWidget().text14W700(
                        availableIOModel.sponsor!.sponsorName!,
                        clr: AppColor.plainBlack,
                        txtAlign: TextAlign.end,
                      )
                    ],
                  ),
                  SizedBox(
                    height: 8.h,
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      SizedBox(
                        width: 150.w,
                        child: TextWidget().text14W500(
                          "${localizations.translate(AppText.estimatedReturnText)}:",
                          clr: AppColor.portoflioCardTextColor,
                          txtAlign: TextAlign.start,
                        ),
                      ),
                      TextWidget().text14W700(
                        availableIOModel.expectedReturn!,
                        clr: AppColor.plainBlack,
                        txtAlign: TextAlign.end,
                      ),
                    ],
                  ),
                  SizedBox(
                    height: 8.h,
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      SizedBox(
                        width: 150.w,
                        child: TextWidget().text14W500(
                          "${localizations.translate(AppText.holdingPeriodText)}:",
                          clr: AppColor.portoflioCardTextColor,
                          txtAlign: TextAlign.start,
                        ),
                      ),
                      TextWidget().text14W700(
                        availableIOModel.holdingPeriod!,
                        clr: AppColor.plainBlack,
                        txtAlign: TextAlign.end,
                      ),
                    ],
                  ),
                  SizedBox(
                    height: 8.h,
                  ),
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      TextWidget().text14W500(
                        "${localizations.translate(AppText.minimumInvestmentText)}:",
                        clr: AppColor.portoflioCardTextColor,
                        txtAlign: TextAlign.start,
                      ),
                      TextWidget().text14W700(
                        'BHD ${availableIOModel.minInvestmentAmt![0].minInvestmentAmt}',
                        clr: AppColor.plainBlack,
                        txtAlign: TextAlign.end,
                      ),
                    ],
                  )
                ],
              ),
            ),
          ),
        )
      ],
    );
  }
}
