feat: Adds form style to styleguide.

This commit is contained in:
2024-06-14 11:12:10 -04:00
parent eb0253077b
commit 50e80d39eb
6 changed files with 24 additions and 23 deletions

View File

@@ -321,11 +321,10 @@ public struct EquipmentMeasurementFormView: View {
} }
} }
} }
.applyFormStyle()
.bind($focusedField, to: $store.focusedField) .bind($focusedField, to: $store.focusedField)
.labeledContentStyle(.gridRow) .labeledContentStyle(.gridRow)
.onAppear { send(.onAppear) } .onAppear { send(.onAppear) }
.textLabelStyle(.boldSecondary)
.textFieldStyle(.roundedBorder)
.toolbar { .toolbar {
NextButton { send(.nextButtonTapped) } NextButton { send(.nextButtonTapped) }
.nextButtonStyle(.toolbar) .nextButtonStyle(.toolbar)

View File

@@ -222,10 +222,8 @@ public struct EquipmentSettingsFormView: View {
} }
} }
} }
.labelsHidden() .applyFormStyle()
.bind($focusedField, to: $store.focusedField) .bind($focusedField, to: $store.focusedField)
.textLabelStyle(.boldSecondary)
.textFieldStyle(.roundedBorder)
.sheet( .sheet(
item: $store.scope( item: $store.scope(
state: \.destination?.infoView, state: \.destination?.infoView,

View File

@@ -173,9 +173,7 @@ public struct EstimationFormView: View {
} }
} }
} }
.labelsHidden() .applyFormStyle()
.textLabelStyle(.boldSecondary)
.textFieldStyle(.roundedBorder)
} }
} }

View File

@@ -182,16 +182,6 @@ public struct FlaggedMeasurementsList: Sendable {
print("No changes found, not generating a new flagged estimation measurement.") print("No changes found, not generating a new flagged estimation measurement.")
return .none 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 return .receive(action: \.receive) { [sharedSettings = state.sharedSettings] in

View File

@@ -126,6 +126,7 @@ public struct PressureEstimationsView: View {
EquipmentMeasurementFormView(store: measurementStore) EquipmentMeasurementFormView(store: measurementStore)
.navigationTitle("Existing Measurements") .navigationTitle("Existing Measurements")
} }
} }
} }

View 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
}
}