This commit is contained in:
wyf
2025-11-14 15:12:35 +08:00
parent 7e44998240
commit 18bd13a7b6
18 changed files with 431 additions and 112 deletions

View File

@@ -76,7 +76,8 @@ class _HeartChangeWidgetState extends State<HeartChangeWidget> {
14.rpx, 10.rpx, 14.rpx, 10.rpx), //
borderRadius: 0.rpx, // 圆形点击区域
onTap: () {
if (AppConstants().ent_type == APPPackageType.MHT.code) {
if (AppConstants().ent_type ==
APPPackageType.MHT.code) {
showTipDialog(
context,
Container(
@@ -251,7 +252,9 @@ class _HeartChangeWidgetState extends State<HeartChangeWidget> {
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: themeController.currentColor.sc3,
color:
getColorByRange(data['value'], data['range']),
// color: themeController.currentColor.sc3,
fontSize: AppConstants().normal_text_fontSize,
),
),
@@ -334,4 +337,33 @@ class _HeartChangeWidgetState extends State<HeartChangeWidget> {
};
}).toList();
}
getColorByRange(double value, String? range) {
try {
// 1. 空、"-"、null 都直接返回默认颜色
if (range == null || range.toString().isEmpty || range == "-") {
return themeController.currentColor.sc3;
}
// 2. 拆分范围,例如 "70-150"
final parts = range.split('-');
if (parts.length != 2) {
return themeController.currentColor.sc3; // 格式不对直接默认
}
final min = int.parse(parts[0].trim());
final max = int.parse(parts[1].trim());
// 3. 判断是否在范围内
if (value < min || value > max) {
// 不在范围 → 返回 danger 色
return themeController.currentColor.sc9;
}
// 在范围 → 正常色
return themeController.currentColor.sc3;
} catch (e) {
// 任意解析错误都回默认
return themeController.currentColor.sc3;
}
}
}