Commit ba1e6e733e4fadc1520dd8a932adbe4c836b6db4

Authored by 常守达
1 parent 492fc9e0

fix(today):修改睡眠区间

... ... @@ -161,16 +161,7 @@ final class HealthKitHostApiImpl: HealthKitHostApi {
completion(.success(target.map {
HealthActivityTargetData(
move: $0.move.map(Int64.init),
stand: $0.stand.map(Int64.init),
activityMoveMode: $0.activityMoveMode.map(Int64.init),
activeEnergyBurned: $0.activeEnergyBurned,
activeEnergyBurnedGoal: $0.activeEnergyBurnedGoal,
appleMoveTime: $0.appleMoveTime,
appleMoveTimeGoal: $0.appleMoveTimeGoal,
appleExerciseTime: $0.appleExerciseTime,
exerciseTimeGoal: $0.exerciseTimeGoal,
appleStandHours: $0.appleStandHours,
standHoursGoal: $0.standHoursGoal
stand: $0.stand.map(Int64.init)
)
}))
} catch {
... ...
... ... @@ -171,6 +171,7 @@ class BindPartnerController extends GetxController {
if (userStateService.isVip) {
Get.offAllNamed(AppRoutes.home);
} else {
await Future.delayed(Durations.medium1);
Get.toNamed(
Routes.MEMBERSHIP_OFFER,
arguments: {'from': 'onboarding'},
... ... @@ -209,6 +210,7 @@ class _BindSuccessPage extends StatelessWidget {
if (userStateService.isVip) {
Get.offAllNamed(AppRoutes.home);
} else {
await Future.delayed(Durations.medium1);
Get.toNamed(
Routes.MEMBERSHIP_OFFER,
arguments: {'from': 'onboarding'},
... ...
... ... @@ -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);
... ...