更新睡眠报告

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/LineChartByRange.dart';
import 'package:EasyDartModule/EasyDartModule.dart' as es;
class BreathePauseNewWidget extends StatefulWidget {
var sleepReport;
@@ -34,102 +35,127 @@ class _SnoreViewWidgetWidgetState extends State<BreathePauseNewWidget> {
@override
Widget build(BuildContext context) {
if (widget.sleepReport == null ||
widget.sleepReport is! Map ||
widget.sleepReport.isEmpty) {
return Container();
}
try {
if (widget.sleepReport == null ||
widget.sleepReport is! Map ||
widget.sleepReport.isEmpty) {
return Container();
}
List<Map<String, dynamic>> data =
(widget.sleepReport['asp'] as List).cast<Map<String, dynamic>>();
List<Map<String, dynamic>> showLabel = convertToShowLabel(data);
var startTime = widget.sleepReport['startTime'];
var endTime = widget.sleepReport['endTime'];
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, 0.rpx, 14.rpx, 0), //
borderRadius: 0.rpx, // 圆形点击区域
onTap: () {
showTipDialog(
context,
Container(
child: Text(
"呼吸暂停监测介绍。",
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,
List standard = widget.sleepReport['brs'] ?? [];
final Map? result = standard.cast<Map>().firstWhere(
(element) => element['id'] == 302,
orElse: () => <dynamic, dynamic>{},
);
int threshold = 0;
if (result != null && result.isNotEmpty) {
final rangeValue = result['range'];
if (rangeValue is int) {
threshold = rangeValue;
} else if (rangeValue is String) {
threshold = int.tryParse(rangeValue) ?? 0;
}
}
List<Map<String, dynamic>> data =
(widget.sleepReport['asp'] as List).cast<Map<String, dynamic>>();
List<Map<String, dynamic>> showLabel = convertToShowLabel(data);
var startTime = widget.sleepReport['startTime'];
var endTime = widget.sleepReport['endTime'];
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, 0.rpx, 14.rpx, 0), //
borderRadius: 0.rpx, // 圆形点击区域
onTap: () {
showTipDialog(
context,
Container(
child: Text(
"呼吸暂停监测介绍。",
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,
),
);
},
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: 32.rpx,
),
Row(
children: [
Text(
"".tr,
style: TextStyle(
color: stringToColor("#FFFFFF"), fontSize: 18.rpx),
),
],
),
),
SizedBox(
height: 32.rpx,
),
Row(
children: [
Text(
"".tr,
style: TextStyle(
color: stringToColor("#FFFFFF"), fontSize: 18.rpx),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 40.rpx, 0.rpx, 0.rpx),
child: LineChartByRange(
showLabel: showLabel,
startTime: startTime,
endTime: endTime,
threshold: threshold != 0 ? threshold : null,
maxY: threshold == 0 ? threshold + 10 : 70,
ySegments: 7,
),
],
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 40.rpx, 0.rpx, 0.rpx),
child: LineChartByRange(
showLabel: showLabel,
startTime: startTime,
endTime: endTime,
),
),
SizedBox(
height: 52.rpx,
),
],
SizedBox(
height: 52.rpx,
),
],
),
),
),
);
);
} catch (e) {
es.EasyDartModule.logger.error("打鼾监测绘制异常${e}");
return Container();
}
}
List<Map<String, dynamic>> convertToShowLabel(