import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import '../../../../lookups/patient_lookup.dart';
import '../../../../models/patient/vital_sign/vital_sign_res_model.dart';
import '../../../../providers/patients_provider.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();
  // ;
  PatientsProvider patientsProv;
  List<VitalSignResModel> vitalList = [];
  String pageTitle;
  @override
  Widget build(BuildContext context) {
    patientsProv = Provider.of<PatientsProvider>(context);
    final routeArgs = ModalRoute.of(context).settings.arguments as Map;
    pageTitle = routeArgs['title'];
    var pageKey = routeArgs['key'];
    List<Map> VSchart;
    vitalList = patientsProv.patientVitalSignOrderdSubList;
    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 AppScaffold(
      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']) : Container();
        }).toList(),
      ),
    );
  }
}


