-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHKDataTypeExt.swift
49 lines (40 loc) · 1.16 KB
/
HKDataTypeExt.swift
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// DataTypes.swift
// Recover
//
// Created by Jason Tsang on 2022-08-24.
//
import Foundation
import UIKit
import HealthKit
/// A representation of health data to use for `HealthDataTypeTableViewController`.
struct HealthDataTypeValue {
let startDate: Date
let endDate: Date
var value: Double
}
public enum HKCategoryValueSleepAnalysis: Int {
case inBed = 0
case asleepUnspecified = 1// 👈🏻 Replaces asleep, used when user is asleep but no sleep stage is specified
case awake = 2
case asleepCore = 3// 👈🏻 New
case asleepDeep = 4 // 👈🏻 New
case asleepREM = 5 // 👈🏻 New
}
protocol HealthClientType {
var healthStore: HKHealthStore? { get set }
}
extension UIViewController {
func injectHealthStore(_ healthStore: HKHealthStore) {
if var client = self as? HealthClientType {
client.healthStore = healthStore
}
for childViewController in children {
childViewController.injectHealthStore(healthStore)
}
}
}
protocol HealthStoreContainer {
// A required property that contains the health store.
var healthStore: HKHealthStore! { get set }
}