更新睡眠报告

This commit is contained in:
wyf
2025-05-28 21:14:04 +08:00
parent 98cd7f4e6a
commit b34737dbe8
46 changed files with 1580 additions and 974 deletions

View File

@@ -11,6 +11,8 @@ class TimeSeriesChart extends StatelessWidget {
final double yMin;
final double yMax;
final List<TimeSeriesPoint> dataPoints;
final double actYMin;
final double actYMax;
TimeSeriesChart({
required this.startTime,
@@ -18,6 +20,8 @@ class TimeSeriesChart extends StatelessWidget {
required this.yMin,
required this.yMax,
required this.dataPoints,
required this.actYMin,
required this.actYMax,
});
@override
@@ -147,7 +151,7 @@ class TimeSeriesChart extends StatelessWidget {
return Padding(
padding: EdgeInsets.only(right: 14.rpx),
child: Text(
yMin.toStringAsFixed(0),
"${actYMin.toStringAsFixed(0)}",
style: TextStyle(
fontSize: 18.rpx,
color: themeController.currentColor.sc4,
@@ -161,7 +165,8 @@ class TimeSeriesChart extends StatelessWidget {
return Padding(
padding: EdgeInsets.only(right: 14.rpx),
child: Text(
midValue.toStringAsFixed(0),
"${((actYMax + actYMin) / 2).toStringAsFixed(0)}",
// "${midValue}",
style: TextStyle(
fontSize: 18.rpx,
color: themeController.currentColor.sc4,
@@ -175,7 +180,7 @@ class TimeSeriesChart extends StatelessWidget {
return Padding(
padding: EdgeInsets.only(right: 14.rpx),
child: Text(
yMax.toStringAsFixed(0),
"${actYMax.toStringAsFixed(0)}",
style: TextStyle(
fontSize: 18.rpx,
color: themeController.currentColor.sc4,

View File

@@ -52,6 +52,7 @@ class _BreatheCardState extends State<BreatheCard> {
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),

View File

@@ -105,9 +105,18 @@ class _SnoreViewWidgetWidgetState extends State<BreathePauseNewWidget> {
SizedBox(
height: 32.rpx,
),
Row(
children: [
Text(
"".tr,
style: TextStyle(
color: stringToColor("#FFFFFF"), fontSize: 18.rpx),
),
],
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 0.rpx, 0.rpx),
EdgeInsetsDirectional.fromSTEB(0.rpx, 40.rpx, 0.rpx, 0.rpx),
child: LineChartByRange(
showLabel: showLabel,
startTime: startTime,

View File

@@ -59,6 +59,48 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
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: () => {},
);
// 305 基准呼吸
Map<String, dynamic>? baseBreath = brs.firstWhere(
(element) => element['id'] == 305,
orElse: () => {},
);
// 308 最低呼吸
Map<String, dynamic>? minBreath = brs.firstWhere(
(element) => element['id'] == 308,
orElse: () => {},
);
// 309 最高呼吸
Map<String, dynamic>? maxBreath = brs.firstWhere(
(element) => element['id'] == 309,
orElse: () => {},
);
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;
}
}
return Container(
width: double.infinity,
decoration: BoxDecoration(
@@ -76,7 +118,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"呼吸基准".tr,
"呼吸数据".tr,
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().title_text_fontSize),
@@ -92,7 +134,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
context,
Container(
child: Text(
"呼吸基准介绍".tr,
"呼吸数据介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,
@@ -139,7 +181,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
SizedBox(width: 15.rpx), // 圆球和文字之间的间隔
// 文字
Text(
'正常范围(8~20)',
'正常范围'.tr + "${range}",
style: TextStyle(
fontSize:
AppConstants().smaller_text_fontSize, // 文字的大小
@@ -158,6 +200,8 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
yMin: 50,
yMax: 150,
dataPoints: dataPoints,
actYMax: max.toDouble(),
actYMin: min.toDouble(),
),
),
Padding(
@@ -169,7 +213,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
Column(
children: [
Text(
"平均呼吸",
"${avgBreath['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -179,14 +223,14 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"12",
"${avgBreath['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
AppConstants().normal_text_fontSize),
),
Text(
"次/分钟",
"${avgBreath['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -201,7 +245,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
Column(
children: [
Text(
"基准呼吸",
"${baseBreath['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -213,7 +257,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"15",
"${baseBreath['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
@@ -222,7 +266,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
overflow: TextOverflow.ellipsis,
),
Text(
"次/分钟",
"${baseBreath['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -239,7 +283,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
Column(
children: [
Text(
"最低呼吸",
"${minBreath['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -251,7 +295,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"11",
"${minBreath['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
@@ -260,7 +304,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
overflow: TextOverflow.ellipsis,
),
Text(
"次/分钟",
"${minBreath['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -277,7 +321,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
Column(
children: [
Text(
"最高呼吸",
"${maxBreath['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -289,7 +333,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"18",
"${maxBreath['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
@@ -298,7 +342,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
overflow: TextOverflow.ellipsis,
),
Text(
"次/分钟",
"${maxBreath['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:

View File

@@ -169,7 +169,7 @@ class _CompareSleepWidgetState extends State<CompareSleepWidget> {
SizedBox(width: 13.rpx), // 文字和容器之间的间距
// 文字
Text(
'今日数据', // 文字内容
'今日数据'.tr, // 文字内容
style: TextStyle(
fontSize: 18.rpx, // 文字大小
color:
@@ -190,7 +190,7 @@ class _CompareSleepWidgetState extends State<CompareSleepWidget> {
SizedBox(width: 13.rpx), // 文字和容器之间的间距
// 文字
Text(
'昨日数据', // 文字内容
'昨日数据'.tr, // 文字内容
style: TextStyle(
fontSize: 18.rpx, // 文字大小
color:

View File

@@ -61,7 +61,7 @@ class _DiseasePercentsWidgetState extends State<DiseasePercentsWidget> {
// "explain": "呼吸系统是负责气体交换的器官系统,包括鼻、喉、气管和肺等。",
// },
// ];
@override
void setState(VoidCallback callback) {
super.setState(callback);
@@ -84,7 +84,7 @@ class _DiseasePercentsWidgetState extends State<DiseasePercentsWidget> {
widget.sleepReport['cdri'].isEmpty) {
return Container();
}
List diseaseData = widget.sleepReport['cdri'];
List diseaseData = widget.sleepReport['cdri'];
var showLabel = convertDiseaseData(diseaseData);
return Container(
width: double.infinity,
@@ -120,7 +120,7 @@ class _DiseasePercentsWidgetState extends State<DiseasePercentsWidget> {
context,
Container(
child: Text(
"慢性病风险指数介绍",
"慢性病风险指数介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,
@@ -158,23 +158,24 @@ class _DiseasePercentsWidgetState extends State<DiseasePercentsWidget> {
),
);
}
List<Map<String, dynamic>> convertDiseaseData(List data) {
return data.asMap().entries.map<Map<String, dynamic>>((entry) {
final index = entry.key;
final item = entry.value;
return {
"key": item["id"],
"name": item["name"],
"color": item["id"] == 40004
? stringToColor("#FF7159") // 特殊颜色处理
: stringToColor("#00C1AA"),
"percent": item["value"],
"explain": (item["tips"] != null && (item["tips"] as String).trim().isNotEmpty)
? item["tips"]
: '未知数据'.tr,
};
}).toList();
}
List<Map<String, dynamic>> convertDiseaseData(List data) {
return data.asMap().entries.map<Map<String, dynamic>>((entry) {
final index = entry.key;
final item = entry.value;
return {
"key": item["id"],
"name": item["name"],
"color": item["id"] == 40004
? stringToColor("#FF7159") // 特殊颜色处理
: stringToColor("#00C1AA"),
"percent": item["value"],
"explain":
(item["tips"] != null && (item["tips"] as String).trim().isNotEmpty)
? item["tips"]
: '未知数据'.tr,
};
}).toList();
}
}

View File

@@ -76,7 +76,7 @@ class _HeartHealthWidgetState extends State<HeartHealthWidget> {
context,
Container(
child: Text(
"心理健康评估介绍",
"心理健康评估介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,

View File

@@ -104,7 +104,7 @@ class _HeartPointWidgetState extends State<HeartPointWidget> {
context,
Container(
child: Text(
"心率散点图介绍",
"心率散点图介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,

View File

@@ -52,6 +52,7 @@ class _HeartRateCardState extends State<HeartRateCard> {
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),

View File

@@ -46,13 +46,52 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
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 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: () => {},
);
// 找 id == 202 的元素(基准心率)
Map<String, dynamic>? baseHeartRate = hrs.firstWhere(
(element) => element['id'] == 202,
orElse: () => {},
);
// 找 id == 207 的元素(最低心率)
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;
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(
@@ -70,7 +109,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"心率基准".tr,
"心率数据".tr,
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().title_text_fontSize),
@@ -86,7 +125,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
context,
Container(
child: Text(
"心率基准介绍".tr,
"心率数据介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,
@@ -133,7 +172,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
SizedBox(width: 15.rpx), // 圆球和文字之间的间隔
// 文字
Text(
'正常范围(50~80)',
'正常范围'.tr + "${range}",
style: TextStyle(
fontSize:
AppConstants().smaller_text_fontSize, // 文字的大小
@@ -142,6 +181,18 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
),
],
),
// 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,
@@ -152,6 +203,8 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
yMin: 50,
yMax: 150,
dataPoints: dataPoints,
actYMin: min.toDouble(),
actYMax: max.toDouble(),
),
),
Padding(
@@ -163,7 +216,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
Column(
children: [
Text(
"平均心率",
"${avgHeartRate['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -173,14 +226,14 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"89",
"${avgHeartRate['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
AppConstants().normal_text_fontSize),
),
Text(
"次/分钟",
"${avgHeartRate['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -195,7 +248,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
Column(
children: [
Text(
"基准心率",
"${baseHeartRate['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -207,7 +260,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"80",
"${baseHeartRate['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
@@ -216,7 +269,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
overflow: TextOverflow.ellipsis,
),
Text(
"次/分钟",
"${baseHeartRate['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -233,7 +286,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
Column(
children: [
Text(
"最低心率",
"${minHeartRate['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -245,7 +298,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"68",
"${minHeartRate['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
@@ -254,7 +307,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
overflow: TextOverflow.ellipsis,
),
Text(
"次/分钟",
"${minHeartRate['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -271,7 +324,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
Column(
children: [
Text(
"最高心率",
"${maxHeartRate['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -283,7 +336,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"98",
"${maxHeartRate['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
@@ -292,7 +345,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
overflow: TextOverflow.ellipsis,
),
Text(
"次/分钟",
"${maxHeartRate['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:

View File

@@ -92,7 +92,7 @@ class _SkinPercentWidgetState extends State<SkinPercentWidget> {
context,
Container(
child: Text(
"皮肤指数介绍",
"皮肤指数介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,

View File

@@ -52,6 +52,7 @@ class _SleepCardState extends State<SleepCard> {
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),

View File

@@ -67,12 +67,16 @@ class _SleepScoreWidgetState extends State<SleepScoreWidget> {
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'30天平均分'.tr,
style: TextStyle(
color: Color(0xFFD3D3D3),
fontSize: 26.rpx,
letterSpacing: 0.0,
Container(
constraints: BoxConstraints(maxWidth: 150.rpx),
child: Text(
'30天平均分'.tr,
style: TextStyle(
color: Color(0xFFD3D3D3),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
maxLines: 1,
),
),
Text(

View File

@@ -47,69 +47,13 @@ class _SleepViewWidgetState extends State<SleepViewWidget> {
.where((item) => item['show'] != false)
.toList();
// final snoreValues = generateSnoreValues(
// widget.sleepReport['startTime'],
// widget.sleepReport['endTime'],
// );
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 = [
// {"et": 1748011592746, "st": 1748010870326, "type": 1},
// {"et": 1748013519534, "st": 1748011593746, "type": 2},
// {"et": 1748013639534, "st": 1748013520534, "type": 1},
// {"et": 1748014183143, "st": 1748013640534, "type": 2},
// {"et": 1748014363143, "st": 1748014184143, "type": 1},
// {"et": 1748014423143, "st": 1748014364143, "type": 2},
// {"et": 1748014541143, "st": 1748014424143, "type": 1},
// {"et": 1748015439477, "st": 1748014542143, "type": 0},
// {"et": 1748018470415, "st": 1748015440477, "type": 1},
// {"et": 1748019755726, "st": 1748018471415, "type": 2},
// {"et": 1748020123225, "st": 1748019756726, "type": 1},
// {"et": 1748021138809, "st": 1748020124225, "type": 2},
// {"et": 1748021535809, "st": 1748021139809, "type": 1},
// {"et": 1748021776809, "st": 1748021536809, "type": 2},
// {"et": 1748022140117, "st": 1748021777809, "type": 1},
// {"et": 1748022320117, "st": 1748022141117, "type": 2},
// {"et": 1748022996627, "st": 1748022321117, "type": 1},
// {"et": 1748023439627, "st": 1748022997627, "type": 2},
// {"et": 1748023812173, "st": 1748023440627, "type": 1},
// {"et": 1748023895173, "st": 1748023813173, "type": 2},
// {"et": 1748024692483, "st": 1748023896173, "type": 1},
// {"et": 1748024960483, "st": 1748024693483, "type": 2},
// {"et": 1748025678983, "st": 1748024961483, "type": 1},
// {"et": 1748026351585, "st": 1748025679983, "type": 2},
// {"et": 1748027131585, "st": 1748026352585, "type": 1},
// {"et": 1748027209585, "st": 1748027132585, "type": 2},
// {"et": 1748027487864, "st": 1748027210585, "type": 1},
// {"et": 1748027967864, "st": 1748027488864, "type": 3},
// {"et": 1748028182371, "st": 1748027968864, "type": 1},
// {"et": 1748028372371, "st": 1748028183371, "type": 2},
// {"et": 1748029109981, "st": 1748028373371, "type": 1},
// {"et": 1748029958223, "st": 1748029110981, "type": 2},
// {"et": 1748030792223, "st": 1748029959223, "type": 1},
// {"et": 1748030874723, "st": 1748030793223, "type": 2},
// {"et": 1748032042305, "st": 1748030875723, "type": 1},
// {"et": 1748032170305, "st": 1748032043305, "type": 2},
// {"et": 1748033387611, "st": 1748032171305, "type": 1},
// {"et": 1748033967118, "st": 1748033388611, "type": 2},
// {"et": 1748034087118, "st": 1748033968118, "type": 1},
// {"et": 1748034147118, "st": 1748034088118, "type": 2},
// {"et": 1748034327118, "st": 1748034148118, "type": 1},
// {"et": 1748034930672, "st": 1748034328118, "type": 2},
// {"et": 1748035230672, "st": 1748034931672, "type": 1},
// {"et": 1748035353974, "st": 1748035231672, "type": 2},
// {"et": 1748036710471, "st": 1748035354974, "type": 1},
// {"et": 1748037126471, "st": 1748036711471, "type": 2},
// {"et": 1748037310051, "st": 1748037127471, "type": 1},
// {"et": 1748037380051, "st": 1748037311051, "type": 2},
// {"et": 1748038881358, "st": 1748037381051, "type": 1},
// {"et": 1748038962867, "st": 1748038882358, "type": 0},
// {"et": 1748039291867, "st": 1748038963867, "type": 1},
// {"et": 1748039684867, "st": 1748039292867, "type": 0}
// ];
List stages = widget.sleepReport['sleepData']['stages'];
return Container(
width: double.infinity,

View File

@@ -43,6 +43,10 @@ class _SnoreViewWidgetWidgetState extends State<SnoreViewWidgetWidget> {
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(
@@ -105,9 +109,18 @@ class _SnoreViewWidgetWidgetState extends State<SnoreViewWidgetWidget> {
SizedBox(
height: 32.rpx,
),
Row(
children: [
Text(
"".tr,
style: TextStyle(
color: stringToColor("#FFFFFF"), fontSize: 18.rpx),
),
],
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 0.rpx, 0.rpx),
EdgeInsetsDirectional.fromSTEB(0.rpx, 40.rpx, 0.rpx, 0.rpx),
child: LineChartByRange(
showLabel: showLabel,
startTime: startTime,
@@ -132,13 +145,14 @@ class _SnoreViewWidgetWidgetState extends State<SnoreViewWidgetWidget> {
List<Map<String, dynamic>> result = [];
int startTime = data[0]['st'];
int endTime = data[0]['st'];
int endTime = data[0]['et'];
int currentValue = data[0]['value'];
for (int i = 1; i < data.length; i++) {
final item = data[i];
final st = item['st'];
final value = item['value'];
final et = item['et'];
if (value == currentValue) {
endTime = st;
@@ -149,7 +163,7 @@ class _SnoreViewWidgetWidgetState extends State<SnoreViewWidgetWidget> {
"times": currentValue,
});
startTime = st;
endTime = st;
endTime = et;
currentValue = value;
}
}

View File

@@ -95,7 +95,7 @@ class _ZiZhuShenJingPercentWidgetState
context,
Container(
child: Text(
"自主神经平衡指数监测介绍",
"自主神经平衡指数监测介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,

View File

@@ -6,9 +6,12 @@ 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/common/util/requestWithLog.dart';
import 'package:vbvs_app/component/NullDataComponentWidget.dart';
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
import 'package:vbvs_app/controller/date/CalendarController.dart';
import 'package:vbvs_app/controller/sleep/sleep_report_controller.dart';
import 'package:vbvs_app/language/AppLanguage.dart';
import 'package:vbvs_app/pages/common/selectDialog.dart';
import 'package:vbvs_app/pages/sleep_report/component/AIAdviceWidget.dart';
import 'package:vbvs_app/pages/sleep_report/component/BreatheCard.dart';
@@ -55,17 +58,22 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
sleepReportController.model.type = 1;
}
String date = MyUtils.formatToDate(widget.data['date']);
// String date = '2025-5-27';
requestWithLog(
logTitle: "查询睡眠报告",
method: MyHttpMethod.get,
queryUrl:
"http://192.168.1.80:9898/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=${date}&type=${sleepReportController.model.type}",
"https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=${date}&type=${sleepReportController.model.type}",
onSuccess: (res) {
print(res);
sleepReportController.sleepReport.value = res.data;
sleepReportController.updateAll();
},
onFailure: (res) {
TopSlideNotification.show(context,
text: res.msg!, textColor: themeController.currentColor.sc9);
sleepReportController.sleepReport.value = {};
sleepReportController.updateAll();
print(res);
});
super.initState();
@@ -78,6 +86,7 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
@override
Widget build(BuildContext context) {
double lineWidth = 115.rpx;
return LayoutBuilder(
builder: (context, bodySize) => GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
@@ -152,54 +161,52 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
Row(
mainAxisSize: MainAxisSize.max,
children: [
Obx(() {
return ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: themeController
.currentColor.sc3,
borderRadius: 8.rpx,
padding: EdgeInsets.all(0),
onTap: () async {
sleepReportController.model.type =
1;
sleepReportController.updateAll();
},
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Container(
width:
115.rpx, // 固定宽度为 160.rpx
alignment:
Alignment.center, // 文字居中
child: Text(
'日报'.tr,
style: FlutterFlowTheme.of(
context)
.bodyMedium
.override(
fontFamily: 'Inter',
fontSize: AppConstants()
.title_text_fontSize,
letterSpacing: 0.0,
color: sleepReportController
.model
.type ==
1
? themeController
.currentColor
.sc2
: themeController
.currentColor
.sc3,
),
),
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor:
themeController.currentColor.sc3,
borderRadius: 8.rpx,
padding: EdgeInsets.all(0),
onTap: () async {
sleepReportController.model.type =
1;
sleepReportController.updateAll();
},
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Container(
width: 115.rpx, // 固定宽度为 160.rpx
alignment:
Alignment.center, // 文字居中
child: Text(
'日报'.tr,
style: FlutterFlowTheme.of(
context)
.bodyMedium
.override(
fontFamily: 'Inter',
fontSize: AppConstants()
.title_text_fontSize,
letterSpacing: 0.0,
color:
sleepReportController
.model
.type ==
1
? themeController
.currentColor
.sc2
: themeController
.currentColor
.sc3,
),
),
SizedBox(height: 10.rpx),
],
),
);
}),
),
SizedBox(height: 10.rpx),
],
),
),
// Obx(() {
// return ClickableContainer(
@@ -299,33 +306,28 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
// }),
],
),
Obx(() {
double lineWidth = 115.rpx;
return AnimatedPositioned(
duration: Duration(milliseconds: 300),
curve: Curves.easeInOut,
bottom: 0,
left:
sleepReportController.model.type ==
1
? 0
: sleepReportController
.model.type ==
2
? 115.rpx
: 230.rpx,
child: Container(
width: lineWidth,
height: 4.rpx,
decoration: BoxDecoration(
color: themeController
.currentColor.sc2,
borderRadius:
BorderRadius.circular(2.rpx),
),
AnimatedPositioned(
duration: Duration(milliseconds: 300),
curve: Curves.easeInOut,
bottom: 0,
left: sleepReportController.model.type ==
1
? 0
: sleepReportController.model.type ==
2
? 115.rpx
: 230.rpx,
child: Container(
width: lineWidth,
height: 4.rpx,
decoration: BoxDecoration(
color:
themeController.currentColor.sc2,
borderRadius:
BorderRadius.circular(2.rpx),
),
);
}),
),
),
],
),
// Padding(
@@ -353,10 +355,7 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
30.rpx, 32.rpx, 30.rpx, 32.rpx),
child: Obx(() {
var date = sleepReportController.selectedDate;
return getTimeWidget();
}),
child: getTimeWidget(),
),
),
Padding(
@@ -430,7 +429,7 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
),
),
Text(
'2022-02-02',
'69',
style:
FlutterFlowTheme.of(context)
.bodyMedium
@@ -703,23 +702,42 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
Widget getTimeWidget() {
final selectedDate = sleepReportController.selectedDate.value!;
final type = sleepReportController.model.type;
bool isChinese = AppLanguage().isChinese();
String displayText = '';
if (type == 1) {
// 日报
displayText =
MyUtils.getFormatChineseTime(selectedDate.millisecondsSinceEpoch);
} else if (type == 2) {
// 周报
final startOfWeek =
selectedDate.subtract(Duration(days: selectedDate.weekday - 1));
final endOfWeek = startOfWeek.add(const Duration(days: 6));
displayText =
'${MyUtils.getFormatChineseTime(startOfWeek.millisecondsSinceEpoch, showWeekday: false)}-${MyUtils.getFormatChineseTime(endOfWeek.millisecondsSinceEpoch, showWeekday: false)}';
} else if (type == 3) {
// 月报
displayText =
'${selectedDate.year}${selectedDate.month.toString().padLeft(2, '0')}';
if (isChinese) {
if (type == 1) {
// 日报
displayText =
MyUtils.getFormatChineseTime(selectedDate.millisecondsSinceEpoch);
} else if (type == 2) {
// 周报
final startOfWeek =
selectedDate.subtract(Duration(days: selectedDate.weekday - 1));
final endOfWeek = startOfWeek.add(const Duration(days: 6));
displayText =
'${MyUtils.getFormatChineseTime(startOfWeek.millisecondsSinceEpoch, showWeekday: false)}-${MyUtils.getFormatChineseTime(endOfWeek.millisecondsSinceEpoch, showWeekday: false)}';
} else if (type == 3) {
// 月报
displayText =
'${selectedDate.year}${selectedDate.month.toString().padLeft(2, '0')}';
}
} else {
if (type == 1) {
// Daily Report
displayText =
MyUtils.getFormatEnglishDate(selectedDate.millisecondsSinceEpoch);
} else if (type == 2) {
// Weekly Report
final startOfWeek =
selectedDate.subtract(Duration(days: selectedDate.weekday - 1));
final endOfWeek = startOfWeek.add(const Duration(days: 6));
displayText =
'${MyUtils.getFormatEnglishDate(startOfWeek.millisecondsSinceEpoch)} - ${MyUtils.getFormatEnglishDate(endOfWeek.millisecondsSinceEpoch)}';
} else if (type == 3) {
// Monthly Report
displayText =
'${_getEnglishMonthName(selectedDate.month)} ${selectedDate.year}';
}
}
void onLeftArrowTap() {
@@ -738,6 +756,26 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
}
calendarController.selectedDate.value =
sleepReportController.selectedDate.value;
// String date = MyUtils.formatToDate(widget.data['date']);
String data = MyUtils.formatDate(calendarController.selectedDate.value!);
requestWithLog(
logTitle: "查询睡眠报告",
method: MyHttpMethod.get,
queryUrl:
"https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=${data}&type=${sleepReportController.model.type}",
onSuccess: (res) {
print(res);
sleepReportController.sleepReport.value = res.data;
sleepReportController.updateAll();
},
onFailure: (res) {
TopSlideNotification.show(context,
text: res.msg!, textColor: themeController.currentColor.sc9);
sleepReportController.sleepReport.value = {};
sleepReportController.updateAll();
print(res);
});
sleepReportController.updateAll();
calendarController.updateAll();
}
@@ -758,6 +796,24 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
}
calendarController.selectedDate.value =
sleepReportController.selectedDate.value;
String data = MyUtils.formatDate(calendarController.selectedDate.value!);
requestWithLog(
logTitle: "查询睡眠报告",
method: MyHttpMethod.get,
queryUrl:
"https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=${data}&type=${sleepReportController.model.type}",
onSuccess: (res) {
print(res);
sleepReportController.sleepReport.value = res.data;
sleepReportController.updateAll();
},
onFailure: (res) {
TopSlideNotification.show(context,
text: res.msg!, textColor: themeController.currentColor.sc9);
sleepReportController.sleepReport.value = {};
sleepReportController.updateAll();
print(res);
});
sleepReportController.updateAll();
calendarController.updateAll();
}
@@ -823,6 +879,26 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
onDateSelected: (newDate) {
sleepReportController.selectedDate.value = newDate;
calendarController.selectedDate.value = newDate;
String data =
MyUtils.formatDate(calendarController.selectedDate.value!);
requestWithLog(
logTitle: "查询睡眠报告",
method: MyHttpMethod.get,
queryUrl:
"https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=${data}&type=${sleepReportController.model.type}",
onSuccess: (res) {
print(res);
sleepReportController.sleepReport.value = res.data;
sleepReportController.updateAll();
},
onFailure: (res) {
TopSlideNotification.show(context,
text: res.msg!,
textColor: themeController.currentColor.sc9);
sleepReportController.sleepReport.value = {};
sleepReportController.updateAll();
print(res);
});
sleepReportController.updateAll();
calendarController.updateAll();
},
@@ -841,4 +917,22 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
],
);
}
static String _getEnglishMonthName(int month) {
const monthNames = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'
];
return monthNames[month - 1];
}
}