import 'package:diplomaticquarterapp/core/enum/patient_lookup.dart';
import 'package:diplomaticquarterapp/core/model/vital_sign/vital_sign_res_model.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/pages/medical/vital_sign/vital_sing_chart_and_detials.dart';
import 'package:diplomaticquarterapp/pages/medical/vital_sign/vital_sing_chart_blood_pressure.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class VitalSignItemDetailsScreen extends StatelessWidget {
  final VitalSignDetails pageKey;
  final String pageTitle;
  List<Map> VSchart;

  VitalSignItemDetailsScreen({this.vitalList, this.pageKey, this.pageTitle});

  final List<VitalSignResModel> vitalList;

  @override
  Widget build(BuildContext context) {
    ProjectViewModel projectViewModel = Provider.of(context);
    switch (pageKey) {
      case VitalSignDetails.BodyMeasurements:
        VSchart = [
          {
            'name': 'BMI',
            'nameAr': 'مؤشر الكتلة',
            'title1': 'Date',
            'title2': 'BMI',
            'title2Ar': 'الكتلة',
            'viewKey': 'BodyMassIndex',
          },

        ];

        break;

      case VitalSignDetails.Temperature:
        VSchart = [
          {
            'name': 'Temperature In Celsius',
            'nameAr': 'درجة الحرارة بالدرجة المئوية',
            'title1': 'Date',
            'title2': 'C',
            'title2Ar': 'ْس',
            'viewKey': 'TemperatureCelcius',
          },
        ];

        break;
      case VitalSignDetails.Pulse:
        VSchart = [
          {
            'name': 'Pulse Beat Per Minute',
            'nameAr': 'نبضة نبضة في الدقيقة',
            'title1': 'Date',
            'title2': 'Minute',
            'title2Ar': 'دقيقة',
            'viewKey': 'PulseBeatPerMinute',
          },
        ];

        break;
      case VitalSignDetails.Prescriptions:
        VSchart = [
          {
            'name': 'Respiration Beat Per Minute',
            'nameAr': 'ضربات التنفس في الدقيقة',
            'title1': 'Date',
            'title2': 'Beat Per Minute',
            'title2Ar': 'نفس في الدقيقة',
            'viewKey': 'RespirationBeatPerMinute',
          },
        ];

        break;
      case VitalSignDetails.BloodPressure:
        VSchart = [
          {
            'name': 'Blood Pressure Systolic Diastolic',
            'nameAr': 'ضغط الدم الإنقباض الإنبساط',
            'title1': 'Date',
            'title2': 'systolic',
            'title3': 'Diastolic',
            'title2Ar': 'الإنقباض',
            'title3Ar': 'الإنبساط',
            'viewKey': 'BloodPressure',
          },

        ];

        break;
      case VitalSignDetails.Respiration:
        VSchart = [
          {
            'name': 'Respiration Rate',
            'nameAr': 'معدل التنفس',
            'title1': 'Date',
            'title2': 'bpm',
            'title2Ar': 'نفس',
            'viewKey': 'RespirationBeatPerMinute',
          },
        ];

        break;
      case VitalSignDetails.heart:
        VSchart = [
          {
            'name': 'Heart rate',
            'nameAr': 'معدل النبض بالدقيقة',
            'title1': 'Date',
            'title2': 'bpm',
            'title2Ar': 'نبضة',
            'viewKey': 'PulseBeatPerMinute',
          },
        ];

        break;
      case VitalSignDetails.PainScale:
        VSchart = [
          {
            'name': 'PainScore',
            'nameAr': 'نقاط الألم',
            'title1': 'Date',
            'title2': 'Cm',
            'title2Ar': 'سم',
            'viewKey': 'PainScore',
          },
        ];

        break;
      case VitalSignDetails.Weight:
        VSchart = [
          {
            'name': 'Weight Kg',
            'nameAr': 'الوزن كجم',
            'title1': 'Date',
            'title2': 'Kg',
            'title2Ar': 'كجم',
            'viewKey': 'WeightKg',
          },
        ];

        break;

      case VitalSignDetails.Height:
        VSchart = [
          {
            'name': 'Height Cm',
            'nameAr': 'الطول سم',
            'title1': 'Date',
            'title2': 'Cm',
            'title2Ar': 'سم',
            'viewKey': 'HeightCm',
          },
        ];

        break;
      default:
    }
    return AppScaffold(
      appBarTitle: pageTitle,
      isShowAppBar: true,
      body: ListView(
        children: VSchart.map((chartInfo) {
          var vitalListTemp = vitalList.where(
            (element) => element.toJson()[chartInfo['viewKey']] != null,
          );

          if(vitalListTemp.length != 0 && chartInfo['viewKey']=='BloodPressure'){
            return VitalSingChartBloodPressure(
                vitalList: vitalList,
                name:projectViewModel.isArabic? chartInfo['nameAr']:chartInfo['name'],
                title1: chartInfo['title1'],
                title2:projectViewModel.isArabic?chartInfo['title2Ar']: chartInfo['title2'],
                title3:projectViewModel.isArabic?chartInfo['title3Ar']: chartInfo['title3'],
                viewKey1: 'BloodPressureHigher',
                viewKey2: 'BloodPressureLower',

            );
          }

          return vitalListTemp.length != 0
              ? VitalSingChartAndDetials(
                  vitalList: vitalList,
                  name:projectViewModel.isArabic? chartInfo['nameAr']:chartInfo['name'],
                  title1: chartInfo['title1'],
                  title2:projectViewModel.isArabic?chartInfo['title2Ar']: chartInfo['title2'],
                  viewKey: chartInfo['viewKey'])
              : Container();
        }).toList(),
      ),
    );
  }
}
