import 'package:diplomaticquarterapp/core/enum/patient_lookup.dart';
import 'package:diplomaticquarterapp/core/viewModels/medical/vital_sign_view_model.dart';
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/pages/medical/vital_sign/vital_sign_item.dart';
import 'package:diplomaticquarterapp/pages/medical/vital_sign/vital_sign_item_details_screen.dart';
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart';
import 'package:flutter/material.dart';

import '../../../d_q_icons_icons.dart';

class VitalSignDetailsScreen extends StatelessWidget {
  static const String url = "assets/images/";

  int appointmentNo;
  int projectID;
  VitalSignDetailsScreen({this.appointmentNo, this.projectID});

  @override
  Widget build(BuildContext context) {
    return BaseView<VitalSignViewModel>(
      onModelReady: appointmentNo != null && projectID != null
          ? (model) => model.getPatientRadOrders(
              appointmentNo: appointmentNo, projectID: projectID)
          : (model) => model.getPatientRadOrders(),
      builder: (_, mode, widget) => AppScaffold(
        isShowAppBar: true,
        appBarTitle: TranslationBase.of(context).vitalSigns,
        baseViewModel: mode,
        body: mode.vitalSignResModelList.length > 0
            ? Container(
                child: ListView(
                  children: <Widget>[
                    Row(
                      children: <Widget>[
                        InkWell(
                          onTap: () => Navigator.push(
                            context,
                            FadePage(
                              page: VitalSignItemDetailsScreen(
                                pageKey: VitalSignDetails.Height,
                                pageTitle: TranslationBase.of(context).height,
                                vitalList: mode.vitalSignResModelList,
                              ),
                            ),
                          ),
                          child: Container(
                            child: VitalSignItem(
                              des: TranslationBase.of(context).height,
                              icon: DQIcons.height,
                              lastVal: mode
                                  .vitalSignResModelList[
                                      mode.vitalSignResModelList.length - 1]
                                  .heightCm
                                  .toString(),
                              unit: ' Cm',
                            ),
                          ),
                        ),
                        InkWell(
                          onTap: () => Navigator.push(
                            context,
                            FadePage(
                              page: VitalSignItemDetailsScreen(
                                pageKey: VitalSignDetails.Weight,
                                pageTitle: TranslationBase.of(context).weight,
                                vitalList: mode.vitalSignResModelList,
                              ),
                            ),
                          ),
                          child: VitalSignItem(
                            des: TranslationBase.of(context).weight,
                            icon: DQIcons.weight_scale,
                            unit: ' Kg',
                            lastVal: mode
                                .vitalSignResModelList[
                                    mode.vitalSignResModelList.length - 1]
                                .weightKg
                                .toString(),
                          ),
                        ),
                      ],
                    ),
                    Row(
                      children: <Widget>[
                        InkWell(
                          onTap: () => Navigator.push(
                            context,
                            FadePage(
                              page: VitalSignItemDetailsScreen(
                                pageKey: VitalSignDetails.BodyMeasurements,
                                pageTitle: TranslationBase.of(context)
                                    .bodyMeasurements,
                                vitalList: mode.vitalSignResModelList,
                              ),
                            ),
                          ),
                          child: VitalSignItem(
                            des: TranslationBase.of(context).bodyMeasurements,
                            icon: DQIcons.bmi,
                            lastVal: mode
                                .vitalSignResModelList[0].pulseBeatPerMinute
                                .toString(),
                            unit: 'BMI',
                          ),
                        ),
                        InkWell(
                          onTap: () => Navigator.push(
                            context,
                            FadePage(
                              page: VitalSignItemDetailsScreen(
                                pageKey: VitalSignDetails.Temperature,
                                pageTitle:
                                    TranslationBase.of(context).temperature,
                                vitalList: mode.vitalSignResModelList,
                              ),
                            ),
                          ),
                          child: Container(
                            child: VitalSignItem(
                              des: TranslationBase.of(context).temperature,
                              icon: DQIcons.thermometer,
                              lastVal: mode
                                  .vitalSignResModelList[0].temperatureCelcius
                                  .toString(),
                              unit: 'C',
                            ),
                          ),
                        ),
                      ],
                    ),
                    Row(
                      children: <Widget>[
                        InkWell(
                          onTap: () => Navigator.push(
                            context,
                            FadePage(
                              page: VitalSignItemDetailsScreen(
                                pageKey: VitalSignDetails.heart,
                                pageTitle: TranslationBase.of(context).heart,
                                vitalList: mode.vitalSignResModelList,
                              ),
                            ),
                          ),
                          child: VitalSignItem(
                            des: TranslationBase.of(context).heart,
                            icon: DQIcons.heart,
                            lastVal: mode
                                .vitalSignResModelList[
                                    mode.vitalSignResModelList.length - 1]
                                .pulseBeatPerMinute
                                .toString(),
                            unit: ' bpm',
                          ),
                        ),
                        InkWell(
                          onTap: () => Navigator.push(
                            context,
                            FadePage(
                              page: VitalSignItemDetailsScreen(
                                pageKey: VitalSignDetails.Respiration,
                                pageTitle:
                                    TranslationBase.of(context).respirationRate,
                                vitalList: mode.vitalSignResModelList,
                              ),
                            ),
                          ),
                          child: VitalSignItem(
                            des: TranslationBase.of(context).respirationRate,
                            icon: DQIcons.outline,
                            lastVal: mode
                                .vitalSignResModelList[
                                    mode.vitalSignResModelList.length - 1]
                                .respirationBeatPerMinute
                                .toString(),
                            unit: ' bmp',
                          ),
                        ),
                      ],
                    ),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: <Widget>[
                        InkWell(
                          onTap: () => Navigator.push(
                            context,
                            FadePage(
                              page: VitalSignItemDetailsScreen(
                                pageKey: VitalSignDetails.BloodPressure,
                                pageTitle: TranslationBase.of(context).pulse,
                                vitalList: mode.vitalSignResModelList,
                              ),
                            ),
                          ),
                          child: VitalSignItem(
                            des: TranslationBase.of(context).pulse,
                            icon: DQIcons.blood_pressure,
                            lastVal: mode
                                .vitalSignResModelList[
                                    mode.vitalSignResModelList.length - 1]
                                .bloodPressure
                                .toString(),
                            unit: ' SBP/DBP',
                          ),
                        ),
                      ],
                    ),
                  ],
                ),
              )
            : Center(
                child: Texts('No Data'),
              ),
      ),
    );
  }
}
