feat: Adds form style to styleguide.
This commit is contained in:
@@ -293,7 +293,7 @@ public struct EquipmentMeasurementFormView: View {
|
|||||||
}
|
}
|
||||||
Section {
|
Section {
|
||||||
Grid(alignment: .leading, horizontalSpacing: 40) {
|
Grid(alignment: .leading, horizontalSpacing: 40) {
|
||||||
ForEach(store.pressureFields, content: gridRow(for:))
|
ForEach(store.pressureFields, content: gridRow(for:))
|
||||||
}
|
}
|
||||||
} header: {
|
} header: {
|
||||||
HStack {
|
HStack {
|
||||||
@@ -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)
|
||||||
@@ -347,13 +346,13 @@ public struct EquipmentMeasurementFormView: View {
|
|||||||
FlaggedMeasurementListView(store: store)
|
FlaggedMeasurementListView(store: store)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func gridRow(for field: EquipmentMeasurementForm.State.Field) -> some View {
|
private func gridRow(for field: EquipmentMeasurementForm.State.Field) -> some View {
|
||||||
TextLabeledContent(store.label(field: field)) {
|
TextLabeledContent(store.label(field: field)) {
|
||||||
textField(for: field)
|
textField(for: field)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func textField(
|
private func textField(
|
||||||
for field: EquipmentMeasurementForm.State.Field
|
for field: EquipmentMeasurementForm.State.Field
|
||||||
) -> some View {
|
) -> some View {
|
||||||
@@ -413,7 +412,7 @@ public struct EquipmentMeasurementFormView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fileprivate extension InfoViewFeature.State {
|
fileprivate extension InfoViewFeature.State {
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
self.init(
|
self.init(
|
||||||
title: "Existing Measurements",
|
title: "Existing Measurements",
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -173,9 +173,7 @@ public struct EstimationFormView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.labelsHidden()
|
.applyFormStyle()
|
||||||
.textLabelStyle(.boldSecondary)
|
|
||||||
.textFieldStyle(.roundedBorder)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -182,17 +182,7 @@ 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
|
||||||
|
|
||||||
let flaggedMeasurement = try await flaggedMeasurement(
|
let flaggedMeasurement = try await flaggedMeasurement(
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ public struct PressureEstimationsView: View {
|
|||||||
EquipmentMeasurementFormView(store: measurementStore)
|
EquipmentMeasurementFormView(store: measurementStore)
|
||||||
.navigationTitle("Existing Measurements")
|
.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