|
...
|
...
|
@@ -576,17 +576,17 @@ class LocalHealthDataConvert { |
|
|
|
move: (latest?.activeEnergyBurned ?? 0).ceil(),
|
|
|
|
standHours: latest?.appleStandHours ?? 0,
|
|
|
|
exerciseSeconds: latest?.appleExerciseTime ?? 0,
|
|
|
|
moveGoal: latest?.activeEnergyBurnedGoal ?? 480,
|
|
|
|
standGoal: latest?.standHoursGoal ?? 8,
|
|
|
|
moveGoal: latest?.activeEnergyBurnedGoal,
|
|
|
|
standGoal: latest?.standHoursGoal,
|
|
|
|
exerciseGoalSeconds: latest?.exerciseTimeGoal,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool _hasActivityGoal(HealthKitRawActivityDataPoint item) {
|
|
|
|
return item.activeEnergyBurnedGoal != null ||
|
|
|
|
item.appleMoveTimeGoal != null ||
|
|
|
|
item.standHoursGoal != null ||
|
|
|
|
item.exerciseTimeGoal != null;
|
|
|
|
return _isPositive(item.activeEnergyBurnedGoal) ||
|
|
|
|
_isPositive(item.appleMoveTimeGoal) ||
|
|
|
|
_isPositive(item.standHoursGoal) ||
|
|
|
|
_isPositive(item.exerciseTimeGoal);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HealthRawHrvStressPoint? _latestHrvByRawEndTime(
|
|
...
|
...
|
@@ -641,10 +641,42 @@ class LocalHealthDataConvert { |
|
|
|
static _ActivityDaySummary? _latestActivitySummaryWithGoal(
|
|
|
|
List<_ActivityDaySummary> daily,
|
|
|
|
) {
|
|
|
|
num? moveGoal;
|
|
|
|
num? standGoal;
|
|
|
|
num? exerciseGoalSeconds;
|
|
|
|
DateTime? latestGoalDay;
|
|
|
|
for (final item in daily.reversed) {
|
|
|
|
if (item.hasGoal) return item;
|
|
|
|
if (moveGoal == null && _isPositive(item.moveGoal)) {
|
|
|
|
moveGoal = item.moveGoal;
|
|
|
|
latestGoalDay ??= item.day;
|
|
|
|
}
|
|
|
|
if (standGoal == null && _isPositive(item.standGoal)) {
|
|
|
|
standGoal = item.standGoal;
|
|
|
|
latestGoalDay ??= item.day;
|
|
|
|
}
|
|
|
|
if (exerciseGoalSeconds == null &&
|
|
|
|
_isPositive(item.exerciseGoalSeconds)) {
|
|
|
|
exerciseGoalSeconds = item.exerciseGoalSeconds;
|
|
|
|
latestGoalDay ??= item.day;
|
|
|
|
}
|
|
|
|
if (moveGoal != null &&
|
|
|
|
standGoal != null &&
|
|
|
|
exerciseGoalSeconds != null) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
if (moveGoal == null && standGoal == null && exerciseGoalSeconds == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return _ActivityDaySummary(
|
|
|
|
day: latestGoalDay ?? daily.last.day,
|
|
|
|
move: 0,
|
|
|
|
standHours: 0,
|
|
|
|
exerciseSeconds: 0,
|
|
|
|
moveGoal: moveGoal,
|
|
|
|
standGoal: standGoal,
|
|
|
|
exerciseGoalSeconds: exerciseGoalSeconds,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ActivityTargetInfo? _activityTargetInfo(
|
|
...
|
...
|
@@ -945,6 +977,8 @@ class LocalHealthDataConvert { |
|
|
|
if (values.isEmpty) return null;
|
|
|
|
return values.reduce(math.min);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool _isPositive(num? value) => value != null && value > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
class _ActivityDaySummary {
|
|
...
|
...
|
@@ -967,9 +1001,9 @@ class _ActivityDaySummary { |
|
|
|
final num? exerciseGoalSeconds;
|
|
|
|
|
|
|
|
bool get hasGoal =>
|
|
|
|
moveGoal != null ||
|
|
|
|
standGoal != null ||
|
|
|
|
exerciseGoalSeconds != null;
|
|
|
|
(moveGoal ?? 0) > 0 ||
|
|
|
|
(standGoal ?? 0) > 0 ||
|
|
|
|
(exerciseGoalSeconds ?? 0) > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
class _HrvDaySummary {
|
...
|
...
|
|