Skip to content

Commit f541d41

Browse files
authored
Minor fixes on BluetoothView and HealthKit Permission Requests (#41)
# Minor fixes on BluetoothView and HealthKit Permission Requests ## ♻️ Current situation & Problem 1. In Bluetooth Connection View, the account button was not showing. 2. HealthKit permissions were asked multiple times. ## ⚙️ Release Notes 1. Can see account button on bluetooth view now. 2. All HealthKit permissions are asked in the onboarding. ## 📝 Code of Conduct & Contributing Guidelines By submitting creating this pull request, you agree to follow our [Code of Conduct](https://github.com/CS342/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/CS342/.github/blob/main/CONTRIBUTING.md): - [X] I agree to follow the [Code of Conduct](https://github.com/CS342/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/CS342/.github/blob/main/CONTRIBUTING.md).
1 parent 26db3a7 commit f541d41

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

NeutroFeverGuard/BluetoothRelated/BluetoothView.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ struct BluetoothView: View {
177177
}
178178
}
179179
.scanNearbyDevices(with: bluetooth, autoConnect: true)
180-
}
181-
.toolbar {
182-
if account != nil {
183-
AccountButton(isPresented: $presentingAccount)
180+
.toolbar {
181+
if account != nil {
182+
AccountButton(isPresented: $presentingAccount)
183+
}
184184
}
185185
}
186186
}

NeutroFeverGuard/Onboarding/HealthKitPermissions.swift

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,26 @@ import SwiftUI
1414
struct HealthKitPermissions: View {
1515
@Environment(HealthKit.self) private var healthKitDataSource
1616
@Environment(OnboardingNavigationPath.self) private var onboardingNavigationPath
17-
17+
1818
@State private var healthKitProcessing = false
1919

20-
20+
let accessRequirements = HealthKit.DataAccessRequirements(
21+
read: [
22+
HKQuantityType(.heartRate),
23+
HKQuantityType(.oxygenSaturation),
24+
HKQuantityType(.bodyTemperature),
25+
HKQuantityType(.bloodPressureSystolic),
26+
HKQuantityType(.bloodPressureDiastolic)
27+
],
28+
write: [
29+
HKQuantityType(.heartRate),
30+
HKQuantityType(.oxygenSaturation),
31+
HKQuantityType(.bodyTemperature),
32+
HKQuantityType(.bloodPressureSystolic),
33+
HKQuantityType(.bloodPressureDiastolic)
34+
]
35+
)
36+
2137
var body: some View {
2238
OnboardingView(
2339
contentView: {
@@ -46,7 +62,7 @@ struct HealthKitPermissions: View {
4662
if ProcessInfo.processInfo.isPreviewSimulator {
4763
try await _Concurrency.Task.sleep(for: .seconds(5))
4864
} else {
49-
try await healthKitDataSource.askForAuthorization()
65+
try await healthKitDataSource.askForAuthorization(for: accessRequirements)
5066
}
5167
} catch {
5268
print("Could not request HealthKit permissions.")

0 commit comments

Comments
 (0)