import 'package:hmg_patient_app/models/Appointments/AppoimentAllHistoryResultList.dart';
import 'package:hmg_patient_app/uitl/date_uitl.dart';
import 'package:hmg_patient_app/uitl/translations_delegate_base.dart';
import 'package:hmg_patient_app/widgets/data_display/medical/doctor_card.dart';
import 'package:hmg_patient_app/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class AvailableAppointmentsPage extends StatelessWidget {
  final List<AppoitmentAllHistoryResultList> appointmentsAllHistoryList;

  const AvailableAppointmentsPage({Key? key, required this.appointmentsAllHistoryList}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return AppScaffold(
      isShowAppBar: true,
      appBarTitle: TranslationBase.of(context).myAppointmentsList,
      showNewAppBar: true,
      backgroundColor: Color(0xffF8F8F8),
      showNewAppBarTitle: true,
      body: SingleChildScrollView(
        child: Container(
          padding: EdgeInsets.only(bottom: 14, top: 14, left: 21, right: 21),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              SizedBox(
                height: 12,
              ),
              ...List.generate(
                appointmentsAllHistoryList.length,
                (index) => InkWell(
                  onTap: () {
                    Navigator.pop(context, appointmentsAllHistoryList[index]);
                  },
                  child: DoctorCard(
                      isInOutPatient: appointmentsAllHistoryList[index].isInOutPatient,
                      name: appointmentsAllHistoryList[index].doctorTitle! + " " + appointmentsAllHistoryList[index].doctorNameObj!,
                      profileUrl: appointmentsAllHistoryList[index].doctorImageURL,
                      subName: appointmentsAllHistoryList[index].clinicName,
                      isLiveCareAppointment: appointmentsAllHistoryList[index].isLiveCareAppointment,
                      date: DateUtil.convertStringToDate(appointmentsAllHistoryList[index].appointmentDate!),
                      isSortByClinic: false,
                      rating: appointmentsAllHistoryList[index].actualDoctorRate! + 0.0,
                      appointmentTime: appointmentsAllHistoryList[index].isLiveCareAppointment!
                          ? DateUtil.convertStringToDate(appointmentsAllHistoryList[index].appointmentDate!).toString().split(" ")[1].substring(0, 5)
                          : appointmentsAllHistoryList[index].startTime!.substring(0, 5),
                      remainingTimeInMinutes: null),
                ),
              )
            ],
          ),
        ),
      ),
    );
  }
}
