239 lines
8.0 KiB
Dart
239 lines
8.0 KiB
Dart
import 'package:ef/ef.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/svg.dart';
|
|
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/component/tool/ClickableContainer.dart';
|
|
import 'package:vbvs_app/enum/APPPackageType.dart';
|
|
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
|
import 'package:vbvs_app/pages/sleep_report/chart/StatusBarWithIndicator.dart';
|
|
import 'package:EasyDartModule/EasyDartModule.dart' as es;
|
|
|
|
class QcPiLaoZhiShuPercentWidget extends StatefulWidget {
|
|
var reportData; // 改为更通用的名称
|
|
QcPiLaoZhiShuPercentWidget({super.key, required this.reportData});
|
|
|
|
@override
|
|
State<QcPiLaoZhiShuPercentWidget> createState() =>
|
|
_PiLaoZhiShuPercentWidgetState();
|
|
}
|
|
|
|
class _PiLaoZhiShuPercentWidgetState extends State<QcPiLaoZhiShuPercentWidget> {
|
|
@override
|
|
void setState(VoidCallback callback) {
|
|
super.setState(callback);
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
try {
|
|
if (widget.reportData == null) {
|
|
return Container();
|
|
}
|
|
|
|
// 从reportData中获取plzs数据
|
|
Map<String, dynamic> plzsData = widget.reportData['plzs'] ?? {};
|
|
if (plzsData.isEmpty) {
|
|
return Container();
|
|
}
|
|
|
|
int level = plzsData['level'] ?? 0;
|
|
|
|
// 根据level值确定显示内容和颜色
|
|
String levelText = '';
|
|
Color levelColor = themeController.currentColor.sc3;
|
|
|
|
switch (level) {
|
|
case 0:
|
|
levelText = '正常';
|
|
levelColor = Colors.green;
|
|
break;
|
|
case 1:
|
|
levelText = '轻度疲劳';
|
|
levelColor = Colors.orange;
|
|
break;
|
|
case 2:
|
|
levelText = '中度疲劳';
|
|
levelColor = Colors.red;
|
|
break;
|
|
case 3:
|
|
levelText = '重度疲劳';
|
|
levelColor = Colors.red;
|
|
break;
|
|
default:
|
|
levelText = '未知';
|
|
levelColor = Colors.grey;
|
|
}
|
|
|
|
// 构建StatusBarWithIndicator需要的数据格式
|
|
List<Map<String, dynamic>> showLabel = [
|
|
{
|
|
'key': 0,
|
|
'name': '正常',
|
|
'color': Colors.green,
|
|
},
|
|
{
|
|
'key': 1,
|
|
'name': '轻度疲劳',
|
|
'color': Colors.orange,
|
|
},
|
|
{
|
|
'key': 2,
|
|
'name': '中度疲劳',
|
|
'color': Colors.red,
|
|
},
|
|
{
|
|
'key': 3,
|
|
'name': '重度疲劳',
|
|
'color': Colors.red,
|
|
},
|
|
];
|
|
|
|
return Container(
|
|
width: double.infinity,
|
|
decoration: BoxDecoration(
|
|
color: themeController.currentColor.sc5,
|
|
borderRadius:
|
|
BorderRadius.circular(AppConstants().normal_container_radius),
|
|
),
|
|
child: Padding(
|
|
padding:
|
|
EdgeInsetsDirectional.fromSTEB(26.rpx, 29.rpx, 26.rpx, 45.rpx),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.max,
|
|
children: [
|
|
Container(
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Expanded(
|
|
child: Text(
|
|
"疲劳指数".tr,
|
|
style: TextStyle(
|
|
color: themeController.currentColor.sc3,
|
|
fontSize: AppConstants().title_text_fontSize),
|
|
maxLines: 1,
|
|
overflow: TextOverflow.ellipsis,
|
|
),
|
|
),
|
|
ClickableContainer(
|
|
backgroundColor: Colors.transparent,
|
|
highlightColor: Colors.white,
|
|
padding: EdgeInsetsDirectional.fromSTEB(
|
|
14.rpx, 10.rpx, 14.rpx, 10.rpx),
|
|
borderRadius: 0.rpx,
|
|
onTap: () {
|
|
if (AppConstants().ent_type ==
|
|
APPPackageType.MHT.code) {
|
|
showTipDialog(
|
|
context,
|
|
Container(
|
|
child: Text(
|
|
"疲劳指数是评估人体疲劳程度的重要指标,反映身体和精神状态的疲劳水平。".tr,
|
|
style: TextStyle(
|
|
fontSize: 26.rpx,
|
|
color: Colors.black,
|
|
),
|
|
),
|
|
),
|
|
backgroundColor: Color(0xFFFFFFFF),
|
|
colors: [
|
|
Color(0XFF1592AA),
|
|
Color(0xFF0C83A7),
|
|
Color(0xFF006FA3)
|
|
],
|
|
);
|
|
} else {
|
|
showTipDialog(
|
|
context,
|
|
Container(
|
|
child: Text(
|
|
"疲劳指数是评估人体疲劳程度的重要指标,反映身体和精神状态的疲劳水平。".tr,
|
|
style: TextStyle(
|
|
fontSize: 26.rpx,
|
|
color: themeController.currentColor.sc3,
|
|
),
|
|
),
|
|
),
|
|
backgroundColor: themeController.currentColor.sc17,
|
|
colors: AppConstants().thNormalButton,
|
|
);
|
|
}
|
|
},
|
|
child: Container(
|
|
padding:
|
|
EdgeInsetsDirectional.fromSTEB(0, 0.rpx, 0.rpx, 0),
|
|
width: 28.rpx,
|
|
height: 28.rpx,
|
|
child: SvgPicture.asset(
|
|
'assets/img/icon/explain.svg',
|
|
fit: BoxFit.cover,
|
|
color: themeController.currentColor.sc4,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 83.rpx,
|
|
),
|
|
// 显示level值的文本
|
|
// Padding(
|
|
// padding: EdgeInsetsDirectional.fromSTEB(30.rpx, 0.rpx, 30.rpx, 30.rpx),
|
|
// child: Row(
|
|
// mainAxisAlignment: MainAxisAlignment.center,
|
|
// children: [
|
|
// Text(
|
|
// '当前状态:',
|
|
// style: TextStyle(
|
|
// fontSize: 30.rpx,
|
|
// color: themeController.currentColor.sc4,
|
|
// ),
|
|
// ),
|
|
// Text(
|
|
// levelText,
|
|
// style: TextStyle(
|
|
// fontSize: 36.rpx,
|
|
// fontWeight: FontWeight.bold,
|
|
// color: levelColor,
|
|
// ),
|
|
// ),
|
|
// ],
|
|
// ),
|
|
// ),
|
|
Padding(
|
|
padding: EdgeInsetsDirectional.fromSTEB(
|
|
30.rpx, 0.rpx, 30.rpx, 0.rpx),
|
|
child: StatusBarWithIndicator(
|
|
selectKey: level, // 使用level值作为选中的key
|
|
showLabel: showLabel,
|
|
currentValueText: "当前属于".tr,
|
|
showCurrentValue: true,
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 56.rpx,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
} catch (e) {
|
|
es.EasyDartModule.logger.error("疲劳指数绘制异常${e}");
|
|
return Container();
|
|
}
|
|
}
|
|
}
|