Commit b9503e555c01466de7f1ea1f32822eac317d5170

Authored by 常守达
1 parent 0c17ac6c

fix(today):实时压力UI修改

@@ -231,16 +231,24 @@ class TodayHrvChartCard extends StatelessWidget { @@ -231,16 +231,24 @@ class TodayHrvChartCard extends StatelessWidget {
231 controller.toPremiumPage('今日-实时压力-立即解锁'); 231 controller.toPremiumPage('今日-实时压力-立即解锁');
232 } 232 }
233 233
234 - // 槽时间秒 → state 映射(与 _buildStressBarGroups 一致:取 value 最大那条 of state) 234 + // 槽时间秒 → state 映射
  235 + // 同一 slot 内:优先"活跃"点(isWorkout / isSuspectedActivity / isMoving 任一为1),
  236 + // 活跃状态相同时取 value 更大的
235 const slotSec = 6 * 60; 237 const slotSec = 6 * 60;
236 - final slotStateMap = <int, ({int value, int? state})>{}; 238 + final slotStateMap = <int, ({int value, int? state, bool active})>{};
237 for (final p in stressPoints) { 239 for (final p in stressPoints) {
238 final sec = _tsToSecondsFromMidnight(p.time).round(); 240 final sec = _tsToSecondsFromMidnight(p.time).round();
239 final slot = (sec / slotSec).round() * slotSec; 241 final slot = (sec / slotSec).round() * slotSec;
240 final v = p.value ?? 0; 242 final v = p.value ?? 0;
  243 + final active = (p.isWorkout ?? 0) == 1 ||
  244 + (p.isSuspectedActivity ?? 0) == 1 ||
  245 + (p.isMoving ?? 0) == 1;
241 final existing = slotStateMap[slot]; 246 final existing = slotStateMap[slot];
242 - if (existing == null || v > existing.value) {  
243 - slotStateMap[slot] = (value: v, state: p.state); 247 + final shouldReplace = existing == null ||
  248 + (active && !existing.active) ||
  249 + (active == existing.active && v > existing.value);
  250 + if (shouldReplace) {
  251 + slotStateMap[slot] = (value: v, state: p.state, active: active);
244 } 252 }
245 } 253 }
246 return Stack( 254 return Stack(
@@ -384,7 +392,7 @@ class TodayHrvChartCard extends StatelessWidget { @@ -384,7 +392,7 @@ class TodayHrvChartCard extends StatelessWidget {
384 style: TextStyle( 392 style: TextStyle(
385 fontSize: 14, 393 fontSize: 14,
386 color: 394 color:
387 - isWorkout == true ? Color(0xFF78787D) : _getColorByState(state), 395 + isWorkout == true ? Color(0xFFB0B0B6) : _getColorByState(state),
388 fontWeight: FontWeight.bold, 396 fontWeight: FontWeight.bold,
389 inherit: false, 397 inherit: false,
390 fontFamilyFallback: null, 398 fontFamilyFallback: null,
@@ -413,7 +421,7 @@ class TodayHrvChartCard extends StatelessWidget { @@ -413,7 +421,7 @@ class TodayHrvChartCard extends StatelessWidget {
413 TextSpan( 421 TextSpan(
414 text: '♥ ', 422 text: '♥ ',
415 style: const TextStyle( 423 style: const TextStyle(
416 - color: Color(0xFF78787D), 424 + color: Color(0xFFB0B0B6),
417 fontSize: 14, 425 fontSize: 14,
418 fontWeight: FontWeight.bold, 426 fontWeight: FontWeight.bold,
419 inherit: false, 427 inherit: false,
@@ -466,7 +474,7 @@ class TodayHrvChartCard extends StatelessWidget { @@ -466,7 +474,7 @@ class TodayHrvChartCard extends StatelessWidget {
466 inherit: false, 474 inherit: false,
467 fontFamilyFallback: null, 475 fontFamilyFallback: null,
468 fontFamily: '', 476 fontFamily: '',
469 - color: Color(0xFF78787D), 477 + color: Color(0xFFB0B0B6),
470 fontSize: 14, 478 fontSize: 14,
471 fontWeight: FontWeight.bold, 479 fontWeight: FontWeight.bold,
472 ), 480 ),
@@ -939,7 +947,7 @@ class _StressBarChartState extends State<_StressBarChart> { @@ -939,7 +947,7 @@ class _StressBarChartState extends State<_StressBarChart> {
939 bottom: chartHeight - gridBottom, // 修正:bottom 指的是距离 Stack 底部的像素值 947 bottom: chartHeight - gridBottom, // 修正:bottom 指的是距离 Stack 底部的像素值
940 child: IgnorePointer( 948 child: IgnorePointer(
941 child: ColoredBox( 949 child: ColoredBox(
942 - color: context.colors.textTertiary.withAlpha(125), 950 + color: context.colors.textTertiary,
943 ), 951 ),
944 ), 952 ),
945 ); 953 );
@@ -1188,15 +1196,22 @@ class _StressBarChartState extends State<_StressBarChart> { @@ -1188,15 +1196,22 @@ class _StressBarChartState extends State<_StressBarChart> {
1188 const slotSec = 6 * 60; // 360 秒 = 6 分钟 1196 const slotSec = 6 * 60; // 360 秒 = 6 分钟
1189 final maxSec = widget.maxSeconds.round(); 1197 final maxSec = widget.maxSeconds.round();
1190 1198
1191 - // 按槽分组,记录每槽的最大 value 及对应的 state / isWorkout  
1192 - final slotMax = <int, ({int value, int? state, int? isWorkout})>{}; 1199 + // 按槽分组,优先"活跃"点(isWorkout / isSuspectedActivity / isMoving 任一为1),
  1200 + // 活跃状态相同时取 value 更大的
  1201 + final slotMax = <int, ({int value, int? state, bool active})>{};
1193 for (final p in stressPoints) { 1202 for (final p in stressPoints) {
1194 final sec = TodayHrvChartCard._tsToSecondsFromMidnight(p.time).round(); 1203 final sec = TodayHrvChartCard._tsToSecondsFromMidnight(p.time).round();
1195 final slot = (sec / slotSec).round() * slotSec; 1204 final slot = (sec / slotSec).round() * slotSec;
1196 final v = p.value ?? 0; 1205 final v = p.value ?? 0;
  1206 + final active = (p.isWorkout ?? 0) == 1 ||
  1207 + (p.isSuspectedActivity ?? 0) == 1 ||
  1208 + (p.isMoving ?? 0) == 1;
1197 final existing = slotMax[slot]; 1209 final existing = slotMax[slot];
1198 - if (existing == null || v > existing.value) {  
1199 - slotMax[slot] = (value: v, state: p.state, isWorkout: p.isWorkout); 1210 + final shouldReplace = existing == null ||
  1211 + (active && !existing.active) ||
  1212 + (active == existing.active && v > existing.value);
  1213 + if (shouldReplace) {
  1214 + slotMax[slot] = (value: v, state: p.state, active: active);
1200 } 1215 }
1201 } 1216 }
1202 1217
@@ -1214,8 +1229,8 @@ class _StressBarChartState extends State<_StressBarChart> { @@ -1214,8 +1229,8 @@ class _StressBarChartState extends State<_StressBarChart> {
1214 toY: entry != null ? entry.value.toDouble() : 0, 1229 toY: entry != null ? entry.value.toDouble() : 0,
1215 width: barWidth, 1230 width: barWidth,
1216 color: entry != null 1231 color: entry != null
1217 - ? (entry.isWorkout == 1  
1218 - ? const Color(0xFF78787D) 1232 + ? (entry.active
  1233 + ? const Color(0xFFD9D9D9)
1219 : widget.getColorByState(entry.state)) 1234 : widget.getColorByState(entry.state))
1220 : Colors.transparent, 1235 : Colors.transparent,
1221 borderRadius: BorderRadius.circular(barWidth / 2), 1236 borderRadius: BorderRadius.circular(barWidth / 2),