generated from StanfordSpezi/SpeziTemplateApplication
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LifeSpaceDelegate.swift
94 lines (82 loc) · 2.73 KB
/
LifeSpaceDelegate.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//
// This source file is part of the LifeSpace application based on the Stanford Spezi Template Application project
//
// SPDX-FileCopyrightText: 2023 Stanford University
//
// SPDX-License-Identifier: MIT
//
import class FirebaseFirestore.FirestoreSettings
import class FirebaseFirestore.MemoryCacheSettings
import Spezi
import SpeziAccount
import SpeziFirebaseAccount
import SpeziFirebaseAccountStorage
import SpeziFirebaseStorage
import SpeziFirestore
import SpeziHealthKit
import SpeziOnboarding
import SpeziScheduler
import SwiftUI
class LifeSpaceDelegate: SpeziAppDelegate {
override var configuration: Configuration {
Configuration(standard: LifeSpaceStandard()) {
if !FeatureFlags.disableFirebase {
AccountConfiguration(
service: FirebaseAccountService(
providers: [.signInWithApple],
emulatorSettings: accountEmulator
),
configuration: [
.requires(\.userId)
]
)
firestore
if FeatureFlags.useFirebaseEmulator {
FirebaseStorageConfiguration(emulatorSettings: (host: "localhost", port: 9199))
} else {
FirebaseStorageConfiguration()
}
}
if HKHealthStore.isHealthDataAvailable() {
healthKit
}
LifeSpaceScheduler()
OnboardingDataSource()
LocationModule()
}
}
private var accountEmulator: (host: String, port: Int)? {
if FeatureFlags.useFirebaseEmulator {
(host: "localhost", port: 9099)
} else {
nil
}
}
private var firestore: Firestore {
let settings = FirestoreSettings()
if FeatureFlags.useFirebaseEmulator {
settings.host = "localhost:8080"
settings.cacheSettings = MemoryCacheSettings()
settings.isSSLEnabled = false
}
return Firestore(
settings: settings
)
}
private var healthKit: HealthKit {
HealthKit {
CollectSamples(
[
HKQuantityType(.stepCount),
HKQuantityType(.walkingSpeed),
HKQuantityType(.walkingAsymmetryPercentage),
HKQuantityType(.appleWalkingSteadiness),
HKQuantityType(.appleStandTime),
HKQuantityType(.appleMoveTime),
HKCategoryType(.sleepAnalysis)
],
deliverySetting: .background(.automatic)
)
}
}
}