更新一级睡眠报告页面
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:EasyDartModule/EasyDartModule.dart' as es;
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
@@ -6,9 +7,8 @@ import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
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/GradientLine.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/SnoreWaveform.dart';
|
||||
import 'package:EasyDartModule/EasyDartModule.dart' as es;
|
||||
|
||||
//睡眠规律性
|
||||
class NewSleepViewWidget extends StatefulWidget {
|
||||
@@ -48,8 +48,27 @@ class _NewSleepViewWidgetState extends State<NewSleepViewWidget> {
|
||||
.where((item) => item['show'] != false)
|
||||
.toList();
|
||||
final bsList = widget.sleepReport['bs'] as List;
|
||||
final deepSleep =
|
||||
bsList.firstWhere((e) => e['id'] == 111, orElse: () => null);
|
||||
final lightSleep =
|
||||
bsList.firstWhere((e) => e['id'] == 117, orElse: () => null);
|
||||
final snore =
|
||||
bsList.firstWhere((e) => e['id'] == 116, orElse: () => null);
|
||||
final movement =
|
||||
bsList.firstWhere((e) => e['id'] == 108, orElse: () => null);
|
||||
final leaveBed =
|
||||
bsList.firstWhere((e) => e['id'] == 114, orElse: () => null);
|
||||
|
||||
final Map<int, int> typeIdMap = {
|
||||
0: 114, // 离床时长
|
||||
1: 117, // 浅睡时长
|
||||
2: 111, // 深睡时长
|
||||
3: 108, // 频繁体动时长
|
||||
4: 116, // 打鼾时长
|
||||
};
|
||||
|
||||
List snoreValues = [];
|
||||
|
||||
List lightSnore = widget.sleepReport['ssp']['data'][0];
|
||||
List heavySnore = widget.sleepReport['ssp']['data'][1];
|
||||
snoreValues = [...lightSnore, ...heavySnore];
|
||||
@@ -156,10 +175,53 @@ class _NewSleepViewWidgetState extends State<NewSleepViewWidget> {
|
||||
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,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }).toList(),
|
||||
// ),
|
||||
Wrap(
|
||||
spacing: 55.rpx,
|
||||
runSpacing: 20.rpx,
|
||||
children: showLabel.map<Widget>((item) {
|
||||
final int type = item["type"];
|
||||
final int? targetId = typeIdMap[type];
|
||||
|
||||
// 在 bsList 中查找对应 id 的元素
|
||||
final matchedItem = bsList.firstWhere(
|
||||
(e) => e["id"] == targetId,
|
||||
orElse: () => {},
|
||||
);
|
||||
|
||||
final dynamic value = matchedItem?["value"];
|
||||
final String displayValue = formatHourToHM(value);
|
||||
return Container(
|
||||
padding: EdgeInsets.all(5.rpx),
|
||||
child: Row(
|
||||
@@ -177,7 +239,9 @@ class _NewSleepViewWidgetState extends State<NewSleepViewWidget> {
|
||||
),
|
||||
SizedBox(width: 17.rpx),
|
||||
Text(
|
||||
item["name"],
|
||||
value != null
|
||||
? "${item["name"]} $displayValue"
|
||||
: "${item["name"]} -",
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 24.rpx,
|
||||
@@ -188,9 +252,19 @@ class _NewSleepViewWidgetState extends State<NewSleepViewWidget> {
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
|
||||
Row(mainAxisAlignment: MainAxisAlignment.end, children: [
|
||||
OutlinedButton(
|
||||
onPressed: () {},
|
||||
onPressed: () {
|
||||
MHTHomeController homeController = Get.find();
|
||||
Get.toNamed("/newSleepReportPage", arguments: {
|
||||
'date': widget.sleepReport['startTime'],
|
||||
"mac": homeController.selectDevcie.value,
|
||||
'type': 1,
|
||||
'backgroundImg': 'assets/images/new_background.png',
|
||||
'person_show': false,
|
||||
});
|
||||
},
|
||||
style: OutlinedButton.styleFrom(
|
||||
side: const BorderSide(color: Color(0XFF85F5FF)),
|
||||
foregroundColor: Color(0XFF85F5FF),
|
||||
@@ -255,4 +329,19 @@ class _NewSleepViewWidgetState extends State<NewSleepViewWidget> {
|
||||
}
|
||||
}).toList();
|
||||
}
|
||||
|
||||
String formatHourToHM(dynamic value) {
|
||||
if (value == null) return "-";
|
||||
if (value is num) {
|
||||
int hours = value.floor();
|
||||
int minutes = ((value - hours) * 60).round();
|
||||
|
||||
if (hours > 0) {
|
||||
return "${hours}h ${minutes}m";
|
||||
} else {
|
||||
return "${minutes}m";
|
||||
}
|
||||
}
|
||||
return "-";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user