更新睡眠报告
This commit is contained in:
@@ -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 SkinPercentWidget extends StatefulWidget {
|
||||
SkinPercentWidget({super.key});
|
||||
var sleepReport;
|
||||
SkinPercentWidget({super.key, required this.sleepReport});
|
||||
|
||||
@override
|
||||
State<SkinPercentWidget> createState() => _SkinPercentWidgetState();
|
||||
@@ -32,7 +33,32 @@ class _SkinPercentWidgetState extends State<SkinPercentWidget> {
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport['sicp'] == null ||
|
||||
widget.sleepReport['sicp'].isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
int id = 100001;
|
||||
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(
|
||||
@@ -62,7 +88,7 @@ class _SkinPercentWidgetState extends State<SkinPercentWidget> {
|
||||
14.rpx, 0.rpx, 14.rpx, 0), //
|
||||
borderRadius: 0.rpx, // 圆形点击区域
|
||||
onTap: () {
|
||||
showTipDialog(
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
@@ -97,13 +123,8 @@ class _SkinPercentWidgetState extends State<SkinPercentWidget> {
|
||||
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)},
|
||||
],
|
||||
selectKey: target['value'],
|
||||
showLabel: showLabel,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
|
||||
Reference in New Issue
Block a user