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/models/patient/vital_sign/patient-vital-sign-data.dart';
import 'package:doctor_app_flutter/screens/base/base_view.dart';
import 'package:doctor_app_flutter/util/date-utils.dart';
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
import 'package:doctor_app_flutter/widgets/patients/profile/patient-page-header-widget.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/shared/expandable-widget-header-body.dart';
import 'package:flutter/material.dart';
import 'package:hexcolor/hexcolor.dart';

class PatientVitalSignScreen extends StatelessWidget {
  @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'];

    return BaseView<VitalSignsViewModel>(
      onModelReady: (model) => model.getPatientVitalSign(patient),
      builder: (_, model, w) => AppScaffold(
        baseViewModel: model,
        appBarTitle: TranslationBase.of(context).vitalSign,
        body: model.patientVitalSigns != null
            ? SingleChildScrollView(
                child: Container(
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.start,
                    children: [
                      PatientPageHeaderWidget(patient),
                      SizedBox(
                        height: 16,
                      ),
                      Container(
                        margin:
                            EdgeInsets.symmetric(horizontal: 16, vertical: 16),
                        child: Column(
                          children: [
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Row(
                                  children: [
                                    AppText(
                                      "${TranslationBase.of(context).weight} :",
                                      fontSize: SizeConfig.textMultiplier * 2,
                                      color: Colors.black,
                                      fontWeight: FontWeight.bold,
                                    ),
                                    SizedBox(
                                      width: 8,
                                    ),
                                    AppText(
                                      "${model.patientVitalSigns.weightKg} ${TranslationBase.of(context).kg}",
                                      fontSize: SizeConfig.textMultiplier * 2,
                                      color: Colors.grey.shade800,
                                      fontWeight: FontWeight.normal,
                                    ),
                                  ],
                                ),
                                Row(
                                  children: [
                                    AppText(
                                      "${TranslationBase.of(context).idealBodyWeight} :",
                                      fontSize: SizeConfig.textMultiplier * 2,
                                      color: Colors.black,
                                      fontWeight: FontWeight.bold,
                                    ),
                                    SizedBox(
                                      width: 8,
                                    ),
                                    AppText(
                                      "${model.patientVitalSigns.idealBodyWeightLbs} ${TranslationBase.of(context).kg}",
                                      fontSize: SizeConfig.textMultiplier * 2,
                                      color: Colors.grey.shade800,
                                      fontWeight: FontWeight.normal,
                                    ),
                                  ],
                                ),
                              ],
                            ),
                            SizedBox(
                              height: 4,
                            ),
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Row(
                                  children: [
                                    AppText(
                                      "${TranslationBase.of(context).height} :",
                                      fontSize: SizeConfig.textMultiplier * 2,
                                      color: Colors.black,
                                      fontWeight: FontWeight.bold,
                                    ),
                                    SizedBox(
                                      width: 8,
                                    ),
                                    AppText(
                                      "${model.patientVitalSigns.heightCm} ${TranslationBase.of(context).cm}",
                                      fontSize: SizeConfig.textMultiplier * 2,
                                      color: Colors.grey.shade800,
                                      fontWeight: FontWeight.normal,
                                    ),
                                  ],
                                ),
                              ],
                            ),
                            SizedBox(
                              height: 4,
                            ),
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                /*Row(
                                  children: [
                                    AppText(
                                      "${TranslationBase.of(context).waistSize} :",
                                      fontSize: SizeConfig.textMultiplier * 2,
                                      color: Colors.black,
                                      fontWeight: FontWeight.bold,
                                    ),
                                    SizedBox(
                                      width: 8,
                                    ),
                                    AppText(
                                      "${model.patientVitalSigns.waistSizeInch} ${TranslationBase.of(context).inch}",
                                      fontSize: SizeConfig.textMultiplier * 2,
                                      color: Colors.grey.shade800,
                                      fontWeight: FontWeight.normal,
                                    ),
                                  ],
                                ),*/
                                Row(
                                  children: [
                                    AppText(
                                      "${TranslationBase.of(context).headCircum} :",
                                      fontSize: SizeConfig.textMultiplier * 2,
                                      color: Colors.black,
                                      fontWeight: FontWeight.bold,
                                    ),
                                    SizedBox(
                                      width: 8,
                                    ),
                                    AppText(
                                      "${model.patientVitalSigns.headCircumCm} ${TranslationBase.of(context).cm}",
                                      fontSize: SizeConfig.textMultiplier * 2,
                                      color: Colors.grey.shade800,
                                      fontWeight: FontWeight.normal,
                                    ),
                                  ],
                                ),
                              ],
                            ),
                            SizedBox(
                              height: 16,
                            ),
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Row(
                                  children: [
                                    AppText(
                                      "${TranslationBase.of(context).leanBodyWeight} :",
                                      fontSize: SizeConfig.textMultiplier * 2,
                                      color: Colors.black,
                                      fontWeight: FontWeight.bold,
                                    ),
                                    SizedBox(
                                      width: 8,
                                    ),
                                    AppText(
                                      "${model.patientVitalSigns.leanBodyWeightLbs} ${TranslationBase.of(context).kg}",
                                      fontSize: SizeConfig.textMultiplier * 2,
                                      color: Colors.grey.shade800,
                                      fontWeight: FontWeight.normal,
                                    ),
                                  ],
                                ),
                              ],
                            ),
                            SizedBox(
                              height: 4,
                            ),
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Row(
                                  children: [
                                    AppText(
                                      "${TranslationBase.of(context).bodyMassIndex} :",
                                      fontSize: SizeConfig.textMultiplier * 2,
                                      color: Colors.black,
                                      fontWeight: FontWeight.bold,
                                    ),
                                    SizedBox(
                                      width: 8,
                                    ),
                                    AppText(
                                      "${model.patientVitalSigns.bodyMassIndex}",
                                      fontSize: SizeConfig.textMultiplier * 2,
                                      color: Colors.grey.shade800,
                                      fontWeight: FontWeight.normal,
                                    ),
                                    SizedBox(
                                      width: 8,
                                    ),
                                    Container(
                                      color: Colors.green,
                                      child: Padding(
                                        padding: EdgeInsets.symmetric(
                                            vertical: 2, horizontal: 8),
                                        child: AppText(
                                          "${model.getBMI(model.patientVitalSigns.bodyMassIndex)}",
                                          fontSize:
                                              SizeConfig.textMultiplier * 2,
                                          color: Colors.white,
                                          fontWeight: FontWeight.bold,
                                        ),
                                      ),
                                    )
                                  ],
                                ),
                              ],
                            ),
                            SizedBox(
                              height: 4,
                            ),
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Row(
                                  children: [
                                    AppText(
                                      "G.C.S :",
                                      fontSize: SizeConfig.textMultiplier * 2,
                                      color: Colors.black,
                                      fontWeight: FontWeight.bold,
                                    ),
                                    SizedBox(
                                      width: 8,
                                    ),
                                    AppText(
                                      "N/A",
                                      fontSize: SizeConfig.textMultiplier * 2,
                                      color: Colors.grey.shade800,
                                      fontWeight: FontWeight.normal,
                                    ),
                                  ],
                                ),
                              ],
                            ),
                            SizedBox(
                              height: 16,
                            ),
                            const Divider(
                              color: Color(0xffCCCCCC),
                              height: 1,
                              thickness: 2,
                              indent: 0,
                              endIndent: 0,
                            ),
                            SizedBox(
                              height: 16,
                            ),
                            TemperatureWidget(model, model.patientVitalSigns),
                            SizedBox(
                              height: 16,
                            ),
                            const Divider(
                              color: Color(0xffCCCCCC),
                              height: 1,
                              thickness: 2,
                              indent: 0,
                              endIndent: 0,
                            ),
                            SizedBox(
                              height: 16,
                            ),
                            PulseWidget(model.patientVitalSigns),
                            SizedBox(
                              height: 16,
                            ),
                            const Divider(
                              color: Color(0xffCCCCCC),
                              height: 1,
                              thickness: 2,
                              indent: 0,
                              endIndent: 0,
                            ),
                            SizedBox(
                              height: 16,
                            ),
                            RespirationWidget(model.patientVitalSigns),
                            SizedBox(
                              height: 16,
                            ),
                            const Divider(
                              color: Color(0xffCCCCCC),
                              height: 1,
                              thickness: 2,
                              indent: 0,
                              endIndent: 0,
                            ),
                            SizedBox(
                              height: 16,
                            ),
                            BloodPressureWidget(model.patientVitalSigns),
                            SizedBox(
                              height: 16,
                            ),
                            const Divider(
                              color: Color(0xffCCCCCC),
                              height: 1,
                              thickness: 2,
                              indent: 0,
                              endIndent: 0,
                            ),
                            SizedBox(
                              height: 16,
                            ),
                            OxygenationWidget(model.patientVitalSigns),
                            SizedBox(
                              height: 16,
                            ),
                            const Divider(
                              color: Color(0xffCCCCCC),
                              height: 1,
                              thickness: 2,
                              indent: 0,
                              endIndent: 0,
                            ),
                            SizedBox(
                              height: 16,
                            ),
                            PainScaleWidget(model.patientVitalSigns),
                            SizedBox(
                              height: 16,
                            ),
                            const Divider(
                              color: Color(0xffCCCCCC),
                              height: 1,
                              thickness: 2,
                              indent: 0,
                              endIndent: 0,
                            ),
                            SizedBox(
                              height: 16,
                            ),
                          ],
                        ),
                      )
                    ],
                  ),
                ),
              )
            : Center(
                child: AppText(
                  "${TranslationBase.of(context).vitalSignEmptyMsg}",
                  fontSize: SizeConfig.textMultiplier * 2.5,
                  color: HexColor("#B8382B"),
                  fontWeight: FontWeight.normal,
                ),
              ),
      ),
    );
  }
}

class TemperatureWidget extends StatefulWidget {
  final VitalSignsViewModel model;
  final VitalSignData vitalSign;

  TemperatureWidget(this.model, this.vitalSign);

  @override
  _TemperatureWidgetState createState() => _TemperatureWidgetState();
}

class _TemperatureWidgetState extends State<TemperatureWidget> {
  bool isExpand = false;

  @override
  Widget build(BuildContext context) {
    return Container(
      child: HeaderBodyExpandableNotifier(
        headerWidget: Container(
          margin: EdgeInsets.symmetric(vertical: 16.0),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              AppText(
                "${TranslationBase.of(context).temperature}",
                fontSize: SizeConfig.textMultiplier * 2.5,
                color: Colors.black,
                fontWeight: isExpand ? FontWeight.bold : FontWeight.normal,
              ),
              InkWell(
                onTap: () {
                  setState(() {
                    isExpand = !isExpand;
                  });
                },
                child: Icon(isExpand ? Icons.remove : Icons.add),
              ),
            ],
          ),
        ),
        bodyWidget: Container(
          child: Column(
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Expanded(
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Expanded(
                          child: AppText(
                            "${TranslationBase.of(context).temperature} (C):",
                            fontSize: SizeConfig.textMultiplier * 1.8,
                            color: Colors.black,
                            fontWeight: FontWeight.w700,
                          ),
                        ),
                        SizedBox(
                          width: 8,
                        ),
                        Expanded(
                          child: AppText(
                            "${widget.vitalSign.temperatureCelcius}",
                            fontSize: SizeConfig.textMultiplier * 2,
                            color: Colors.grey.shade800,
                            fontWeight: FontWeight.normal,
                          ),
                        ),
                      ],
                    ),
                  ),
                  Expanded(
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Expanded(
                          child: AppText(
                            "${TranslationBase.of(context).temperature} (F):",
                            fontSize: SizeConfig.textMultiplier * 1.8,
                            color: Colors.black,
                            fontWeight: FontWeight.w700,
                          ),
                        ),
                        SizedBox(
                          width: 8,
                        ),
                        Expanded(
                          child: AppText(
                            "${widget.vitalSign.temperatureCelcius * (9 / 5) + 32}",
                            fontSize: SizeConfig.textMultiplier * 2,
                            color: Colors.grey.shade800,
                            fontWeight: FontWeight.normal,
                          ),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
              SizedBox(
                height: 4,
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Row(
                    children: [
                      AppText(
                        "${TranslationBase.of(context).method} :",
                        fontSize: SizeConfig.textMultiplier * 1.8,
                        color: Colors.black,
                        fontWeight: FontWeight.w700,
                      ),
                      SizedBox(
                        width: 8,
                      ),
                      AppText(
                        "${widget.model.getTempratureMethod(widget.vitalSign.temperatureCelciusMethod)}",
                        fontSize: SizeConfig.textMultiplier * 2,
                        color: Colors.grey.shade800,
                        fontWeight: FontWeight.normal,
                      ),
                    ],
                  ),
                ],
              ),
            ],
          ),
        ),
        isExpand: isExpand,
      ),
    );
  }
}

class PulseWidget extends StatefulWidget {
  final VitalSignData vitalSign;

  PulseWidget(this.vitalSign);

  @override
  _PulseWidgetState createState() => _PulseWidgetState();
}

class _PulseWidgetState extends State<PulseWidget> {
  bool isExpand = false;

  @override
  Widget build(BuildContext context) {
    return Container(
      child: HeaderBodyExpandableNotifier(
        headerWidget: Container(
          margin: EdgeInsets.symmetric(vertical: 16.0),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              AppText(
                "${TranslationBase.of(context).pulse}",
                fontSize: SizeConfig.textMultiplier * 2.5,
                color: Colors.black,
                fontWeight: isExpand ? FontWeight.bold : FontWeight.normal,
              ),
              InkWell(
                onTap: () {
                  setState(() {
                    isExpand = !isExpand;
                  });
                },
                child: Icon(isExpand ? Icons.remove : Icons.add),
              ),
            ],
          ),
        ),
        bodyWidget: Container(
          child: Column(
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Expanded(
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Expanded(
                          child: AppText(
                            "${TranslationBase.of(context).pulseBeats}",
                            fontSize: SizeConfig.textMultiplier * 1.8,
                            color: Colors.black,
                            fontWeight: FontWeight.w700,
                          ),
                        ),
                        SizedBox(
                          width: 8,
                        ),
                        Expanded(
                          child: AppText(
                            "${widget.vitalSign.pulseBeatPerMinute}",
                            fontSize: SizeConfig.textMultiplier * 2,
                            color: Colors.grey.shade800,
                            fontWeight: FontWeight.normal,
                          ),
                        ),
                      ],
                    ),
                  ),
                  Expanded(
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Expanded(
                          child: AppText(
                            "${TranslationBase.of(context).rhythm}",
                            fontSize: SizeConfig.textMultiplier * 1.8,
                            color: Colors.black,
                            fontWeight: FontWeight.w700,
                          ),
                        ),
                        SizedBox(
                          width: 8,
                        ),
                        Expanded(
                          child: AppText(
                            "${widget.vitalSign.pulseRhythm}",
                            fontSize: SizeConfig.textMultiplier * 2,
                            color: Colors.grey.shade800,
                            fontWeight: FontWeight.normal,
                          ),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ],
          ),
        ),
        isExpand: isExpand,
      ),
    );
  }
}

class RespirationWidget extends StatefulWidget {
  final VitalSignData vitalSign;

  RespirationWidget(this.vitalSign);

  @override
  _RespirationWidgetState createState() => _RespirationWidgetState();
}

class _RespirationWidgetState extends State<RespirationWidget> {
  bool isExpand = false;

  @override
  Widget build(BuildContext context) {
    return Container(
      child: HeaderBodyExpandableNotifier(
        headerWidget: Container(
          margin: EdgeInsets.symmetric(vertical: 16.0),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              AppText(
                "${TranslationBase.of(context).respiration}",
                fontSize: SizeConfig.textMultiplier * 2.5,
                color: Colors.black,
                fontWeight: isExpand ? FontWeight.bold : FontWeight.normal,
              ),
              InkWell(
                onTap: () {
                  setState(() {
                    isExpand = !isExpand;
                  });
                },
                child: Icon(isExpand ? Icons.remove : Icons.add),
              ),
            ],
          ),
        ),
        bodyWidget: Container(
          child: Column(
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Expanded(
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Expanded(
                          child: AppText(
                            "${TranslationBase.of(context).respBeats}",
                            fontSize: SizeConfig.textMultiplier * 1.8,
                            color: Colors.black,
                            fontWeight: FontWeight.w700,
                          ),
                        ),
                        SizedBox(
                          width: 8,
                        ),
                        Expanded(
                          child: AppText(
                            "${widget.vitalSign.respirationBeatPerMinute}",
                            fontSize: SizeConfig.textMultiplier * 2,
                            color: Colors.grey.shade800,
                            fontWeight: FontWeight.normal,
                          ),
                        ),
                      ],
                    ),
                  ),
                  Expanded(
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Expanded(
                          child: AppText(
                            "${TranslationBase.of(context).patternOfRespiration}",
                            fontSize: SizeConfig.textMultiplier * 1.8,
                            color: Colors.black,
                            fontWeight: FontWeight.w700,
                          ),
                        ),
                        SizedBox(
                          width: 8,
                        ),
                        Expanded(
                          child: AppText(
                            "${widget.vitalSign.respirationPattern}",
                            fontSize: SizeConfig.textMultiplier * 2,
                            color: Colors.grey.shade800,
                            fontWeight: FontWeight.normal,
                          ),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ],
          ),
        ),
        isExpand: isExpand,
      ),
    );
  }
}

class BloodPressureWidget extends StatefulWidget {
  final VitalSignData vitalSign;

  BloodPressureWidget(this.vitalSign);

  @override
  _BloodPressureWidgetState createState() => _BloodPressureWidgetState();
}

class _BloodPressureWidgetState extends State<BloodPressureWidget> {
  bool isExpand = false;

  @override
  Widget build(BuildContext context) {
    return Container(
      child: HeaderBodyExpandableNotifier(
        headerWidget: Container(
          margin: EdgeInsets.symmetric(vertical: 16.0),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              AppText(
                "${TranslationBase.of(context).bloodPressure}",
                fontSize: SizeConfig.textMultiplier * 2.5,
                color: Colors.black,
                fontWeight: isExpand ? FontWeight.bold : FontWeight.normal,
              ),
              InkWell(
                onTap: () {
                  setState(() {
                    isExpand = !isExpand;
                  });
                },
                child: Icon(isExpand ? Icons.remove : Icons.add),
              ),
            ],
          ),
        ),
        bodyWidget: Container(
          child: Column(
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Expanded(
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Expanded(
                          child: AppText(
                            "${TranslationBase.of(context).bloodPressureDiastoleAndSystole}",
                            fontSize: SizeConfig.textMultiplier * 1.8,
                            color: Colors.black,
                            fontWeight: FontWeight.w700,
                          ),
                        ),
                        SizedBox(
                          width: 8,
                        ),
                        Expanded(
                          child: AppText(
                            "${widget.vitalSign.bloodPressureHigher}, ${widget.vitalSign.bloodPressureLower}",
                            fontSize: SizeConfig.textMultiplier * 2,
                            color: Colors.grey.shade800,
                            fontWeight: FontWeight.normal,
                          ),
                        ),
                      ],
                    ),
                  ),
                  Expanded(
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Expanded(
                          child: AppText(
                            "${TranslationBase.of(context).cuffLocation}",
                            fontSize: SizeConfig.textMultiplier * 1.8,
                            color: Colors.black,
                            fontWeight: FontWeight.w700,
                          ),
                        ),
                        SizedBox(
                          width: 8,
                        ),
                        Expanded(
                          child: AppText(
                            "${widget.vitalSign.bloodPressureCuffLocation}",
                            fontSize: SizeConfig.textMultiplier * 2,
                            color: Colors.grey.shade800,
                            fontWeight: FontWeight.normal,
                          ),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
              SizedBox(
                height: 4,
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Expanded(
                    child: Row(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Expanded(
                          child: AppText(
                            "${TranslationBase.of(context).patientPosition}",
                            fontSize: SizeConfig.textMultiplier * 1.8,
                            color: Colors.black,
                            fontWeight: FontWeight.w700,
                          ),
                        ),
                        SizedBox(
                          width: 8,
                        ),
                        Expanded(
                          child: AppText(
                            "${widget.vitalSign.bloodPressurePatientPosition}",
                            fontSize: SizeConfig.textMultiplier * 2,
                            color: Colors.grey.shade800,
                            fontWeight: FontWeight.normal,
                          ),
                        ),
                      ],
                    ),
                  ),
                  Expanded(
                    child: Row(
                      children: [
                        AppText(
                          "${TranslationBase.of(context).cuffSize}",
                          fontSize: SizeConfig.textMultiplier * 1.8,
                          color: Colors.black,
                          fontWeight: FontWeight.w700,
                        ),
                        SizedBox(
                          width: 8,
                        ),
                        AppText(
                          "${widget.vitalSign.bloodPressureCuffSize}",
                          fontSize: SizeConfig.textMultiplier * 2,
                          color: Colors.grey.shade800,
                          fontWeight: FontWeight.normal,
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ],
          ),
        ),
        isExpand: isExpand,
      ),
    );
  }
}

class OxygenationWidget extends StatefulWidget {
  final VitalSignData vitalSign;

  OxygenationWidget(this.vitalSign);

  @override
  _OxygenationWidgetState createState() => _OxygenationWidgetState();
}

class _OxygenationWidgetState extends State<OxygenationWidget> {
  bool isExpand = false;

  @override
  Widget build(BuildContext context) {
    return Container(
      child: HeaderBodyExpandableNotifier(
        headerWidget: Container(
          margin: EdgeInsets.symmetric(vertical: 16.0),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              AppText(
                "${TranslationBase.of(context).oxygenation}",
                fontSize: SizeConfig.textMultiplier * 2.5,
                color: Colors.black,
                fontWeight: isExpand ? FontWeight.bold : FontWeight.normal,
              ),
              InkWell(
                onTap: () {
                  setState(() {
                    isExpand = !isExpand;
                  });
                },
                child: Icon(isExpand ? Icons.remove : Icons.add),
              ),
            ],
          ),
        ),
        bodyWidget: Container(
          child: Column(
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Row(
                    children: [
                      AppText(
                        "${TranslationBase.of(context).sao2}",
                        fontSize: SizeConfig.textMultiplier * 1.8,
                        color: Colors.black,
                        fontWeight: FontWeight.w700,
                      ),
                      SizedBox(
                        width: 8,
                      ),
                      AppText(
                        "${widget.vitalSign.sao2}",
                        fontSize: SizeConfig.textMultiplier * 2,
                        color: Colors.grey.shade800,
                        fontWeight: FontWeight.normal,
                      ),
                    ],
                  ),
                  Row(
                    children: [
                      AppText(
                        "${TranslationBase.of(context).fio2}",
                        fontSize: SizeConfig.textMultiplier * 1.8,
                        color: Colors.black,
                        fontWeight: FontWeight.w700,
                      ),
                      SizedBox(
                        width: 8,
                      ),
                      AppText(
                        "${widget.vitalSign.fio2}",
                        fontSize: SizeConfig.textMultiplier * 2,
                        color: Colors.grey.shade800,
                        fontWeight: FontWeight.normal,
                      ),
                    ],
                  ),
                ],
              ),
            ],
          ),
        ),
        isExpand: isExpand,
      ),
    );
  }
}

class PainScaleWidget extends StatefulWidget {
  final VitalSignData vitalSign;

  PainScaleWidget(this.vitalSign);

  @override
  _PainScaleWidgetState createState() => _PainScaleWidgetState();
}

class _PainScaleWidgetState extends State<PainScaleWidget> {
  bool isExpand = false;

  @override
  Widget build(BuildContext context) {
    return Container(
      child: HeaderBodyExpandableNotifier(
        headerWidget: Container(
          margin: EdgeInsets.symmetric(vertical: 16.0),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              AppText(
                "${TranslationBase.of(context).painScale}",
                fontSize: SizeConfig.textMultiplier * 2.5,
                color: Colors.black,
                fontWeight: isExpand ? FontWeight.bold : FontWeight.normal,
              ),
              InkWell(
                onTap: () {
                  setState(() {
                    isExpand = !isExpand;
                  });
                },
                child: Icon(isExpand ? Icons.remove : Icons.add),
              ),
            ],
          ),
        ),
        bodyWidget: Container(
          child: Column(
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Expanded(
                    child: Row(
                      children: [
                        AppText(
                          "${TranslationBase.of(context).painScale}",
                          fontSize: SizeConfig.textMultiplier * 1.8,
                          color: Colors.black,
                          fontWeight: FontWeight.w700,
                        ),
                        SizedBox(
                          width: 8,
                        ),
                        AppText(
                          "${widget.vitalSign.painScore}",
                          fontSize: SizeConfig.textMultiplier * 2,
                          color: Colors.grey.shade800,
                          fontWeight: FontWeight.normal,
                        ),
                      ],
                    ),
                  ),
                  Expanded(
                    child: Row(
                      children: [
                        AppText(
                          "${TranslationBase.of(context).painManagement}",
                          fontSize: SizeConfig.textMultiplier * 1.8,
                          color: Colors.black,
                          fontWeight: FontWeight.w700,
                        ),
                        SizedBox(
                          width: 8,
                        ),
                        AppText(
                          "${widget.vitalSign.isPainManagementDone}",
                          fontSize: SizeConfig.textMultiplier * 2,
                          color: Colors.grey.shade800,
                          fontWeight: FontWeight.normal,
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ],
          ),
        ),
        isExpand: isExpand,
      ),
    );
  }
}
