更新快检功能
This commit is contained in:
136
lib/pages/sleep_report/qc_report/QcAIAdviceWidget.dart
Normal file
136
lib/pages/sleep_report/qc_report/QcAIAdviceWidget.dart
Normal file
@@ -0,0 +1,136 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/AdviceComponnetWidget.dart';
|
||||
import 'package:EasyDartModule/EasyDartModule.dart' as es;
|
||||
|
||||
class QcAIAdviceWidget extends StatefulWidget {
|
||||
var sleepReport;
|
||||
QcAIAdviceWidget({super.key, required this.sleepReport});
|
||||
|
||||
@override
|
||||
State<QcAIAdviceWidget> createState() => _QcAIAdviceWidgetState();
|
||||
}
|
||||
|
||||
class _QcAIAdviceWidgetState extends State<QcAIAdviceWidget> {
|
||||
@override
|
||||
void setState(VoidCallback callback) {
|
||||
super.setState(callback);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
try {
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport['sugges'] == null ||
|
||||
widget.sleepReport['sugges'].isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
List advices = widget.sleepReport['sugges'];
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc5,
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppConstants().normal_container_radius), // 你可以按需调整圆角半径
|
||||
),
|
||||
child: Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(26.rpx, 29.rpx, 26.rpx, 45.rpx),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"AI分析".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().title_text_fontSize),
|
||||
),
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: Colors.white, // 或设置为你需要的水波纹颜色
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
14.rpx, 10.rpx, 14.rpx, 10.rpx),//
|
||||
borderRadius: 0.rpx, // 圆形点击区域
|
||||
onTap: () {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
// "AI分析介绍".tr,
|
||||
"AI分析是指利用人工智能技术对用户的睡眠数据进行自动化处理与规律提取,对用户的异常睡眠数据给到一定的辅助决策或者解决问题。"
|
||||
.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: Color(0xFFFFFFFF),
|
||||
colors: [
|
||||
Color(0XFF1592AA),
|
||||
Color(0xFF0C83A7),
|
||||
Color(0xFF006FA3)
|
||||
],
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0, 0.rpx, 0.rpx, 0), // 外部 padding 移到内部
|
||||
width: 28.rpx,
|
||||
height: 28.rpx,
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/explain.svg',
|
||||
fit: BoxFit.cover,
|
||||
color: themeController.currentColor.sc4,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 31.rpx,
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 30.rpx, 0.rpx),
|
||||
child: Column(
|
||||
children: advices.map<Widget>((advice) {
|
||||
return AdviceComponnetWidget(
|
||||
title: advice["q"],
|
||||
description: advice["s"],
|
||||
).paddingOnly(bottom: 0.rpx); // 在每个组件下方添加间隔
|
||||
}).toList(),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
es.EasyDartModule.logger.error("AI分析绘制异常${e}");
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
}
|
||||
355
lib/pages/sleep_report/qc_report/QcBreatheStandardWidget.dart
Normal file
355
lib/pages/sleep_report/qc_report/QcBreatheStandardWidget.dart
Normal file
@@ -0,0 +1,355 @@
|
||||
import 'package:EasyDartModule/EasyDartModule.dart' as es;
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/enum/APPPackageType.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/QcTimeSeriesChart.dart';
|
||||
|
||||
class QcBreatheStandardWidget extends StatefulWidget {
|
||||
var reportData;
|
||||
QcBreatheStandardWidget({super.key, required this.reportData});
|
||||
|
||||
@override
|
||||
State<QcBreatheStandardWidget> createState() =>
|
||||
_QcBreatheStandardWidgetState();
|
||||
}
|
||||
|
||||
class _QcBreatheStandardWidgetState extends State<QcBreatheStandardWidget> {
|
||||
@override
|
||||
void setState(VoidCallback callback) {
|
||||
super.setState(callback);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
// 计算y轴的最大最小值
|
||||
(double, double) _calculateYMinMax(List<QcTimeSeriesPoint> dataPoints) {
|
||||
if (dataPoints.isEmpty) {
|
||||
return (8.0, 20.0);
|
||||
}
|
||||
|
||||
// 过滤掉无效数据点(值为-1的)
|
||||
final validPoints = dataPoints.where((point) => point.value >= 0).toList();
|
||||
|
||||
if (validPoints.isEmpty) {
|
||||
return (8.0, 20.0);
|
||||
}
|
||||
|
||||
// 找出数据中的实际最小值和最大值
|
||||
double dataMin =
|
||||
validPoints.map((point) => point.value).reduce((a, b) => a < b ? a : b);
|
||||
double dataMax =
|
||||
validPoints.map((point) => point.value).reduce((a, b) => a > b ? a : b);
|
||||
|
||||
// 计算最小值(向下取整到5的倍数)
|
||||
double yMin = (dataMin / 5).floor() * 5.0;
|
||||
// 如果最小值小于0,设为0
|
||||
if (yMin < 0) yMin = 0;
|
||||
|
||||
// 计算最大值(向上取整到5的倍数)
|
||||
double yMax = (dataMax / 5).ceil() * 5.0;
|
||||
|
||||
// 确保至少有10的差值
|
||||
if (yMax - yMin < 10) {
|
||||
yMax = yMin + 10;
|
||||
}
|
||||
|
||||
return (yMin, yMax);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
try {
|
||||
if (widget.reportData == null || widget.reportData is! Map) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
// 从reportData中获取br数据
|
||||
Map<String, dynamic> brData = widget.reportData['br'] ?? {};
|
||||
if (brData.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
// 获取呼吸数据点
|
||||
List<dynamic> dataList = brData['data'] ?? [];
|
||||
List<QcTimeSeriesPoint> dataPoints = [];
|
||||
|
||||
// 构建数据点(只保留值,不需要时间戳)
|
||||
for (int i = 0; i < dataList.length; i++) {
|
||||
dynamic value = dataList[i];
|
||||
if (value == null || value == '') {
|
||||
dataPoints.add(QcTimeSeriesPoint(-1));
|
||||
} else {
|
||||
double y = (value as num).toDouble();
|
||||
dataPoints.add(QcTimeSeriesPoint(y));
|
||||
}
|
||||
}
|
||||
|
||||
// 计算动态的y轴范围
|
||||
final (yMin, yMax) = _calculateYMinMax(dataPoints);
|
||||
|
||||
// 构建呼吸统计数据
|
||||
Map<String, dynamic> avgBreath = {
|
||||
'name': '平均呼吸'.tr,
|
||||
'value': brData['avg'].toInt() ?? 0,
|
||||
'unit': '次/分',
|
||||
};
|
||||
|
||||
Map<String, dynamic> baseBreath = {
|
||||
'name': '基础呼吸',
|
||||
'value': brData['base'].toInt() ?? 0,
|
||||
'unit': '次/分',
|
||||
};
|
||||
|
||||
Map<String, dynamic> minBreath = {
|
||||
'name': '最低呼吸',
|
||||
'value': brData['min'].toInt() ?? 0,
|
||||
'unit': '次/分',
|
||||
};
|
||||
|
||||
Map<String, dynamic> maxBreath = {
|
||||
'name': '最高呼吸',
|
||||
'value': brData['max'].toInt() ?? 0,
|
||||
'unit': '次/分',
|
||||
};
|
||||
|
||||
// 构建正常范围字符串
|
||||
String range = '';
|
||||
if (baseBreath['value'] != 0) {
|
||||
int baseValue = baseBreath['value'];
|
||||
range = '${baseValue - 3}~${baseValue + 3}';
|
||||
} else {
|
||||
range = '12~20';
|
||||
}
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc5,
|
||||
borderRadius:
|
||||
BorderRadius.circular(AppConstants().normal_container_radius),
|
||||
),
|
||||
child: Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(26.rpx, 29.rpx, 26.rpx, 45.rpx),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"呼吸数据".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().title_text_fontSize),
|
||||
),
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: Colors.white,
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
14.rpx, 10.rpx, 14.rpx, 10.rpx),
|
||||
borderRadius: 0.rpx,
|
||||
onTap: () {
|
||||
if (AppConstants().ent_type ==
|
||||
APPPackageType.MHT.code) {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
"呼吸数据是指用户在睡眠过程中呼吸的基本数据,是评估睡眠呼吸质量、筛查睡眠呼吸障碍的核心指标。"
|
||||
.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: Color(0xFFFFFFFF),
|
||||
colors: [
|
||||
Color(0XFF1592AA),
|
||||
Color(0xFF0C83A7),
|
||||
Color(0xFF006FA3)
|
||||
],
|
||||
);
|
||||
} else {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
"呼吸数据是指用户在睡眠过程中呼吸的基本数据,是评估睡眠呼吸质量、筛查睡眠呼吸障碍的核心指标。"
|
||||
.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: themeController.currentColor.sc17,
|
||||
colors: AppConstants().thNormalButton,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0, 0.rpx, 0.rpx, 0),
|
||||
width: 28.rpx,
|
||||
height: 28.rpx,
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/explain.svg',
|
||||
fit: BoxFit.cover,
|
||||
color: themeController.currentColor.sc4,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 31.rpx,
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 30.rpx, 0.rpx),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Container(
|
||||
width: 14.rpx,
|
||||
height: 14.rpx,
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc2,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 15.rpx),
|
||||
Text(
|
||||
'正常范围 '.tr + range,
|
||||
style: TextStyle(
|
||||
fontSize: AppConstants().smaller_text_fontSize,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Container(
|
||||
width: double.infinity,
|
||||
child: QcTimeSeriesChart(
|
||||
yMin: yMin,
|
||||
yMax: yMax,
|
||||
dataPoints: dataPoints,
|
||||
xSegmentCount: 11,
|
||||
baseValue: brData['base'].toDouble(), // 传入基准值
|
||||
// baseValue: 16, // 传入基准值
|
||||
baseLabel: '基准', // 可选的自定义标签
|
||||
yAxisPadding: 0,
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(
|
||||
height: 18.rpx,
|
||||
)),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 0.rpx, 0.rpx),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildBreathItem(avgBreath),
|
||||
_buildBreathItem(baseBreath),
|
||||
_buildBreathItem(minBreath),
|
||||
_buildBreathItem(maxBreath),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
es.EasyDartModule.logger.error("呼吸基准监测绘制异常${e}");
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildBreathItem(Map<String, dynamic> data) {
|
||||
return Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 4.rpx, vertical: 4.rpx),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
"${data['name']}",
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 4.rpx),
|
||||
Flexible(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Flexible(
|
||||
fit: FlexFit.loose,
|
||||
child: Text(
|
||||
"${data['value']}",
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc2,
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 4.rpx),
|
||||
Flexible(
|
||||
fit: FlexFit.loose,
|
||||
child: Text(
|
||||
"${data['unit']}",
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().small_text_fontSize,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
208
lib/pages/sleep_report/qc_report/QcDiseasePercentsWidget.dart
Normal file
208
lib/pages/sleep_report/qc_report/QcDiseasePercentsWidget.dart
Normal file
@@ -0,0 +1,208 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/enum/APPPackageType.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/HorizontalBarChart.dart';
|
||||
import 'package:EasyDartModule/EasyDartModule.dart' as es;
|
||||
|
||||
class QcDiseasePercentsWidget extends StatefulWidget {
|
||||
var reportData; // 改为更通用的名称
|
||||
QcDiseasePercentsWidget({super.key, required this.reportData});
|
||||
|
||||
@override
|
||||
State<QcDiseasePercentsWidget> createState() =>
|
||||
_QcDiseasePercentsWidgetState();
|
||||
}
|
||||
|
||||
class _QcDiseasePercentsWidgetState extends State<QcDiseasePercentsWidget> {
|
||||
@override
|
||||
void setState(VoidCallback callback) {
|
||||
super.setState(callback);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
try {
|
||||
if (widget.reportData == null) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
// 从reportData中获取mbzs数据
|
||||
List mbzsData = widget.reportData['mbzs'] ?? [];
|
||||
if (mbzsData.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
var showLabel = convertDiseaseData(mbzsData);
|
||||
|
||||
// 如果没有有效数据,不显示组件
|
||||
if (showLabel.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc5,
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppConstants().normal_container_radius), // 你可以按需调整圆角半径
|
||||
),
|
||||
child: Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(26.rpx, 29.rpx, 26.rpx, 45.rpx),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"慢性病风险指数".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().title_text_fontSize),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: Colors.white, // 或设置为你需要的水波纹颜色
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
14.rpx, 10.rpx, 14.rpx, 10.rpx), //
|
||||
borderRadius: 0.rpx, // 圆形点击区域
|
||||
onTap: () {
|
||||
// 你的点击逻辑
|
||||
|
||||
if (AppConstants().ent_type ==
|
||||
APPPackageType.MHT.code) {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
// "心理健康评估介绍".tr,
|
||||
"慢性病风险指数是通过整合个体的生理指标、生活方式等多维度数据,构建的量化评估模型,用于预测用户未来患慢性非传染性疾病(如高血压、糖尿病、冠心病、癌症等)的风险概率。"
|
||||
.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: Color(0xFFFFFFFF),
|
||||
colors: [
|
||||
Color(0XFF1592AA),
|
||||
Color(0xFF0C83A7),
|
||||
Color(0xFF006FA3)
|
||||
],
|
||||
);
|
||||
} else {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
"慢性病风险指数是通过整合个体的生理指标、生活方式等多维度数据,构建的量化评估模型,用于预测用户未来患慢性非传染性疾病(如高血压、糖尿病、冠心病、癌症等)的风险概率。"
|
||||
.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: themeController.currentColor.sc17,
|
||||
colors: AppConstants().thNormalButton,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0, 0.rpx, 0.rpx, 0), // 外部 padding 移到内部
|
||||
width: 28.rpx,
|
||||
height: 28.rpx,
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/explain.svg',
|
||||
fit: BoxFit.cover,
|
||||
color: themeController.currentColor.sc4,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 34.rpx,
|
||||
),
|
||||
Container(
|
||||
child: HorizontalBarChart(
|
||||
showLabel: showLabel,
|
||||
showPercent: true,
|
||||
showRangeBackground: true),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
es.EasyDartModule.logger.error("疾病绘制异常${e}");
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> convertDiseaseData(List data) {
|
||||
return data.asMap().entries.map<Map<String, dynamic>>((entry) {
|
||||
final index = entry.key;
|
||||
final item = entry.value;
|
||||
|
||||
// 根据名称生成一个简单的ID(如果没有id字段)
|
||||
String id = 'disease_$index';
|
||||
if (item['name'] != null) {
|
||||
// 根据名称生成一个简单的哈希值作为id
|
||||
id = '${item['name']}_$index';
|
||||
}
|
||||
|
||||
// 根据值的大小决定颜色深浅
|
||||
Color barColor = _getColorByValue(item['val'] ?? 0);
|
||||
|
||||
return {
|
||||
"key": id,
|
||||
"name": item["name"] ?? '未知指标',
|
||||
"color": barColor,
|
||||
"percent": item["val"] ?? 0, // 注意这里从val取值
|
||||
"explain":
|
||||
(item["tips"] != null && (item["tips"] as String).trim().isNotEmpty)
|
||||
? item["tips"]
|
||||
: '${item["val"] ?? 0}%的风险概率',
|
||||
};
|
||||
}).toList();
|
||||
}
|
||||
|
||||
// 根据风险值获取对应的颜色
|
||||
Color _getColorByValue(int value) {
|
||||
if (value < 30) {
|
||||
return stringToColor("#00C1AA"); // 低风险 - 绿色
|
||||
} else if (value < 60) {
|
||||
return stringToColor("#FFB800"); // 中风险 - 黄色
|
||||
} else if (value < 80) {
|
||||
return stringToColor("#FF7159"); // 高风险 - 橙色
|
||||
} else {
|
||||
return stringToColor("#FF4D4F"); // 极高风险 - 红色
|
||||
}
|
||||
}
|
||||
}
|
||||
215
lib/pages/sleep_report/qc_report/QcHeartHealthWidget.dart
Normal file
215
lib/pages/sleep_report/qc_report/QcHeartHealthWidget.dart
Normal file
@@ -0,0 +1,215 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/enum/APPPackageType.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/FatigueCircleIndicator.dart';
|
||||
import 'package:EasyDartModule/EasyDartModule.dart' as es;
|
||||
|
||||
class QcHeartHealthWidget extends StatefulWidget {
|
||||
var reportData; // 改为更通用的名称
|
||||
QcHeartHealthWidget({super.key, required this.reportData});
|
||||
|
||||
@override
|
||||
State<QcHeartHealthWidget> createState() => _QcHeartHealthWidgetState();
|
||||
}
|
||||
|
||||
class _QcHeartHealthWidgetState extends State<QcHeartHealthWidget> {
|
||||
@override
|
||||
void setState(VoidCallback callback) {
|
||||
super.setState(callback);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
try {
|
||||
if (widget.reportData == null) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
// 从reportData中获取xljk数据
|
||||
List xljkData = widget.reportData['xljk'] ?? [];
|
||||
if (xljkData.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
var showLabel = convertMentalHealthData(xljkData);
|
||||
|
||||
// 如果没有有效数据,不显示组件
|
||||
if (showLabel.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc5,
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppConstants().normal_container_radius), // 你可以按需调整圆角半径
|
||||
),
|
||||
child: Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(26.rpx, 29.rpx, 26.rpx, 0.rpx),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"心理健康评估".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().title_text_fontSize),
|
||||
),
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: Colors.white, // 或设置为你需要的水波纹颜色
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
14.rpx, 10.rpx, 14.rpx, 10.rpx), //
|
||||
borderRadius: 0.rpx, // 圆形点击区域
|
||||
onTap: () {
|
||||
if (AppConstants().ent_type ==
|
||||
APPPackageType.MHT.code) {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
"心率健康评估主要通过用户睡眠报告中的时间点、体征数据及HRV数据等信息,来判断其心理健康水平、疲劳程度。"
|
||||
.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: Color(0xFFFFFFFF),
|
||||
colors: [
|
||||
Color(0XFF1592AA),
|
||||
Color(0xFF0C83A7),
|
||||
Color(0xFF006FA3)
|
||||
],
|
||||
);
|
||||
} else {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
"心率健康评估主要通过用户睡眠报告中的时间点、体征数据及HRV数据等信息,来判断其心理健康水平、疲劳程度。"
|
||||
.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: themeController.currentColor.sc17,
|
||||
colors: AppConstants().thNormalButton,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0, 0.rpx, 0.rpx, 0), // 外部 padding 移到内部
|
||||
width: 28.rpx,
|
||||
height: 28.rpx,
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/explain.svg',
|
||||
fit: BoxFit.cover,
|
||||
color: themeController.currentColor.sc4,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 104.rpx,
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 0.rpx, 30.rpx, 0.rpx),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
if (showLabel.length > 0)
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FatigueCircleIndicator(
|
||||
data: showLabel[0],
|
||||
),
|
||||
),
|
||||
if (showLabel.length > 1)
|
||||
Flexible(
|
||||
flex: 1,
|
||||
child: FatigueCircleIndicator(
|
||||
data: showLabel[1],
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(
|
||||
width: 110.rpx,
|
||||
)),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 72.rpx,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
es.EasyDartModule.logger.error("心理健康绘制异常${e}");
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> convertMentalHealthData(List data) {
|
||||
return data.map<Map<String, dynamic>>((item) {
|
||||
final String? colorStr = item['color'];
|
||||
final int value = item['val'].toInt() ?? 0; // 注意这里从val取值
|
||||
final String explain =
|
||||
(item['tips'] != null && (item['tips'] as String).trim().isNotEmpty)
|
||||
? item['tips']
|
||||
: '未知数据'.tr;
|
||||
|
||||
// 根据value值确定level描述
|
||||
String level = '';
|
||||
if (value <= 30) {
|
||||
level = '较低';
|
||||
} else if (value <= 60) {
|
||||
level = '正常';
|
||||
} else if (value <= 80) {
|
||||
level = '偏高';
|
||||
} else {
|
||||
level = '严重';
|
||||
}
|
||||
|
||||
return {
|
||||
'name': item['name'] ?? '未知指标',
|
||||
'color': colorStr != null && colorStr.isNotEmpty
|
||||
? stringToColor(colorStr)
|
||||
: stringToColor("#00C1AA"), // 默认颜色
|
||||
'percent': value,
|
||||
'explain': level, // 使用计算出的level
|
||||
"bottomColor": stringToColor("#393D49"),
|
||||
};
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
364
lib/pages/sleep_report/qc_report/QcHeartRateStandardWidget.dart
Normal file
364
lib/pages/sleep_report/qc_report/QcHeartRateStandardWidget.dart
Normal file
@@ -0,0 +1,364 @@
|
||||
import 'package:EasyDartModule/EasyDartModule.dart' as es;
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/enum/APPPackageType.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/QcTimeSeriesChart.dart';
|
||||
|
||||
//心率基准
|
||||
class QcHeartRateStandardWidget extends StatefulWidget {
|
||||
var reportData;
|
||||
QcHeartRateStandardWidget({super.key, required this.reportData});
|
||||
|
||||
@override
|
||||
State<QcHeartRateStandardWidget> createState() =>
|
||||
_QcHeartRateStandardWidgetState();
|
||||
}
|
||||
|
||||
class _QcHeartRateStandardWidgetState extends State<QcHeartRateStandardWidget> {
|
||||
@override
|
||||
void setState(VoidCallback callback) {
|
||||
super.setState(callback);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
// 计算y轴的最大最小值
|
||||
(double, double) _calculateYMinMax(List<QcTimeSeriesPoint> dataPoints) {
|
||||
if (dataPoints.isEmpty) {
|
||||
return (50.0, 150.0);
|
||||
}
|
||||
|
||||
// 过滤掉无效数据点(值为-1的)
|
||||
final validPoints = dataPoints.where((point) => point.value >= 0).toList();
|
||||
|
||||
if (validPoints.isEmpty) {
|
||||
return (50.0, 150.0);
|
||||
}
|
||||
|
||||
// 找出数据中的实际最小值和最大值
|
||||
double dataMin =
|
||||
validPoints.map((point) => point.value).reduce((a, b) => a < b ? a : b);
|
||||
double dataMax =
|
||||
validPoints.map((point) => point.value).reduce((a, b) => a > b ? a : b);
|
||||
|
||||
// 计算最小值(向下取整到10的倍数)
|
||||
double yMin = (dataMin / 10).floor() * 10.0;
|
||||
// 如果最小值小于0,设为0
|
||||
if (yMin < 0) yMin = 0;
|
||||
|
||||
// 计算最大值(向上取整到10的倍数)
|
||||
double yMax = (dataMax / 10).ceil() * 10.0;
|
||||
|
||||
// 确保至少有20的差值
|
||||
if (yMax - yMin < 20) {
|
||||
yMax = yMin + 20;
|
||||
}
|
||||
|
||||
return (yMin, yMax);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
try {
|
||||
if (widget.reportData == null || widget.reportData is! Map) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
// 从reportData中获取hr数据
|
||||
Map<String, dynamic> hrData = widget.reportData['hr'] ?? {};
|
||||
if (hrData.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
// 获取心率数据点
|
||||
List<dynamic> dataList = hrData['data'] ?? [];
|
||||
List<QcTimeSeriesPoint> dataPoints = [];
|
||||
|
||||
// 构建数据点(只保留值,不需要时间戳)
|
||||
for (int i = 0; i < dataList.length; i++) {
|
||||
dynamic value = dataList[i];
|
||||
if (value == null || value == '') {
|
||||
dataPoints.add(QcTimeSeriesPoint(-1));
|
||||
} else {
|
||||
double y = (value as num).toDouble();
|
||||
dataPoints.add(QcTimeSeriesPoint(y));
|
||||
}
|
||||
}
|
||||
|
||||
// 计算动态的y轴范围
|
||||
final (yMin, yMax) = _calculateYMinMax(dataPoints);
|
||||
|
||||
// 构建心率统计数据
|
||||
Map<String, dynamic> avgHeartRate = {
|
||||
'name': '平均心率'.tr,
|
||||
'value': hrData['avg'].toInt() ?? 0,
|
||||
'unit': '次/分'.tr,
|
||||
};
|
||||
|
||||
Map<String, dynamic> baseHeartRate = {
|
||||
'name': '基准心率'.tr,
|
||||
'value': hrData['base'].toInt() ?? 0,
|
||||
'unit': '次/分'.tr,
|
||||
};
|
||||
|
||||
Map<String, dynamic> minHeartRate = {
|
||||
'name': '最低心率'.tr,
|
||||
'value': hrData['min'].toInt() ?? 0,
|
||||
'unit': '次/分'.tr,
|
||||
};
|
||||
|
||||
Map<String, dynamic> maxHeartRate = {
|
||||
'name': '最高心率'.tr,
|
||||
'value': hrData['max'].toInt() ?? 0,
|
||||
'unit': '次/分'.tr,
|
||||
};
|
||||
|
||||
// 构建正常范围字符串
|
||||
String range = '';
|
||||
if (baseHeartRate['value'] != 0) {
|
||||
int baseValue = baseHeartRate['value'];
|
||||
range = '${baseValue - 10}~${baseValue + 10}';
|
||||
} else {
|
||||
range = '60~100';
|
||||
}
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc5,
|
||||
borderRadius:
|
||||
BorderRadius.circular(AppConstants().normal_container_radius),
|
||||
),
|
||||
child: Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(26.rpx, 29.rpx, 26.rpx, 45.rpx),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"心率数据".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().title_text_fontSize),
|
||||
),
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: Colors.white,
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
14.rpx, 10.rpx, 14.rpx, 10.rpx),
|
||||
borderRadius: 0.rpx,
|
||||
onTap: () {
|
||||
if (AppConstants().ent_type ==
|
||||
APPPackageType.MHT.code) {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
"心率数据是指用户在睡眠过程中基本心率数据,可初步判断睡眠中的心血管负荷及自主神经功能状态,为睡眠健康评估提供重要依据。"
|
||||
.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: Color(0xFFFFFFFF),
|
||||
colors: [
|
||||
Color(0XFF1592AA),
|
||||
Color(0xFF0C83A7),
|
||||
Color(0xFF006FA3)
|
||||
],
|
||||
);
|
||||
} else {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
"心率数据是指用户在睡眠过程中基本心率数据,可初步判断睡眠中的心血管负荷及自主神经功能状态,为睡眠健康评估提供重要依据。"
|
||||
.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: themeController.currentColor.sc17,
|
||||
colors: AppConstants().thNormalButton,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0, 0.rpx, 0.rpx, 0),
|
||||
width: 28.rpx,
|
||||
height: 28.rpx,
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/explain.svg',
|
||||
fit: BoxFit.cover,
|
||||
color: themeController.currentColor.sc4,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 31.rpx,
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 0.rpx, 0.rpx),
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0.rpx, 0.rpx, 30.rpx, 0.rpx),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Container(
|
||||
width: 14.rpx,
|
||||
height: 14.rpx,
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc2,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 15.rpx),
|
||||
Text(
|
||||
'正常范围 '.tr + range,
|
||||
style: TextStyle(
|
||||
fontSize: AppConstants().smaller_text_fontSize,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0.rpx, 0.rpx, 30.rpx, 0.rpx),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
child: QcTimeSeriesChart(
|
||||
yMin: yMin,
|
||||
yMax: yMax,
|
||||
dataPoints: dataPoints,
|
||||
xSegmentCount: 11,
|
||||
baseValue: hrData['base'].toDouble(), // 传入基准值
|
||||
// baseValue: 65, // 传入基准值
|
||||
baseLabel: '基准', // 可选的自定义标签
|
||||
yAxisPadding: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0.rpx, 0.rpx, 0.rpx, 0.rpx),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildHeartRateItem(avgHeartRate),
|
||||
_buildHeartRateItem(baseHeartRate),
|
||||
_buildHeartRateItem(minHeartRate),
|
||||
_buildHeartRateItem(maxHeartRate),
|
||||
],
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(
|
||||
height: 18.rpx,
|
||||
)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
es.EasyDartModule.logger.error("心率基准绘制异常${e}");
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildHeartRateItem(Map<String, dynamic> data) {
|
||||
return Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 4.rpx, vertical: 4.rpx),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
"${data['name']}",
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 4.rpx),
|
||||
Flexible(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Flexible(
|
||||
fit: FlexFit.loose,
|
||||
child: Text(
|
||||
"${data['value']}",
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc2,
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 6.rpx),
|
||||
Flexible(
|
||||
fit: FlexFit.loose,
|
||||
child: Text(
|
||||
"${data['unit']}",
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().small_text_fontSize,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
238
lib/pages/sleep_report/qc_report/QcPiLaoZhiShuPercentWidget.dart
Normal file
238
lib/pages/sleep_report/qc_report/QcPiLaoZhiShuPercentWidget.dart
Normal file
@@ -0,0 +1,238 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/enum/APPPackageType.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/StatusBarWithIndicator.dart';
|
||||
import 'package:EasyDartModule/EasyDartModule.dart' as es;
|
||||
|
||||
class QcPiLaoZhiShuPercentWidget extends StatefulWidget {
|
||||
var reportData; // 改为更通用的名称
|
||||
QcPiLaoZhiShuPercentWidget({super.key, required this.reportData});
|
||||
|
||||
@override
|
||||
State<QcPiLaoZhiShuPercentWidget> createState() =>
|
||||
_PiLaoZhiShuPercentWidgetState();
|
||||
}
|
||||
|
||||
class _PiLaoZhiShuPercentWidgetState extends State<QcPiLaoZhiShuPercentWidget> {
|
||||
@override
|
||||
void setState(VoidCallback callback) {
|
||||
super.setState(callback);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
try {
|
||||
if (widget.reportData == null) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
// 从reportData中获取plzs数据
|
||||
Map<String, dynamic> plzsData = widget.reportData['plzs'] ?? {};
|
||||
if (plzsData.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
int level = plzsData['level'] ?? 0;
|
||||
|
||||
// 根据level值确定显示内容和颜色
|
||||
String levelText = '';
|
||||
Color levelColor = themeController.currentColor.sc3;
|
||||
|
||||
switch (level) {
|
||||
case 0:
|
||||
levelText = '正常';
|
||||
levelColor = Colors.green;
|
||||
break;
|
||||
case 1:
|
||||
levelText = '轻度疲劳';
|
||||
levelColor = Colors.orange;
|
||||
break;
|
||||
case 2:
|
||||
levelText = '中度疲劳';
|
||||
levelColor = Colors.red;
|
||||
break;
|
||||
case 3:
|
||||
levelText = '重度疲劳';
|
||||
levelColor = Colors.red;
|
||||
break;
|
||||
default:
|
||||
levelText = '未知';
|
||||
levelColor = Colors.grey;
|
||||
}
|
||||
|
||||
// 构建StatusBarWithIndicator需要的数据格式
|
||||
List<Map<String, dynamic>> showLabel = [
|
||||
{
|
||||
'key': 0,
|
||||
'name': '正常',
|
||||
'color': Colors.green,
|
||||
},
|
||||
{
|
||||
'key': 1,
|
||||
'name': '轻度疲劳',
|
||||
'color': Colors.orange,
|
||||
},
|
||||
{
|
||||
'key': 2,
|
||||
'name': '中度疲劳',
|
||||
'color': Colors.red,
|
||||
},
|
||||
{
|
||||
'key': 3,
|
||||
'name': '重度疲劳',
|
||||
'color': Colors.red,
|
||||
},
|
||||
];
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc5,
|
||||
borderRadius:
|
||||
BorderRadius.circular(AppConstants().normal_container_radius),
|
||||
),
|
||||
child: Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(26.rpx, 29.rpx, 26.rpx, 45.rpx),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"疲劳指数".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().title_text_fontSize),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: Colors.white,
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
14.rpx, 10.rpx, 14.rpx, 10.rpx),
|
||||
borderRadius: 0.rpx,
|
||||
onTap: () {
|
||||
if (AppConstants().ent_type ==
|
||||
APPPackageType.MHT.code) {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
"疲劳指数是评估人体疲劳程度的重要指标,反映身体和精神状态的疲劳水平。".tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: Color(0xFFFFFFFF),
|
||||
colors: [
|
||||
Color(0XFF1592AA),
|
||||
Color(0xFF0C83A7),
|
||||
Color(0xFF006FA3)
|
||||
],
|
||||
);
|
||||
} else {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
"疲劳指数是评估人体疲劳程度的重要指标,反映身体和精神状态的疲劳水平。".tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: themeController.currentColor.sc17,
|
||||
colors: AppConstants().thNormalButton,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0, 0.rpx, 0.rpx, 0),
|
||||
width: 28.rpx,
|
||||
height: 28.rpx,
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/explain.svg',
|
||||
fit: BoxFit.cover,
|
||||
color: themeController.currentColor.sc4,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 83.rpx,
|
||||
),
|
||||
// 显示level值的文本
|
||||
// Padding(
|
||||
// padding: EdgeInsetsDirectional.fromSTEB(30.rpx, 0.rpx, 30.rpx, 30.rpx),
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: [
|
||||
// Text(
|
||||
// '当前状态:',
|
||||
// style: TextStyle(
|
||||
// fontSize: 30.rpx,
|
||||
// color: themeController.currentColor.sc4,
|
||||
// ),
|
||||
// ),
|
||||
// Text(
|
||||
// levelText,
|
||||
// style: TextStyle(
|
||||
// fontSize: 36.rpx,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// color: levelColor,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 0.rpx, 30.rpx, 0.rpx),
|
||||
child: StatusBarWithIndicator(
|
||||
selectKey: level, // 使用level值作为选中的key
|
||||
showLabel: showLabel,
|
||||
currentValueText: "当前属于".tr,
|
||||
showCurrentValue: true,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 56.rpx,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
es.EasyDartModule.logger.error("疲劳指数绘制异常${e}");
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/enum/APPPackageType.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/StatusBarWithIndicator.dart';
|
||||
import 'package:EasyDartModule/EasyDartModule.dart' as es;
|
||||
|
||||
class QcZiZhuShenJingPercentWidget extends StatefulWidget {
|
||||
var reportData; // 改为更通用的名称
|
||||
QcZiZhuShenJingPercentWidget({super.key, required this.reportData});
|
||||
|
||||
@override
|
||||
State<QcZiZhuShenJingPercentWidget> createState() =>
|
||||
_ZiZhuShenJingPercentWidgetState();
|
||||
}
|
||||
|
||||
class _ZiZhuShenJingPercentWidgetState
|
||||
extends State<QcZiZhuShenJingPercentWidget> {
|
||||
@override
|
||||
void setState(VoidCallback callback) {
|
||||
super.setState(callback);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
try {
|
||||
if (widget.reportData == null) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
// 从reportData中获取zzsjphzs数据
|
||||
Map<String, dynamic> zzsjphzsData = widget.reportData['zzsjphzs'] ?? {};
|
||||
if (zzsjphzsData.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
int level = zzsjphzsData['level'] ?? 0;
|
||||
|
||||
// 根据level值确定显示内容和颜色
|
||||
String levelText = '';
|
||||
Color levelColor = themeController.currentColor.sc3;
|
||||
|
||||
switch (level) {
|
||||
case 0:
|
||||
levelText = '正常';
|
||||
levelColor = Colors.green;
|
||||
break;
|
||||
case 1:
|
||||
levelText = '轻度失衡';
|
||||
levelColor = Colors.orange;
|
||||
break;
|
||||
case 2:
|
||||
levelText = '中度失衡';
|
||||
levelColor = Colors.red;
|
||||
break;
|
||||
case 3:
|
||||
levelText = '重度失衡';
|
||||
levelColor = Colors.red;
|
||||
break;
|
||||
default:
|
||||
levelText = '未知';
|
||||
levelColor = Colors.grey;
|
||||
}
|
||||
|
||||
// 构建StatusBarWithIndicator需要的数据格式
|
||||
List<Map<String, dynamic>> showLabel = [
|
||||
{
|
||||
'key': 0,
|
||||
'name': '正常',
|
||||
'color': Colors.green,
|
||||
},
|
||||
{
|
||||
'key': 1,
|
||||
'name': '轻度失衡',
|
||||
'color': Colors.orange,
|
||||
},
|
||||
{
|
||||
'key': 2,
|
||||
'name': '中度失衡',
|
||||
'color': Colors.red,
|
||||
},
|
||||
{
|
||||
'key': 3,
|
||||
'name': '重度失衡',
|
||||
'color': Colors.red,
|
||||
},
|
||||
];
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc5,
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppConstants().normal_container_radius), // 你可以按需调整圆角半径
|
||||
),
|
||||
child: Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(26.rpx, 29.rpx, 26.rpx, 45.rpx),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"自主神经平衡指数".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().title_text_fontSize),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: Colors.white, // 或设置为你需要的水波纹颜色
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
14.rpx, 10.rpx, 14.rpx, 10.rpx), //
|
||||
borderRadius: 0.rpx, // 圆形点击区域
|
||||
onTap: () {
|
||||
if (AppConstants().ent_type ==
|
||||
APPPackageType.MHT.code) {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
// "心理健康评估介绍".tr,
|
||||
"自主神经平衡指数 是评估人体自主神经系统(ANS)功能状态的重要指标,主要反映交感神经和副交感神经的活性平衡关系。"
|
||||
.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: Color(0xFFFFFFFF),
|
||||
colors: [
|
||||
Color(0XFF1592AA),
|
||||
Color(0xFF0C83A7),
|
||||
Color(0xFF006FA3)
|
||||
],
|
||||
);
|
||||
} else {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
"自主神经平衡指数 是评估人体自主神经系统(ANS)功能状态的重要指标,主要反映交感神经和副交感神经的活性平衡关系。"
|
||||
.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: themeController.currentColor.sc17,
|
||||
colors: AppConstants().thNormalButton,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0, 0.rpx, 0.rpx, 0), // 外部 padding 移到内部
|
||||
width: 28.rpx,
|
||||
height: 28.rpx,
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/explain.svg',
|
||||
fit: BoxFit.cover,
|
||||
color: themeController.currentColor.sc4,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 83.rpx,
|
||||
),
|
||||
// 显示level值的文本
|
||||
// Padding(
|
||||
// padding: EdgeInsetsDirectional.fromSTEB(30.rpx, 0.rpx, 30.rpx, 30.rpx),
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: [
|
||||
// Text(
|
||||
// '当前状态:',
|
||||
// style: TextStyle(
|
||||
// fontSize: 30.rpx,
|
||||
// color: themeController.currentColor.sc4,
|
||||
// ),
|
||||
// ),
|
||||
// Text(
|
||||
// levelText,
|
||||
// style: TextStyle(
|
||||
// fontSize: 36.rpx,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// color: levelColor,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 0.rpx, 30.rpx, 0.rpx),
|
||||
child: StatusBarWithIndicator(
|
||||
selectKey: level, // 使用level值作为选中的key
|
||||
showLabel: showLabel,
|
||||
currentValueText: "当前属于".tr,
|
||||
showCurrentValue: true,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 56.rpx,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
es.EasyDartModule.logger.error("自主神经平衡指数绘制异常${e}");
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
}
|
||||
380
lib/pages/sleep_report/qc_report/qc_heart_change.dart
Normal file
380
lib/pages/sleep_report/qc_report/qc_heart_change.dart
Normal file
@@ -0,0 +1,380 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/enum/APPPackageType.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/DataShowWidget.dart';
|
||||
import 'package:EasyDartModule/EasyDartModule.dart' as es;
|
||||
|
||||
class QcHeartChangeWidget extends StatefulWidget {
|
||||
var reportData; // 改为更通用的名称
|
||||
QcHeartChangeWidget({super.key, required this.reportData});
|
||||
|
||||
@override
|
||||
State<QcHeartChangeWidget> createState() => _QcHeartChangeWidgetState();
|
||||
}
|
||||
|
||||
class _QcHeartChangeWidgetState extends State<QcHeartChangeWidget> {
|
||||
@override
|
||||
void setState(VoidCallback callback) {
|
||||
super.setState(callback);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
try {
|
||||
if (widget.reportData == null) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
// 从reportData中获取hrv数据
|
||||
List hrvData = widget.reportData['hrv'] ?? [];
|
||||
if (hrvData.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> data = transformHrvData(hrvData);
|
||||
|
||||
// 获取人员姓名用于显示
|
||||
String personName = widget.reportData['person']?['name'] ?? '--';
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc5,
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppConstants().normal_container_radius), // 你可以按需调整圆角半径
|
||||
),
|
||||
child: Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(30.rpx, 29.rpx, 30.rpx, 45.rpx),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"心率变异性(HRV)".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().title_text_fontSize),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: Colors.white, // 或设置为你需要的水波纹颜色
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
14.rpx, 10.rpx, 14.rpx, 10.rpx), //
|
||||
borderRadius: 0.rpx, // 圆形点击区域
|
||||
onTap: () {
|
||||
if (AppConstants().ent_type ==
|
||||
APPPackageType.MHT.code) {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
// "心率变异性(HRV)介绍".tr,
|
||||
"心率变异性(HRV)是指心脏每次跳动间隔时间的差异程度,反映自主神经系统(交感神经和副交感神经)对心脏的调节能力,是评估心血管健康和压力状态的重要指标。"
|
||||
.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: Color(0xFFFFFFFF),
|
||||
colors: [
|
||||
Color(0XFF1592AA),
|
||||
Color(0xFF0C83A7),
|
||||
Color(0xFF006FA3)
|
||||
],
|
||||
);
|
||||
} else {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
"心率变异性(HRV)是指心脏每次跳动间隔时间的差异程度,反映自主神经系统(交感神经和副交感神经)对心脏的调节能力,是评估心血管健康和压力状态的重要指标。"
|
||||
.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: themeController.currentColor.sc17,
|
||||
colors: AppConstants().thNormalButton,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0, 0.rpx, 0.rpx, 0), // 外部 padding 移到内部
|
||||
width: 28.rpx,
|
||||
height: 28.rpx,
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/explain.svg',
|
||||
fit: BoxFit.cover,
|
||||
color: themeController.currentColor.sc4,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 31.rpx,
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 0.rpx, 0.rpx),
|
||||
child: Column(
|
||||
children: [
|
||||
DataShowWidget(
|
||||
alignment: MainAxisAlignment.center,
|
||||
widget1: Text(
|
||||
"名称".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc4,
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
),
|
||||
),
|
||||
widget2: Text(
|
||||
"测量值".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc4,
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
),
|
||||
),
|
||||
widget3: Text(
|
||||
"参考范围".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc4,
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
),
|
||||
),
|
||||
widget4: Text(
|
||||
"趋势".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc4,
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
Column(
|
||||
children: data.map<Widget>((data) {
|
||||
return DataShowWidget(
|
||||
alignment: MainAxisAlignment.center,
|
||||
widget1: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(
|
||||
'${data['name']}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize:
|
||||
AppConstants().normal_text_fontSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: Colors.white,
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
14.rpx, 14.rpx, 14.rpx, 14.rpx),
|
||||
borderRadius: 0.rpx,
|
||||
onTap: () {
|
||||
// Get.toNamed("/deviceShareListPage", arguments: explain);
|
||||
if (AppConstants().ent_type ==
|
||||
APPPackageType.MHT) {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
'${data['desc']}',
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: Color(0xFFFFFFFF),
|
||||
colors: [
|
||||
Color(0XFF1592AA),
|
||||
Color(0xFF0C83A7),
|
||||
Color(0xFF006FA3)
|
||||
],
|
||||
);
|
||||
} else {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
'${data['desc']}',
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: themeController
|
||||
.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor:
|
||||
themeController.currentColor.sc17,
|
||||
colors: AppConstants().thNormalButton,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: SizedBox(
|
||||
width: 17.rpx,
|
||||
height: 17.rpx,
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/question.svg',
|
||||
fit: BoxFit.cover,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
widget2: Text(
|
||||
'${data['value']}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color:
|
||||
getColorByRange(data['value'], data['range']),
|
||||
// color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
),
|
||||
),
|
||||
widget3: Text(
|
||||
'${data['range']}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
),
|
||||
),
|
||||
widget4: data['change'] == 0
|
||||
? Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0, 0.rpx, 0, 0),
|
||||
child: Container(
|
||||
width: 22.rpx,
|
||||
height: 22.rpx,
|
||||
decoration: BoxDecoration(),
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/score_up.svg',
|
||||
// fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
)
|
||||
: data['change'] == 1
|
||||
? Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0, 0.rpx, 0, 0),
|
||||
child: Container(
|
||||
width: 22.rpx,
|
||||
height: 22.rpx,
|
||||
decoration: BoxDecoration(),
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/score_down.svg',
|
||||
// fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0, 0.rpx, 0, 0),
|
||||
child: Container(
|
||||
width: 22.rpx,
|
||||
height: 22.rpx,
|
||||
decoration: BoxDecoration(),
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/score_equal.svg',
|
||||
// fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
),
|
||||
).paddingOnly(bottom: 0.rpx); // 在每个组件下方添加间隔
|
||||
}).toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
es.EasyDartModule.logger.error("心率变化绘制异常${e}");
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> transformHrvData(List<dynamic> originalData) {
|
||||
return originalData.map((item) {
|
||||
return {
|
||||
"name": item["name"] ?? "未知指标".tr,
|
||||
"value":
|
||||
(item["val"] is num) ? item["val"].toDouble() : 0.0, // 注意这里从val取值
|
||||
"range": item["range"] ?? "0-0",
|
||||
"change": item["trend"] ?? 0, // 如果没有trend字段,默认为0
|
||||
"desc": item["tips"]?.toString().isNotEmpty == true
|
||||
? item["tips"].toString()
|
||||
: "心率变异性(HRV)是指心脏每次跳动间隔时间的差异程度,反映自主神经系统对心脏的调节能力。".tr
|
||||
};
|
||||
}).toList();
|
||||
}
|
||||
|
||||
getColorByRange(double value, String? range) {
|
||||
try {
|
||||
// 1. 空、"-"、null 都直接返回默认颜色
|
||||
if (range == null || range.toString().isEmpty || range == "-") {
|
||||
return themeController.currentColor.sc3;
|
||||
}
|
||||
// 2. 拆分范围,例如 "70-150"
|
||||
final parts = range.split('-');
|
||||
if (parts.length != 2) {
|
||||
return themeController.currentColor.sc3; // 格式不对直接默认
|
||||
}
|
||||
|
||||
final min = int.parse(parts[0].trim());
|
||||
final max = int.parse(parts[1].trim());
|
||||
|
||||
// 3. 判断是否在范围内
|
||||
if (value < min || value > max) {
|
||||
// 不在范围 → 返回 danger 色
|
||||
return themeController.currentColor.sc9;
|
||||
}
|
||||
|
||||
// 在范围 → 正常色
|
||||
return themeController.currentColor.sc3;
|
||||
} catch (e) {
|
||||
// 任意解析错误都回默认
|
||||
return themeController.currentColor.sc3;
|
||||
}
|
||||
}
|
||||
}
|
||||
323
lib/pages/sleep_report/qc_report/qc_heart_point.dart
Normal file
323
lib/pages/sleep_report/qc_report/qc_heart_point.dart
Normal file
@@ -0,0 +1,323 @@
|
||||
import 'package:EasyDartModule/EasyDartModule.dart' as es;
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/enum/APPPackageType.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/ScatterPlotChart.dart';
|
||||
|
||||
class QcHeartPointWidget extends StatefulWidget {
|
||||
var reportData; // 改为更通用的名称
|
||||
QcHeartPointWidget({super.key, required this.reportData});
|
||||
|
||||
@override
|
||||
State<QcHeartPointWidget> createState() => _QcHeartPointWidgetState();
|
||||
}
|
||||
|
||||
class _QcHeartPointWidgetState extends State<QcHeartPointWidget> {
|
||||
@override
|
||||
void setState(VoidCallback callback) {
|
||||
super.setState(callback);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
try {
|
||||
if (widget.reportData == null) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
// 从reportData中获取hrs数据
|
||||
List hrsData = widget.reportData['hrs'] ?? [];
|
||||
if (hrsData.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
double maxX = 0;
|
||||
double maxY = 0;
|
||||
|
||||
List<ScatterSpot> data = [];
|
||||
|
||||
try {
|
||||
data = hrsData.map<ScatterSpot>((item) {
|
||||
double x = (item['x'] ?? 0).toDouble(); // 注意这里从x取值
|
||||
double y = (item['y'] ?? 0).toDouble(); // 注意这里从y取值
|
||||
if (x > maxX) maxX = x;
|
||||
if (y > maxY) maxY = y;
|
||||
return ScatterSpot(x, y);
|
||||
}).toList();
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc5,
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppConstants().normal_container_radius), // 你可以按需调整圆角半径
|
||||
),
|
||||
child: Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(26.rpx, 29.rpx, 26.rpx, 45.rpx),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"心率散点图".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().title_text_fontSize),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
),
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: Colors.white, // 或设置为你需要的水波纹颜色
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
14.rpx, 10.rpx, 14.rpx, 10.rpx), //
|
||||
borderRadius: 0.rpx, // 圆形点击区域
|
||||
onTap: () {
|
||||
if (AppConstants().ent_type ==
|
||||
APPPackageType.MHT.code) {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
// "心率散点图介绍".tr,
|
||||
"心电散点图是用非线性的图形方法描记的连续心冲击图的RR间期图,因图形由散点组成,又称散点图。"
|
||||
.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: Color(0xFFFFFFFF),
|
||||
colors: [
|
||||
Color(0XFF1592AA),
|
||||
Color(0xFF0C83A7),
|
||||
Color(0xFF006FA3)
|
||||
],
|
||||
);
|
||||
} else {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
"心电散点图是用非线性的图形方法描记的连续心冲击图的RR间期图,因图形由散点组成,又称散点图。"
|
||||
.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: themeController.currentColor.sc17,
|
||||
colors: AppConstants().thNormalButton,
|
||||
);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0, 0.rpx, 0.rpx, 0), // 外部 padding 移到内部
|
||||
width: 28.rpx,
|
||||
height: 28.rpx,
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/explain.svg',
|
||||
fit: BoxFit.cover,
|
||||
color: themeController.currentColor.sc4,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 31.rpx,
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 30.rpx, 0.rpx),
|
||||
child: Container(
|
||||
width: MediaQuery.of(context).size.width * 0.7,
|
||||
height: MediaQuery.of(context).size.width * 0.7,
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 430.rpx,
|
||||
minHeight: 430.rpx,
|
||||
),
|
||||
child: ScatterPlotChart(
|
||||
points: data,
|
||||
// 根据实际数据动态设置最大最小值
|
||||
xMax: maxX > 0 ? maxX.toInt() + 100 : 3000,
|
||||
yMax: maxY > 0 ? maxY.toInt() + 100 : 3000,
|
||||
xMin: 0,
|
||||
yMin: 0,
|
||||
pointColor: stringToColor("#00C1AA"), // 点的颜色
|
||||
// divisions: 7, // 刻度分割数量
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 31.rpx,
|
||||
),
|
||||
// Row(
|
||||
// children: [
|
||||
// Text(
|
||||
// "图形参考".tr,
|
||||
// style: TextStyle(
|
||||
// color: themeController.currentColor.sc3,
|
||||
// fontSize: AppConstants().middler_text_fontSize),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// SizedBox(
|
||||
// height: 31.rpx,
|
||||
// ),
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// // 第 1 个
|
||||
// SizedBox(
|
||||
// width: (MediaQuery.sizeOf(context).width - 60.rpx * 3) / 4,
|
||||
// child: Column(
|
||||
// children: [
|
||||
// Image.asset(
|
||||
// "assets/img/heartPic1.png",
|
||||
// width: 120.rpx,
|
||||
// height: 120.rpx,
|
||||
// ),
|
||||
// SizedBox(height: 10),
|
||||
// SizedBox(
|
||||
// height: 60.rpx, // 👈 固定说明文字高度
|
||||
// child: Text(
|
||||
// '正常心率窦性图'.tr,
|
||||
// maxLines: 2,
|
||||
// overflow: TextOverflow.ellipsis,
|
||||
// textAlign: TextAlign.center,
|
||||
// style: TextStyle(
|
||||
// fontSize: AppConstants().small_text_fontSize,
|
||||
// color: themeController.currentColor.sc3,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
|
||||
// // 第 2 个
|
||||
// SizedBox(
|
||||
// width: (MediaQuery.sizeOf(context).width - 60.rpx * 3) / 4,
|
||||
// child: Column(
|
||||
// children: [
|
||||
// Image.asset(
|
||||
// "assets/img/heartPic2.png",
|
||||
// width: 120.rpx,
|
||||
// height: 120.rpx,
|
||||
// ),
|
||||
// SizedBox(height: 10),
|
||||
// SizedBox(
|
||||
// height: 60.rpx,
|
||||
// child: Text(
|
||||
// '窦性心律不齐图'.tr,
|
||||
// maxLines: 2,
|
||||
// overflow: TextOverflow.ellipsis,
|
||||
// textAlign: TextAlign.center,
|
||||
// style: TextStyle(
|
||||
// fontSize: AppConstants().small_text_fontSize,
|
||||
// color: themeController.currentColor.sc3,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
|
||||
// // 第 3 个
|
||||
// SizedBox(
|
||||
// width: (MediaQuery.sizeOf(context).width - 60.rpx * 3) / 4,
|
||||
// child: Column(
|
||||
// children: [
|
||||
// Image.asset(
|
||||
// "assets/img/heartPic3.png",
|
||||
// width: 120.rpx,
|
||||
// height: 120.rpx,
|
||||
// ),
|
||||
// SizedBox(height: 10),
|
||||
// SizedBox(
|
||||
// height: 60.rpx,
|
||||
// child: Text(
|
||||
// '持续性房颤图'.tr,
|
||||
// maxLines: 2,
|
||||
// overflow: TextOverflow.ellipsis,
|
||||
// textAlign: TextAlign.center,
|
||||
// style: TextStyle(
|
||||
// fontSize: AppConstants().small_text_fontSize,
|
||||
// color: themeController.currentColor.sc3,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
|
||||
// // 第 4 个
|
||||
// SizedBox(
|
||||
// width: (MediaQuery.sizeOf(context).width - 60.rpx * 3) / 4,
|
||||
// child: Column(
|
||||
// children: [
|
||||
// Image.asset(
|
||||
// "assets/img/heartPic4.png",
|
||||
// width: 120.rpx,
|
||||
// height: 120.rpx,
|
||||
// ),
|
||||
// SizedBox(height: 10),
|
||||
// SizedBox(
|
||||
// height: 60.rpx,
|
||||
// child: Text(
|
||||
// '阵法性房颤图'.tr,
|
||||
// maxLines: 2,
|
||||
// overflow: TextOverflow.ellipsis,
|
||||
// textAlign: TextAlign.center,
|
||||
// style: TextStyle(
|
||||
// fontSize: AppConstants().small_text_fontSize,
|
||||
// color: themeController.currentColor.sc3,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ].divide(SizedBox(width: 20.rpx)),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
} catch (e) {
|
||||
es.EasyDartModule.logger.error("心率点绘制异常${e}");
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user