更新英文语言相关问题。

This commit is contained in:
wyf
2026-03-23 15:19:09 +08:00
parent 2d28a550bd
commit a1e835ecbc
20 changed files with 472 additions and 1040 deletions

View File

@@ -1,17 +1,13 @@
import 'package:ef/ef.dart';
import 'package:flutter/material.dart';
import 'package:flutterflow_ui/flutterflow_ui.dart';
import 'package:vbvs_app/common/color/ServiceConstant.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/common/util/requestWithLog.dart';
import 'package:vbvs_app/component/NullDataComponentWidget.dart';
import 'package:vbvs_app/component/tool/NewTopSlideNotification.dart';
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
import 'package:vbvs_app/controller/date/CalendarController.dart';
import 'package:vbvs_app/controller/sleep/sleep_report_controller.dart';
import 'package:vbvs_app/controller/sleep/sleep_time_convert.dart';
import 'package:vbvs_app/pages/sleep_report/QcReportWidget.dart';
import 'package:vbvs_app/pages/sleep_report/chart/StatusBarWithIndicator.dart';
@@ -52,30 +48,16 @@ class _QuickHealthReportPageState extends State<QuickHealthReportPage> {
@override
void initState() {
super.initState();
if (!Get.isRegistered<SleepReportController>(tag: widget.data["tag"])) {
Get.put(tag: widget.data["tag"], SleepReportController());
}
sleepReportController = Get.find(tag: widget.data["tag"]);
// sleepReportController.sleepReport.value = {};
if (widget.data['date'] == null) {
widget.data['date'] = DateTime.now().millisecondsSinceEpoch;
}
}
@override
Widget build(BuildContext context) {
// Future.microtask(() {
// _initSleepReportData();
// });
final healthLevelInfo = getHealthLevelInfo(widget.data);
double lineWidth = 150.rpx;
try {
return LayoutBuilder(
builder: (context, bodySize) => GestureDetector(
// onTap: () => FocusScope.of(context).unfocus(),,
child: Container(
decoration: BoxDecoration(
image: (widget.data['noBackImg'] != null &&
@@ -135,291 +117,263 @@ class _QuickHealthReportPageState extends State<QuickHealthReportPage> {
),
body: SafeArea(
top: true,
child: Obx(() {
try {
var sleepReport = sleepReportController.sleepReport.value;
if (sleepReport == null || sleepReport.isEmpty) {
return SingleChildScrollView(
child: Column(
children: [
Padding(
padding: EdgeInsets.fromLTRB(
30.rpx, 30.rpx, 30.rpx, 26.rpx),
child: Container(
width: double.infinity,
constraints: BoxConstraints(
minHeight: 90.rpx, // 最小高度
),
decoration: BoxDecoration(
// color: themeController.currentColor.sc5, // 背景色
),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
0.rpx, 0.rpx, 0.rpx, 0.rpx),
child: Row(
crossAxisAlignment:
CrossAxisAlignment.center,
children: [
// 左侧图标
Container(
margin: EdgeInsets.only(right: 7.rpx),
child: Icon(
Icons.info_outline,
size: 26.rpx,
color:
themeController.currentColor.sc8,
),
),
// 中间可换行文字
Expanded(
child: Container(
margin:
EdgeInsets.only(right: 69.rpx),
child: Text(
'5分钟快速检测可能受到用户当前状态、过程中说话动作、精神紧张等情况影响数据仅供参考。'
.tr,
style: TextStyle(
fontFamily: 'Inter',
fontSize: AppConstants()
.smaller_text_fontSize,
color: themeController
.currentColor.sc8,
height: 1.4,
),
softWrap: true,
),
),
),
],
child: SingleChildScrollView(
child: Column(
children: [
Padding(
padding:
EdgeInsets.fromLTRB(30.rpx, 30.rpx, 30.rpx, 26.rpx),
child: Container(
width: double.infinity,
constraints: BoxConstraints(
minHeight: 90.rpx, // 最小高度
),
decoration: BoxDecoration(
// color: themeController.currentColor.sc5, // 背景色
),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
0.rpx, 0.rpx, 0.rpx, 0.rpx),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// 左侧图标
Container(
margin: EdgeInsets.only(right: 7.rpx),
child: Icon(
Icons.info_outline,
size: 26.rpx,
color: themeController.currentColor.sc8,
),
),
),
// 中间可换行文字
Expanded(
child: Container(
margin: EdgeInsets.only(right: 69.rpx),
child: Text(
'5分钟快速检测可能受到用户当前状态、过程中说话动作、精神紧张等情况影响数据仅供参考。'
.tr,
style: TextStyle(
fontFamily: 'Inter',
fontSize: AppConstants()
.smaller_text_fontSize,
color: themeController.currentColor.sc8,
height: 1.4,
),
softWrap: true,
),
),
),
],
),
Padding(
padding:
EdgeInsets.fromLTRB(30.rpx, 0, 30.rpx, 0),
child: Container(
),
),
),
Padding(
padding: EdgeInsets.fromLTRB(30.rpx, 0, 30.rpx, 0),
child: Container(
decoration: BoxDecoration(
color: themeController.currentColor.sc5,
borderRadius: BorderRadius.circular(16.rpx),
),
child: Column(
children: [
// 第一个容器 - 包含Row布局
Container(
width: double.infinity,
padding: EdgeInsets.all(30.rpx),
decoration: BoxDecoration(
color: themeController.currentColor.sc5,
// color: themeController.currentColor.sc5,
borderRadius: BorderRadius.circular(16.rpx),
),
child: Column(
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// 第一个容器 - 包含Row布局
Container(
width: double.infinity,
padding: EdgeInsets.all(30.rpx),
decoration: BoxDecoration(
// color: themeController.currentColor.sc5,
borderRadius:
BorderRadius.circular(16.rpx),
),
child: Row(
// 左边的Column包含五行文字
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.center,
CrossAxisAlignment.start,
children: [
// 左边的Column包含五行文字
Expanded(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
'${widget.data['person']['name']} (${widget.data['person']['gender']} ${widget.data['person']['age'].toInt()}岁)',
style: TextStyle(
fontSize: AppConstants()
.bigger_text_fontSize,
color: themeController
.currentColor.sc3,
// fontWeight: FontWeight.bold,
),
),
SizedBox(height: 18.rpx),
Text(
"快检得分:".tr +
'${widget.data['score']['score'].toInt()}',
style: TextStyle(
fontSize: AppConstants()
.small_an_text_fontSize,
color: themeController
.currentColor.sc3,
),
),
SizedBox(height: 18.rpx),
Row(
children: [
Text(
"健康等级:".tr,
style: TextStyle(
fontSize: AppConstants()
.small_an_text_fontSize,
color: themeController
.currentColor.sc3,
),
),
Text(
healthLevelInfo['text'],
style: TextStyle(
fontSize: AppConstants()
.small_an_text_fontSize,
color: healthLevelInfo[
'color'],
),
),
],
),
SizedBox(height: 18.rpx),
Text(
"设备ID".tr +
'${widget.data['mac']}',
style: TextStyle(
fontSize: AppConstants()
.small_an_text_fontSize,
color: themeController
.currentColor.sc3,
),
),
SizedBox(height: 18.rpx),
Text(
"快检时间:".tr +
'${MyUtils.timestampToDateString(widget.data['create_time'].toInt())}',
style: TextStyle(
fontSize: AppConstants()
.small_an_text_fontSize,
color: themeController
.currentColor.sc3,
),
),
],
Text(
'${widget.data['person']['name']} (${widget.data['person']['gender']} ${widget.data['person']['age'].toInt()}岁)',
style: TextStyle(
fontSize: AppConstants()
.bigger_text_fontSize,
color: themeController
.currentColor.sc3,
// fontWeight: FontWeight.bold,
),
),
// SizedBox(width: 20.rpx), // 左边文字和右边图片的间距
// 右边的本地图片
Container(
width: 120.rpx,
height: 190.rpx,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(12.rpx),
image: DecorationImage(
image: AssetImage(
'assets/img/black_body_still.png'), // 替换为您的本地图片路径
fit: BoxFit.cover,
SizedBox(height: 18.rpx),
Text(
"快检得分:".tr +
'${widget.data['score']['score'].toInt()}',
style: TextStyle(
fontSize: AppConstants()
.small_an_text_fontSize,
color: themeController
.currentColor.sc3,
),
),
SizedBox(height: 18.rpx),
Row(
children: [
Text(
"健康等级:".tr,
style: TextStyle(
fontSize: AppConstants()
.small_an_text_fontSize,
color: themeController
.currentColor.sc3,
),
),
Text(
healthLevelInfo['text'],
style: TextStyle(
fontSize: AppConstants()
.small_an_text_fontSize,
color:
healthLevelInfo['color'],
),
),
],
),
SizedBox(height: 18.rpx),
Text(
"设备ID".tr +
'${widget.data['mac']}',
style: TextStyle(
fontSize: AppConstants()
.small_an_text_fontSize,
color: themeController
.currentColor.sc3,
),
),
SizedBox(height: 18.rpx),
Text(
"快检时间:".tr +
'${MyUtils.timestampToDateString(widget.data['create_time'].toInt())}',
style: TextStyle(
fontSize: AppConstants()
.small_an_text_fontSize,
color: themeController
.currentColor.sc3,
),
),
],
),
),
// SizedBox(width: 20.rpx), // 左边文字和右边图片的间距
SizedBox(height: 34.rpx), // 两个容器之间的间距
// 第二个容器 - 包含StatusBarWithIndicator todo接入报告数据
// 右边的本地图片
Container(
width: double.infinity,
// height: 220.rpx,
width: 120.rpx,
height: 190.rpx,
decoration: BoxDecoration(
// color: themeController.currentColor.sc5,
borderRadius:
BorderRadius.circular(16.rpx),
),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
30.rpx, 20.rpx, 30.rpx, 20.rpx),
child: StatusBarWithIndicator(
selectKey: widget.data['score']
['level']
.toInt(), // 这里传入对应的 level 值
showLabel: (widget.data['type']
['score'] as List)
.map<Map<String, dynamic>>(
(item) {
return {
'key': item['level']?.toInt() ??
0, // 使用 level 作为 key
'name': item['name'] ?? '',
'color': stringToColor(
item['color'] ??
''), // 将颜色字符串转换为 Color
'range':
item['range'] ?? '', // 添加范围数据
};
}).toList(),
showCurrentValue: true, // 显示当前值
currentValueText:
'当前属于'.tr, // 或者根据实际值动态生成
showRange: true, // 显示范围
BorderRadius.circular(12.rpx),
image: DecorationImage(
image: AssetImage(
'assets/img/black_body_still.png'), // 替换为您的本地图片路径
fit: BoxFit.cover,
),
),
),
SizedBox(height: 25.rpx), // 两个容器之间的间距
],
),
),
),
Padding(
padding:
EdgeInsets.fromLTRB(30.rpx, 0, 30.rpx, 0),
child: Container(
SizedBox(height: 34.rpx), // 两个容器之间的间距
// 第二个容器 - 包含StatusBarWithIndicator todo接入报告数据
Container(
width: double.infinity,
// padding: EdgeInsets.all(30.rpx),
// height: 220.rpx,
decoration: BoxDecoration(
// color: themeController.currentColor.sc5,
borderRadius: BorderRadius.circular(16.rpx),
),
child: QcReportWidget(widget.data),
),
),
Padding(
padding:
EdgeInsets.fromLTRB(46.rpx, 0, 46.rpx, 0),
child: Column(
children: [
// Text(
// "MAC号".tr +
// ": ${widget.data['mac'] ?? '未知数据'.tr}",
// style: TextStyle(
// color: themeController.currentColor.sc4,
// fontSize:
// AppConstants().smaller_text_fontSize,
// ),
// ),
SizedBox(
height: 4.rpx,
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
30.rpx, 20.rpx, 30.rpx, 20.rpx),
child: StatusBarWithIndicator(
selectKey: widget.data['score']['level']
.toInt(), // 这里传入对应的 level 值
showLabel:
(widget.data['type']['score'] as List)
.map<Map<String, dynamic>>((item) {
return {
'key': item['level']?.toInt() ??
0, // 使用 level 作为 key
'name': item['name'] ?? '',
'color': stringToColor(item['color'] ??
''), // 将颜色字符串转换为 Color
'range': item['range'] ?? '', // 添加范围数据
};
}).toList(),
showCurrentValue: true, // 显示当前值
currentValueText: '当前属于'.tr, // 或者根据实际值动态生成
showRange: true, // 显示范围
),
Text(
"本页报告是基于心率、呼吸等体征波形数据通过AI算法模型分析完成其结果仅供参考其中报告未见数据异常部分并不代表没有潜在性的疾病风险如有不适请及时就医。"
.tr,
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize:
AppConstants().smaller_text_fontSize,
),
),
],
),
),
),
SizedBox(
height: 40.rpx,
),
]
.divide(SizedBox(
height: 25.rpx,
))
.addToEnd(SizedBox(height: 25.rpx)),
SizedBox(height: 25.rpx), // 两个容器之间的间距
],
),
),
);
} else {
return Container();
}
} catch (e, s) {
ef.log('ERROR:$e$s');
}
return NullDataWidget();
}),
),
Padding(
padding: EdgeInsets.fromLTRB(30.rpx, 0, 30.rpx, 0),
child: Container(
width: double.infinity,
// padding: EdgeInsets.all(30.rpx),
decoration: BoxDecoration(
// color: themeController.currentColor.sc5,
borderRadius: BorderRadius.circular(16.rpx),
),
child: QcReportWidget(widget.data),
),
),
Padding(
padding: EdgeInsets.fromLTRB(46.rpx, 0, 46.rpx, 0),
child: Column(
children: [
// Text(
// "MAC号".tr +
// ": ${widget.data['mac'] ?? '未知数据'.tr}",
// style: TextStyle(
// color: themeController.currentColor.sc4,
// fontSize:
// AppConstants().smaller_text_fontSize,
// ),
// ),
SizedBox(
height: 4.rpx,
),
Text(
"本页报告是基于心率、呼吸等体征波形数据通过AI算法模型分析完成其结果仅供参考其中报告未见数据异常部分并不代表没有潜在性的疾病风险如有不适请及时就医。"
.tr,
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().smaller_text_fontSize,
),
),
],
),
),
SizedBox(
height: 40.rpx,
),
]
.divide(SizedBox(
height: 25.rpx,
))
.addToEnd(SizedBox(height: 25.rpx)),
),
),
),
),
),
@@ -434,42 +388,6 @@ class _QuickHealthReportPageState extends State<QuickHealthReportPage> {
}
}
Future<void> loadSleepReport(int type) async {
if (sleepReportController.isLoading.value) return;
sleepReportController.model.type = type;
sleepReportController.isLoading.value = true;
String data = MyUtils.formatDate(calendarController.selectedDate.value!);
String serviceAddress = ServiceConstant.service_address;
String serviceName = ServiceConstant.server_service;
String serviceApi = ServiceConstant.sleep_report;
String queryUrl =
"$serviceAddress$serviceName$serviceApi?mac=${widget.data['mac']}&time=$data&type=$type&sleepType=2";
await requestWithLog(
logTitle: "查询睡眠报告",
method: MyHttpMethod.get,
// queryUrl:
// "https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=$data&type=$type",
queryUrl: queryUrl,
onSuccess: (res) {
final sleepData = Map<String, dynamic>.from(res.data);
// 处理时区转换
applyTimezoneConversion(sleepData);
sleepReportController.sleepReport.value = sleepData;
},
onFailure: (res) {
TopSlideNotification.show(
context,
text: res.msg!,
textColor: themeController.currentColor.sc9,
);
sleepReportController.sleepReport.value = {};
},
);
sleepReportController.isLoading.value = false;
sleepReportController.updateAll();
}
// 获取健康等级信息的方法
Map<String, dynamic> getHealthLevelInfo(Map data) {
// 默认值