更新睡眠报告

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/AdviceComponnetWidget.dart';
import 'package:EasyDartModule/EasyDartModule.dart' as es;
class AIAdviceWidget extends StatefulWidget {
var sleepReport;
@@ -34,88 +35,94 @@ class _AIAdviceWidgetState extends State<AIAdviceWidget> {
@override
Widget build(BuildContext context) {
if (widget.sleepReport == null ||
widget.sleepReport['sugges'] == null ||
widget.sleepReport['sugges'].isEmpty) {
return Container();
}
List advices = widget.sleepReport['sugges'];
try {
if (widget.sleepReport == null ||
widget.sleepReport['sugges'] == null ||
widget.sleepReport['sugges'].isEmpty) {
return Container();
}
List advices = widget.sleepReport['sugges'];
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: [
Text(
"AI分析".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(
"AI分析介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,
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: [
Text(
"AI分析".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(
"AI分析介绍".tr,
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: 31.rpx,
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 30.rpx, 0.rpx),
child: Column(
children: advices.map<Widget>((advice) {
return AdviceComponnetWidget(
title: advice["q"],
description: advice["s"],
).paddingOnly(bottom: 0.rpx); // 在每个组件下方添加间隔
}).toList(),
SizedBox(
height: 31.rpx,
),
)
],
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 30.rpx, 0.rpx),
child: Column(
children: advices.map<Widget>((advice) {
return AdviceComponnetWidget(
title: advice["q"],
description: advice["s"],
).paddingOnly(bottom: 0.rpx); // 在每个组件下方添加间隔
}).toList(),
),
)
],
),
),
),
);
);
} catch (e) {
es.EasyDartModule.logger.error("打鼾监测绘制异常${e}");
return Container();
}
}
}

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/DotBarChart.dart';
import 'package:EasyDartModule/EasyDartModule.dart' as es;
class BreathPauseWidget extends StatefulWidget {
var sleepReport;
@@ -34,107 +35,100 @@ class _BreathPauseWidgetState extends State<BreathPauseWidget> {
@override
Widget build(BuildContext context) {
if (widget.sleepReport == null ||
widget.sleepReport['asp'] == null ||
widget.sleepReport['asp'].isEmpty) {
return Container();
}
try {
if (widget.sleepReport == null ||
widget.sleepReport['asp'] == null ||
widget.sleepReport['asp'].isEmpty) {
return Container();
}
// List data = widget.sleepReport['asp'];
// var showLabel = [
// {"time": 1744547251000, "times": 25},
// {"time": 1744550851000, "times": 27},
// {"time": 1744554451000, "times": 40},
// {"time": 1744558051000, "times": 28},
// {"time": 1744561651000, "times": 15},
// {"time": 1744565251000, "times": 48},
// {"time": 1744568851000, "times": 25},
// {"time": 1744572451000, "times": 17},
// {"time": 1744583251000, "times": 35},
// {"time": 1744586851000, "times": 40},
// ];
List data = widget.sleepReport['asp'];
var showLabel = convertAspData(data);
var threshold = 30;
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 data = widget.sleepReport['asp'];
var showLabel = convertAspData(data);
var threshold = 30;
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,
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 0.rpx, 0.rpx),
child: DotBarChart(
showLabel: showLabel,
threshold: threshold,
startTime: startTime,
endTime: endTime,
SizedBox(
height: 32.rpx,
),
),
SizedBox(
height: 52.rpx,
),
],
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 0.rpx, 0.rpx),
child: DotBarChart(
showLabel: showLabel,
threshold: threshold,
startTime: startTime,
endTime: endTime,
),
),
SizedBox(
height: 52.rpx,
),
],
),
),
),
);
);
} catch (e) {
es.EasyDartModule.logger.error("打鼾监测绘制异常${e}");
return Container();
}
}
List<Map<String, dynamic>> convertAspData(List data) {

View File

@@ -3,68 +3,137 @@ 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/home_page/SleepDataModuleWidget.dart';
import 'package:EasyDartModule/EasyDartModule.dart' as es;
class BreatheCard extends StatefulWidget {
var sleepReport;
BreatheCard({super.key, required this.sleepReport});
final int? highlightItem;
BreatheCard({super.key, required this.sleepReport, this.highlightItem});
@override
State<BreatheCard> createState() => _BreatheCardState();
}
class _BreatheCardState extends State<BreatheCard> {
@override
void setState(VoidCallback callback) {
super.setState(callback);
}
class _BreatheCardState extends State<BreatheCard>
with TickerProviderStateMixin {
final GlobalKey _highlightKey = GlobalKey();
AnimationController? _animationController;
bool _shouldAnimate = false;
int? _highlightedId;
int _flashCount = 0;
@override
void initState() {
super.initState();
if (widget.highlightItem != null) {
_highlightedId = widget.highlightItem;
_shouldAnimate = true;
_initAnimation();
}
WidgetsBinding.instance.addPostFrameCallback((_) {
if (widget.highlightItem != null &&
_highlightKey.currentContext != null) {
Scrollable.ensureVisible(
_highlightKey.currentContext!,
duration: Duration(milliseconds: 500),
curve: Curves.easeInOut,
alignment: 0.3,
);
}
});
}
void _initAnimation() {
_animationController = AnimationController(
vsync: this,
duration: Duration(milliseconds: 300),
)..addStatusListener((status) {
if (status == AnimationStatus.completed) {
_animationController!.reverse();
} else if (status == AnimationStatus.dismissed) {
_flashCount++;
if (_flashCount >= 3) {
_animationController!.dispose();
setState(() {
_shouldAnimate = false;
_highlightedId = null;
});
} else {
_animationController!.forward();
}
}
});
_animationController!.forward();
}
@override
void dispose() {
_animationController?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
if (widget.sleepReport == null ||
widget.sleepReport is! Map ||
widget.sleepReport.isEmpty) {
try {
if (widget.sleepReport == null ||
widget.sleepReport is! Map ||
widget.sleepReport.isEmpty) {
return Container();
}
List data = widget.sleepReport['brs'] ?? [];
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: Wrap(
spacing: 23.rpx,
runSpacing: 25.rpx,
children: List.generate(data.length, (index) {
final item = data[index];
item['showTip'] = true;
final bool isHighlighted =
_shouldAnimate && item['id'] == _highlightedId;
return SizedBox(
width: (MediaQuery.of(context).size.width - 160.rpx) / 3,
child: AnimatedBuilder(
animation: _animationController ?? AlwaysStoppedAnimation(0),
builder: (context, child) {
return Container(
key: isHighlighted ? _highlightKey : null,
decoration: isHighlighted
? BoxDecoration(
border: Border.all(
color: themeController.currentColor.sc2
.withOpacity(
_animationController?.value ?? 0),
width: 1.rpx,
),
borderRadius: BorderRadius.circular(8),
)
: null,
child: SleepDataModuleWidget(data: item),
);
},
),
);
}),
),
),
);
} catch (e) {
es.EasyDartModule.logger.error("呼吸监测绘制异常${e}");
return Container();
}
List data = widget.sleepReport['brs'] ?? [];
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: Wrap(
spacing: 23.rpx, // 横向间距(左右间距如需加可设置)
runSpacing: 25.rpx, // 每行之间的垂直间距
children: List.generate(data.length, (index) {
final item = data[index];
item['showTip'] = true;
return SizedBox(
width: (MediaQuery.of(context).size.width - 160.rpx) / 3,
child: SleepDataModuleWidget(data: item),
// child: Container(
// width: 20,
// height: 20,
// color: Colors.red,
// ),
);
}),
),
),
);
}
}

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(

View File

@@ -8,6 +8,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/TimeSeriesChart.dart';
import 'package:EasyDartModule/EasyDartModule.dart' as es;
class BreatheStandardWidget extends StatefulWidget {
var sleepReport;
@@ -35,338 +36,336 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
@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();
}
final startTime = widget.sleepReport['startTime'];
final endTime = widget.sleepReport['endTime'];
List<Map<String, dynamic>> data =
(widget.sleepReport['brbc'] as List).cast<Map<String, dynamic>>();
// final dataPoints = [
// TimeSeriesPoint(12121, 50),
// TimeSeriesPoint(1212, 120),
// TimeSeriesPoint(121, 80),
// TimeSeriesPoint(1212, 180),
// TimeSeriesPoint(1212, 30),
// TimeSeriesPoint(1212, 150),
// ];
final dataPoints = data.map((item) {
final x = item['st'] as int;
final y = (item['value'] as num).toDouble(); // 安全地转换为 double
return TimeSeriesPoint(x, y);
}).toList();
final startTime = widget.sleepReport['startTime'];
final endTime = widget.sleepReport['endTime'];
List<Map<String, dynamic>> data =
(widget.sleepReport['brbc'] as List).cast<Map<String, dynamic>>();
final dataPoints = data.map((item) {
final x = item['st'] as int;
final y = (item['value'] as num).toDouble(); // 安全地转换为 double
return TimeSeriesPoint(x, y);
}).toList();
List<Map<String, dynamic>> brs =
(widget.sleepReport['brs'] as List).cast<Map<String, dynamic>>();
//307 平均呼吸
//305 基准呼吸
//308 最低呼吸
//309 最高呼吸
// 307 平均呼吸
Map<String, dynamic>? avgBreath = brs.firstWhere(
(element) => element['id'] == 307,
orElse: () => {},
);
List<Map<String, dynamic>> brs =
(widget.sleepReport['brs'] as List).cast<Map<String, dynamic>>();
//307 平均呼吸
//305 基准呼吸
//308 最低呼吸
//309 最高呼吸
// 307 平均呼吸
Map<String, dynamic>? avgBreath = brs.firstWhere(
(element) => element['id'] == 307,
orElse: () => {},
);
// 305 基准呼吸
Map<String, dynamic>? baseBreath = brs.firstWhere(
(element) => element['id'] == 305,
orElse: () => {},
);
Map<String, dynamic>? baseBreath = brs.firstWhere(
(element) => element['id'] == 305,
orElse: () => {},
);
// 308 最低呼吸
Map<String, dynamic>? minBreath = brs.firstWhere(
(element) => element['id'] == 308,
orElse: () => {},
);
Map<String, dynamic>? minBreath = brs.firstWhere(
(element) => element['id'] == 308,
orElse: () => {},
);
// 309 最高呼吸
Map<String, dynamic>? maxBreath = brs.firstWhere(
(element) => element['id'] == 309,
orElse: () => {},
);
Map<String, dynamic>? maxBreath = brs.firstWhere(
(element) => element['id'] == 309,
orElse: () => {},
);
String range = baseBreath['range'] ?? '';
int min = 0;
int max = 0;
String range = baseBreath['range'] ?? '';
int min = 0;
int max = 0;
if (range.isNotEmpty && range.contains('~')) {
List<String> parts = range.split('~');
if (parts.length == 2) {
min = int.tryParse(parts[0]) ?? 0;
max = int.tryParse(parts[1]) ?? 0;
if (range.isNotEmpty && range.contains('~')) {
List<String> parts = range.split('~');
if (parts.length == 2) {
min = int.tryParse(parts[0]) ?? 0;
max = int.tryParse(parts[1]) ?? 0;
}
}
}
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: [
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(
"呼吸数据介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,
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: [
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(
"呼吸数据介绍".tr,
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: 31.rpx,
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 30.rpx, 0.rpx),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
// 圆形小球容器
Container(
width: 14.rpx, // 圆球的直径
height: 14.rpx,
decoration: BoxDecoration(
color: themeController.currentColor.sc2, // 小球的颜色
shape: BoxShape.circle, // 设置为圆形
),
),
SizedBox(width: 15.rpx), // 圆球和文字之间的间隔
// 文字
Text(
'正常范围'.tr + "${range}",
style: TextStyle(
fontSize:
AppConstants().smaller_text_fontSize, // 文字的大小
color: themeController.currentColor.sc3, // 文字颜色
),
),
],
),
Container(
// color: Colors.red,
width: double.infinity,
// height: 300.rpx,
child: TimeSeriesChart(
startTime: startTime,
endTime: endTime,
yMin: 50,
yMax: 150,
dataPoints: dataPoints,
actYMax: max.toDouble(),
actYMin: min.toDouble(),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
30.rpx, 0.rpx, 0.rpx, 0.rpx),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
SizedBox(
height: 31.rpx,
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 30.rpx, 0.rpx),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
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,
)),
),
],
// 圆形小球容器
Container(
width: 14.rpx, // 圆球的直径
height: 14.rpx,
decoration: BoxDecoration(
color: themeController.currentColor.sc2, // 小球的颜色
shape: BoxShape.circle, // 设置为圆形
),
),
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,
)),
),
],
SizedBox(width: 15.rpx), // 圆球和文字之间的间隔
// 文字
Text(
'正常范围'.tr + "${range}",
style: TextStyle(
fontSize:
AppConstants().smaller_text_fontSize, // 文字的大小
color: themeController.currentColor.sc3, // 文字颜色
),
),
],
),
),
].divide(SizedBox(
height: 18.rpx,
)),
Container(
// color: Colors.red,
width: double.infinity,
// height: 300.rpx,
child: TimeSeriesChart(
startTime: startTime,
endTime: endTime,
yMin: 50,
yMax: 150,
dataPoints: dataPoints,
actYMax: max.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(
height: 18.rpx,
)),
),
),
),
],
],
),
),
),
);
);
} catch (e) {
es.EasyDartModule.logger.error("打鼾监测绘制异常${e}");
return Container();
}
}
}

View File

@@ -8,6 +8,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/SleepRadarChart.dart';
import 'package:EasyDartModule/EasyDartModule.dart' as es;
class CompareSleepWidget extends StatefulWidget {
var sleepReport;
@@ -35,29 +36,15 @@ class _CompareSleepWidgetState extends State<CompareSleepWidget> {
@override
Widget build(BuildContext context) {
if (widget.sleepReport == null ||
try {
if (widget.sleepReport == null ||
widget.sleepReport['yc'] == null ||
widget.sleepReport['yc'].isEmpty) {
return Container();
}
List<Map<String, dynamic>> data = (widget.sleepReport['yc'] as List)
.map((e) => e as Map<String, dynamic>)
.toList();
// var today = {
// "type1": 40.0,
// "type2": 80.0,
// "type3": 60.0,
// "type4": 70.0,
// "type5": 100.0
// };
// var yesterday = {
// "type1": 40.0,
// "type2": 90.0,
// "type3": 50.0,
// "type4": 70.0,
// "type5": 30.0
// };
.toList();
Map<String, double> today = {};
Map<String, double> yesterday = {};
@@ -210,5 +197,10 @@ class _CompareSleepWidgetState extends State<CompareSleepWidget> {
),
),
);
} catch (e) {
es.EasyDartModule.logger.error("打鼾监测绘制异常${e}");
return Container();
}
}
}

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/HorizontalBarChart.dart';
import 'package:EasyDartModule/EasyDartModule.dart' as es;
class DiseasePercentsWidget extends StatefulWidget {
var sleepReport;
@@ -17,51 +18,7 @@ class DiseasePercentsWidget extends StatefulWidget {
}
class _DiseasePercentsWidgetState extends State<DiseasePercentsWidget> {
// var showLabel = [
// {
// "key": 1,
// "name": "心脏病",
// "color": stringToColor("#00C1AA"),
// "percent": 45,
// "explain": "心脏病是指心脏的结构或功能异常,可能导致心脏无法有效地泵血。"
// },
// {
// "key": 2,
// "name": "高血压",
// "color": stringToColor("#00C1AA"),
// "percent": 32,
// "explain": "高血压是指血液在动脉中流动时对血管壁施加的压力过高。"
// },
// {
// "key": 3,
// "name": "糖尿病",
// "color": stringToColor("#00C1AA"),
// "percent": 50,
// "explain": "糖尿病是一种代谢性疾病,导致血糖水平异常升高。"
// },
// {
// "key": 4,
// "name": "甲亢",
// "color": stringToColor("#FF7159"),
// "percent": 80,
// "explain": "甲亢是指甲状腺分泌过多的甲状腺激素,导致新陈代谢加速。"
// },
// {
// "key": 5,
// "name": "消化系统",
// "color": stringToColor("#00C1AA"),
// "percent": 12,
// "explain": "消化系统是身体中处理食物的机构,是造成疾病和疾病症状的来源。",
// },
// {
// "key": 6,
// "name": "呼吸系统",
// "color": stringToColor("#00C1AA"),
// "percent": 62,
// "explain": "呼吸系统是负责气体交换的器官系统,包括鼻、喉、气管和肺等。",
// },
// ];
@override
void setState(VoidCallback callback) {
super.setState(callback);
@@ -79,7 +36,8 @@ class _DiseasePercentsWidgetState extends State<DiseasePercentsWidget> {
@override
Widget build(BuildContext context) {
if (widget.sleepReport == null ||
try {
if (widget.sleepReport == null ||
widget.sleepReport['cdri'] == null ||
widget.sleepReport['cdri'].isEmpty) {
return Container();
@@ -157,6 +115,11 @@ class _DiseasePercentsWidgetState extends State<DiseasePercentsWidget> {
),
),
);
} catch (e) {
es.EasyDartModule.logger.error("打鼾监测绘制异常${e}");
return Container();
}
}
List<Map<String, dynamic>> convertDiseaseData(List data) {

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/DataShowWidget.dart';
import 'package:EasyDartModule/EasyDartModule.dart' as es;
class HeartChangeWidget extends StatefulWidget {
var sleepReport;
@@ -34,293 +35,235 @@ class _HeartChangeWidgetState extends State<HeartChangeWidget> {
@override
Widget build(BuildContext context) {
if (widget.sleepReport == null ||
widget.sleepReport['hrvs'] == null ||
widget.sleepReport['hrvs'].isEmpty) {
try {
if (widget.sleepReport == null ||
widget.sleepReport['hrvs'] == null ||
widget.sleepReport['hrvs'].isEmpty) {
return Container();
}
List dataList = widget.sleepReport['hrvs'];
List<Map<String, dynamic>> data = transformHrvData(dataList);
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: [
Text(
"心率变异性HRV".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(
"心率变异性HRV介绍".tr,
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,
),
),
),
],
),
),
SizedBox(
height: 31.rpx,
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 0.rpx, 0.rpx),
child: Column(
children: [
DataShowWidget(
alignment: MainAxisAlignment.center,
widget1: Text(
"名称",
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
),
),
widget2: Text(
"测量值",
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
),
),
widget3: Text(
"参考范围",
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
),
),
widget4: Text(
"趋势",
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
),
),
),
Column(
children: data.map<Widget>((data) {
return DataShowWidget(
alignment: MainAxisAlignment.center,
widget1: Row(
children: [
Text(
'${data['name']}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().normal_text_fontSize,
),
),
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: Colors.white,
padding: EdgeInsetsDirectional.fromSTEB(
14.rpx, 14.rpx, 14.rpx, 14.rpx),
borderRadius: 0.rpx,
onTap: () {
// Get.toNamed("/deviceShareListPage", arguments: explain);
showTipDialog(
context,
Container(
child: Text(
'${data['desc']}',
style: TextStyle(
fontSize: 26.rpx,
color:
themeController.currentColor.sc3,
),
),
),
);
},
child: SizedBox(
width: 17.rpx,
height: 17.rpx,
child: SvgPicture.asset(
'assets/img/icon/explain.svg',
fit: BoxFit.cover,
color: Colors.white,
),
),
),
],
),
widget2: Text(
'${data['value']}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().normal_text_fontSize,
),
),
widget3: Text(
'${data['range']}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().normal_text_fontSize,
),
),
widget4: data['change'] == 0
? Padding(
padding: EdgeInsetsDirectional.fromSTEB(
0, 0.rpx, 0, 0),
child: Container(
width: 22.rpx,
height: 22.rpx,
decoration: BoxDecoration(),
child: SvgPicture.asset(
'assets/img/icon/score_up.svg',
// fit: BoxFit.cover,
),
),
)
: data['change'] == 1
? Padding(
padding: EdgeInsetsDirectional.fromSTEB(
0, 0.rpx, 0, 0),
child: Container(
width: 22.rpx,
height: 22.rpx,
decoration: BoxDecoration(),
child: SvgPicture.asset(
'assets/img/icon/score_down.svg',
// fit: BoxFit.cover,
),
),
)
: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
0, 0.rpx, 0, 0),
child: Container(
width: 22.rpx,
height: 22.rpx,
decoration: BoxDecoration(),
child: SvgPicture.asset(
'assets/img/icon/score_equal.svg',
// fit: BoxFit.fill,
),
),
),
).paddingOnly(bottom: 0.rpx); // 在每个组件下方添加间隔
}).toList(),
),
],
),
),
],
),
),
);
} catch (e) {
es.EasyDartModule.logger.error("打鼾监测绘制异常${e}");
return Container();
}
List dataList = widget.sleepReport['hrvs'];
//0上升 1下降 2持平
// List data = [
// {
// "name": "心脏总能量",
// "value": 5262,
// "range": "2055-6000",
// "change": 0,
// "desc": "心脏总能量介绍"
// },
// {
// "name": "心率减速力",
// "value": 5262,
// "range": "2055-6000",
// "change": 1,
// "desc": "心率减速力介绍"
// },
// {
// "name": "迷走神经张力指数",
// "value": 5262,
// "range": "2055-6000",
// "change": 2,
// "desc": "迷走神经张力指数介绍"
// },
// {
// "name": "交感神经张力指数",
// "value": 5262,
// "range": "2055-6000",
// "change": 0,
// "desc": "交感神经张力指数介绍"
// },
// {
// "name": "自主神经张力指数",
// "value": 5262,
// "range": "2055-6000",
// "change": 2,
// "desc": "自主神经张力指数介绍"
// },
// {
// "name": "血管舒张指数",
// "value": 5262,
// "range": "2055-6000",
// "change": 1,
// "desc": "血管舒张指数介绍"
// },
// {
// "name": "SDNN",
// "value": 5262,
// "range": "2055-6000",
// "change": 0,
// "desc": "SDNN介绍"
// },
// {
// "name": "PNN50",
// "value": 5262,
// "range": "2055-6000",
// "change": 1,
// "desc": "PNN50介绍"
// },
// {
// "name": "RMSSD",
// "value": 5262,
// "range": "2055-6000",
// "change": 2,
// "desc": "RMSSD介绍"
// },
// ];
List<Map<String, dynamic>> data = transformHrvData(dataList);
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: [
Text(
"心率变异性HRV".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(
"心率变异性HRV介绍".tr,
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,
),
),
),
],
),
),
SizedBox(
height: 31.rpx,
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 0.rpx, 0.rpx),
child: Column(
children: [
DataShowWidget(
alignment: MainAxisAlignment.center,
widget1: Text(
"名称",
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
),
),
widget2: Text(
"测量值",
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
),
),
widget3: Text(
"参考范围",
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
),
),
widget4: Text(
"趋势",
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
),
),
),
Column(
children: data.map<Widget>((data) {
return DataShowWidget(
alignment: MainAxisAlignment.center,
widget1: Row(
children: [
Text(
'${data['name']}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().normal_text_fontSize,
),
),
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: Colors.white,
padding: EdgeInsetsDirectional.fromSTEB(
14.rpx, 14.rpx, 14.rpx, 14.rpx),
borderRadius: 0.rpx,
onTap: () {
// Get.toNamed("/deviceShareListPage", arguments: explain);
showTipDialog(
context,
Container(
child: Text(
'${data['desc']}',
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,
),
),
),
);
},
child: SizedBox(
width: 17.rpx,
height: 17.rpx,
child: SvgPicture.asset(
'assets/img/icon/explain.svg',
fit: BoxFit.cover,
color: Colors.white,
),
),
),
],
),
widget2: Text(
'${data['value']}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().normal_text_fontSize,
),
),
widget3: Text(
'${data['range']}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().normal_text_fontSize,
),
),
widget4: data['change'] == 0
? Padding(
padding: EdgeInsetsDirectional.fromSTEB(
0, 0.rpx, 0, 0),
child: Container(
width: 22.rpx,
height: 22.rpx,
decoration: BoxDecoration(),
child: SvgPicture.asset(
'assets/img/icon/score_up.svg',
// fit: BoxFit.cover,
),
),
)
: data['change'] == 1
? Padding(
padding: EdgeInsetsDirectional.fromSTEB(
0, 0.rpx, 0, 0),
child: Container(
width: 22.rpx,
height: 22.rpx,
decoration: BoxDecoration(),
child: SvgPicture.asset(
'assets/img/icon/score_down.svg',
// fit: BoxFit.cover,
),
),
)
: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
0, 0.rpx, 0, 0),
child: Container(
width: 22.rpx,
height: 22.rpx,
decoration: BoxDecoration(),
child: SvgPicture.asset(
'assets/img/icon/score_equal.svg',
// fit: BoxFit.fill,
),
),
),
).paddingOnly(bottom: 0.rpx); // 在每个组件下方添加间隔
}).toList(),
),
],
),
),
],
),
),
);
}
List<Map<String, dynamic>> transformHrvData(List<dynamic> originalData) {

View File

@@ -8,6 +8,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/FatigueCircleIndicator.dart';
import 'package:EasyDartModule/EasyDartModule.dart' as es;
class HeartHealthWidget extends StatefulWidget {
var sleepReport;
@@ -35,98 +36,104 @@ class _HeartHealthWidgetState extends State<HeartHealthWidget> {
@override
Widget build(BuildContext context) {
if (widget.sleepReport == null ||
widget.sleepReport['mha'] == null ||
widget.sleepReport['mha'].isEmpty) {
return Container();
}
try {
if (widget.sleepReport == null ||
widget.sleepReport['mha'] == null ||
widget.sleepReport['mha'].isEmpty) {
return Container();
}
List data = widget.sleepReport['mha'];
var showLabel = convertMentalHealthData(data);
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(
"心理健康评估介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,
List data = widget.sleepReport['mha'];
var showLabel = convertMentalHealthData(data);
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(
"心理健康评估介绍".tr,
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: 104.rpx,
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(30.rpx, 0.rpx, 30.rpx, 0.rpx),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FatigueCircleIndicator(
data: showLabel[0],
),
FatigueCircleIndicator(
data: showLabel[1],
),
].divide(SizedBox(
width: 110.rpx,
)),
SizedBox(
height: 104.rpx,
),
),
SizedBox(
height: 72.rpx,
),
],
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
30.rpx, 0.rpx, 30.rpx, 0.rpx),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FatigueCircleIndicator(
data: showLabel[0],
),
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) {
@@ -136,7 +143,7 @@ class _HeartHealthWidgetState extends State<HeartHealthWidget> {
final String explain =
(item['tips'] != null && (item['tips'] as String).trim().isNotEmpty)
? item['tips']
: '高风险';
: '未知数据'.tr;
return {
'name': item['name'],
@@ -144,7 +151,7 @@ class _HeartHealthWidgetState extends State<HeartHealthWidget> {
? stringToColor(colorStr)
: stringToColor("#00C1AA"), // 默认红色
'percent': value,
'explain': explain,
'explain': item['level'],
"bottomColor": Colors.grey,
};
}).toList();

View File

@@ -10,6 +10,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/ScatterPlotChart.dart';
import 'package:EasyDartModule/EasyDartModule.dart' as es;
class HeartPointWidget extends StatefulWidget {
var sleepReport;
@@ -37,125 +38,120 @@ class _HeartPointWidgetState extends State<HeartPointWidget> {
@override
Widget build(BuildContext context) {
if (widget.sleepReport == null ||
widget.sleepReport['hrsp'] == null ||
widget.sleepReport['hrsp'].isEmpty) {
return Container();
}
// List rawData = widget.sleepReport['hrsp'];
// List<ScatterSpot> data = List.generate(200, (index) {
// // 随机生成 x 和 y 值,范围都在 0-1400 之间
// double x = Random().nextDouble() * 1400; // x 值在 0-1400 范围
// double y = Random().nextDouble() * 1400; // y 值也在 0-1400 范围
// // 返回 ScatterSpot使用圆点绘制器自定义大小和颜色
// return ScatterSpot(
// x,
// y,
// );
// });
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);
}
if (widget.sleepReport == null ||
widget.sleepReport['hrsp'] == null ||
widget.sleepReport['hrsp'].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, 45.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(
"心率散点图介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,
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: [
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(
"心率散点图介绍".tr,
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: 31.rpx,
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
30.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轴最大值
pointColor: stringToColor("#00C1AA"), // 点的颜色
divisions: 7, // 刻度分割数量
),
],
),
),
SizedBox(
height: 31.rpx,
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(30.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轴最大值
pointColor: stringToColor("#00C1AA"), // 点的颜色
divisions: 7, // 刻度分割数量
),
),
),
// SizedBox(
// height: 31.rpx,
// ),
],
// SizedBox(
// height: 31.rpx,
// ),
],
),
),
),
);
);
} catch (e) {
es.EasyDartModule.logger.error("打鼾监测绘制异常${e}");
return Container();
}
}
}

View File

@@ -3,68 +3,138 @@ 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/home_page/SleepDataModuleWidget.dart';
import 'package:EasyDartModule/EasyDartModule.dart' as es;
class HeartRateCard extends StatefulWidget {
var sleepReport;
HeartRateCard({super.key, required this.sleepReport});
final int? highlightItem;
HeartRateCard({super.key, required this.sleepReport, this.highlightItem});
@override
State<HeartRateCard> createState() => _HeartRateCardState();
}
class _HeartRateCardState extends State<HeartRateCard> {
@override
void setState(VoidCallback callback) {
super.setState(callback);
}
class _HeartRateCardState extends State<HeartRateCard> with TickerProviderStateMixin {
final GlobalKey _highlightKey = GlobalKey();
AnimationController? _animationController;
bool _shouldAnimate = false;
int? _highlightedId;
int _flashCount = 0; // 用于跟踪闪烁次数
@override
void initState() {
super.initState();
if (widget.highlightItem != null) {
_highlightedId = widget.highlightItem;
_shouldAnimate = true;
_initAnimation();
}
WidgetsBinding.instance.addPostFrameCallback((_) {
if (widget.highlightItem != null && _highlightKey.currentContext != null) {
Scrollable.ensureVisible(
_highlightKey.currentContext!,
duration: Duration(milliseconds: 500),
curve: Curves.easeInOut,
alignment: 0.3,
);
}
});
}
void _initAnimation() {
_animationController = AnimationController(
vsync: this,
duration: Duration(milliseconds: 300),
)..addStatusListener((status) {
if (status == AnimationStatus.completed) {
// 正向动画完成,开始反向动画
_animationController!.reverse();
} else if (status == AnimationStatus.dismissed) {
// 反向动画完成,增加计数
_flashCount++;
// 闪烁3次后停止
if (_flashCount >= 5) {
_animationController!.dispose();
setState(() {
_shouldAnimate = false;
_highlightedId = null;
});
} else {
// 继续下一次闪烁
_animationController!.forward();
}
}
});
_animationController!.forward();
}
@override
void dispose() {
_animationController?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
if (widget.sleepReport == null ||
widget.sleepReport is! Map ||
widget.sleepReport.isEmpty) {
try {
if (widget.sleepReport == null ||
widget.sleepReport is! Map ||
widget.sleepReport.isEmpty) {
return Container();
}
List data = widget.sleepReport['hrs'] ?? [];
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: Wrap(
spacing: 23.rpx,
runSpacing: 25.rpx,
children: List.generate(data.length, (index) {
final item = data[index];
item['showTip'] = true;
final bool isHighlighted = _shouldAnimate &&
item['id'] == _highlightedId;
return SizedBox(
width: (MediaQuery.of(context).size.width - 160.rpx) / 3,
child: AnimatedBuilder(
animation: _animationController ?? AlwaysStoppedAnimation(0),
builder: (context, child) {
return Container(
key: isHighlighted ? _highlightKey : null,
decoration: isHighlighted
? BoxDecoration(
border: Border.all(
color: themeController.currentColor.sc2
.withOpacity(_animationController?.value ?? 0),
width: 1.rpx,
),
borderRadius: BorderRadius.circular(8),
)
: null,
child: SleepDataModuleWidget(data: item),
);
},
),
);
}),
),
),
);
} catch (e) {
es.EasyDartModule.logger.error("心率监测绘制异常${e}");
return Container();
}
List data = widget.sleepReport['hrs'] ?? [];
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: Wrap(
spacing: 23.rpx, // 横向间距(左右间距如需加可设置)
runSpacing: 25.rpx, // 每行之间的垂直间距
children: List.generate(data.length, (index) {
final item = data[index];
item['showTip'] = true;
return SizedBox(
width: (MediaQuery.of(context).size.width - 160.rpx) / 3,
child: SleepDataModuleWidget(data: item),
// child: Container(
// width: 20,
// height: 20,
// color: Colors.red,
// ),
);
}),
),
),
);
}
}
}

View File

@@ -8,6 +8,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/TimeSeriesChart.dart';
import 'package:EasyDartModule/EasyDartModule.dart' as es;
class HeartRateStandardWidget extends StatefulWidget {
var sleepReport;
@@ -36,340 +37,346 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
@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();
}
final startTime = widget.sleepReport['startTime'];
final endTime = widget.sleepReport['endTime'];
List<Map<String, dynamic>> data =
(widget.sleepReport['hrbc'] as List).cast<Map<String, dynamic>>();
final dataPoints = data.map((item) {
final x = item['st'] as int;
final y = (item['value'] as num).toDouble(); // 安全地转换为 double
return TimeSeriesPoint(x, y);
}).toList();
final startTime = widget.sleepReport['startTime'];
final endTime = widget.sleepReport['endTime'];
List<Map<String, dynamic>> data =
(widget.sleepReport['hrbc'] as List).cast<Map<String, dynamic>>();
final dataPoints = data.map((item) {
final x = item['st'] as int;
final y = (item['value'] as num).toDouble(); // 安全地转换为 double
return TimeSeriesPoint(x, y);
}).toList();
List<Map<String, dynamic>> hrs =
(widget.sleepReport['hrs'] as List).cast<Map<String, dynamic>>();
//206 平均心率
//202 基准心率
//207 最低心率
//208 最高心率
// 找 id == 206 的元素(平均心率)
Map<String, dynamic>? avgHeartRate = hrs.firstWhere(
(element) => element['id'] == 206,
orElse: () => {},
);
List<Map<String, dynamic>> hrs =
(widget.sleepReport['hrs'] as List).cast<Map<String, dynamic>>();
//206 平均心率
//202 基准心率
//207 最低心率
//208 最高心率
// 找 id == 206 的元素(平均心率)
Map<String, dynamic>? avgHeartRate = hrs.firstWhere(
(element) => element['id'] == 206,
orElse: () => {},
);
// 找 id == 202 的元素(基准心率)
Map<String, dynamic>? baseHeartRate = hrs.firstWhere(
(element) => element['id'] == 202,
orElse: () => {},
);
Map<String, dynamic>? baseHeartRate = hrs.firstWhere(
(element) => element['id'] == 202,
orElse: () => {},
);
// 找 id == 207 的元素(最低心率)
Map<String, dynamic>? minHeartRate = hrs.firstWhere(
(element) => element['id'] == 207,
orElse: () => {},
);
Map<String, dynamic>? minHeartRate = hrs.firstWhere(
(element) => element['id'] == 207,
orElse: () => {},
);
// 找 id == 208 的元素(最高心率)
Map<String, dynamic>? maxHeartRate = hrs.firstWhere(
(element) => element['id'] == 208,
orElse: () => {},
);
String range = baseHeartRate['range'] ?? '';
int min = 0;
int max = 0;
Map<String, dynamic>? maxHeartRate = hrs.firstWhere(
(element) => element['id'] == 208,
orElse: () => {},
);
String range = baseHeartRate['range'] ?? '';
int min = 0;
int max = 0;
if (range.isNotEmpty && range.contains('~')) {
List<String> parts = range.split('~');
if (parts.length == 2) {
min = int.tryParse(parts[0]) ?? 0;
max = int.tryParse(parts[1]) ?? 0;
if (range.isNotEmpty && range.contains('~')) {
List<String> parts = range.split('~');
if (parts.length == 2) {
min = int.tryParse(parts[0]) ?? 0;
max = int.tryParse(parts[1]) ?? 0;
}
}
}
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: [
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(
"心率数据介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,
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: [
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(
"心率数据介绍".tr,
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: 31.rpx,
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 30.rpx, 0.rpx),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
// 圆形小球容器
Container(
width: 14.rpx, // 圆球的直径
height: 14.rpx,
decoration: BoxDecoration(
color: themeController.currentColor.sc2, // 小球的颜色
shape: BoxShape.circle, // 设置为圆形
),
),
SizedBox(width: 15.rpx), // 圆球和文字之间的间隔
// 文字
Text(
'正常范围'.tr + "${range}",
style: TextStyle(
fontSize:
AppConstants().smaller_text_fontSize, // 文字的大小
color: themeController.currentColor.sc3, // 文字颜色
),
),
],
),
// Container(
// // color: Colors.red,
// width: double.infinity,
// // height: 300.rpx,
// child: TimeSeriesChart(
// startTime: startTime,
// endTime: endTime,
// yMin: min.toDouble(),
// yMax: max.toDouble(),
// dataPoints: dataPoints,
// ),
// ),
Container(
// color: Colors.red,
width: double.infinity,
// height: 300.rpx,
child: TimeSeriesChart(
startTime: startTime,
endTime: endTime,
yMin: 50,
yMax: 150,
dataPoints: dataPoints,
actYMin: min.toDouble(),
actYMax: max.toDouble(),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
30.rpx, 0.rpx, 0.rpx, 0.rpx),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
SizedBox(
height: 31.rpx,
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 30.rpx, 0.rpx),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Column(
children: [
Text(
"${avgHeartRate['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
AppConstants().normal_text_fontSize),
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"${avgHeartRate['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
AppConstants().normal_text_fontSize),
),
Text(
"${avgHeartRate['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
AppConstants().small_text_fontSize),
),
].divide(SizedBox(
width: 6.rpx,
)),
),
],
// 圆形小球容器
Container(
width: 14.rpx, // 圆球的直径
height: 14.rpx,
decoration: BoxDecoration(
color: themeController.currentColor.sc2, // 小球的颜色
shape: BoxShape.circle, // 设置为圆形
),
),
Column(
children: [
Text(
"${baseHeartRate['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
AppConstants().normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"${baseHeartRate['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
AppConstants().normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
"${baseHeartRate['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(
"${minHeartRate['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
AppConstants().normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"${minHeartRate['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
AppConstants().normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
"${minHeartRate['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(
"${maxHeartRate['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
AppConstants().normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"${maxHeartRate['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
AppConstants().normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
"${maxHeartRate['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
AppConstants().small_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
].divide(SizedBox(
width: 6.rpx,
)),
),
],
SizedBox(width: 15.rpx), // 圆球和文字之间的间隔
// 文字
Text(
'正常范围'.tr + "${range}",
style: TextStyle(
fontSize:
AppConstants().smaller_text_fontSize, // 文字的大小
color: themeController.currentColor.sc3, // 文字颜色
),
),
],
),
),
].divide(SizedBox(
height: 18.rpx,
)),
// Container(
// // color: Colors.red,
// width: double.infinity,
// // height: 300.rpx,
// child: TimeSeriesChart(
// startTime: startTime,
// endTime: endTime,
// yMin: min.toDouble(),
// yMax: max.toDouble(),
// dataPoints: dataPoints,
// ),
// ),
Container(
// color: Colors.red,
width: double.infinity,
// height: 300.rpx,
child: TimeSeriesChart(
startTime: startTime,
endTime: endTime,
yMin: 50,
yMax: 150,
dataPoints: dataPoints,
actYMin: min.toDouble(),
actYMax: max.toDouble(),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
30.rpx, 0.rpx, 0.rpx, 0.rpx),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
children: [
Text(
"${avgHeartRate['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
AppConstants().normal_text_fontSize),
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"${avgHeartRate['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize: AppConstants()
.normal_text_fontSize),
),
Text(
"${avgHeartRate['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
AppConstants().small_text_fontSize),
),
].divide(SizedBox(
width: 6.rpx,
)),
),
],
),
Column(
children: [
Text(
"${baseHeartRate['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
AppConstants().normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"${baseHeartRate['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize: AppConstants()
.normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
"${baseHeartRate['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(
"${minHeartRate['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
AppConstants().normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"${minHeartRate['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize: AppConstants()
.normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
"${minHeartRate['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(
"${maxHeartRate['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
AppConstants().normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"${maxHeartRate['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize: AppConstants()
.normal_text_fontSize),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
Text(
"${maxHeartRate['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,
)),
),
),
),
],
],
),
),
),
);
);
} catch (e) {
es.EasyDartModule.logger.error("打鼾监测绘制异常${e}");
return Container();
}
}
}

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/StatusBarWithIndicator.dart';
import 'package:EasyDartModule/EasyDartModule.dart' as es;
class HrvWidget extends StatefulWidget {
HrvWidget({super.key});
@@ -33,85 +34,91 @@ class _HrvWidgetState extends State<HrvWidget> {
@override
Widget build(BuildContext context) {
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: [
Text(
"心率变异性HRV".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(
"心率变异性HRV介绍。",
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,
try {
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: [
Text(
"心率变异性HRV".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(
"心率变异性HRV介绍。",
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: 83.rpx,
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(30.rpx, 0.rpx, 30.rpx, 0.rpx),
child: StatusBarWithIndicator(
selectKey: 2,
showLabel: [
{"key": 1, "name": "正常", "color": Color(0xFF4CAF50)},
{"key": 2, "name": "一般", "color": Color(0xFF8BC34A)},
{"key": 3, "name": "注意", "color": Color(0xFFFFC107)},
{"key": 4, "name": "警告", "color": Color(0xFFF44336)},
],
SizedBox(
height: 83.rpx,
),
),
SizedBox(
height: 56.rpx,
),
],
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
30.rpx, 0.rpx, 30.rpx, 0.rpx),
child: StatusBarWithIndicator(
selectKey: 2,
showLabel: [
{"key": 1, "name": "正常", "color": Color(0xFF4CAF50)},
{"key": 2, "name": "一般", "color": Color(0xFF8BC34A)},
{"key": 3, "name": "注意", "color": Color(0xFFFFC107)},
{"key": 4, "name": "警告", "color": Color(0xFFF44336)},
],
),
),
SizedBox(
height: 56.rpx,
),
],
),
),
),
);
);
} catch (e) {
es.EasyDartModule.logger.error("打鼾监测绘制异常${e}");
return Container();
}
}
}

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/StatusBarWithIndicator.dart';
import 'package:EasyDartModule/EasyDartModule.dart' as es;
class SkinPercentWidget extends StatefulWidget {
var sleepReport;
@@ -34,7 +35,8 @@ class _SkinPercentWidgetState extends State<SkinPercentWidget> {
@override
Widget build(BuildContext context) {
if (widget.sleepReport == null ||
try {
if (widget.sleepReport == null ||
widget.sleepReport['sicp'] == null ||
widget.sleepReport['sicp'].isEmpty) {
return Container();
@@ -134,5 +136,10 @@ class _SkinPercentWidgetState extends State<SkinPercentWidget> {
),
),
);
} catch (e) {
es.EasyDartModule.logger.error("打鼾监测绘制异常${e}");
return Container();
}
}
}

View File

@@ -3,68 +3,139 @@ 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/home_page/SleepDataModuleWidget.dart';
import 'package:EasyDartModule/EasyDartModule.dart' as es;
class SleepCard extends StatefulWidget {
var sleepReport;
SleepCard({super.key, required this.sleepReport});
final dynamic sleepReport;
final int? highlightItem;
SleepCard({super.key, required this.sleepReport, this.highlightItem});
@override
State<SleepCard> createState() => _SleepCardState();
}
class _SleepCardState extends State<SleepCard> {
@override
void setState(VoidCallback callback) {
super.setState(callback);
}
class _SleepCardState extends State<SleepCard> with TickerProviderStateMixin {
final GlobalKey _highlightKey = GlobalKey();
AnimationController? _animationController;
bool _shouldAnimate = false;
int? _highlightedId;
int _flashCount = 0; // 用于跟踪闪烁次数
@override
void initState() {
super.initState();
if (widget.highlightItem != null) {
_highlightedId = widget.highlightItem;
_shouldAnimate = true;
_initAnimation();
}
WidgetsBinding.instance.addPostFrameCallback((_) {
if (widget.highlightItem != null && _highlightKey.currentContext != null) {
Scrollable.ensureVisible(
_highlightKey.currentContext!,
duration: Duration(milliseconds: 500),
curve: Curves.easeInOut,
alignment: 0.3,
);
}
});
}
void _initAnimation() {
_animationController = AnimationController(
vsync: this,
duration: Duration(milliseconds: 300),
)..addStatusListener((status) {
if (status == AnimationStatus.completed) {
// 正向动画完成,开始反向动画
_animationController!.reverse();
} else if (status == AnimationStatus.dismissed) {
// 反向动画完成,增加计数
_flashCount++;
// 闪烁3次后停止
if (_flashCount >= 5) {
_animationController!.dispose();
setState(() {
_shouldAnimate = false;
_highlightedId = null;
});
} else {
// 继续下一次闪烁
_animationController!.forward();
}
}
});
_animationController!.forward();
}
@override
void dispose() {
_animationController?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
if (widget.sleepReport == null ||
widget.sleepReport is! Map ||
widget.sleepReport.isEmpty) {
try {
if (widget.sleepReport == null ||
widget.sleepReport is! Map ||
widget.sleepReport.isEmpty) {
return Container();
}
List data = widget.sleepReport['bs'] ?? [];
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: Wrap(
spacing: 23.rpx,
runSpacing: 25.rpx,
children: List.generate(data.length, (index) {
final item = data[index];
item['showTip'] = true;
final bool isHighlighted = _shouldAnimate &&
item['id'] == _highlightedId;
return SizedBox(
width: (MediaQuery.of(context).size.width - 160.rpx) / 3,
child: AnimatedBuilder(
animation: _animationController ?? AlwaysStoppedAnimation(0),
builder: (context, child) {
return Container(
key: isHighlighted ? _highlightKey : null,
decoration: isHighlighted
? BoxDecoration(
border: Border.all(
color: themeController.currentColor.sc2
.withOpacity(_animationController?.value ?? 0),
width: 1.rpx,
),
borderRadius: BorderRadius.circular(8),
)
: null,
child: SleepDataModuleWidget(data: item),
);
},
),
);
}),
),
),
);
} catch (e) {
es.EasyDartModule.logger.error("打鼾监测绘制异常${e}");
return Container();
}
List data = widget.sleepReport['bs'] ?? [];
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: Wrap(
spacing: 23.rpx, // 横向间距(左右间距如需加可设置)
runSpacing: 25.rpx, // 每行之间的垂直间距
children: List.generate(data.length, (index) {
final item = data[index];
item['showTip'] = true;
return SizedBox(
width: (MediaQuery.of(context).size.width - 160.rpx) / 3,
child: SleepDataModuleWidget(data: item),
// child: Container(
// width: 20,
// height: 20,
// color: Colors.red,
// ),
);
}),
),
),
);
}
}
}

View File

@@ -5,6 +5,7 @@ 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/pages/sleep_report/chart/SegmentedCirclePainter.dart';
import 'package:EasyDartModule/EasyDartModule.dart' as es;
class SleepScoreWidget extends StatefulWidget {
var sleepReport;
@@ -32,17 +33,13 @@ class _SleepScoreWidgetState extends State<SleepScoreWidget> {
@override
Widget build(BuildContext context) {
if (widget.sleepReport == null ||
try {
if (widget.sleepReport == null ||
widget.sleepReport is! Map ||
widget.sleepReport.isEmpty) {
return Container();
}
// List<Map<String, dynamic>> showLabel = [
// {"level": 1, "name": "优秀(≥85)", "color": Color(0xFF4CAF50)},
// {"level": 2, "name": "良好(75~84)", "color": Color(0xFF8BC34A)},
// {"level": 3, "name": "合格(60~74)", "color": Color(0xFFFFC107)},
// {"level": 4, "name": "注意(60)", "color": Color(0xFFF44336)},
// ];
List showLabel = widget.sleepReport['score']['type'];
List stages = widget.sleepReport['score']['stages'];
List<SegmentData> segments = parseSegments(widget.sleepReport);
@@ -191,6 +188,11 @@ class _SleepScoreWidgetState extends State<SleepScoreWidget> {
),
),
);
} catch (e) {
es.EasyDartModule.logger.error("打鼾监测绘制异常${e}");
return Container();
}
}
//获取睡眠等级

View File

@@ -8,6 +8,7 @@ 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/GradientLine.dart';
import 'package:vbvs_app/pages/sleep_report/chart/SnoreWaveform.dart';
import 'package:EasyDartModule/EasyDartModule.dart' as es;
//睡眠规律性
class SleepViewWidget extends StatefulWidget {
@@ -36,183 +37,126 @@ class _SleepViewWidgetState extends State<SleepViewWidget> {
@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 showLabel = widget.sleepReport['sleepData']['type'];
List showLabel = widget.sleepReport['sleepData']['type']
.where((item) => item['show'] != false)
.toList();
// List showLabel = widget.sleepReport['sleepData']['type'];
List showLabel = widget.sleepReport['sleepData']['type']
.where((item) => item['show'] != false)
.toList();
List snoreValues = widget.sleepReport['ssp'];
Map time = MyUtils.diffHoursMinutesMap(
widget.sleepReport['startTime'], widget.sleepReport['endTime']);
int hour = time['hours'];
int minutes = time['minutes'];
List stages = widget.sleepReport['sleepData']['stages'];
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: [
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,
List snoreValues = [];
List lightSnore = widget.sleepReport['ssp']['data'][0];
List heavySnore = widget.sleepReport['ssp']['data'][1];
snoreValues = [...lightSnore, ...heavySnore];
snoreValues.sort((a, b) {
return a['st'].compareTo(b['st']);
});
Map time = MyUtils.diffHoursMinutesMap(
widget.sleepReport['startTime'], widget.sleepReport['endTime']);
int hour = time['hours'];
int minutes = time['minutes'];
List stages = widget.sleepReport['sleepData']['stages'];
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: [
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,
),
),
),
],
),
),
SizedBox(
height: 83.rpx,
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
30.rpx, 0.rpx, 30.rpx, 0.rpx),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
// 左侧 - 入睡时间
Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
"assets/img/moon.png",
width: 43.rpx,
height: 43.rpx,
fit: BoxFit.cover,
),
SizedBox(height: 33.rpx),
Container(
height: 40.rpx,
child: Text(
"睡眠规律性介绍。",
"${MyUtils.formatToHHmm(widget.sleepReport['startTime'])}",
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,
fontSize: AppConstants().normal_text_fontSize,
),
),
),
);
},
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: 83.rpx,
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(30.rpx, 0.rpx, 30.rpx, 0.rpx),
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
// 左侧 - 入睡时间
Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
"assets/img/moon.png",
width: 43.rpx,
height: 43.rpx,
fit: BoxFit.cover,
),
SizedBox(height: 33.rpx),
Container(
height: 40.rpx,
child: Text(
"${MyUtils.formatToHHmm(widget.sleepReport['startTime'])}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().normal_text_fontSize,
),
),
),
SizedBox(height: 20.rpx),
Text(
"入睡时间".tr,
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
// 中间 - 渐变线 + 时间
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
height: 43.rpx,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GradientLine(
height: 1,
color: Colors.white60,
),
],
)),
SizedBox(height: 33.rpx), // 与图标对齐
Text.rich(
TextSpan(
children: [
TextSpan(
text: "$hour",
style: TextStyle(
color: themeController
.currentColor.sc2, // 小时数字颜色
fontSize: 36.rpx, // 小时数字字号
),
),
TextSpan(
text: "小时",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().title_text_fontSize,
),
),
TextSpan(
text: "$minutes",
style: TextStyle(
color: themeController
.currentColor.sc2, // 小时数字颜色
fontSize: 36.rpx, // 分钟数字字号
),
),
TextSpan(
text: "分钟",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().title_text_fontSize,
),
),
],
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
SizedBox(height: 20.rpx),
Text(
"睡眠时长".tr,
"入睡时间".tr,
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
@@ -222,111 +166,170 @@ class _SleepViewWidgetState extends State<SleepViewWidget> {
),
],
),
),
// 右侧 - 起床时间图标
Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
"assets/img/sun.png",
width: 43.rpx,
height: 43.rpx,
fit: BoxFit.cover,
// 中间 - 渐变线 + 时间
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
height: 43.rpx,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
GradientLine(
height: 1,
color: Colors.white60,
),
],
)),
SizedBox(height: 33.rpx), // 与图标对齐
Text.rich(
TextSpan(
children: [
TextSpan(
text: "$hour",
style: TextStyle(
color: themeController
.currentColor.sc2, // 小时数字颜色
fontSize: 36.rpx, // 小时数字字号
),
),
TextSpan(
text: "小时",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
AppConstants().title_text_fontSize,
),
),
TextSpan(
text: "$minutes",
style: TextStyle(
color: themeController
.currentColor.sc2, // 小时数字颜色
fontSize: 36.rpx, // 分钟数字字号
),
),
TextSpan(
text: "分钟",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
AppConstants().title_text_fontSize,
),
),
],
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
SizedBox(height: 20.rpx),
Text(
"睡眠时长".tr,
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
SizedBox(height: 33.rpx),
Container(
height: 40.rpx,
child: Text(
"${MyUtils.formatToHHmm(widget.sleepReport['endTime'])}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().normal_text_fontSize,
),
// 右侧 - 起床时间图标
Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
"assets/img/sun.png",
width: 43.rpx,
height: 43.rpx,
fit: BoxFit.cover,
),
SizedBox(height: 33.rpx),
Container(
height: 40.rpx,
child: Text(
"${MyUtils.formatToHHmm(widget.sleepReport['endTime'])}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().normal_text_fontSize,
),
),
),
),
SizedBox(height: 20.rpx),
Text(
"起床时间".tr,
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
SizedBox(height: 20.rpx),
Text(
"起床时间".tr,
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
],
],
),
],
),
),
),
SizedBox(
height: 49.rpx,
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(26.rpx, 0.rpx, 26.rpx, 0.rpx),
child: SnoreChartContainer(
snoreValues: snoreValues,
barData: stages,
startTime: widget.sleepReport['startTime'],
endTime: widget.sleepReport['endTime'],
showLabel: showLabel,
SizedBox(
height: 49.rpx,
),
),
SizedBox(
height: 70.rpx,
),
Wrap(
spacing: 55.rpx,
runSpacing: 20.rpx,
children: showLabel.map<Widget>((item) {
return Container(
padding: EdgeInsets.all(5.rpx),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 20.rpx,
height: 20.rpx,
decoration: BoxDecoration(
color: item["color"] == null || item["color"] == ""
? Colors.transparent
: stringToColor(item["color"]),
borderRadius: BorderRadius.circular(10.rpx),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
26.rpx, 0.rpx, 26.rpx, 0.rpx),
child: SnoreChartContainer(
snoreValues: snoreValues,
barData: stages,
startTime: widget.sleepReport['startTime'],
endTime: widget.sleepReport['endTime'],
showLabel: showLabel,
),
),
SizedBox(
height: 70.rpx,
),
Wrap(
spacing: 55.rpx,
runSpacing: 20.rpx,
children: showLabel.map<Widget>((item) {
return Container(
padding: EdgeInsets.all(5.rpx),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 20.rpx,
height: 20.rpx,
decoration: BoxDecoration(
color: item["color"] == null || item["color"] == ""
? Colors.transparent
: stringToColor(item["color"]),
borderRadius: BorderRadius.circular(10.rpx),
),
),
),
SizedBox(width: 17.rpx),
Text(
item["name"],
style: TextStyle(
color: Colors.white,
fontSize: 24.rpx,
SizedBox(width: 17.rpx),
Text(
item["name"],
style: TextStyle(
color: Colors.white,
fontSize: 24.rpx,
),
),
),
],
),
);
}).toList(),
),
],
],
),
);
}).toList(),
),
],
),
),
),
);
}
List<Map<String, dynamic>> generateSnoreValues(int startTime, int endTime) {
final int count = 100;
final int interval = ((endTime - startTime) / count).floor();
return List.generate(count, (index) {
final timestamp = startTime + interval * index;
final value =
(2 + 1 * (index % 7) / 6.0) * (index % 2 == 0 ? 1 : -1); // 示例上下对称波动
return {
"timestamp": timestamp,
"value": double.parse(value.toStringAsFixed(2)),
};
});
);
} catch (e) {
es.EasyDartModule.logger.error("打鼾监测绘制异常${e}");
return Container();
}
}
}

View File

@@ -1,3 +1,6 @@
import 'dart:math';
import 'package:EasyDartModule/EasyDartModule.dart' as es;
import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
@@ -7,6 +10,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:vbvs_app/pages/sleep_report/chart/SnoreChart.dart';
class SnoreViewWidgetWidget extends StatefulWidget {
var sleepReport;
@@ -34,106 +38,243 @@ class _SnoreViewWidgetWidgetState extends State<SnoreViewWidgetWidget> {
@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();
}
double maxY = 60;
var startTime = widget.sleepReport['startTime'];
var endTime = widget.sleepReport['endTime'];
List snoreValues = [];
List<Map<String, dynamic>> data =
(widget.sleepReport['ssp'] as List).cast<Map<String, dynamic>>();
List<Map<String, dynamic>> showLabel = convertToShowLabel(data);
// List<Map<String, dynamic>> showLabel = [
// // {'startTime': 1748275800344, "endTime": 1748283000000, "times": 4},
// {'startTime': 1748293800000, "endTime": 1748294400000, "times": 7},
// ];
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 type = widget.sleepReport['ssp']['type'];
List lightSnore = widget.sleepReport['ssp']['data'][0];
List heavySnore = widget.sleepReport['ssp']['data'][1];
List<Map> processedLightSnore = lightSnore.map((item) {
return {
...item,
'id': type[0]['id'],
'name': type[0]['name'],
'color': type[0]['color'],
};
}).toList();
List<Map> processedHeavySnore = heavySnore.map((item) {
return {
...item,
'id': type[1]['id'],
'name': type[1]['name'],
'color': type[1]['color'],
};
}).toList();
snoreValues = [...processedLightSnore, ...processedHeavySnore];
snoreValues.sort((a, b) => a['st'].compareTo(b['st']));
print(snoreValues);
List<BarData> barDataList = snoreValues.map<BarData>((item) {
return BarData(
st: item['st'],
et: item['et'],
value: (item['value'] as num).toDouble() > maxY
? maxY + 3
: (item['value'] as num).toDouble(),
id: item['id'],
name: item['name'],
color: (item['color'] == null || item['color'].isEmpty)
? (item['id'] == 1 ? Colors.green : Colors.red)
: stringToColor(item['color']),
);
}).toList();
// List<Map<String, dynamic>> data =
// (widget.sleepReport['ssp'] as List).cast<Map<String, dynamic>>();
// List<Map<String, dynamic>> showLabel = convertToShowLabel(data);
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, 20.rpx, 0.rpx),
// child: LineChartByRange(
// showLabel: showLabel,
// startTime: startTime,
// endTime: endTime,
// ),
child: BarChartWidget(
data: barDataList,
startTime: startTime,
endTime: endTime,
maxYValue: maxY, // 最大值可自定义
yStepCount: 6, // 分4段0, 5, 10, 15, 20
),
],
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 40.rpx, 0.rpx, 0.rpx),
child: LineChartByRange(
showLabel: showLabel,
startTime: startTime,
endTime: endTime,
),
),
SizedBox(
height: 52.rpx,
),
],
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 52.rpx, 0.rpx, 0.rpx),
child: Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.center, // 左对齐
children: [
Row(
children: [
// 小圆球
Container(
width: 14.rpx,
height: 14.rpx,
decoration: BoxDecoration(
color: (type[0]?['color'] == null ||
type[0]?['color'].isEmpty)
? Colors.green
: stringToColor(
"${type[0]['color']}"), // 你想要的颜色
shape: BoxShape.circle,
),
),
SizedBox(width: 12.rpx), // 小圆球和文字间距
Text(
'${type[0]?['name']}',
style: TextStyle(
fontSize:
AppConstants().normal_text_fontSize,
color: themeController.currentColor.sc3),
),
],
),
SizedBox(height: 16.rpx), // 两行文字间距
Text(
'${(type[0]?['value'] == null || type[0]['value'].toString().isEmpty) ? '未知数据'.tr : '${type[0]?['value']}${(type[0]?['unit'] == null || type[0]['unit'].toString().isEmpty) ? '' : type[0]?['unit']}'}',
style: TextStyle(
fontSize: AppConstants().small_text_fontSize,
color: themeController.currentColor.sc4),
),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.center, // 左对齐
children: [
Row(
children: [
// 小圆球
Container(
width: 14.rpx,
height: 14.rpx,
decoration: BoxDecoration(
color: (type[1]?['color'] == null ||
type[1]?['color'].isEmpty)
? Colors.red
: stringToColor(
"${type[1]['color']}"), // 你想要的颜色
shape: BoxShape.circle,
),
),
SizedBox(width: 12.rpx), // 小圆球和文字间距
Text(
'${type[1]?['name']}',
style: TextStyle(
fontSize:
AppConstants().normal_text_fontSize,
color: themeController.currentColor.sc3),
),
],
),
SizedBox(height: 16.rpx), // 两行文字间距
Text(
'${(type[1]?['value'] == null || type[1]['value'].toString().isEmpty) ? '未知数据'.tr : '${type[1]?['value']}${(type[1]?['unit'] == null || type[1]['unit'].toString().isEmpty) ? '' : type[1]?['unit']}'}',
style: TextStyle(
fontSize: AppConstants().small_text_fontSize,
color: themeController.currentColor.sc4),
),
],
),
],
),
),
),
SizedBox(
height: 52.rpx,
),
],
),
),
),
);
);
} catch (e) {
es.EasyDartModule.logger.error("打鼾监测绘制异常${e}");
return Container();
}
}
List<Map<String, dynamic>> convertToShowLabel(

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/StatusBarWithIndicator.dart';
import 'package:EasyDartModule/EasyDartModule.dart' as es;
class ZiZhuShenJingPercentWidget extends StatefulWidget {
var sleepReport;
@@ -36,106 +37,112 @@ class _ZiZhuShenJingPercentWidgetState
@override
Widget build(BuildContext context) {
if (widget.sleepReport == null ||
widget.sleepReport['sicp'] == null ||
widget.sleepReport['sicp'].isEmpty) {
return Container();
}
int id = 100000;
List data = widget.sleepReport['sicp'];
final target = data.firstWhere(
(element) => element['id'] == id,
orElse: () => null, // 如果没有找到,返回 null你也可以抛异常或用 {} 替代)
);
try {
if (widget.sleepReport == null ||
widget.sleepReport['sicp'] == null ||
widget.sleepReport['sicp'].isEmpty) {
return Container();
}
int id = 100000;
List data = widget.sleepReport['sicp'];
final target = data.firstWhere(
(element) => element['id'] == id,
orElse: () => null, // 如果没有找到,返回 null你也可以抛异常或用 {} 替代)
);
if (target == null) {
return Container();
}
List<Map<String, dynamic>> showLabel = [];
if (target != null && target['type'] is List) {
showLabel = (target['type'] as List).map<Map<String, dynamic>>((item) {
return {
'key': item['type'],
'name': item['name'],
'color': stringToColor(item['color']),
};
}).toList();
}
if (target == null) {
return Container();
}
List<Map<String, dynamic>> showLabel = [];
if (target != null && target['type'] is List) {
showLabel = (target['type'] as List).map<Map<String, dynamic>>((item) {
return {
'key': item['type'],
'name': item['name'],
'color': stringToColor(item['color']),
};
}).toList();
}
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: [
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(
"自主神经平衡指数监测介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,
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: [
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(
"自主神经平衡指数监测介绍".tr,
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: 83.rpx,
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(30.rpx, 0.rpx, 30.rpx, 0.rpx),
child: StatusBarWithIndicator(
selectKey: target['value'],
showLabel: showLabel,
SizedBox(
height: 83.rpx,
),
),
SizedBox(
height: 56.rpx,
),
],
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
30.rpx, 0.rpx, 30.rpx, 0.rpx),
child: StatusBarWithIndicator(
selectKey: target['value'],
showLabel: showLabel,
),
),
SizedBox(
height: 56.rpx,
),
],
),
),
),
);
);
} catch (e) {
es.EasyDartModule.logger.error("打鼾监测绘制异常${e}");
return Container();
}
}
}