import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:doctor_app_flutter/core/viewModel/patient-vital-sign-viewmodel.dart';
import 'package:doctor_app_flutter/lookups/patient_lookup.dart';
import 'package:doctor_app_flutter/models/patient/patiant_info_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/screens/patients/profile/vital_sign/vital_sign_item.dart';
import 'package:doctor_app_flutter/screens/patients/profile/vital_sign/vital_sign_item_details_screen.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart';
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
import 'package:doctor_app_flutter/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';

class VitalSignDetailsScreen extends StatelessWidget {
  int appointmentNo;
  int projectID;
  bool isNotOneAppointment;

  VitalSignDetailsScreen(
      {this.appointmentNo, this.projectID, this.isNotOneAppointment = true});

  @override
  Widget build(BuildContext context) {
    final routeArgs = ModalRoute.of(context).settings.arguments as Map;
    PatiantInformtion patient = routeArgs['patient'];
    String from = routeArgs['from'];
    String to = routeArgs['to'];
    String imageBasePath = 'assets/images/';

    return BaseView<VitalSignsViewModel>(
      onModelReady: (model) =>
          model.getPatientVitalSignHistory(patient, from, to),
      builder: (_, mode, widget) => AppScaffold(
        isShowAppBar: true,
        baseViewModel: mode,
        appBarTitle: TranslationBase.of(context).vitalSign,
        body: mode.patientVitalSignsHistory.length > 0
            ? Container(
                child: ListView(
                  children: <Widget>[
                    Row(
                      children: <Widget>[
                        InkWell(
                          onTap: () => isNotOneAppointment
                              ? Navigator.push(
                                  context,
                                  FadePage(
                                    page: VitalSignItemDetailsScreen(
                                      pageKey: vitalSignDetails.Height,
                                      pageTitle:
                                          TranslationBase.of(context).height,
                                      vitalList: mode.patientVitalSignsHistory,
                                    ),
                                  ),
                                )
                              : null,
                          child: Container(
                            child: VitalSignItem(
                              des: TranslationBase.of(context).height,
                              imagePath: "${imageBasePath}vital_height.png",
                              lastVal: mode.heightCm,
                              unit: TranslationBase.of(context).cm,
                            ),
                          ),
                        ),
                        InkWell(
                          onTap: () => isNotOneAppointment
                              ? Navigator.push(
                                  context,
                                  FadePage(
                                    page: VitalSignItemDetailsScreen(
                                      pageKey: vitalSignDetails.Weight,
                                      pageTitle:
                                          TranslationBase.of(context).weight,
                                      vitalList: mode.patientVitalSignsHistory,
                                    ),
                                  ),
                                )
                              : null,
                          child: VitalSignItem(
                            des: TranslationBase.of(context).weight,
                            imagePath: "${imageBasePath}vital_weight.png",
                            unit: TranslationBase.of(context).kg,
                            lastVal: mode.weightKg,
                          ),
                        ),
                      ],
                    ),
                    Row(
                      children: <Widget>[
                        InkWell(
                          onTap: () => isNotOneAppointment
                              ? Navigator.push(
                                  context,
                                  FadePage(
                                    page: VitalSignItemDetailsScreen(
                                      pageKey:
                                          vitalSignDetails.BodyMeasurements,
                                      pageTitle: TranslationBase.of(context)
                                          .bodyMeasurements,
                                      vitalList: mode.patientVitalSignsHistory,
                                    ),
                                  ),
                                )
                              : null,
                          child: VitalSignItem(
                            des: TranslationBase.of(context).body,
                            imagePath: "${imageBasePath}vital_body_mass.png",
                            lastVal: mode.bodyMax,
                            unit: TranslationBase.of(context).mass,
                          ),
                        ),
                        InkWell(
                          onTap: () => isNotOneAppointment
                              ? Navigator.push(
                                  context,
                                  FadePage(
                                    page: VitalSignItemDetailsScreen(
                                      pageKey: vitalSignDetails.Temperature,
                                      pageTitle: TranslationBase.of(context)
                                          .temperature,
                                      vitalList: mode.patientVitalSignsHistory,
                                    ),
                                  ),
                                )
                              : null,
                          child: Container(
                            child: VitalSignItem(
                              des: TranslationBase.of(context).temperature,
                              imagePath:
                                  "${imageBasePath}vital_temperature.png",
                              lastVal: mode.temperatureCelcius,
                              unit: TranslationBase.of(context).tempC,
                            ),
                          ),
                        ),
                      ],
                    ),
                    Row(
                      children: <Widget>[
                        InkWell(
                          onTap: () => isNotOneAppointment
                              ? Navigator.push(
                                  context,
                                  FadePage(
                                    page: VitalSignItemDetailsScreen(
                                      pageKey: vitalSignDetails.heart,
                                      pageTitle:
                                          TranslationBase.of(context).heart,
                                      vitalList: mode.patientVitalSignsHistory,
                                    ),
                                  ),
                                )
                              : null,
                          child: VitalSignItem(
                            des: TranslationBase.of(context).heart,
                            imagePath: "${imageBasePath}vital_heart_rate.png",
                            lastVal: mode.hartRat,
                            unit: TranslationBase.of(context).bpm,
                          ),
                        ),
                        InkWell(
                          onTap: () => isNotOneAppointment
                              ? Navigator.push(
                                  context,
                                  FadePage(
                                    page: VitalSignItemDetailsScreen(
                                      pageKey: vitalSignDetails.Respiration,
                                      pageTitle: TranslationBase.of(context)
                                          .respirationRate,
                                      vitalList: mode.patientVitalSignsHistory,
                                    ),
                                  ),
                                )
                              : null,
                          child: VitalSignItem(
                            des: TranslationBase.of(context).respirationRate,
                            imagePath: "${imageBasePath}vital_respiration.png",
                            lastVal: mode.respirationBeatPerMinute,
                            unit: TranslationBase.of(context).respirationSigns,
                          ),
                        ),
                      ],
                    ),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        InkWell(
                          onTap: () => isNotOneAppointment
                              ? Navigator.push(
                                  context,
                                  FadePage(
                                    page: VitalSignItemDetailsScreen(
                                      pageKey: vitalSignDetails.BloodPressure,
                                      pageTitle: TranslationBase.of(context)
                                          .bloodPressure,
                                      vitalList: mode.patientVitalSignsHistory,
                                    ),
                                  ),
                                )
                              : null,
                          child: VitalSignItem(
                            des: TranslationBase.of(context).bloodPressure,
                            imagePath:
                                "${imageBasePath}vital_blood-pressure.png",
                            lastVal: mode.bloodPressure,
                            unit: TranslationBase.of(context).sysDias,
                          ),
                        ),
                      ],
                    ),
                  ],
                ),
              )
            : Center(
                child: AppText(
                  TranslationBase.of(context).vitalSignEmptyMsg,
                  fontWeight: FontWeight.normal,
                  color: HexColor("#B8382B"),
                  fontSize: SizeConfig.textMultiplier * 2.5,
                ),
              ),
      ),
    );
  }
}
