406 lines
16 KiB
Dart
406 lines
16 KiB
Dart
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: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/ScatterPlotChart.dart';
|
||
|
||
class HeartPointWidget extends StatefulWidget {
|
||
var sleepReport;
|
||
HeartPointWidget({super.key, required this.sleepReport});
|
||
|
||
@override
|
||
State<HeartPointWidget> createState() => _HeartPointWidgetState();
|
||
}
|
||
|
||
class _HeartPointWidgetState extends State<HeartPointWidget> {
|
||
@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['hrsp'] == null ||
|
||
widget.sleepReport['hrsp'].isEmpty) {
|
||
return Container();
|
||
}
|
||
|
||
double maxX = 0;
|
||
double maxY = 0;
|
||
|
||
List<ScatterSpot> data = [];
|
||
List rawData = widget.sleepReport['hrsp'];
|
||
try {
|
||
data = rawData.map<ScatterSpot>((item) {
|
||
double x = (item['st'] ?? 0).toDouble();
|
||
double y = (item['value'] ?? 0).toDouble();
|
||
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.toInt(), // x轴最大值
|
||
// yMax: maxY.toInt(), // y轴最大值
|
||
xMax: 3000, // x轴最大值
|
||
yMax: 3000, // y轴最大值
|
||
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(
|
||
// // 使用 start 避免 spaceBetween 抵消 divide 的间隔
|
||
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||
// children: [
|
||
// // 第 1 个
|
||
// Column(
|
||
// mainAxisSize: MainAxisSize.min,
|
||
// children: [
|
||
// Image.asset(
|
||
// "assets/img/heartPic1.png",
|
||
// width: 120.rpx,
|
||
// height: 120.rpx,
|
||
// ),
|
||
// SizedBox(height: 10),
|
||
// Text(
|
||
// '正常心率窦性图'.tr, // ← 替换文字
|
||
// style: TextStyle(
|
||
// fontSize: AppConstants().small_text_fontSize,
|
||
// color: themeController.currentColor.sc3),
|
||
// ),
|
||
// ],
|
||
// ),
|
||
|
||
// // 第 2 个
|
||
// Column(
|
||
// mainAxisSize: MainAxisSize.min,
|
||
// children: [
|
||
// Image.asset(
|
||
// "assets/img/heartPic2.png",
|
||
// width: 120.rpx,
|
||
// height: 120.rpx,
|
||
// ),
|
||
// SizedBox(height: 10),
|
||
// Text(
|
||
// '窦性心律不齐图'.tr, // ← 替换文字
|
||
// style: TextStyle(
|
||
// fontSize: AppConstants().small_text_fontSize,
|
||
// color: themeController.currentColor.sc3),
|
||
// ),
|
||
// ],
|
||
// ),
|
||
|
||
// // 第 3 个
|
||
// Column(
|
||
// mainAxisSize: MainAxisSize.min,
|
||
// children: [
|
||
// Image.asset(
|
||
// "assets/img/heartPic3.png",
|
||
// width: 120.rpx,
|
||
// height: 120.rpx,
|
||
// ),
|
||
// SizedBox(height: 10),
|
||
// Text(
|
||
// '持续性房颤图'.tr, // ← 替换文字
|
||
// style: TextStyle(
|
||
// fontSize: AppConstants().small_text_fontSize,
|
||
// color: themeController.currentColor.sc3),
|
||
// ),
|
||
// ],
|
||
// ),
|
||
|
||
// // 第 4 个
|
||
// Column(
|
||
// mainAxisSize: MainAxisSize.min,
|
||
// children: [
|
||
// Image.asset(
|
||
// "assets/img/heartPic3.png",
|
||
// width: 120.rpx,
|
||
// height: 120.rpx,
|
||
// ),
|
||
// SizedBox(height: 10),
|
||
// Text(
|
||
// '阵法性房颤图'.tr, // ← 替换文字
|
||
// style: TextStyle(
|
||
// fontSize: AppConstants().small_text_fontSize,
|
||
// color: themeController.currentColor.sc3),
|
||
// ),
|
||
// ],
|
||
// ),
|
||
// ].divide(
|
||
// SizedBox(width: 20.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();
|
||
}
|
||
}
|
||
}
|