diff --git a/Sources/PressureEstimationsFeature/EquipmentMeasurementForm.swift b/Sources/PressureEstimationsFeature/EquipmentMeasurementForm.swift index 55e075c..81c67ac 100644 --- a/Sources/PressureEstimationsFeature/EquipmentMeasurementForm.swift +++ b/Sources/PressureEstimationsFeature/EquipmentMeasurementForm.swift @@ -293,7 +293,7 @@ public struct EquipmentMeasurementFormView: View { } Section { Grid(alignment: .leading, horizontalSpacing: 40) { - ForEach(store.pressureFields, content: gridRow(for:)) + ForEach(store.pressureFields, content: gridRow(for:)) } } header: { HStack { @@ -321,11 +321,10 @@ public struct EquipmentMeasurementFormView: View { } } } + .applyFormStyle() .bind($focusedField, to: $store.focusedField) .labeledContentStyle(.gridRow) .onAppear { send(.onAppear) } - .textLabelStyle(.boldSecondary) - .textFieldStyle(.roundedBorder) .toolbar { NextButton { send(.nextButtonTapped) } .nextButtonStyle(.toolbar) @@ -347,13 +346,13 @@ public struct EquipmentMeasurementFormView: View { FlaggedMeasurementListView(store: store) } } - + private func gridRow(for field: EquipmentMeasurementForm.State.Field) -> some View { TextLabeledContent(store.label(field: field)) { textField(for: field) } } - + private func textField( for field: EquipmentMeasurementForm.State.Field ) -> some View { @@ -413,7 +412,7 @@ public struct EquipmentMeasurementFormView: View { } fileprivate extension InfoViewFeature.State { - + init() { self.init( title: "Existing Measurements", diff --git a/Sources/PressureEstimationsFeature/EquipmentSettingsForm.swift b/Sources/PressureEstimationsFeature/EquipmentSettingsForm.swift index 002bd2b..1316261 100644 --- a/Sources/PressureEstimationsFeature/EquipmentSettingsForm.swift +++ b/Sources/PressureEstimationsFeature/EquipmentSettingsForm.swift @@ -222,10 +222,8 @@ public struct EquipmentSettingsFormView: View { } } } - .labelsHidden() + .applyFormStyle() .bind($focusedField, to: $store.focusedField) - .textLabelStyle(.boldSecondary) - .textFieldStyle(.roundedBorder) .sheet( item: $store.scope( state: \.destination?.infoView, diff --git a/Sources/PressureEstimationsFeature/EstimationsForm.swift b/Sources/PressureEstimationsFeature/EstimationsForm.swift index 238e7c4..6cc791e 100644 --- a/Sources/PressureEstimationsFeature/EstimationsForm.swift +++ b/Sources/PressureEstimationsFeature/EstimationsForm.swift @@ -173,9 +173,7 @@ public struct EstimationFormView: View { } } } - .labelsHidden() - .textLabelStyle(.boldSecondary) - .textFieldStyle(.roundedBorder) + .applyFormStyle() } } diff --git a/Sources/PressureEstimationsFeature/FlaggedMeasurementsList.swift b/Sources/PressureEstimationsFeature/FlaggedMeasurementsList.swift index 083b610..766c4eb 100644 --- a/Sources/PressureEstimationsFeature/FlaggedMeasurementsList.swift +++ b/Sources/PressureEstimationsFeature/FlaggedMeasurementsList.swift @@ -182,17 +182,7 @@ public struct FlaggedMeasurementsList: Sendable { print("No changes found, not generating a new flagged estimation measurement.") return .none } -// -// let estimationState = form.estimationState -// // Check if there's an existing estimation with the same id, and -// // check for changes. If no changes, then short circuit and return nothing. -// if let id = form.id, -// let existingState = state.sharedSettings.flaggedEstimations[id: id]?.estimationState, -// existingState.hasChanges(estimationState) -// { -// return .none -// } - + return .receive(action: \.receive) { [sharedSettings = state.sharedSettings] in let flaggedMeasurement = try await flaggedMeasurement( diff --git a/Sources/PressureEstimationsFeature/PressureEstimations.swift b/Sources/PressureEstimationsFeature/PressureEstimations.swift index 1bf1e80..d91c8e3 100644 --- a/Sources/PressureEstimationsFeature/PressureEstimations.swift +++ b/Sources/PressureEstimationsFeature/PressureEstimations.swift @@ -126,6 +126,7 @@ public struct PressureEstimationsView: View { EquipmentMeasurementFormView(store: measurementStore) .navigationTitle("Existing Measurements") } + } } diff --git a/Sources/Styleguide/Styles/FormStyle.swift b/Sources/Styleguide/Styles/FormStyle.swift new file mode 100644 index 0000000..dab21a3 --- /dev/null +++ b/Sources/Styleguide/Styles/FormStyle.swift @@ -0,0 +1,15 @@ +import SwiftUI + +// Note: This does not work as an actual form style, as it adds toolbars, etc. multiple times, so just using as a modifier. +extension View { + + public func applyFormStyle() -> some View { + self + .labelsHidden() + .textLabelStyle(.boldSecondary) + .textFieldStyle(.roundedBorder) + #if os(macOS) + .padding() + #endif + } +}