import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/app_export.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/extensions/string_extensions.dart';
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
import 'package:hmg_patient_app_new/features/emergency_services/emergency_services_view_model.dart';
import 'package:hmg_patient_app_new/features/emergency_services/models/AmbulanceCallingPlace.dart';
import 'package:hmg_patient_app_new/features/emergency_services/models/ambulance_direction.dart';
import 'package:hmg_patient_app_new/presentation/emergency_services/call_ambulance/widgets/transport_option_Item.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';

import '../../../../generated/locale_keys.g.dart' show LocaleKeys;

class WayPickup extends StatelessWidget {
  final VoidCallback onTap;
  const WayPickup({super.key, required this.onTap});

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        LocaleKeys.selectWay.tr(context: context)
            .toText24(color: AppColors.textColor, isBold: true),
        SizedBox(
          height: 16.h,
        ),
        // LocaleKeys.selectDirection.tr(context: context)
        //     .toText16(color: AppColors.textColor, isBold: true),
        // SizedBox(
        //   height: 12.h,
        // ),
        Column(
          children: [
            SizedBox(height: 12.h),
            Column(
              mainAxisAlignment: MainAxisAlignment.start,
              spacing:8.h,
              children: [
                TransportOptionItem(
                  title:  LocaleKeys.oneWay.tr(context: context),
                  subTitle: LocaleKeys.oneWaySubtitle.tr(context: context),
                  firstIcon: AppAssets.to_arrow,
                  middleIcon: AppAssets.to_arrow,
                  lastIcon: AppAssets.hospital,
                  shouldFlipIcon: getIt.get<AppState>().isArabic(),
                  price: context.read<EmergencyServicesViewModel>().selectedTransportOption?.priceTotal?.toString()??"",
                  onTap: () {
                    context
                                                  .read<EmergencyServicesViewModel>()
                                                  .updateDirection( AmbulanceDirection.ONE_WAY);
                    onTap();
                  },
                ),

                TransportOptionItem(
                  title: LocaleKeys.twoWay.tr(context: context),
                  subTitle: LocaleKeys.twoWaySubtitle.tr(context: context),
                  firstIcon: AppAssets.dual_arrow,
                  middleIcon: AppAssets.dual_arrow,
                  lastIcon: AppAssets.hospital,
                  price: ((context.read<EmergencyServicesViewModel>().selectedTransportOption?.priceTotal??0)*2).toString(),
                  onTap: () {
                    context
                        .read<EmergencyServicesViewModel>()
                        .updateDirection( AmbulanceDirection.TWO_WAY);
                    onTap();
                  },
                ),

                // Visibility(
                //   visible: value == AmbulanceCallingPlace.TO_HOSPITAL,
                //   child: Selector<EmergencyServicesViewModel, AmbulanceDirection>(
                //     selector: (context, viewModel) => viewModel.ambulanceDirection,
                //     builder: (context, directionValue, _) {
                //       return Column(
                //         crossAxisAlignment: CrossAxisAlignment.start,
                //         children: [
                //           SizedBox(height: 16.h),
                //           LocaleKeys.selectWay.tr(context: context)
                //               .toText16(color: AppColors.textColor, isBold: true),
                //           SizedBox(height: 12.h),
                //           Row(
                //             mainAxisAlignment: MainAxisAlignment.start,
                //             children: [
                //               Expanded(
                //                 child: Row(
                //                   children: [
                //                     Radio<AmbulanceDirection>(
                //                       value: AmbulanceDirection.ONE_WAY,
                //                       groupValue: directionValue,
                //                       onChanged: (AmbulanceDirection? newValue) {
                //                         if (newValue != null) {
                //                           context
                //                               .read<EmergencyServicesViewModel>()
                //                               .updateDirection(newValue);
                //                         }
                //                       },
                //                       activeColor: AppColors.primaryRedColor,
                //                       fillColor: MaterialStateProperty.all(AppColors.primaryRedColor),
                //                     ),
                //                     LocaleKeys.oneWay.tr(context: context)
                //                         .toText12(color: AppColors.textColor, isBold: true)
                //                   ],
                //                 ).onPress(() {
                //                   context
                //                       .read<EmergencyServicesViewModel>()
                //                       .updateDirection(AmbulanceDirection.ONE_WAY);
                //                 }),
                //               ),
                //               Expanded(
                //                 child: Row(
                //                   children: [
                //                     Radio<AmbulanceDirection>(
                //                       value: AmbulanceDirection.TWO_WAY,
                //                       groupValue: directionValue,
                //                       onChanged: (AmbulanceDirection? newValue) {
                //                         if (newValue != null) {
                //                           context
                //                               .read<EmergencyServicesViewModel>()
                //                               .updateDirection(newValue);
                //                         }
                //                       },
                //                       activeColor: AppColors.primaryRedColor,
                //                       fillColor: MaterialStateProperty.all(AppColors.primaryRedColor),
                //                     ),
                //                     LocaleKeys.twoWay.tr(context: context)
                //                         .toText14(color: AppColors.textColor, isBold: true)
                //                   ],
                //                 ).onPress(() {
                //                   context
                //
                //                       .read<EmergencyServicesViewModel>()
                //                       .updateDirection(AmbulanceDirection.TWO_WAY);
                //                 }),
                //               ),
                //             ],
                //           ),
                //         ],
                //       );
                //     },
                //   ),
              ],
            ),
          ],
        ),
        // Selector<EmergencyServicesViewModel, AmbulanceCallingPlace>(
        //   selector: (context, viewModel) => viewModel.callingPlace,
        //   builder: (context, value, _) {
        //     return ;
        //   },
        // ),
        SizedBox(
          height: 16.h,
        ),
        // CustomButton(
        //   text: LocaleKeys.confirm.tr(context: context),
        //   onPressed: onTap,
        //   backgroundColor: AppColors.primaryRedColor,
        //   borderColor: AppColors.primaryRedColor,
        //   textColor: AppColors.whiteColor,
        //   iconColor: AppColors.whiteColor,
        // ),
      ],
    );
  }
}