From 793dddfba801342725ced66a2484a09522838b66 Mon Sep 17 00:00:00 2001 From: wyf <494641114@qq.com> Date: Tue, 9 Dec 2025 18:09:31 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=AF=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/langs/en_US.json | 4 +- assets/langs/zh_CN.json | 6 +- assets/langs/zh_TW.json | 6 +- lib/controller/user_info_controller.dart | 1 + .../component/BreatheStandardWidget.dart | 86 ++++++++++++------- lib/pages/user/update_user_email.dart | 2 +- lib/pages/user/update_user_tel.dart | 4 +- 7 files changed, 71 insertions(+), 38 deletions(-) diff --git a/assets/langs/en_US.json b/assets/langs/en_US.json index f8b5804..fbec5d3 100644 --- a/assets/langs/en_US.json +++ b/assets/langs/en_US.json @@ -612,5 +612,7 @@ "去绑定": "Go Bind", "解除分享": "Unshare", "详情": "Detail", - "更新成功": "Update Success" + "更新成功": "Update Success", + "原邮箱号": "Original Email", + "请输入邮箱号":"Please enter email" } \ No newline at end of file diff --git a/assets/langs/zh_CN.json b/assets/langs/zh_CN.json index d170ae9..3cd8dcc 100644 --- a/assets/langs/zh_CN.json +++ b/assets/langs/zh_CN.json @@ -611,5 +611,9 @@ "允许对方配置wifi": "允许对方配置wifi", "去绑定": "去绑定", "解除分享": "解除分享", - "详情": "详情" + "详情": "详情", + "原邮箱号": "原邮箱号", + "用户拒绝授权": "用户拒绝授权", + "用户取消授权": "用户取消授权", + "请输入邮箱号":"请输入邮箱号" } \ No newline at end of file diff --git a/assets/langs/zh_TW.json b/assets/langs/zh_TW.json index 52eaf3a..319a383 100644 --- a/assets/langs/zh_TW.json +++ b/assets/langs/zh_TW.json @@ -608,5 +608,9 @@ "去绑定": "去綁定", "解除分享": "解除分享", "详情": "詳情", - "更新成功": "更新成功" + "更新成功": "更新成功", + "原邮箱号": "原郵箱號", + "用户拒绝授权": "用戶拒絕授權", + "用户取消授权": "用戶取消授權", + "请输入邮箱号":"請輸入郵箱號" } \ No newline at end of file diff --git a/lib/controller/user_info_controller.dart b/lib/controller/user_info_controller.dart index 5bca888..b9b6523 100644 --- a/lib/controller/user_info_controller.dart +++ b/lib/controller/user_info_controller.dart @@ -155,6 +155,7 @@ class UserInfoController extends GetControllerEx { apiResponse.msg = "昵称为空".tr; return apiResponse; } + if ((phone != null && phone.isNotEmpty) || (email != null && email.isNotEmpty)) { if (loginController.model.updateCode == null || diff --git a/lib/pages/sleep_report/component/BreatheStandardWidget.dart b/lib/pages/sleep_report/component/BreatheStandardWidget.dart index 8468ff8..26f0c2e 100644 --- a/lib/pages/sleep_report/component/BreatheStandardWidget.dart +++ b/lib/pages/sleep_report/component/BreatheStandardWidget.dart @@ -35,6 +35,41 @@ class _BreatheStandardWidgetState extends State { super.dispose(); } + // 计算y轴的最大最小值 + (double, double) _calculateYMinMax(List dataPoints) { + if (dataPoints.isEmpty) { + return (8.0, 20.0); + } + + // 过滤掉无效数据点(值为-1的) + final validPoints = dataPoints.where((point) => point.value >= 0).toList(); + + if (validPoints.isEmpty) { + return (8.0, 20.0); + } + + // 找出数据中的实际最小值和最大值 + double dataMin = validPoints.map((point) => point.value).reduce((a, b) => a < b ? a : b); + double dataMax = validPoints.map((point) => point.value).reduce((a, b) => a > b ? a : b); + + // 设置默认范围 + double yMin = 8.0; + double yMax = 20.0; + + // 如果数据范围超出了默认范围,则调整 + if (dataMin < yMin) { + // 最小值为0,不能为负数,且向下浮动2 + yMin = (dataMin - 2).clamp(0.0, double.infinity); + } + + if (dataMax > yMax) { + // 向上浮动2 + yMax = dataMax + 2; + } + + return (yMin, yMax); + } + @override Widget build(BuildContext context) { try { @@ -54,41 +89,35 @@ class _BreatheStandardWidgetState extends State { data.forEach((item) { final x = item['st'] as int; if (item['value'] == null || item['value'] == '') { - // return; dataPoints.add(TimeSeriesPoint(x, -1)); return; } - final y = (item['value'] as num).toDouble(); // 安全地转换为 double - // return TimeSeriesPoint(x, y); + final y = (item['value'] as num).toDouble(); dataPoints.add(TimeSeriesPoint(x, y)); }); } + // 计算动态的y轴范围 + final (yMin, yMax) = _calculateYMinMax(dataPoints); + List> brs = (widget.sleepReport['brs'] as List).cast>(); - //307 平均呼吸 - //305 基准呼吸 - //308 最低呼吸 - //309 最高呼吸 - // 307 平均呼吸 + Map? avgBreath = brs.firstWhere( (element) => element['id'] == 307, orElse: () => {}, ); -// 305 基准呼吸 Map? baseBreath = brs.firstWhere( (element) => element['id'] == 305, orElse: () => {}, ); -// 308 最低呼吸 Map? minBreath = brs.firstWhere( (element) => element['id'] == 308, orElse: () => {}, ); -// 309 最高呼吸 Map? maxBreath = brs.firstWhere( (element) => element['id'] == 309, orElse: () => {}, @@ -111,7 +140,7 @@ class _BreatheStandardWidgetState extends State { decoration: BoxDecoration( color: themeController.currentColor.sc5, borderRadius: BorderRadius.circular( - AppConstants().normal_container_radius), // 你可以按需调整圆角半径 + AppConstants().normal_container_radius), ), child: Padding( padding: @@ -131,10 +160,10 @@ class _BreatheStandardWidgetState extends State { ), ClickableContainer( backgroundColor: Colors.transparent, - highlightColor: Colors.white, // 或设置为你需要的水波纹颜色 + highlightColor: Colors.white, padding: EdgeInsetsDirectional.fromSTEB( - 14.rpx, 10.rpx, 14.rpx, 10.rpx), // - borderRadius: 0.rpx, // 圆形点击区域 + 14.rpx, 10.rpx, 14.rpx, 10.rpx), + borderRadius: 0.rpx, onTap: () { if (AppConstants().ent_type == APPPackageType.MHT.code) { @@ -142,7 +171,6 @@ class _BreatheStandardWidgetState extends State { context, Container( child: Text( - // "呼吸数据介绍".tr, "呼吸数据是指用户在睡眠过程中呼吸的基本数据,是评估睡眠呼吸质量、筛查睡眠呼吸障碍的核心指标。" .tr, style: TextStyle( @@ -178,7 +206,7 @@ class _BreatheStandardWidgetState extends State { }, child: Container( padding: EdgeInsetsDirectional.fromSTEB( - 0, 0.rpx, 0.rpx, 0), // 外部 padding 移到内部 + 0, 0.rpx, 0.rpx, 0), width: 28.rpx, height: 28.rpx, child: SvgPicture.asset( @@ -202,39 +230,33 @@ class _BreatheStandardWidgetState extends State { Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - // 圆形小球容器 Container( - width: 14.rpx, // 圆球的直径 + width: 14.rpx, height: 14.rpx, decoration: BoxDecoration( - color: themeController.currentColor.sc2, // 小球的颜色 - shape: BoxShape.circle, // 设置为圆形 + color: themeController.currentColor.sc2, + shape: BoxShape.circle, ), ), - SizedBox(width: 15.rpx), // 圆球和文字之间的间隔 - // 文字 + SizedBox(width: 15.rpx), Text( '正常范围'.tr + "${range}", style: TextStyle( fontSize: - AppConstants().smaller_text_fontSize, // 文字的大小 - color: themeController.currentColor.sc3, // 文字颜色 + AppConstants().smaller_text_fontSize, + color: themeController.currentColor.sc3, ), ), ], ), Container( - // color: Colors.red, width: double.infinity, - // height: 300.rpx, child: TimeSeriesChart( startTime: startTime, endTime: endTime, - yMin: 8, - yMax: 20, + yMin: yMin, + yMax: yMax, dataPoints: dataPoints, - // actYMax: max.toDouble(), - // actYMin: min.toDouble(), ), ), ].divide(SizedBox( @@ -398,4 +420,4 @@ class _BreatheStandardWidgetState extends State { return Container(); } } -} +} \ No newline at end of file diff --git a/lib/pages/user/update_user_email.dart b/lib/pages/user/update_user_email.dart index 6ac66d6..e85981f 100644 --- a/lib/pages/user/update_user_email.dart +++ b/lib/pages/user/update_user_email.dart @@ -96,7 +96,7 @@ class _UpdateUserEmailPageState extends State { if (loginController.model.updatePhone == null || loginController.model.updatePhone == '') { NewTopSlideNotification.show( - text: "请输入邮箱号", + text: "请输入邮箱号".tr, textColor: themeController.currentColor.sc9, ); return; diff --git a/lib/pages/user/update_user_tel.dart b/lib/pages/user/update_user_tel.dart index e6ad7aa..3c90536 100644 --- a/lib/pages/user/update_user_tel.dart +++ b/lib/pages/user/update_user_tel.dart @@ -100,7 +100,7 @@ class _UpdateUserTelPageState extends State { if (loginController.model.updatePhone == null || loginController.model.updatePhone == '') { NewTopSlideNotification.show( - text: "请输入手机号", + text: "请输入手机号".tr, textColor: themeController.currentColor.sc9, ); return; @@ -183,7 +183,7 @@ class _UpdateUserTelPageState extends State { padding: EdgeInsetsDirectional.fromSTEB( 60.rpx, 0, 35.rpx, 0), child: Text( - "原手机号码" + ":" + "${getHidePhone()}", + "原手机号码".tr + ":" + "${getHidePhone()}", style: TextStyle( color: themeController.currentColor.sc3, fontSize: AppConstants().normal_text_fontSize,