generated from StanfordBDHG/SwiftPackageTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finish
HealthChart
as public-facing api
- Loading branch information
Showing
7 changed files
with
132 additions
and
98 deletions.
There are no files selected for viewing
72 changes: 0 additions & 72 deletions
72
Sources/SpeziHealthCharts/MetricChart/ChartViews/HealthChart+ViewModel.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
Sources/SpeziHealthCharts/MetricChart/ChartViews/InternalHealthChart.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// | ||
// This source file is part of the Stanford Spezi open-source project | ||
// | ||
// SPDX-FileCopyrightText: 2024 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
import HealthKit | ||
import SwiftUI | ||
|
||
|
||
struct InternalHealthChart: View { | ||
@Binding private var range: ChartRange | ||
@State private var measurements: [Int] = [1] | ||
|
||
|
||
@Environment(\.disabledChartInteractions) private var disabledInteractions | ||
@Environment(\.healthChartStyle) private var chartStyle | ||
|
||
|
||
private let quantityType: HKQuantityType | ||
private let dataProvider: any DataProvider | ||
|
||
|
||
var body: some View { | ||
List { | ||
HStack { | ||
Text("Quantity Type:") | ||
.bold() | ||
Spacer(minLength: 5) | ||
Text(quantityType.identifier) | ||
} | ||
HStack { | ||
Text("Chart Range (Binding):") | ||
.bold() | ||
Spacer(minLength: 5) | ||
Text(range.interval.description) | ||
} | ||
HStack { | ||
Text("Chart Style (Modifier):") | ||
.bold() | ||
Spacer(minLength: 5) | ||
Text("\(chartStyle.frameSize)") | ||
} | ||
HStack { | ||
Text("Disabled Interactions (Modifier):") | ||
.bold() | ||
Spacer(minLength: 5) | ||
Text(String(disabledInteractions.rawValue, radix: 2)) | ||
} | ||
Section("Measurements") { | ||
ForEach(measurements, id: \.self) { measurement in | ||
Text("\(measurement)") | ||
} | ||
} | ||
} | ||
.onChange(of: range) { _, _ in | ||
measurements.append(measurements.reduce(0, +)) | ||
} | ||
} | ||
|
||
|
||
init( | ||
_ type: HKQuantityType, | ||
range: Binding<ChartRange>, | ||
provider: any DataProvider = HealthKitDataProvider() | ||
) { | ||
self._range = range | ||
self.quantityType = type | ||
self.dataProvider = provider | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters