更新快检功能
This commit is contained in:
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user