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:
sleepReportController
.sleepReport.value,
onRefresh: () {
// 这里写刷新逻辑
String data =
MyUtils.formatDate(
calendarController
.selectedDate
.value!);
loadSleepReport(data);
},
),
SizedBox(height: 25.rpx),
VitalSignsWidget(
sleepReport:
sleepReportController
.sleepReport.value,
onRefresh: () {
// 这里写刷新逻辑
String data =
MyUtils.formatDate(
calendarController
.selectedDate
.value!);
loadSleepReport(data);
},
),
],
)
@@ -661,7 +679,7 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
logTitle: "查询睡眠报告",
method: MyHttpMethod.get,
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) {
isLoading.value = false;
print(res);

View File

@@ -21,8 +21,13 @@ class ScatterPlotChart extends StatelessWidget {
@override
Widget build(BuildContext context) {
// 计算向上取整后的最大值
double xMaxCeil = (xMax / 100).ceil() * 100.0;
double yMaxCeil = (yMax / 100).ceil() * 100.0;
// double xMaxCeil = (xMax / divisions).ceil() * divisions.toDouble();
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(
child: ScatterChart(
@@ -62,7 +67,7 @@ class ScatterPlotChart extends StatelessWidget {
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.right, // 右对齐
textAlign: TextAlign.center, // 右对齐
),
);
},
@@ -78,6 +83,9 @@ class ScatterPlotChart extends StatelessWidget {
fontSize: 18.rpx,
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 =
(widget.sleepReport['asp'] as List).cast<Map<String, dynamic>>();
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 endTime = widget.sleepReport['endTime'];
return Container(
@@ -94,7 +107,8 @@ class _SnoreViewWidgetWidgetState extends State<BreathePauseNewWidget> {
14.rpx, 10.rpx, 14.rpx, 10.rpx), //
borderRadius: 0.rpx, // 圆形点击区域
onTap: () {
if (AppConstants().ent_type == APPPackageType.MHT.code) {
if (AppConstants().ent_type ==
APPPackageType.MHT.code) {
showTipDialog(
context,
Container(
@@ -166,7 +180,7 @@ class _SnoreViewWidgetWidgetState extends State<BreathePauseNewWidget> {
startTime: startTime,
endTime: endTime,
threshold: threshold != 0 ? threshold : null,
maxY: threshold == 0 ? threshold + 10 : 70,
maxY: roundedMaxTimes,
ySegments: 7,
),
),

View File

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

View File

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

View File

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

View File

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

View File

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