import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/app_state.dart';
import 'package:hmg_patient_app_new/core/dependencies.dart';
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
import 'package:hmg_patient_app_new/core/utils/utils.dart';
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
import 'package:provider/provider.dart';

class TransportOptionItem extends StatelessWidget {
  final String title;
  final String subTitle;
  final String firstIcon;
  final String middleIcon;
  final String lastIcon;
  final String price;
  final VoidCallback onTap;
  final bool shouldFlipIcon;

  const TransportOptionItem(
      {super.key,
      required this.title,
      required this.subTitle,
      required this.firstIcon,
      required this.middleIcon,
      required this.lastIcon,
      required this.price,
        this.shouldFlipIcon = false,
      required this.onTap});

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.all(16.h),
        decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
          color: AppColors.whiteColor,
          borderRadius: 20.h,
          hasShadow: false,
        ),
        child: Column(
          spacing: 16.h,
          children: [
            headerSection(),
            titleSection(context),
          ],
        )).onPress((){
          onTap();
    });
  }

  titleSection(BuildContext context) {
    return Row(
      children: [
        Expanded(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              title.toText16(
                  color: AppColors.textColor, isBold: true),
              subTitle.toText12(color: AppColors.greyTextColor, isBold: true),
            ],
          ),
        ),
        Transform.flip(flipX: getIt.get<AppState>().isArabic(), child: Utils.buildSvgWithAssets(icon: AppAssets.forward_arrow_medium, width: 24.h, height: 24.h))
      ],
    );
  }

  headerSection() {
    return Row(
      mainAxisAlignment: MainAxisAlignment.end,
      children: [
        Expanded(
          child: Row(
            children: [
              Transform.flip(flipX: getIt.get<AppState>().isArabic() && shouldFlipIcon, child: buildIcon(firstIcon)),
              // Utils.buildSvgWithAssets(
              //     icon: middleIcon, width: 24.h, height: 24.h).paddingAll(8.h),
              // buildIcon(lastIcon)
            ],
          ),
        ),
        Visibility(
          visible: price.isNotEmpty,
          child: Utils.getPaymentAmountWithSymbol2(num.tryParse(price) ?? 0.0, fontSize: 18.f, letterSpacing: -2),
        ),
      ],
    );
  }

  buildIcon(String icon) {
    return CustomButton(
      text: '',
      iconSize: 24.h,
      icon: icon,
      onPressed: () {},
      backgroundColor: AppColors.greyColor,
      iconColor: AppColors.greyTextColor,
      borderColor: Colors.transparent,
      height: 42.h,
    );
  }
}
