杨锴
2024-08-14 909e20941e45f8712c012db602034b47da0bfdb0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// HKActivitySummaryExtensions.swift - Copyright 2024 SwifterSwift
 
// HeathKit is not available for tvOS, available only on iOS 8.0+ Mac Catalyst 13.0+ watchOS 2.0+
// See: https://developer.apple.com/documentation/healthkit
#if !os(tvOS)
#if canImport(HealthKit)
import HealthKit
 
// MARK: - Properties
 
@available(macOS 13.0, *)
public extension HKActivitySummary {
    /// SwifterSwift: Check if stand goal is met.
    var isStandGoalMet: Bool {
        if #available(iOS 16.0, watchOS 9.0, *) {
            return standHoursGoal == nil || standHoursGoal!.compare(appleStandHours) != .orderedDescending
        } else {
            return appleStandHoursGoal.compare(appleStandHours) != .orderedDescending
        }
    }
 
    /// SwifterSwift: Check if exercise time goal is met.
    var isExerciseTimeGoalMet: Bool {
        if #available(iOS 16.0, watchOS 9.0, *) {
            return exerciseTimeGoal == nil || exerciseTimeGoal!.compare(appleExerciseTime) != .orderedDescending
        } else {
            return appleExerciseTimeGoal.compare(appleExerciseTime) != .orderedDescending
        }
    }
 
    /// SwifterSwift: Check if active energy goal is met.
    var isEnergyBurnedGoalMet: Bool { activeEnergyBurnedGoal.compare(activeEnergyBurned) != .orderedDescending }
}
#endif
#endif