Skip to content

Commit

Permalink
Add Preview
Browse files Browse the repository at this point in the history
  • Loading branch information
PSchmiedmayer committed May 15, 2024
1 parent 6689d4e commit e71b7b4
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ENGAGEHF.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = ENGAGEHF/ENGAGEHFDebug.entitlements;
CODE_SIGN_ENTITLEMENTS = "ENGAGEHF/Supporting Files/ENGAGEHF.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
Expand Down
62 changes: 61 additions & 1 deletion ENGAGEHF/Bluetooth/Views/MeasurementRecordedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
// SPDX-License-Identifier: MIT
//

@_spi(TestingSupport)
import SpeziBluetooth

Check failure on line 10 in ENGAGEHF/Bluetooth/Views/MeasurementRecordedView.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Attributes Violation: Attributes should be on their own lines in functions and types, but on the same line as variables and imports (attributes)
import BluetoothServices

Check failure on line 11 in ENGAGEHF/Bluetooth/Views/MeasurementRecordedView.swift

View workflow job for this annotation

GitHub Actions / SwiftLint / SwiftLint

Sorted Imports Violation: Imports should be sorted (sorted_imports)
import SpeziViews
import SwiftUI

Expand Down Expand Up @@ -118,6 +121,63 @@ struct MeasurementRecordedView: View {
}

Check warning on line 121 in ENGAGEHF/Bluetooth/Views/MeasurementRecordedView.swift

View check run for this annotation

Codecov / codecov/patch

ENGAGEHF/Bluetooth/Views/MeasurementRecordedView.swift#L106-L121

Added lines #L106 - L121 were not covered by tests
}


private struct MeasurementRecordedViewPreviewWrapper: View {
@Environment(MeasurementManager.self) private var measurementManager
@State private var viewState: ViewState = .idle

Check warning on line 127 in ENGAGEHF/Bluetooth/Views/MeasurementRecordedView.swift

View check run for this annotation

Codecov / codecov/patch

ENGAGEHF/Bluetooth/Views/MeasurementRecordedView.swift#L127

Added line #L127 was not covered by tests


var body: some View {
@Bindable var measurementManager = measurementManager

Button("Mock Measurement") {
loadMockMeasurement()
}
.sheet(isPresented: $measurementManager.showSheet) {
MeasurementRecordedView(viewState: $viewState)
}
}

Check warning on line 139 in ENGAGEHF/Bluetooth/Views/MeasurementRecordedView.swift

View check run for this annotation

Codecov / codecov/patch

ENGAGEHF/Bluetooth/Views/MeasurementRecordedView.swift#L130-L139

Added lines #L130 - L139 were not covered by tests


private func loadMockMeasurement() {
measurementManager.deviceName = "Mock Device"

let deviceInformation = DeviceInformationService()
deviceInformation.$manufacturerName.inject("Mock")
deviceInformation.$modelNumber.inject("42")
deviceInformation.$hardwareRevision.inject("42")
deviceInformation.$firmwareRevision.inject("42")
deviceInformation.$softwareRevision.inject("42")
measurementManager.deviceInformation = deviceInformation

measurementManager.weightScaleParams = WeightScaleFeature(
timeStampEnabled: true,
supportMultipleUsers: true,
supportBMI: true,
weightResolution: .gradeSix,
heightResolution: .gradeThree
)

measurementManager.loadMeasurement(
WeightMeasurement(
units: .metric,
timeStampPresent: true,
userIDPresent: true,
heightBMIPresent: true,
weight: 8400,
timeStamp: DateTime(hours: 0, minutes: 0, seconds: 0),
bmi: 20,
height: 180,
userID: 42
)
)
}

Check warning on line 174 in ENGAGEHF/Bluetooth/Views/MeasurementRecordedView.swift

View check run for this annotation

Codecov / codecov/patch

ENGAGEHF/Bluetooth/Views/MeasurementRecordedView.swift#L142-L174

Added lines #L142 - L174 were not covered by tests
}


#Preview {
MeasurementRecordedView(viewState: .constant(.idle))
MeasurementRecordedViewPreviewWrapper()
.previewWith(standard: ENGAGEHFStandard()) {
MeasurementManager()
}
}
3 changes: 3 additions & 0 deletions ENGAGEHF/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@
},
"Measurement Recorded" : {

},
"Mock Measurement" : {

},
"NOTIFICATION_PERMISSIONS_BUTTON" : {
"localizations" : {
Expand Down

0 comments on commit e71b7b4

Please sign in to comment.