import 'package:doctor_app_flutter/core/viewModel/patient_view_model.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/shared/errors/dr_app_embedded_error.dart';
import 'package:flutter/material.dart';

import '../../../../lookups/patient_lookup.dart';
import '../../../../models/patient/vital_sign/vital_sign_res_model.dart';
import '../../../../screens/patients/profile/vital_sign/vital_sing_chart_and_detials.dart';
import '../../../../widgets/shared/app_scaffold_widget.dart';

/*
 *@author: Elham Rababah 
 *@Date:03/6/2020
 *@param:
 *@return:
 *@desc: VitalSignItemDetailsScreen
 */
class VitalSignItemDetailsScreen extends StatelessWidget {
  VitalSignItemDetailsScreen();

  List<VitalSignResModel> vitalList = [];
  String pageTitle;

  @override
  Widget build(BuildContext context) {
    final routeArgs = ModalRoute.of(context).settings.arguments as Map;
    pageTitle = routeArgs['title'];
    var pageKey = routeArgs['key'];
    List<Map> VSchart;
    switch (pageKey) {
      case vitalSignDetails.bodyMeasurements:
        VSchart = [
          {
            'name': 'Highet',
            'title1': 'Date',
            'title2': 'Cm',
            'viewKey': 'HeightCm',
          },
          {
            'name': 'Weight Kg',
            'title1': 'Date',
            'title2': 'Kg',
            'viewKey': 'WeightKg',
          },
          {
            'name': 'BodyMassIndex',
            'title1': 'Date',
            'title2': 'BodyMass',
            'viewKey': 'BodyMassIndex',
          },
          {
            'name': 'HeadCircumCm',
            'title1': 'Date',
            'title2': 'Cm',
            'viewKey': 'HeadCircumCm',
          },
          {
            'name': 'Ideal Body Weight (Lbs)',
            'title1': 'Date',
            'title2': 'Ideal  Weight',
            'viewKey': 'IdealBodyWeightLbs',
          },
          {
            'name': 'LeanBodyWeightLbs (Lbs)',
            'title1': 'Date',
            'title2': 'Lean Weight',
            'viewKey': 'LeanBodyWeightLbs',
          }
        ];

        break;

      case vitalSignDetails.temperature:
        VSchart = [
          {
            'name': 'Temperature In Celcius',
            'title1': 'Date',
            'title2': 'C',
            'viewKey': 'TemperatureCelcius',
          },
        ];

        break;
      case vitalSignDetails.pulse:
        VSchart = [
          {
            'name': 'Pulse Beat Per Minute',
            'title1': 'Date',
            'title2': 'Minute',
            'viewKey': 'PulseBeatPerMinute',
          },
        ];

        break;
      case vitalSignDetails.pespiration:
        VSchart = [
          {
            'name': 'Respiration Beat Per Minute',
            'title1': 'Date',
            'title2': 'Beat Per Minute',
            'viewKey': 'RespirationBeatPerMinute',
          },
        ];

        break;
      case vitalSignDetails.bloodPressure:
        VSchart = [
          {
            'name': 'Blood Pressure Higher',
            'title1': 'Date',
            'title2': 'Minute',
            'viewKey': 'BloodPressureHigher',
          },
          {
            'name': 'Blood Pressure Lower',
            'title1': 'Date',
            'title2': 'Minute',
            'viewKey': 'BloodPressureLower',
          }
        ];

        break;
      case vitalSignDetails.oxygenation:
        VSchart = [
          {
            'name': 'FIO2',
            'title1': 'Date',
            'title2': 'Cm',
            'viewKey': 'FIO2',
          },
          {
            'name': 'SAO2',
            'title1': 'Date',
            'title2': 'Cm',
            'viewKey': 'SAO2',
          },
        ];

        break;
      case vitalSignDetails.painScale:
        VSchart = [
          {
            'name': 'PainScore',
            'title1': 'Date',
            'title2': 'Cm',
            'viewKey': 'PainScore',
          },
        ];

        break;

      default:
    }
    return BaseView<PatientViewModel>(
      onModelReady: (model) {
        vitalList = model.patientVitalSignOrderdSubList;
      },
      builder: (_, model, w) => AppScaffold(
        baseViewModel: model,
        appBarTitle: pageTitle,
        body: ListView(
          children: VSchart.map((chartInfo) {
            var vitalListTemp = vitalList.where(
              (element) => element.toJson()[chartInfo['viewKey']] != null,
            );
            return vitalListTemp.length != 0
                ? VitalSingChartAndDetials(
                    vitalList: vitalList,
                    name: chartInfo['name'],
                    title1: chartInfo['title1'],
                    title2: chartInfo['title2'],
                    viewKey: chartInfo['viewKey'])
                : Center(
                    child: Container(
                    margin: EdgeInsets.only(
                        top: MediaQuery.of(context).size.height * 0.45),
                    child: Center(
                      child: DrAppEmbeddedError(
                          error:
                              TranslationBase.of(context).youDoNotHaveAnyItem),
                    ),
                  ));
          }).toList(),
        ),
      ),
    );
  }
}


