import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/vital_signs/components/barWidget.dart'; import 'package:diplomaticquarterapp/vital_signs/data/vitals_benchmark.dart'; import 'package:flutter/material.dart'; class VitalSignWidget extends StatelessWidget { final String vitalSignName; final String vitalSignValue; final String vectorUrl; final dynamic condition; final Map? lookupValues; final Map? bloodPressureValues; final Color? textColor; final String vitalName; const VitalSignWidget({ Key? key, required this.vitalSignName, required this.vitalSignValue, required this.vitalName, this.textColor, required this.condition, required this.vectorUrl, this.lookupValues, this.bloodPressureValues, }) : super(key: key); @override Widget build(BuildContext context) { return Container( child: Card( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8), ), color: Colors.white, elevation: 2, shadowColor: CustomColors.lightGreyColor, child: Container( decoration: BoxDecoration( borderRadius: const BorderRadius.all(Radius.circular(8)), border: Border( left: BorderSide( color: condition is RangeConditionWithTitle ? getColor(condition.current.interpretation) : getColor(condition.systolic?.systolic.interpretation), // type == ResultTypes.criticalLow || type == ResultTypes.criticalHigh // ? // Color(0xFFDE7676), // : type == ResultTypes.low || type == ResultTypes.high // ? Color(0xFFEAB157) // : type == ResultTypes.normal // ? Color(0xFF09AA28) // : Color(0xFF09AA28), width: MediaQuery.of(context).size.width * 0.015, ), ), color: Colors.white, boxShadow: [ BoxShadow( color: Colors.grey.withOpacity(0.2), spreadRadius: 2, blurRadius: 5, offset: const Offset(0, 3), ), ], ), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 8), child: Column(crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ Padding( padding: const EdgeInsets.all(8.0), child: Text( vitalSignName, textAlign: TextAlign.start, style: TextStyle( fontSize: 18, fontWeight: FontWeight.w600, color: textColor ?? Colors.white, ), ), ), // SizedBox( // height: 8, // ), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ Container( padding: const EdgeInsets.symmetric(horizontal: 8.0), transform: Matrix4.translationValues(0.0, -8.0, 0.0), width: 80, child: Text( "$vitalSignValue ${condition.unit}", textAlign: TextAlign.start, style: TextStyle( fontSize: 14, color: CustomColors.grey, fontWeight: FontWeight.bold, ), ), ), // if (condition is RangeConditionWithTitle) ItemResultCardWidgetWithParamsVitalSign( title: "Creatinine", subTitle: vitalSignValue, referenceRange: "64-104", // percentage: 4, percentage: getPercentage(vitalName, vitalSignValue, condition is RangeConditionWithTitle ? condition.current.interpretation : condition.systolic?.systolic.interpretation), note: "Mayoclinic is the source of pediatrics value", source: "source", buttonText: "Click", showAtRisk: vitalName == 'bmi', type: ResultTypes.criticalLow) // else if (condition is RangeConditionForBloodPressure) // Status( // status: "${TranslationBase.of(context).getValue(condition.systolic?.systolic.interpretation ?? '')}", // originalData: condition.systolic?.systolic.interpretation ?? '', // ) // Text( // "${TranslationBase.of(context).getValue(condition.current?.quantitativeInterpretation ?? '')}", // style: TextStyle( // fontSize: 14, // color: textColor ?? Colors.white, // fontWeight: FontWeight.w500, // ), // ), ], ), // SizedBox( // height: 8, // ), // SizedBox( // height: 30, // child: Row(mainAxisSize: MainAxisSize.max, children: [ if (condition is RangeConditionWithTitle) // SizedBox( // height: 30, // child: Row(mainAxisSize: MainAxisSize.max, children: [ // Expanded( // flex: 1, // child: ListView.separated( // separatorBuilder: (_, __) => SizedBox( // width: 8, // ), // scrollDirection: Axis.horizontal, // shrinkWrap: true, // itemCount: condition.condition?.length ?? 0, // itemBuilder: (_, index) => RangeWidget( // title: condition.condition?[index].title ?? 'test', // isSelected: condition.condition?[index].isInRange(vitalSignValue) == true, // originalData: condition.current?.interpretation ?? '', // ), // ), // ), // ]), // ), // ItemResultCardWidgetWithParamsVitalSign( // title: "Creatinine", // subTitle: vitalSignValue, // referenceRange: "64-104", // // percentage: 4, // percentage: getPercentage(vitalName, vitalSignValue), // note: "Mayoclinic is the source of pediatrics value", // source: "source", // buttonText: "Click", // type: ResultTypes.criticalLow), // Flexible( // flex: 1, // child: ListView.separated( // physics: NeverScrollableScrollPhysics(), // separatorBuilder: (_, __) => SizedBox( // width: 8, // ), // shrinkWrap: true, // itemCount: lookupValues?.length ?? 0, // itemBuilder: (_, index) { // var key = lookupValues?.keys.elementAt(index); // return RangeWidget( // title: key ?? '', // values: lookupValues?[key] ?? [], // isSelected: false, // ); // }), // ), if (condition is RangeConditionForBloodPressure) SizedBox( height: 30, child: Row(mainAxisSize: MainAxisSize.max, children: [ Expanded( flex: 1, child: ListView.separated( separatorBuilder: (_, __) => SizedBox( width: 8, ), scrollDirection: Axis.horizontal, shrinkWrap: true, itemCount: condition.condition?.length ?? 0, itemBuilder: (_, currentIndex) { var title = condition.condition?[currentIndex].quotient ?? ''; return RangeWidget( title: title, isSelected: condition.condition?[currentIndex]?.getValue("systolic-lng")?.isSelected == true, originalData: condition.systolic?.systolic.interpretation ?? '', ); }), ), ]), ), // Flexible( // flex: 1, // child: ListView.separated( // separatorBuilder: (_, __) => SizedBox( // width: 8, // ), // physics: NeverScrollableScrollPhysics(), // shrinkWrap: true, // itemCount: bloodPressure.length ?? 0, // itemBuilder: (_, index) { // // return RangeWidget( // // title: key??'', // // values: lookupValues?[key]??[],isSelected: false, // // ); // return Column( // children: [ // Row( // mainAxisAlignment: MainAxisAlignment.spaceBetween, // children: [ // Text( // TranslationBase.of(context) // .getValue(bloodPressure[index] ?? ''), // textAlign: TextAlign.center, // style: // TextStyle(color: Colors.black, fontSize: 16), // ), // // Status( // status: // "${TranslationBase.of(context).getValue(condition.getValue(bloodPressure[index])?.quantitativeInterpretation ?? '')}", // originalData:condition.getValue(bloodPressure[index])?.quantitativeInterpretation ?? '' , // ) // ], // ), // SizedBox(height: 16), // SizedBox( // height: 30, // child: Row( // mainAxisSize: MainAxisSize.max, // children: [ // Expanded( // flex: 1, // child: ListView.separated( // separatorBuilder: (_, __) => SizedBox( // width: 8, // ), // scrollDirection: Axis.horizontal, // shrinkWrap: true, // itemCount: // condition.condition?.length ?? 0, // itemBuilder: (_, currentIndex) { // var title = condition // .condition?[currentIndex] // .getValue( // bloodPressure[index]).title ?? // ''; // return RangeWidget( // title: title, // isSelected: condition // .condition?[currentIndex] // ?.getValue( // bloodPressure[index]) // ?.isSelected == // true, // ); // }), // ), // ]), // ), // SizedBox(height: 16), // // SizedBox( // // height:220, // // child: ListView.separated( // // separatorBuilder: (_, __) => SizedBox( // // width: 8, // // ), // // physics: NeverScrollableScrollPhysics(), // // shrinkWrap: true, // // itemCount: bloodPressureValues?[key]?.length ?? 0, // // itemBuilder: (_, index) { // // var title = bloodPressureValues?[key]?.keys.elementAt(index); // // // // return RangeWidget( // // title: title ?? '', // // values: bloodPressureValues?[key]?[title] ?? [], // // isSelected: false, // // ); // // })) // ], // ); // }), // ), // ]), // ), // SizedBox( // height: 8, // ), // Row( // mainAxisAlignment: MainAxisAlignment.spaceBetween, // children: [ // Text( // TranslationBase.of(context).getValue( // condition.condition?.first.interpretation ?? ''), // style: TextStyle( // fontSize: 14, // color: textColor ?? Colors.white, // fontWeight: FontWeight.w500, // ), // ), // Text( // TranslationBase.of(context).getValue( // condition.condition?.last.interpretation ?? ''), // style: TextStyle( // fontSize: 14, // color: textColor ?? Colors.white, // fontWeight: FontWeight.w500, // ), // ), // ], // ), // SizedBox( // height: 8, // ), ]), ), ), ), ); } double getPercentage(String vitalName, String value, String interpretationValue) { double percent = 0; switch (interpretationValue) { case "poor": case "atRisk": percent = 4; case "good": percent = 40; case "excellent": if (vitalName == 'bmi') percent = 55; else percent = 75; } if (interpretationValue == "atRisk" && vitalName == 'bmi') percent = 85; return percent; } getColor(title) { switch (title) { case "excellent": return Color(0xFF14a45f); case "good": return Color(0xff84d368); case "poor": return Color(0xFFDE7676); case "atRisk": return Color(0xFFE82626); } } } class RangeWidget extends StatelessWidget { final String title; final bool isSelected; final String originalData; const RangeWidget({super.key, required this.title, required this.isSelected, required this.originalData}); @override Widget build(BuildContext context) { return SizedBox( height: 30, child: Material( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(3), ), // color: Color(0xFF359846), color: (isSelected) ? getColor(originalData) : CustomColors.lightGreyColor, child: Padding( padding: const EdgeInsets.all(8.0), child: Center( child: Text( title, textAlign: TextAlign.center, style: TextStyle(color: (isSelected) ? Colors.white : Colors.black, fontSize: 12), ), ), ), ), ); } getColor(title) { switch (title) { case "excellent": return Color(0xFF14a45f); case "good": return Color(0xff84d368); case "poor": return Color(0xFFDE7676); case "atRisk": return Color(0xFFa2494b); } } } class Status extends StatelessWidget { final String status; final String originalData; const Status({super.key, required this.status, required this.originalData}); @override Widget build(BuildContext context) { return Material( shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(3), ), // color: Color(0xFF359846), color: getColor(originalData), child: Padding( padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6), child: Text(status, style: TextStyle( color: Colors.white, fontSize: 12, fontWeight: FontWeight.w600, )), )); } getColor(title) { switch (title) { case "excellent": return Color(0xFF275b45); case "good": return Color(0xFF507a3d); case "poor": return Color(0xFFa86452); case "atRisk": return Color(0xFFa2494b); } } }