diff --git a/Sources/CalculateAtFeature/CalculateAtView.swift b/Sources/CalculateAtFeature/CalculateAtView.swift index c847abd..fb57630 100644 --- a/Sources/CalculateAtFeature/CalculateAtView.swift +++ b/Sources/CalculateAtFeature/CalculateAtView.swift @@ -10,7 +10,7 @@ import TCAExtras @Reducer public struct CalculateAtFeature: Sendable { - @Reducer(state: .equatable) + @Reducer(state: .equatable, .sendable) public enum Destination { case infoView(InfoViewFeature) } @@ -39,16 +39,16 @@ public struct CalculateAtFeature: Sendable { && values.targetValue != nil } - public subscript(dynamicMember keyPath: KeyPath) -> T { + public subscript(dynamicMember keyPath: KeyPath) -> T { calculationType[keyPath: keyPath] } - public subscript(dynamicMember keyPath: WritableKeyPath) -> T { + public subscript(dynamicMember keyPath: WritableKeyPath) -> T { get { values[keyPath: keyPath] } set { values[keyPath: keyPath] = newValue } } - public enum Focus: Hashable { + public enum Focus: Hashable, Sendable { case existingAirflow case existingPressure case targetValue diff --git a/Sources/PressureEstimationsFeature/EquipmentSettingsForm.swift b/Sources/PressureEstimationsFeature/EquipmentSettingsForm.swift index 9cb04d0..cc988d7 100644 --- a/Sources/PressureEstimationsFeature/EquipmentSettingsForm.swift +++ b/Sources/PressureEstimationsFeature/EquipmentSettingsForm.swift @@ -42,10 +42,20 @@ public struct EquipmentSettingsForm { self.ratedStaticPressures = .init(staticPressures: sharedSettings.equipmentMetadata.ratedStaticPressures) } + private var equipmentTypeValidation: Bool { + guard equipmentType == .furnaceAndCoil else { return true } + return sharedSettings.heatingCapacity != nil + } + + private var filterDropValidation: Bool { + guard includesFilterDrop else { return true } + return sharedSettings.manufacturersIncludedFilterPressureDrop != nil + } + public var isValid: Bool { - guard equipmentType == .furnaceAndCoil - else { return ratedStaticPressures.isValid } - return ratedStaticPressures.isValid && sharedSettings.heatingCapacity != nil + ratedStaticPressures.isValid + && equipmentTypeValidation + && filterDropValidation } // Note: These need to be in display order. diff --git a/Sources/PressureEstimationsFeature/EstimationsForm.swift b/Sources/PressureEstimationsFeature/EstimationsForm.swift index 6cc791e..a213a03 100644 --- a/Sources/PressureEstimationsFeature/EstimationsForm.swift +++ b/Sources/PressureEstimationsFeature/EstimationsForm.swift @@ -52,7 +52,7 @@ public struct EstimationForm { } // Note: Keep in display order of the picker. - public enum AirflowSelection: Hashable, CaseIterable, Identifiable, CustomStringConvertible { + public enum AirflowSelection: Hashable, CaseIterable, Identifiable, CustomStringConvertible, Sendable { case cfmPerTon case cfm diff --git a/Sources/PressureEstimationsFeature/PressureEstimations.swift b/Sources/PressureEstimationsFeature/PressureEstimations.swift index 8bef696..847053e 100644 --- a/Sources/PressureEstimationsFeature/PressureEstimations.swift +++ b/Sources/PressureEstimationsFeature/PressureEstimations.swift @@ -5,7 +5,6 @@ import Styleguide import SwiftUI import TCAExtras -#warning("Fix shared settings.") @Reducer public struct PressureEstimationsFeature { @@ -19,7 +18,7 @@ public struct PressureEstimationsFeature { @ObservableState public struct State: Equatable { @Presents public var destination: Destination.State? - @Shared(.sharedPressureEstimationSettings) var sharedSettings = SharedPressureEstimationState() + @Shared(.pressureEstimationState) var sharedSettings = SharedPressureEstimationState() public var equipmentSettings: EquipmentSettingsForm.State public init( @@ -108,11 +107,9 @@ public struct PressureEstimationsView: View { } public var body: some View { -// ScrollView { - EquipmentSettingsFormView( - store: store.scope(state: \.equipmentSettings, action: \.equipmentSettings) - ) -// } + EquipmentSettingsFormView( + store: store.scope(state: \.equipmentSettings, action: \.equipmentSettings) + ) .navigationTitle("Equipment Settings") .toolbar { NextButton { send(.nextButtonTapped) } @@ -125,10 +122,8 @@ public struct PressureEstimationsView: View { action: \.destination.equipmentMeasurements ) ) { measurementStore in -// ScrollView { - EquipmentMeasurementFormView(store: measurementStore) - .navigationTitle("Existing Measurements") -// } + EquipmentMeasurementFormView(store: measurementStore) + .navigationTitle("Existing Measurements") } } } diff --git a/Sources/PressureEstimationsFeature/RatedStaticPressuresSection.swift b/Sources/PressureEstimationsFeature/RatedStaticPressuresSection.swift index 05ee997..d16cd36 100644 --- a/Sources/PressureEstimationsFeature/RatedStaticPressuresSection.swift +++ b/Sources/PressureEstimationsFeature/RatedStaticPressuresSection.swift @@ -3,7 +3,6 @@ import SharedModels import Styleguide import SwiftUI -#warning("Add info view destination??") /// Allows for rated static pressure fields to be optional values, setting their corresponding shared state values to zero when they're nilled out. /// @Reducer @@ -38,7 +37,8 @@ public struct RatedStaticPressuresSection { case minimum case rated - var label: String { rawValue.capitalized } + public var label: String { rawValue.capitalized } + public var prompt: String { "\(label) Pressure"} } } @@ -95,7 +95,7 @@ public struct RatedStaticPressuresSectionView: View { "Maximum", value: $store.maxPressure, fractionLength: 2, - prompt: Text("Max Static Pressure") + prompt: prompt(for: .maximum) ) .decimalPad() .focused($focusedField, equals: .maximum) @@ -106,7 +106,7 @@ public struct RatedStaticPressuresSectionView: View { "Minimum", value: $store.minPressure, fractionLength: 2, - prompt: Text("Min Static Pressure") + prompt: prompt(for: .minimum) ) .decimalPad() .focused($focusedField, equals: .minimum) @@ -117,7 +117,7 @@ public struct RatedStaticPressuresSectionView: View { "Rated", value: $store.ratedPressure, fractionLength: 2, - prompt: Text("Rated Static Pressure") + prompt: prompt(for: .rated) ) .decimalPad() .focused($focusedField, equals: .rated) @@ -138,4 +138,8 @@ public struct RatedStaticPressuresSectionView: View { private func label(for field: RatedStaticPressuresSection.State.FocusedField) -> some View { TextLabel(field.label) } + + private func prompt(for field: RatedStaticPressuresSection.State.FocusedField) -> Text { + Text(field.prompt) + } } diff --git a/Sources/PressureEstimationsFeature/SharedPressureEstimationState.swift b/Sources/PressureEstimationsFeature/SharedPressureEstimationState.swift index 3c5c02b..db86802 100644 --- a/Sources/PressureEstimationsFeature/SharedPressureEstimationState.swift +++ b/Sources/PressureEstimationsFeature/SharedPressureEstimationState.swift @@ -124,7 +124,7 @@ public struct SharedPressureEstimationState: Equatable, Sendable { } extension PersistenceReaderKey where Self == InMemoryKey { - static var sharedPressureEstimationSettings: Self { - .inMemory("sharedPressureEstimationSettings") + static var pressureEstimationState: Self { + .inMemory("sharedPressureEstimationState") } } diff --git a/Sources/Styleguide/KeyboardStyles.swift b/Sources/Styleguide/Modifiers/KeyboardStyles.swift similarity index 100% rename from Sources/Styleguide/KeyboardStyles.swift rename to Sources/Styleguide/Modifiers/KeyboardStyles.swift