import 'package:diplomaticquarterapp/core/enum/filter_type.dart';
import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
import 'package:diplomaticquarterapp/core/model/radiology/final_radiology.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/radiology_view_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/medical/radiology/radiology_details_page.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/medical/doctor_card.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:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class RadiologyHomePage extends StatelessWidget {
  List<ImagesInfo> imagesInfo = List();

  @override
  Widget build(BuildContext context) {
    ProjectViewModel projectViewModel = Provider.of(context);
    imagesInfo.add(
        ImagesInfo(imageEn: 'https://hmgwebservices.com/Images/MobileApp/imges-info/my-radiology/en/0.png', imageAr: 'https://hmgwebservices.com/Images/MobileApp/imges-info/my-radiology/ar/0.png'));
    imagesInfo.add(
        ImagesInfo(imageEn: 'https://hmgwebservices.com/Images/MobileApp/imges-info/my-radiology/en/1.png', imageAr: 'https://hmgwebservices.com/Images/MobileApp/imges-info/my-radiology/ar/1.png'));
    return BaseView<RadiologyViewModel>(
      onModelReady: (model) => model.getPatientRadOrders(),
      builder: (_, model, widget) => AppScaffold(
        isShowAppBar: true,
        appBarTitle: TranslationBase.of(context).radiology,
        baseViewModel: model,
        showNewAppBar: true,
        showNewAppBarTitle: true,
        backgroundColor: Color(0xffF8F8F8),
        description: TranslationBase.of(context).infoRadiology,
        imagesInfo: imagesInfo,
        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(),
                    padding: EdgeInsets.only(top: 12),
                    separatorBuilder: (context, index) {
                      return Container(
                        height: 12,
                        margin: EdgeInsets.only(left: 21, right: 21),
                        // color: Color(0xffD9D9D9),
                      );
                    },
                    itemBuilder: (context, index) {
                      return AppExpandableNotifier(
                        title: model.finalRadiologyList[index].filterName,
                        bodyWidget: ListView.separated(
                            shrinkWrap: true,
                            physics: NeverScrollableScrollPhysics(),
                            padding: EdgeInsets.only(bottom: 14, top: 14, left: 21, right: 21),
                            itemBuilder: (context, _index) {
                              FinalRadiology radiology = model.finalRadiologyList[index].finalRadiologyList[_index];
                              bool _isSortByClinic = model.filterType == FilterType.Clinic;
                              return DoctorCard(
                                onTap: () => Navigator.push(
                                  context,
                                  FadePage(
                                    page: RadiologyDetailsPage(
                                      finalRadiology: radiology,
                                    ),
                                  ),
                                ),
                                isInOutPatient: radiology.isInOutPatient,
                                name: TranslationBase.of(context).dr + " " + radiology.doctorName,
                                billNo: radiology.invoiceNo.toString(),
                                profileUrl: radiology.doctorImageURL,
                                subName: _isSortByClinic ? radiology.projectName : radiology.clinicDescription,
                                isLiveCareAppointment: radiology.isLiveCareAppointment,
                                date: radiology.orderDate,
                                isSortByClinic: _isSortByClinic,
                                //projectViewModel.isArabic ? DateUtil.getMonthDayYearDateFormattedAr(labOrder.orderDate) : DateUtil.getMonthDayYearDateFormatted(labOrder.orderDate),
                              );
                            },
                            separatorBuilder: (context, index) => SizedBox(height: 14),
                            itemCount: model.finalRadiologyList[index].finalRadiologyList.length),
                      );
                    },
                    itemCount: model.finalRadiologyList.length),
              ),
            ),
            // ...List.generate(
            //   model.finalRadiologyList.length,
            //       (index) => AppExpandableNotifier(
            //       title: model
            //           .finalRadiologyList[index].filterName,
            //       bodyWidget: Column(
            //         crossAxisAlignment: CrossAxisAlignment.start,
            //         mainAxisAlignment: MainAxisAlignment.spaceBetween,
            //         children: model
            //             .finalRadiologyList[index].finalRadiologyList
            //             .map((radiology) {
            //           return InkWell(
            //             onTap: () => Navigator.push(
            //               context,
            //               FadePage(
            //                 page: RadiologyDetailsPage(finalRadiology: radiology,),
            //               ),
            //             ),
            //             child: DoctorCard(
            //               isInOutPatient: radiology.isInOutPatient,
            //               isLiveCareAppointment: radiology.isLiveCareAppointment,
            //               name: radiology.doctorName,
            //               profileUrl: radiology.doctorImageURL,
            //               billNo: '${radiology.invoiceNo}',
            //               subName: '${radiology.projectName}',
            //               date: radiology.orderDate//projectViewModel.isArabic? DateUtil.getMonthDayYearDateFormattedAr(radiology.orderDate):DateUtil.getMonthDayYearDateFormatted(radiology.orderDate),
            //             ),
            //           );
            //         }).toList(),
            //       )),
            // )
          ],
        ),
      ),
    );
  }
}
