更新睡眠报告

This commit is contained in:
wyf
2025-05-27 23:09:31 +08:00
parent e0fef11b33
commit 98cd7f4e6a
54 changed files with 4450 additions and 1160 deletions

View File

@@ -9,7 +9,8 @@ import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
import 'package:vbvs_app/pages/sleep_report/chart/StatusBarWithIndicator.dart';
class ZiZhuShenJingPercentWidget extends StatefulWidget {
ZiZhuShenJingPercentWidget({super.key});
var sleepReport;
ZiZhuShenJingPercentWidget({super.key, required this.sleepReport});
@override
State<ZiZhuShenJingPercentWidget> createState() =>
@@ -35,6 +36,32 @@ 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你也可以抛异常或用 {} 替代)
);
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(
@@ -99,13 +126,8 @@ class _ZiZhuShenJingPercentWidgetState
padding:
EdgeInsetsDirectional.fromSTEB(30.rpx, 0.rpx, 30.rpx, 0.rpx),
child: StatusBarWithIndicator(
selectKey: 3,
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)},
],
selectKey: target['value'],
showLabel: showLabel,
),
),
SizedBox(