From 5f6bc12c8081f811f71736b66e415328dcb15810 Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Wed, 5 Jun 2024 22:27:43 -0400 Subject: [PATCH] wip --- .../EquipmentMeasurementForm.swift | 3 +- .../EquipmentSettingsForm.swift | 34 +++++++----- Sources/Styleguide/TextLabel.swift | 5 ++ Sources/Styleguide/TextLabeledContent.swift | 54 +++++++++++++++++++ 4 files changed, 80 insertions(+), 16 deletions(-) create mode 100644 Sources/Styleguide/TextLabeledContent.swift diff --git a/Sources/PressureEstimationsFeature/EquipmentMeasurementForm.swift b/Sources/PressureEstimationsFeature/EquipmentMeasurementForm.swift index 4de6185..6d497e9 100644 --- a/Sources/PressureEstimationsFeature/EquipmentMeasurementForm.swift +++ b/Sources/PressureEstimationsFeature/EquipmentMeasurementForm.swift @@ -173,7 +173,7 @@ public struct EquipmentMeasurementForm { } } -fileprivate extension Store where State == EquipmentMeasurementForm.State { +extension Store where State == EquipmentMeasurementForm.State { func prompt( field: EquipmentMeasurementForm.State.Field @@ -271,7 +271,6 @@ public struct EquipmentMeasurementFormView: View { } } } - .navigationTitle("Existing Measurements") .textLabelStyle(.boldSecondary) .textFieldStyle(.roundedBorder) .sheet( diff --git a/Sources/PressureEstimationsFeature/EquipmentSettingsForm.swift b/Sources/PressureEstimationsFeature/EquipmentSettingsForm.swift index 3999ad6..306c117 100644 --- a/Sources/PressureEstimationsFeature/EquipmentSettingsForm.swift +++ b/Sources/PressureEstimationsFeature/EquipmentSettingsForm.swift @@ -127,29 +127,31 @@ public struct EquipmentSettingsFormView: View { public var body: some View { Form { Section { + EquipmentTypePicker(selection: $store.equipmentType) + .pickerStyle(.segmented) EmptyView() } header: { Text("Equipment Type") - } footer: { - EquipmentTypePicker(selection: $store.equipmentType) - .pickerStyle(.segmented) } + .listRowBackground(Color.clear) + Section { - EmptyView() + FanTypePicker(selection: $store.fanType) + .pickerStyle(.segmented) } header: { Text("Fan Type") - #if os(macOS) - .font(.title2) - #endif - } footer: { - FanTypePicker(selection: $store.fanType) - .pickerStyle(.segmented) } - + .listRowBackground(Color.clear) + Section { Grid(alignment: .leading, horizontalSpacing: 40) { GridRow { - TextLabel("Cooling") + TextLabel( + store.equipmentType == .furnaceAndCoil + ? "Cooling" + : "Capacity" + ) + Spacer() Picker("Cooling Capcity", selection: $store.coolingCapacity) { ForEach(CoolingCapacity.allCases) { Text($0.description) @@ -167,11 +169,16 @@ public struct EquipmentSettingsFormView: View { ) .focused($focusedField, equals: .heatingCapacity) .numberPad() + .gridCellColumns(2) } } } } header: { - header("Capacities", infoView: .capacities) + if store.equipmentType == .airHandler { + EmptyView() + } else { + Text("Capacities") + } } Section { @@ -282,7 +289,6 @@ public struct EquipmentSettingsFormView: View { } .labelsHidden() .bind($focusedField, to: $store.focusedField) - .navigationTitle("Equipment Data") .textLabelStyle(.boldSecondary) .textFieldStyle(.roundedBorder) .sheet( diff --git a/Sources/Styleguide/TextLabel.swift b/Sources/Styleguide/TextLabel.swift index b4c28dd..122bbd6 100644 --- a/Sources/Styleguide/TextLabel.swift +++ b/Sources/Styleguide/TextLabel.swift @@ -25,6 +25,11 @@ public struct TextLabel: View { } extension TextLabel where Content == Text { + + public init(_ text: LocalizedStringKey) { + self.init { Text(text) } + } + public init(_ text: S) where S: StringProtocol { self.init { Text(text) } } diff --git a/Sources/Styleguide/TextLabeledContent.swift b/Sources/Styleguide/TextLabeledContent.swift new file mode 100644 index 0000000..796392e --- /dev/null +++ b/Sources/Styleguide/TextLabeledContent.swift @@ -0,0 +1,54 @@ +import SwiftUI + +public struct TextLabeledContent: View { + + @Environment(\.textLabelStyle) var style + + let label: TextLabel