更新睡眠报告

This commit is contained in:
wyf
2025-05-29 20:20:49 +08:00
parent b34737dbe8
commit 7a816922fa
41 changed files with 4604 additions and 2394 deletions

View File

@@ -7,6 +7,7 @@ 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/DataShowWidget.dart';
import 'package:EasyDartModule/EasyDartModule.dart' as es;
class HeartChangeWidget extends StatefulWidget {
var sleepReport;
@@ -34,293 +35,235 @@ class _HeartChangeWidgetState extends State<HeartChangeWidget> {
@override
Widget build(BuildContext context) {
if (widget.sleepReport == null ||
widget.sleepReport['hrvs'] == null ||
widget.sleepReport['hrvs'].isEmpty) {
try {
if (widget.sleepReport == null ||
widget.sleepReport['hrvs'] == null ||
widget.sleepReport['hrvs'].isEmpty) {
return Container();
}
List dataList = widget.sleepReport['hrvs'];
List<Map<String, dynamic>> data = transformHrvData(dataList);
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(
"心率变异性HRV".tr,
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().title_text_fontSize),
),
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: Colors.white, // 或设置为你需要的水波纹颜色
padding: EdgeInsetsDirectional.fromSTEB(
14.rpx, 0.rpx, 14.rpx, 0), //
borderRadius: 0.rpx, // 圆形点击区域
onTap: () {
showTipDialog(
context,
Container(
child: Text(
"心率变异性HRV介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,
),
),
),
);
},
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(
"名称",
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
),
),
widget2: Text(
"测量值",
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
),
),
widget3: Text(
"参考范围",
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
),
),
widget4: Text(
"趋势",
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: [
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);
showTipDialog(
context,
Container(
child: Text(
'${data['desc']}',
style: TextStyle(
fontSize: 26.rpx,
color:
themeController.currentColor.sc3,
),
),
),
);
},
child: SizedBox(
width: 17.rpx,
height: 17.rpx,
child: SvgPicture.asset(
'assets/img/icon/explain.svg',
fit: BoxFit.cover,
color: Colors.white,
),
),
),
],
),
widget2: Text(
'${data['value']}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
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 dataList = widget.sleepReport['hrvs'];
//0上升 1下降 2持平
// List data = [
// {
// "name": "心脏总能量",
// "value": 5262,
// "range": "2055-6000",
// "change": 0,
// "desc": "心脏总能量介绍"
// },
// {
// "name": "心率减速力",
// "value": 5262,
// "range": "2055-6000",
// "change": 1,
// "desc": "心率减速力介绍"
// },
// {
// "name": "迷走神经张力指数",
// "value": 5262,
// "range": "2055-6000",
// "change": 2,
// "desc": "迷走神经张力指数介绍"
// },
// {
// "name": "交感神经张力指数",
// "value": 5262,
// "range": "2055-6000",
// "change": 0,
// "desc": "交感神经张力指数介绍"
// },
// {
// "name": "自主神经张力指数",
// "value": 5262,
// "range": "2055-6000",
// "change": 2,
// "desc": "自主神经张力指数介绍"
// },
// {
// "name": "血管舒张指数",
// "value": 5262,
// "range": "2055-6000",
// "change": 1,
// "desc": "血管舒张指数介绍"
// },
// {
// "name": "SDNN",
// "value": 5262,
// "range": "2055-6000",
// "change": 0,
// "desc": "SDNN介绍"
// },
// {
// "name": "PNN50",
// "value": 5262,
// "range": "2055-6000",
// "change": 1,
// "desc": "PNN50介绍"
// },
// {
// "name": "RMSSD",
// "value": 5262,
// "range": "2055-6000",
// "change": 2,
// "desc": "RMSSD介绍"
// },
// ];
List<Map<String, dynamic>> data = transformHrvData(dataList);
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(
"心率变异性HRV".tr,
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().title_text_fontSize),
),
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: Colors.white, // 或设置为你需要的水波纹颜色
padding: EdgeInsetsDirectional.fromSTEB(
14.rpx, 0.rpx, 14.rpx, 0), //
borderRadius: 0.rpx, // 圆形点击区域
onTap: () {
showTipDialog(
context,
Container(
child: Text(
"心率变异性HRV介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,
),
),
),
);
},
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(
"名称",
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
),
),
widget2: Text(
"测量值",
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
),
),
widget3: Text(
"参考范围",
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
),
),
widget4: Text(
"趋势",
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: [
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);
showTipDialog(
context,
Container(
child: Text(
'${data['desc']}',
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,
),
),
),
);
},
child: SizedBox(
width: 17.rpx,
height: 17.rpx,
child: SvgPicture.asset(
'assets/img/icon/explain.svg',
fit: BoxFit.cover,
color: Colors.white,
),
),
),
],
),
widget2: Text(
'${data['value']}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
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(),
),
],
),
),
],
),
),
);
}
List<Map<String, dynamic>> transformHrvData(List<dynamic> originalData) {