feat: wip

This commit is contained in:
2024-06-17 11:46:42 -04:00
parent cf4c00d9d5
commit fd3d33878a
7 changed files with 35 additions and 26 deletions

View File

@@ -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<T>(dynamicMember keyPath: KeyPath<CalculationType, T>) -> T {
public subscript<T: Sendable>(dynamicMember keyPath: KeyPath<CalculationType, T>) -> T {
calculationType[keyPath: keyPath]
}
public subscript<T>(dynamicMember keyPath: WritableKeyPath<ValueContainer, T>) -> T {
public subscript<T: Sendable>(dynamicMember keyPath: WritableKeyPath<ValueContainer, T>) -> 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

View File

@@ -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.

View File

@@ -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

View File

@@ -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)
)
// }
.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")
// }
}
}
}

View File

@@ -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)
}
}

View File

@@ -124,7 +124,7 @@ public struct SharedPressureEstimationState: Equatable, Sendable {
}
extension PersistenceReaderKey where Self == InMemoryKey<SharedPressureEstimationState> {
static var sharedPressureEstimationSettings: Self {
.inMemory("sharedPressureEstimationSettings")
static var pressureEstimationState: Self {
.inMemory("sharedPressureEstimationState")
}
}