|
...
|
...
|
@@ -135,15 +135,17 @@ class TodayHrvChartCard extends StatelessWidget { |
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(width: 4),
|
|
|
|
GestureDetector(
|
|
|
|
behavior: HitTestBehavior.opaque,
|
|
|
|
onTap: () => showHrvPrincipleExplanationBottomSheet(context),
|
|
|
|
child: Image.asset(
|
|
|
|
'assets/images/common/ic_info.png',
|
|
|
|
width: 14,
|
|
|
|
height: 14,
|
|
|
|
color: context.colors.textTertiary,
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.fromLTRB(4, 12, 16, 12),
|
|
|
|
child: Image.asset(
|
|
|
|
'assets/images/common/ic_info.png',
|
|
|
|
width: 14,
|
|
|
|
height: 14,
|
|
|
|
color: context.colors.textTertiary,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const Spacer(),
|
|
...
|
...
|
@@ -370,7 +372,32 @@ class TodayHrvChartCard extends StatelessWidget { |
|
|
|
final maxSec = _maxChartSeconds();
|
|
|
|
final chartWidth = constraints.maxWidth - rightAxisWidth;
|
|
|
|
|
|
|
|
for (final range in sleepList) {
|
|
|
|
// 1. 过滤并排序睡眠区间
|
|
|
|
final sortedList = List<V2SleepTimeRange>.from(sleepList)
|
|
|
|
..sort((a, b) => a.fromTime.compareTo(b.fromTime));
|
|
|
|
|
|
|
|
// 2. 合并相邻且间隔小于 2 小时的睡眠区间,避免因短暂醒来分段导致多个床图标或跨天首尾大面积相连
|
|
|
|
final mergedList = <V2SleepTimeRange>[];
|
|
|
|
for (final range in sortedList) {
|
|
|
|
if (mergedList.isEmpty) {
|
|
|
|
mergedList.add(range);
|
|
|
|
} else {
|
|
|
|
final lastRange = mergedList.last;
|
|
|
|
if (range.fromTime - lastRange.toTime <= 2 * 3600) {
|
|
|
|
mergedList[mergedList.length - 1] = V2SleepTimeRange(
|
|
|
|
fromTime: lastRange.fromTime,
|
|
|
|
toTime: range.toTime > lastRange.toTime
|
|
|
|
? range.toTime
|
|
|
|
: lastRange.toTime,
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
mergedList.add(range);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 3. 渲染合并后的睡眠区间 Positioned widgets
|
|
|
|
for (final range in mergedList) {
|
|
|
|
final fromSec = range.fromTime - todayMidnightSec;
|
|
|
|
final toSec = range.toTime - todayMidnightSec;
|
|
|
|
final visibleFrom = fromSec.clamp(0.0, maxSec);
|
...
|
...
|
|