import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:gap/gap.dart';
import 'package:tanami_app/core/routes/route_name.dart';

import '../../../../../../core/routes/routes.dart';
import '../../../../../../core/styles/app_color.dart';
import '../../../../../../core/styles/app_text.dart';
import '../../../../../../shared/components/button_widget.dart';
import '../../bloc/payment/invest_payment_bloc.dart';
import '../../bloc/payment/invest_payment_state.dart';

class InvestPayBottomSection extends StatelessWidget {
  const InvestPayBottomSection({super.key});

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        BlocBuilder<InvestPaymentBloc, InvestPaymentState>(
          builder: (context, state) {
            return Container(
              margin: const EdgeInsets.symmetric(
                horizontal: 16,
              ),
              width: 1.sw,
              height: 56.h,
              child: ButtonWidget().elevatedBtn(
                  txtClr: state.isFormValid
                      ? AppColor.plainWhite
                      : AppColor.inactiveBtnTxtColor,
                  function: () {
                    if (state.isFormValid) {
                      goRouter.pushNamed(RouteName.confirmInvestScreen);
                    }
                  },
                  text: AppText.nextText,
                  clr: state.isFormValid
                      ? AppColor.primaryColor2
                      : AppColor.inactiveBtnColor),
            );
          },
        ),
        const Gap(5),
        ButtonWidget().textBorderBtn(
          borderClr: AppColor.txtBorderColor,
          clr: AppColor.plainWhite,
          function: () {
            goRouter.pop();
          },
          text: AppText.backText,
        ),
      ],
    );
  }
}
