import 'package:diplomaticquarterapp/core/enum/filter_type.dart';
import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/my_doctor_view_model.dart';
import 'package:diplomaticquarterapp/models/Appointments/DoctorListResponse.dart';
import 'package:diplomaticquarterapp/pages/BookAppointment/widgets/DoctorView.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/new_design/my_tab_view.dart';
import 'package:diplomaticquarterapp/widgets/others/app_expandable_notifier.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class DoctorHomePage extends StatelessWidget {
  List<ImagesInfo> imagesInfo = List();
  @override
  Widget build(BuildContext context) {
    imagesInfo
        .add(ImagesInfo(imageEn: 'https://hmgwebservices.com/Images/MobileApp/imges-info/my-doctor/en/0.png', imageAr: 'https://hmgwebservices.com/Images/MobileApp/imges-info/my-doctor/ar/0.png'));
    imagesInfo
        .add(ImagesInfo(imageEn: 'https://hmgwebservices.com/Images/MobileApp/imges-info/my-doctor/en/1.png', imageAr: 'https://hmgwebservices.com/Images/MobileApp/imges-info/my-doctor/ar/1.png'));
    return BaseView<MyDoctorViewModel>(
      onModelReady: (model) => model.getMyDoctor(),
      builder: (context, MyDoctorViewModel model, widget) => AppScaffold(
        baseViewModel: model,
        isShowAppBar: true,
        appBarTitle: TranslationBase.of(context).myDoctor,
        description: TranslationBase.of(context).infoMyDoctor,
        infoList: TranslationBase.of(context).infoMyDoctorPoints,
        showNewAppBar: true,
        showNewAppBarTitle: true,
        imagesInfo: imagesInfo,
        backgroundColor: Color(0xffF8F8F8),
        body: Column(
          children: <Widget>[
            Row(
              children: <Widget>[
                MyTabView(TranslationBase.of(context).byClinic, FilterType.Clinic, model.filterType, () {
                  model.setFilterType(FilterType.Clinic);
                }),
                MyTabView(TranslationBase.of(context).byHospital, FilterType.Hospital, model.filterType, () {
                  model.setFilterType(FilterType.Hospital);
                }),
              ],
            ),
            Expanded(
              child: FractionallySizedBox(
                widthFactor: 1.0,
                child: ListView.separated(
                    physics: BouncingScrollPhysics(),
                    separatorBuilder: (context, index) {
                      return Container(
                        height: 12,
                        margin: EdgeInsets.only(left: 21, right: 21),
                        // color: Color(0xffD9D9D9),
                      );
                    },
                    itemBuilder: (context, index) {
                      return AppExpandableNotifier(
                        title: model.patientDoctorAppointmentList[index].filterName,
                        bodyWidget: ListView.separated(
                            shrinkWrap: true,
                            physics: NeverScrollableScrollPhysics(),
                            padding: EdgeInsets.only(bottom: 14, top: 14, left: 21, right: 21),
                            itemBuilder: (context, _index) {
                              DoctorList _doctorList = model.patientDoctorAppointmentList[index].patientDoctorAppointmentList[_index];
                              DoctorList doctorList = DoctorList(
                                  projectID: _doctorList.projectID,
                                  setupID: _doctorList.setupID,
                                  clinicID: _doctorList.clinicID,
                                  projectName: _doctorList.projectName,
                                  clinicName: _doctorList.clinicName,
                                  actualDoctorRate: _doctorList.actualDoctorRate,
                                  doctorID: _doctorList.doctorID,
                                  date: _doctorList.appointmentDate,
                                  doctorRate: _doctorList.doctorRate,
                                  gender: _doctorList.gender,
                                  doctorTitle: _doctorList.doctorTitle,
                                  name: _doctorList.name,
                                  doctorImageURL: _doctorList.doctorImageURL,
                                  nationalityFlagURL: _doctorList.nationalityFlagURL);
                              return DoctorView(
                                doctor: doctorList,
                                isLiveCareAppointment: _doctorList.isLiveCareClinic,
                              );
                            },
                            separatorBuilder: (context, index) => SizedBox(height: 14),
                            itemCount: model.patientDoctorAppointmentList[index].patientDoctorAppointmentList.length),
                      );
                    },
                    itemCount: model.patientDoctorAppointmentList.length),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
