This commit is contained in:
wyf
2025-08-15 10:16:35 +08:00
parent b2fd885192
commit 7cffe978ae
11 changed files with 253 additions and 197 deletions

View File

@@ -514,12 +514,30 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
sleepReport: sleepReport:
sleepReportController sleepReportController
.sleepReport.value, .sleepReport.value,
onRefresh: () {
// 这里写刷新逻辑
String data =
MyUtils.formatDate(
calendarController
.selectedDate
.value!);
loadSleepReport(data);
},
), ),
SizedBox(height: 25.rpx), SizedBox(height: 25.rpx),
VitalSignsWidget( VitalSignsWidget(
sleepReport: sleepReport:
sleepReportController sleepReportController
.sleepReport.value, .sleepReport.value,
onRefresh: () {
// 这里写刷新逻辑
String data =
MyUtils.formatDate(
calendarController
.selectedDate
.value!);
loadSleepReport(data);
},
), ),
], ],
) )
@@ -661,7 +679,7 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
logTitle: "查询睡眠报告", logTitle: "查询睡眠报告",
method: MyHttpMethod.get, method: MyHttpMethod.get,
queryUrl: queryUrl:
"https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${homeController.selectDevcie.value}&time=${data}&type=${sleepReportController.model.type}", "https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${homeController.selectDevcie.value}&time=${data}&type=1",
onSuccess: (res) { onSuccess: (res) {
isLoading.value = false; isLoading.value = false;
print(res); print(res);

View File

@@ -21,8 +21,13 @@ class ScatterPlotChart extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// 计算向上取整后的最大值 // 计算向上取整后的最大值
double xMaxCeil = (xMax / 100).ceil() * 100.0; // double xMaxCeil = (xMax / divisions).ceil() * divisions.toDouble();
double yMaxCeil = (yMax / 100).ceil() * 100.0; double temp = (xMax / divisions).ceil().toDouble(); // 计算向上取整后的每个分区的最大值
double xMaxCeil = (((temp / 100).ceil()) * 100 * (divisions - 1))
.toDouble(); // 向百取整并乘以 divisions
double tempy = (yMax / divisions).ceil().toDouble(); // 计算向上取整后的每个分区的最大值
double yMaxCeil =
(((tempy / 100).ceil()) * 100 * (divisions - 1)).toDouble();
return SizedBox( return SizedBox(
child: ScatterChart( child: ScatterChart(
@@ -62,7 +67,7 @@ class ScatterPlotChart extends StatelessWidget {
), ),
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
textAlign: TextAlign.right, // 右对齐 textAlign: TextAlign.center, // 右对齐
), ),
); );
}, },
@@ -78,6 +83,9 @@ class ScatterPlotChart extends StatelessWidget {
fontSize: 18.rpx, fontSize: 18.rpx,
color: themeController.currentColor.sc4, color: themeController.currentColor.sc4,
), ),
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.center, // 右对齐
); );
}, },
), ),

View File

@@ -62,6 +62,19 @@ class _SnoreViewWidgetWidgetState extends State<BreathePauseNewWidget> {
List<Map<String, dynamic>> data = List<Map<String, dynamic>> data =
(widget.sleepReport['asp'] as List).cast<Map<String, dynamic>>(); (widget.sleepReport['asp'] as List).cast<Map<String, dynamic>>();
List<Map<String, dynamic>> showLabel = convertToShowLabel(data); List<Map<String, dynamic>> showLabel = convertToShowLabel(data);
double maxTimes = 70;
try {
maxTimes = showLabel.fold<double>(0.0, (prev, element) {
double currentTimes =
(element['times'] ?? 0).toDouble(); // 转换为 double 类型
return currentTimes > prev ? currentTimes : prev;
});
} catch (e) {
print("$e");
}
// 向十位数取整
int roundedMaxTimes = (maxTimes / 10).ceil() * 10;
var startTime = widget.sleepReport['startTime']; var startTime = widget.sleepReport['startTime'];
var endTime = widget.sleepReport['endTime']; var endTime = widget.sleepReport['endTime'];
return Container( return Container(
@@ -94,7 +107,8 @@ class _SnoreViewWidgetWidgetState extends State<BreathePauseNewWidget> {
14.rpx, 10.rpx, 14.rpx, 10.rpx), // 14.rpx, 10.rpx, 14.rpx, 10.rpx), //
borderRadius: 0.rpx, // 圆形点击区域 borderRadius: 0.rpx, // 圆形点击区域
onTap: () { onTap: () {
if (AppConstants().ent_type == APPPackageType.MHT.code) { if (AppConstants().ent_type ==
APPPackageType.MHT.code) {
showTipDialog( showTipDialog(
context, context,
Container( Container(
@@ -166,7 +180,7 @@ class _SnoreViewWidgetWidgetState extends State<BreathePauseNewWidget> {
startTime: startTime, startTime: startTime,
endTime: endTime, endTime: endTime,
threshold: threshold != 0 ? threshold : null, threshold: threshold != 0 ? threshold : null,
maxY: threshold == 0 ? threshold + 10 : 70, maxY: roundedMaxTimes,
ySegments: 7, ySegments: 7,
), ),
), ),

View File

@@ -136,7 +136,8 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
14.rpx, 10.rpx, 14.rpx, 10.rpx), // 14.rpx, 10.rpx, 14.rpx, 10.rpx), //
borderRadius: 0.rpx, // 圆形点击区域 borderRadius: 0.rpx, // 圆形点击区域
onTap: () { onTap: () {
if (AppConstants().ent_type == APPPackageType.MHT.code) { if (AppConstants().ent_type ==
APPPackageType.MHT.code) {
showTipDialog( showTipDialog(
context, context,
Container( Container(
@@ -236,166 +237,158 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
// actYMin: min.toDouble(), // actYMin: min.toDouble(),
), ),
), ),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
30.rpx, 0.rpx, 0.rpx, 0.rpx),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
children: [
Text(
"${avgBreath['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
AppConstants().normal_text_fontSize),
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"${avgBreath['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize: AppConstants()
.normal_text_fontSize),
),
Text(
"${avgBreath['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
AppConstants().small_text_fontSize),
),
].divide(SizedBox(
width: 6.rpx,
)),
),
],
),
Column(
children: [
Text(
"${baseBreath['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
AppConstants().normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"${baseBreath['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize: AppConstants()
.normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
"${baseBreath['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
AppConstants().small_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
].divide(SizedBox(
width: 6.rpx,
)),
),
],
),
Column(
children: [
Text(
"${minBreath['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
AppConstants().normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"${minBreath['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize: AppConstants()
.normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
"${minBreath['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
AppConstants().small_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
].divide(SizedBox(
width: 6.rpx,
)),
),
],
),
Column(
children: [
Text(
"${maxBreath['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
AppConstants().normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"${maxBreath['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize: AppConstants()
.normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
"${maxBreath['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
AppConstants().small_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
].divide(SizedBox(
width: 6.rpx,
)),
),
],
),
],
),
),
].divide(SizedBox( ].divide(SizedBox(
height: 18.rpx, height: 18.rpx,
)), )),
), ),
), ),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 0.rpx, 0.rpx),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
children: [
Text(
"${avgBreath['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().normal_text_fontSize),
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"${avgBreath['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
AppConstants().normal_text_fontSize),
),
Text(
"${avgBreath['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().small_text_fontSize),
),
].divide(SizedBox(
width: 6.rpx,
)),
),
],
),
Column(
children: [
Text(
"${baseBreath['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"${baseBreath['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
AppConstants().normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
"${baseBreath['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().small_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
].divide(SizedBox(
width: 6.rpx,
)),
),
],
),
Column(
children: [
Text(
"${minBreath['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"${minBreath['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
AppConstants().normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
"${minBreath['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().small_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
].divide(SizedBox(
width: 6.rpx,
)),
),
],
),
Column(
children: [
Text(
"${maxBreath['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"${maxBreath['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
AppConstants().normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
"${maxBreath['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().small_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
].divide(SizedBox(
width: 6.rpx,
)),
),
],
),
],
),
),
], ],
), ),
), ),

View File

@@ -73,36 +73,38 @@ class _HeartHealthWidgetState extends State<HeartHealthWidget> {
backgroundColor: Colors.transparent, backgroundColor: Colors.transparent,
highlightColor: Colors.white, // 或设置为你需要的水波纹颜色 highlightColor: Colors.white, // 或设置为你需要的水波纹颜色
padding: EdgeInsetsDirectional.fromSTEB( padding: EdgeInsetsDirectional.fromSTEB(
14.rpx, 10.rpx, 14.rpx, 10.rpx),// 14.rpx, 10.rpx, 14.rpx, 10.rpx), //
borderRadius: 0.rpx, // 圆形点击区域 borderRadius: 0.rpx, // 圆形点击区域
onTap: () { onTap: () {
if (AppConstants().ent_type ==
if (AppConstants().ent_type == APPPackageType.MHT.code) { APPPackageType.MHT.code) {
showTipDialog( showTipDialog(
context, context,
Container( Container(
child: Text( child: Text(
// "心理健康评估介绍".tr, // "心理健康评估介绍".tr,
"心率健康评估主要通过用户睡眠报告中的时间点、体征数据及HRV数据等信息来判断其心理健康水平、疲劳程度。".tr, "心率健康评估主要通过用户睡眠报告中的时间点、体征数据及HRV数据等信息来判断其心理健康水平、疲劳程度。"
style: TextStyle( .tr,
fontSize: 26.rpx, style: TextStyle(
color: Colors.black, fontSize: 26.rpx,
color: Colors.black,
),
), ),
), ),
), backgroundColor: Color(0xFFFFFFFF),
backgroundColor: Color(0xFFFFFFFF), colors: [
colors: [ Color(0XFF1592AA),
Color(0XFF1592AA), Color(0xFF0C83A7),
Color(0xFF0C83A7), Color(0xFF006FA3)
Color(0xFF006FA3) ],
], );
);
} else { } else {
showTipDialog( showTipDialog(
context, context,
Container( Container(
child: Text( child: Text(
"心率健康评估主要通过用户睡眠报告中的时间点、体征数据及HRV数据等信息来判断其心理健康水平、疲劳程度。".tr, "心率健康评估主要通过用户睡眠报告中的时间点、体征数据及HRV数据等信息来判断其心理健康水平、疲劳程度。"
.tr,
style: TextStyle( style: TextStyle(
fontSize: 26.rpx, fontSize: 26.rpx,
color: themeController.currentColor.sc3, color: themeController.currentColor.sc3,
@@ -178,7 +180,7 @@ class _HeartHealthWidgetState extends State<HeartHealthWidget> {
: stringToColor("#00C1AA"), // 默认红色 : stringToColor("#00C1AA"), // 默认红色
'percent': value, 'percent': value,
'explain': item['level'], 'explain': item['level'],
"bottomColor": Colors.grey, "bottomColor": stringToColor("#393D49"),
}; };
}).toList(); }).toList();
} }

View File

@@ -93,7 +93,8 @@ class _HeartPointWidgetState extends State<HeartPointWidget> {
14.rpx, 10.rpx, 14.rpx, 10.rpx), // 14.rpx, 10.rpx, 14.rpx, 10.rpx), //
borderRadius: 0.rpx, // 圆形点击区域 borderRadius: 0.rpx, // 圆形点击区域
onTap: () { onTap: () {
if (AppConstants().ent_type == APPPackageType.MHT.code) { if (AppConstants().ent_type ==
APPPackageType.MHT.code) {
showTipDialog( showTipDialog(
context, context,
Container( Container(

View File

@@ -46,7 +46,7 @@ class _SleepScoreWidgetState extends State<SleepScoreWidget> {
} }
List showLabel = widget.sleepReport['score']['type']; List showLabel = widget.sleepReport['score']['type'];
List stages = widget.sleepReport['score']['stages']; // List stages = widget.sleepReport['score']['stages'];
List<SegmentData> segments = parseSegments(widget.sleepReport); List<SegmentData> segments = parseSegments(widget.sleepReport);
int level = widget.sleepReport['score']['level']; int level = widget.sleepReport['score']['level'];
// 查找与 level 匹配的 map // 查找与 level 匹配的 map

View File

@@ -45,7 +45,7 @@ class _SnoreViewWidgetWidgetState extends State<SnoreViewWidgetWidget> {
widget.sleepReport.isEmpty) { widget.sleepReport.isEmpty) {
return Container(); return Container();
} }
double maxY = 60; double maxY = 70;
var startTime = widget.sleepReport['startTime']; var startTime = widget.sleepReport['startTime'];
var endTime = widget.sleepReport['endTime']; var endTime = widget.sleepReport['endTime'];
List snoreValues = []; List snoreValues = [];
@@ -124,7 +124,8 @@ class _SnoreViewWidgetWidgetState extends State<SnoreViewWidgetWidget> {
14.rpx, 10.rpx, 14.rpx, 10.rpx), // 14.rpx, 10.rpx, 14.rpx, 10.rpx), //
borderRadius: 0.rpx, // 圆形点击区域 borderRadius: 0.rpx, // 圆形点击区域
onTap: () { onTap: () {
if (AppConstants().ent_type == APPPackageType.MHT.code) { if (AppConstants().ent_type ==
APPPackageType.MHT.code) {
showTipDialog( showTipDialog(
context, context,
Container( Container(
@@ -201,7 +202,7 @@ class _SnoreViewWidgetWidgetState extends State<SnoreViewWidgetWidget> {
startTime: startTime, startTime: startTime,
endTime: endTime, endTime: endTime,
maxYValue: maxY, // 最大值可自定义 maxYValue: maxY, // 最大值可自定义
yStepCount: 6, // 分4段0, 5, 10, 15, 20 yStepCount: 7, // 分4段0, 5, 10, 15, 20
), ),
), ),
Padding( Padding(

View File

@@ -12,7 +12,12 @@ import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.d
//睡眠规律性 //睡眠规律性
class VitalSignsWidget extends StatefulWidget { class VitalSignsWidget extends StatefulWidget {
var sleepReport; var sleepReport;
VitalSignsWidget({super.key, required this.sleepReport}); final VoidCallback? onRefresh; // 添加回调函数
VitalSignsWidget({
super.key,
required this.sleepReport,
this.onRefresh, // 可选参数
});
@override @override
State<VitalSignsWidget> createState() => _VitalSignsWidgetState(); State<VitalSignsWidget> createState() => _VitalSignsWidgetState();
@@ -166,16 +171,20 @@ class _VitalSignsWidgetState extends State<VitalSignsWidget> {
), ),
Row(mainAxisAlignment: MainAxisAlignment.end, children: [ Row(mainAxisAlignment: MainAxisAlignment.end, children: [
OutlinedButton( OutlinedButton(
onPressed: () { onPressed: () async {
MHTHomeController homeController = Get.find(); MHTHomeController homeController = Get.find();
Get.toNamed("/newSleepReportPage", arguments: { await Get.toNamed("/newSleepReportPage", arguments: {
'date': widget.sleepReport['endTime'], 'date': widget.sleepReport['endTime'],
"mac": homeController.selectDevcie.value, "mac": homeController.selectDevcie.value,
'type': 1, 'type': 1,
'backgroundImg': 'assets/images/new_background.png', 'backgroundImg': 'assets/images/new_background.png',
'person_show': false, 'person_show': false,
'itemName': 206, 'itemName': 206,
'retrun_fresh': true,
}); });
if (widget.onRefresh != null) {
widget.onRefresh!();
}
}, },
style: OutlinedButton.styleFrom( style: OutlinedButton.styleFrom(
side: const BorderSide(color: Color(0XFF85F5FF)), side: const BorderSide(color: Color(0XFF85F5FF)),

View File

@@ -14,7 +14,12 @@ import 'package:vbvs_app/pages/sleep_report/chart/SnoreWaveform.dart';
//睡眠规律性 //睡眠规律性
class NewSleepViewWidget extends StatefulWidget { class NewSleepViewWidget extends StatefulWidget {
var sleepReport; var sleepReport;
NewSleepViewWidget({super.key, required this.sleepReport}); final VoidCallback? onRefresh; // 添加回调函数
NewSleepViewWidget({
super.key,
required this.sleepReport,
this.onRefresh, // 可选参数
});
@override @override
State<NewSleepViewWidget> createState() => _NewSleepViewWidgetState(); State<NewSleepViewWidget> createState() => _NewSleepViewWidgetState();
@@ -120,7 +125,8 @@ class _NewSleepViewWidgetState extends State<NewSleepViewWidget> {
14.rpx, 0.rpx, 14.rpx, 0), // 14.rpx, 0.rpx, 14.rpx, 0), //
borderRadius: 0.rpx, // 圆形点击区域 borderRadius: 0.rpx, // 圆形点击区域
onTap: () { onTap: () {
if (AppConstants().ent_type == APPPackageType.MHT.code) { if (AppConstants().ent_type ==
APPPackageType.MHT.code) {
showTipDialog( showTipDialog(
context, context,
Container( Container(
@@ -158,15 +164,19 @@ class _NewSleepViewWidgetState extends State<NewSleepViewWidget> {
), ),
Row(mainAxisAlignment: MainAxisAlignment.end, children: [ Row(mainAxisAlignment: MainAxisAlignment.end, children: [
OutlinedButton( OutlinedButton(
onPressed: () { onPressed: () async {
MHTHomeController homeController = Get.find(); MHTHomeController homeController = Get.find();
Get.toNamed("/newSleepReportPage", arguments: { await Get.toNamed("/newSleepReportPage", arguments: {
'date': widget.sleepReport['endTime'], 'date': widget.sleepReport['endTime'],
"mac": homeController.selectDevcie.value, "mac": homeController.selectDevcie.value,
'type': 1, 'type': 1,
'backgroundImg': 'assets/images/new_background.png', 'backgroundImg': 'assets/images/new_background.png',
'person_show': false, 'person_show': false,
'retrun_fresh': true,
}); });
if (widget.onRefresh != null) {
widget.onRefresh!();
}
}, },
style: OutlinedButton.styleFrom( style: OutlinedButton.styleFrom(
side: const BorderSide(color: Color(0XFF85F5FF)), side: const BorderSide(color: Color(0XFF85F5FF)),