You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
diplomatic-quarter/lib/vital_signs/result_screen.dart

304 lines
15 KiB
Dart

import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
import 'package:diplomaticquarterapp/vital_signs/data/vitals_benchmark.dart';
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/material.dart';
import 'package:vital_sign_camera/vital_sign_camera.dart';
import 'components/vital_sign_widget.dart';
class ResultScreen extends StatelessWidget {
final Health? healthResult;
late final VitalSign? _vitalSign;
late final HolisticAnalysis? _holisticAnalysis;
late final CardiovascularRisks? _cardiovascularRisks;
late final CovidRisk? _covidRisk;
late final ScanParameters? _scanParameters;
ResultScreen({
Key? key,
required this.healthResult,
}) : super(key: key) {
_vitalSign = healthResult?.vitalSigns;
_holisticAnalysis = healthResult?.holisticHealth;
_cardiovascularRisks = healthResult?.risks?.cardiovascularRisks;
_covidRisk = healthResult?.risks?.covidRisk;
_scanParameters = healthResult?.scanParameters;
}
@override
Widget build(BuildContext context) {
final deviceSize = MediaQuery.of(context).size;
const textColor = Color.fromARGB(255, 0, 0, 0);
return AppScaffold(
isShowAppBar: true,
appBarTitle: TranslationBase.of(context).result,
showNewAppBar: true,
showNewAppBarTitle: true,
overrideUserLogin: true,
backgroundColor: Color(0xffF8F8F8),
appBarIcons: [
Center(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
"Scan Quality: ${_scanParameters!.signalQuality.toStringAsFixed(0)}%",
style: TextStyle(color: Colors.black, fontSize: 14, letterSpacing: -0.68, fontWeight: FontWeight.bold),
),
),
),
],
body: Padding(
padding: const EdgeInsets.all(15),
child: ListView(
shrinkWrap: true,
children: [
Expanded(
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
if (_holisticAnalysis != null && _holisticAnalysis?.generalWellness != null)
VitalSignWidget(
textColor: textColor,
lookupValues: vitalValues['generalWellness']!,
vitalSignName: TranslationBase.of(context).generalWellness,
condition: RangeConditionWithTitle.fromJson(vital['generalWellness']!, formatValueToTwoDp(healthResult?.holisticHealth?.generalWellness)),
vitalSignValue: formatValueToTwoDp(healthResult?.holisticHealth?.generalWellness),
vectorUrl: 'assets/images/svg/wellness.svg',
), //wellness
if (_vitalSign?.stress != null)
VitalSignWidget(
textColor: textColor,
vitalSignName: TranslationBase.of(context).stress,
condition: RangeConditionWithTitle.fromJson(vital['stressLevel']!, formatValueToTwoDp(healthResult?.vitalSigns.stress)),
lookupValues: vitalValues['stressLevel']!,
vitalSignValue: formatValueToTwoDp(healthResult?.vitalSigns.stress),
vectorUrl: 'assets/images/svg/stress.svg',
),
VitalSignWidget(
textColor: textColor,
vitalSignName: TranslationBase.of(context).pulseTitle,
condition: RangeConditionWithTitle.fromJson(vital['HR']!, formatValueToTwoDp(healthResult?.vitalSigns.heartRate)),
lookupValues: vitalValues['HR']!,
vitalSignValue: formatValueToTwoDp(healthResult?.vitalSigns.heartRate),
vectorUrl: 'assets/images/svg/heartrate.svg',
),
//heart rate
if (_vitalSign?.bloodPressure != null)
VitalSignWidget(
textColor: textColor,
vitalSignName: "Blood Pressure",
condition: RangeConditionForBloodPressure.fromJson(vital['blood_pressure']!, healthResult?.vitalSigns.bloodPressure ?? ""),
bloodPressureValues: vitalValues['blood_pressure']!,
vitalSignValue: healthResult?.vitalSigns.bloodPressure ?? "",
vectorUrl: 'assets/images/svg/bloodpressure.svg',
),
if (_vitalSign?.hrvSdnn != null)
VitalSignWidget(
vectorUrl: 'assets/images/svg/heartrate.svg',
textColor: textColor,
vitalSignName: "HRV SDNN",
lookupValues: vitalValues['hrvv']!,
condition: RangeConditionWithTitle.fromJson(vital['hrvv']!, formatValueToTwoDp(healthResult?.vitalSigns.hrvSdnn)),
vitalSignValue: formatValueToTwoDp(healthResult?.vitalSigns.hrvSdnn)),
//oxygen
VitalSignWidget(
textColor: textColor,
lookupValues: vitalValues['Sp02']!,
vitalSignName: TranslationBase.of(context).oxygenSaturation,
condition: RangeConditionWithTitle.fromJson(vital['Sp02']!, formatValueToTwoDp(healthResult?.vitalSigns.spo2)),
vitalSignValue: formatValueToTwoDp(healthResult?.vitalSigns.spo2),
vectorUrl: 'assets/images/svg/oxygen.svg',
),
if (_vitalSign?.respiratoryRate != null)
VitalSignWidget(
textColor: textColor,
lookupValues: vitalValues['respiratoryRate']!,
vitalSignName: TranslationBase.of(context).respiratoryRate,
condition: RangeConditionWithTitle.fromJson(vital['respiratoryRate']!, formatValueToTwoDp(healthResult?.vitalSigns.respiratoryRate)),
vitalSignValue: formatValueToTwoDp(healthResult?.vitalSigns.respiratoryRate),
vectorUrl: 'assets/images/svg/breathing.svg',
),
if (_holisticAnalysis != null && _holisticAnalysis?.bmi != null)
VitalSignWidget(
textColor: textColor,
lookupValues: vitalValues['bmi']!,
vitalSignName: TranslationBase.of(context).BMI,
condition: RangeConditionWithTitle.fromJson(vital['bmi']!, formatValueToTwoDp(healthResult?.holisticHealth?.bmi)),
vitalSignValue: formatValueToTwoDp(healthResult?.holisticHealth?.bmi),
vectorUrl: 'assets/images/svg/bmi.svg',
),
// VitalSignWidget(
// textColor: textColor,
// vitalSignName: "IBI",
// condition: RangeConditionWithTitle.fromJson(vital['HR']!),
// vitalSignValue:
// formatValueToTwoDp(healthResult?.vitalSigns.ibi)),
// if (_vitalSign?.hrvRmssd != null)
// VitalSignWidget(
// textColor: textColor,
// vitalSignName: "HRV RMSSD",
// vitalSignValue: formatValueToTwoDp(
// healthResult?.vitalSigns.hrvRmssd)),
// if (_vitalSign?.temperature != null)
// VitalSignWidget(
// textColor: textColor,
// vitalSignName: "Temperature",
// vitalSignValue: formatValueToTwoDp(
// healthResult?.vitalSigns.temperature)),
// if (_vitalSign?.bloodPressureSystolic != null)
// VitalSignWidget(
// textColor: textColor,
// vitalSignName: "Blood Pressure Systolic",
// vitalSignValue: formatValueToTwoDp(healthResult
// ?.vitalSigns.bloodPressureSystolic)),
// if (_vitalSign?.bloodPressureDiastolic != null)
// VitalSignWidget(
// textColor: textColor,
// vitalSignName: "Blood Pressure Diastolic",
// vitalSignValue: formatValueToTwoDp(healthResult
// ?.vitalSigns.bloodPressureDiastolic)),
// if (_holisticAnalysis != null)
// Container(
// margin: const EdgeInsets.fromLTRB(0, 25, 0, 10),
// child: const Text(
// "Holistic Analysis",
// style: TextStyle(
// fontSize: 15,
// color: Colors.amber,
// fontWeight: FontWeight.bold,
// ),
// ),
// ),
// if (_holisticAnalysis != null &&
// _holisticAnalysis?.absi != null)
// VitalSignWidget(
// textColor: textColor,
// vitalSignName: "ABSI",
// vitalSignValue: formatValueToTwoDp(
// healthResult?.holisticHealth?.absi)),
// if (_holisticAnalysis != null &&
// _holisticAnalysis?.cardiacWorkload != null)
// VitalSignWidget(
// textColor: textColor,
// vitalSignName: "Cardiac Workload",
// vitalSignValue: formatValueToTwoDp(
// healthResult?.holisticHealth?.cardiacWorkload)),
// if (_holisticAnalysis != null &&
// _holisticAnalysis?.pulseRespiratoryQuotient != null)
// VitalSignWidget(
// textColor: textColor,
// vitalSignName: "Pulse Respiratory Quotient",
// vitalSignValue: formatValueToTwoDp(healthResult
// ?.holisticHealth?.pulseRespiratoryQuotient)),
// if (_holisticAnalysis != null &&
// _holisticAnalysis?.waistToHeightRatio != null)
// VitalSignWidget(
// textColor: textColor,
// vitalSignName: "Waist to Height Ratio",
// vitalSignValue: formatValueToTwoDp(healthResult
// ?.holisticHealth?.waistToHeightRatio)),
// if (_cardiovascularRisks != null)
// Container(
// margin: const EdgeInsets.fromLTRB(0, 25, 0, 10),
// child: const Text(
// "Cardiovascular Risks",
// style: TextStyle(
// fontSize: 15,
// color: Colors.amber,
// fontWeight: FontWeight.bold,
// ),
// ),
// ),
// if (_cardiovascularRisks != null)
// VitalSignWidget(
// textColor: textColor,
// vitalSignName: TranslationBase.of(context).cvd,
// condition: RangeConditionWithTitle.fromJson(vital['cvd']!, formatValueToTwoDp(healthResult
// ?.risks?.cardiovascularRisks?.generalRisk)),
// vitalSignValue: formatValueToTwoDp(healthResult
// ?.risks?.cardiovascularRisks?.generalRisk),
// vectorUrl: 'assets/images/svg/heartrate.svg',),
// if (_cardiovascularRisks != null)
// VitalSignWidget(
// textColor: textColor,
// vitalSignName: "Congestive Heart Failure",
// vitalSignValue: formatValueToTwoDp(healthResult
// ?.risks
// ?.cardiovascularRisks
// ?.congestiveHeartFailure)),
// if (_cardiovascularRisks != null)
// VitalSignWidget(
// textColor: textColor,
// vitalSignName: "Coronary Heart Disease",
// vitalSignValue: formatValueToTwoDp(healthResult
// ?.risks
// ?.cardiovascularRisks
// ?.coronaryHeartDisease)),
// if (_cardiovascularRisks != null)
// VitalSignWidget(
// textColor: textColor,
// vitalSignName: "Intermittent Claudication",
// vitalSignValue: formatValueToTwoDp(healthResult
// ?.risks
// ?.cardiovascularRisks
// ?.intermittentClaudication)),
// if (_cardiovascularRisks != null)
// VitalSignWidget(
// textColor: textColor,
// vitalSignName: "Stroke",
// vitalSignValue: formatValueToTwoDp(healthResult
// ?.risks?.cardiovascularRisks?.stroke)),
// if (_covidRisk != null)
// Container(
// margin: const EdgeInsets.fromLTRB(0, 25, 0, 10),
// child: const Text(
// "Covid Risks",
// style: TextStyle(
// fontSize: 15,
// color: Colors.amber,
// fontWeight: FontWeight.bold,
// ),
// ),
// ),
// if (_covidRisk != null)
// VitalSignWidget(
// textColor: textColor,
// vitalSignName: "Risk",
// vitalSignValue: formatValueToTwoDp(
// healthResult?.risks?.covidRisk?.covidRisk)),
// if (_scanParameters != null)
// Container(
// margin: const EdgeInsets.fromLTRB(0, 25, 0, 10),
// child: const Text(
// "Scan Parameters",
// style: TextStyle(
// fontSize: 15,
// color: Colors.amber,
// fontWeight: FontWeight.bold,
// ),
// ),
// ),
// if (_scanParameters != null)
// VitalSignWidget(
// textColor: textColor,
// vitalSignName: "Signal Quality",
// vitalSignValue: formatValueToTwoDp(
// healthResult?.scanParameters?.signalQuality)),
]),
),
],
),
),
);
}
String formatValueToTwoDp(double? value) {
return (value != null) ? value.toStringAsFixed(2) : "";
}
}