更新睡眠报告
This commit is contained in:
@@ -10,7 +10,8 @@ import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/FatigueCircleIndicator.dart';
|
||||
|
||||
class HeartHealthWidget extends StatefulWidget {
|
||||
HeartHealthWidget({super.key});
|
||||
var sleepReport;
|
||||
HeartHealthWidget({super.key, required this.sleepReport});
|
||||
|
||||
@override
|
||||
State<HeartHealthWidget> createState() => _HeartHealthWidgetState();
|
||||
@@ -34,20 +35,14 @@ class _HeartHealthWidgetState extends State<HeartHealthWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var showLabel = [
|
||||
{
|
||||
"name": "焦虑抑郁",
|
||||
"color": Color(0xFF4CAF50),
|
||||
"percent": "7%",
|
||||
"explain": "低风险"
|
||||
},
|
||||
{
|
||||
"name": "过度疲劳",
|
||||
"color": stringToColor("#FF7159"),
|
||||
"percent": "69%",
|
||||
"explain": "高风险"
|
||||
},
|
||||
];
|
||||
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(
|
||||
@@ -115,22 +110,10 @@ class _HeartHealthWidgetState extends State<HeartHealthWidget> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
FatigueCircleIndicator(
|
||||
data: {
|
||||
"name": "焦虑抑郁",
|
||||
"color": stringToColor("#00C1AA"),
|
||||
"percent": 7,
|
||||
"explain": "低风险",
|
||||
"bottomColor": Colors.grey,
|
||||
},
|
||||
data: showLabel[0],
|
||||
),
|
||||
FatigueCircleIndicator(
|
||||
data: {
|
||||
"name": "过度疲劳",
|
||||
"color": stringToColor("#FF7159"),
|
||||
"percent": 69,
|
||||
"explain": "高风险",
|
||||
"bottomColor": Colors.grey,
|
||||
},
|
||||
data: showLabel[1],
|
||||
),
|
||||
].divide(SizedBox(
|
||||
width: 110.rpx,
|
||||
@@ -145,4 +128,25 @@ class _HeartHealthWidgetState extends State<HeartHealthWidget> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> convertMentalHealthData(List data) {
|
||||
return data.map<Map<String, dynamic>>((item) {
|
||||
final String? colorStr = item['color'];
|
||||
final int value = item['value'] ?? 0;
|
||||
final String explain =
|
||||
(item['tips'] != null && (item['tips'] as String).trim().isNotEmpty)
|
||||
? item['tips']
|
||||
: '高风险';
|
||||
|
||||
return {
|
||||
'name': item['name'],
|
||||
'color': colorStr != null && colorStr.isNotEmpty
|
||||
? stringToColor(colorStr)
|
||||
: stringToColor("#00C1AA"), // 默认红色
|
||||
'percent': value,
|
||||
'explain': explain,
|
||||
"bottomColor": Colors.grey,
|
||||
};
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user