feat: Adds form style to styleguide.
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -173,9 +173,7 @@ public struct EstimationFormView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
.labelsHidden()
|
||||
.textLabelStyle(.boldSecondary)
|
||||
.textFieldStyle(.roundedBorder)
|
||||
.applyFormStyle()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -126,6 +126,7 @@ public struct PressureEstimationsView: View {
|
||||
EquipmentMeasurementFormView(store: measurementStore)
|
||||
.navigationTitle("Existing Measurements")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
15
Sources/Styleguide/Styles/FormStyle.swift
Normal file
15
Sources/Styleguide/Styles/FormStyle.swift
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user