import 'package:flutter/material.dart';
import 'package:hmg_patient_app_new/core/app_assets.dart';
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
import 'package:hmg_patient_app_new/core/utils/size_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/features/my_appointments/models/resp_models/appointment_details_resp_model.dart';
import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.dart';

import 'dart:ui' as ui;

import '../../../core/utils/utils.dart';
import '../../../theme/colors.dart';

class BuildDoctorRow extends StatelessWidget {
  bool isForClinic = false;
  AppointmentDetails? appointmentDetails;

   BuildDoctorRow({super.key, required this.isForClinic, this.appointmentDetails});

  @override
  Widget build(BuildContext context) {

   return Padding(padding: EdgeInsets.all(16),child:Row(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
       Utils.buildImgWithNetwork(
         url: isForClinic ?  'https://hmgwebservices.com/Images/Hospitals/${appointmentDetails!.projectID}.jpg' : appointmentDetails!.doctorImageURL ,
          iconColor: AppColors.transparent,
          width: 63.h,
          height: 63.h,
          fit: BoxFit.cover,
        ).circle(100),
        SizedBox(width: 16.h),
        Expanded(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              (isForClinic  ? appointmentDetails!.projectName :   appointmentDetails!.doctorName)!.toString()
                  .toText16(isBold: true, maxlines: 1),

              SizedBox(height: 8.h),

          isForClinic ?     Wrap(
                  direction: Axis.horizontal,
                  spacing: 3.h,
                  runSpacing: 4.h,
                  children: [
                    AppCustomChipWidget(
                      labelText:
                      appointmentDetails!.clinicName.toString(),
                    ),
                    AppCustomChipWidget(
                      icon: AppAssets.ic_date_filter,
                      labelText:
                      DateUtil.formatDateToDate(DateUtil.convertStringToDate(appointmentDetails!.appointmentDate), false),
                      isEnglishOnly: true,
                    ),

                    AppCustomChipWidget(
                    icon: AppAssets.appointment_time_icon,
                    labelText:
                    appointmentDetails!.startTime.substring(0,  appointmentDetails!.startTime.length - 3),
                  ),
                  ]
              ) :  Wrap(
              direction: Axis.horizontal,
              spacing: 3.h,
              runSpacing: 4.h,
              children: [
                AppCustomChipWidget(
                  labelText:
                  appointmentDetails!.projectName.toString(),
                ),
                AppCustomChipWidget(
                  labelText:
                  appointmentDetails!.clinicName.toString(),
                          ),
                          Directionality(
                            textDirection: ui.TextDirection.ltr,
                            child: AppCustomChipWidget(
                              labelPadding: EdgeInsetsDirectional.only(start: -8.w, end: 6.w),
                              icon: AppAssets.ic_date_filter,
                              labelText: DateUtil.formatDateToDate(DateUtil.convertStringToDate(appointmentDetails!.appointmentDate), false),
                              isEnglishOnly: true,
                            ),
                          ),
                        ],
                      ),
              ],
            ),
          ),
      ],
      ),
    );
  }

}