import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/EyeViewModel.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/avatar/large_avatar.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/StarRating.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';

import 'EyeHomePage.dart';

class EyeMeasurementsPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    ProjectViewModel projectViewModel = Provider.of(context);
    return BaseView<EyeViewModel>(
      onModelReady: (model) => model.getEyeMeasurement(),
      builder: (_, model, w) => AppScaffold(
        isShowAppBar: true,
        baseViewModel: model,
        description: TranslationBase.of(context).infoEye,
        imagesInfo: [
          ImagesInfo(
              imageAr: 'https://hmgwebservices.com/Images/MobileApp/imges-info/eye-measurements/ar/0.png',
              imageEn: 'https://hmgwebservices.com/Images/MobileApp/imges-info/eye-measurements/en/0.png')
        ],
        appBarTitle: TranslationBase.of(context).eyeMeasurements,
        body: SingleChildScrollView(
          child: Container(
            margin: EdgeInsets.all(8),
            child: Column(
              children: [
                ...List.generate(
                  model.appointmentFilter.length,
                  (index) => AppExpandableNotifier(
                    title: model.appointmentFilter[index].filterName,
                    bodyWidget: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: model.appointmentFilter[index]
                          .appointmentAllHistoryResultList
                          .map((appointment) {
                        return InkWell(
                          onTap: () {
                            Navigator.push(
                              context,
                              FadePage(
                                page: EyeHomePage(
                                  appointmentAllHistoryResultList: appointment,
                                ),
                              ),
                            );
                          },
                          child: Container(
                            margin: EdgeInsets.all(8),
                            padding: EdgeInsets.all(8.0),
                            decoration: BoxDecoration(
                              borderRadius: BorderRadius.circular(8),
                              color: Colors.white,
                              border: Border.all(color: Colors.grey),
                            ),
                            child: Row(
                              children: [
                                Expanded(
                                  flex: 1,
                                  child: LargeAvatar(
                                    name: appointment.doctorNameObj,
                                    url: appointment.doctorImageURL,
                                  ),
                                ),
                                Expanded(
                                  flex: 4,
                                  child: Container(
                                    margin: EdgeInsets.all(10),
                                    child: Column(
                                      crossAxisAlignment:
                                          CrossAxisAlignment.start,
                                      children: <Widget>[
                                        Texts(
                                          appointment.doctorNameObj,
                                          bold: true,
                                        ),
                                        Texts(
                                          appointment.clinicName,
                                          variant: 'caption3',
                                        ),
                                        Texts(
                                          DateUtil.getMonthDayYearDateFormatted(
                                              appointment.bookDate),
                                          variant: 'caption3',
                                        ),
                                        StarRating(
                                            totalAverage: appointment
                                                .actualDoctorRate
                                                .toDouble(),
                                            forceStars: true),
                                      ],
                                    ),
                                  ),
                                ),
                                Icon(
                                  projectViewModel.isArabic
                                      ? Icons.arrow_forward_ios
                                      : Icons.arrow_back_ios,
                                  color: Colors.grey,
                                  size: 18,
                                )
                              ],
                            ),
                          ),
                        );
                      }).toList(),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
