feat: wip
This commit is contained in:
@@ -10,7 +10,7 @@ import TCAExtras
|
|||||||
@Reducer
|
@Reducer
|
||||||
public struct CalculateAtFeature: Sendable {
|
public struct CalculateAtFeature: Sendable {
|
||||||
|
|
||||||
@Reducer(state: .equatable)
|
@Reducer(state: .equatable, .sendable)
|
||||||
public enum Destination {
|
public enum Destination {
|
||||||
case infoView(InfoViewFeature)
|
case infoView(InfoViewFeature)
|
||||||
}
|
}
|
||||||
@@ -39,16 +39,16 @@ public struct CalculateAtFeature: Sendable {
|
|||||||
&& values.targetValue != nil
|
&& 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]
|
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] }
|
get { values[keyPath: keyPath] }
|
||||||
set { values[keyPath: keyPath] = newValue }
|
set { values[keyPath: keyPath] = newValue }
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Focus: Hashable {
|
public enum Focus: Hashable, Sendable {
|
||||||
case existingAirflow
|
case existingAirflow
|
||||||
case existingPressure
|
case existingPressure
|
||||||
case targetValue
|
case targetValue
|
||||||
|
|||||||
@@ -42,10 +42,20 @@ public struct EquipmentSettingsForm {
|
|||||||
self.ratedStaticPressures = .init(staticPressures: sharedSettings.equipmentMetadata.ratedStaticPressures)
|
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 {
|
public var isValid: Bool {
|
||||||
guard equipmentType == .furnaceAndCoil
|
ratedStaticPressures.isValid
|
||||||
else { return ratedStaticPressures.isValid }
|
&& equipmentTypeValidation
|
||||||
return ratedStaticPressures.isValid && sharedSettings.heatingCapacity != nil
|
&& filterDropValidation
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: These need to be in display order.
|
// Note: These need to be in display order.
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public struct EstimationForm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Note: Keep in display order of the picker.
|
// 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 cfmPerTon
|
||||||
case cfm
|
case cfm
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import Styleguide
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
import TCAExtras
|
import TCAExtras
|
||||||
|
|
||||||
#warning("Fix shared settings.")
|
|
||||||
@Reducer
|
@Reducer
|
||||||
public struct PressureEstimationsFeature {
|
public struct PressureEstimationsFeature {
|
||||||
|
|
||||||
@@ -19,7 +18,7 @@ public struct PressureEstimationsFeature {
|
|||||||
@ObservableState
|
@ObservableState
|
||||||
public struct State: Equatable {
|
public struct State: Equatable {
|
||||||
@Presents public var destination: Destination.State?
|
@Presents public var destination: Destination.State?
|
||||||
@Shared(.sharedPressureEstimationSettings) var sharedSettings = SharedPressureEstimationState()
|
@Shared(.pressureEstimationState) var sharedSettings = SharedPressureEstimationState()
|
||||||
public var equipmentSettings: EquipmentSettingsForm.State
|
public var equipmentSettings: EquipmentSettingsForm.State
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
@@ -108,11 +107,9 @@ public struct PressureEstimationsView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public var body: some View {
|
public var body: some View {
|
||||||
// ScrollView {
|
|
||||||
EquipmentSettingsFormView(
|
EquipmentSettingsFormView(
|
||||||
store: store.scope(state: \.equipmentSettings, action: \.equipmentSettings)
|
store: store.scope(state: \.equipmentSettings, action: \.equipmentSettings)
|
||||||
)
|
)
|
||||||
// }
|
|
||||||
.navigationTitle("Equipment Settings")
|
.navigationTitle("Equipment Settings")
|
||||||
.toolbar {
|
.toolbar {
|
||||||
NextButton { send(.nextButtonTapped) }
|
NextButton { send(.nextButtonTapped) }
|
||||||
@@ -125,10 +122,8 @@ public struct PressureEstimationsView: View {
|
|||||||
action: \.destination.equipmentMeasurements
|
action: \.destination.equipmentMeasurements
|
||||||
)
|
)
|
||||||
) { measurementStore in
|
) { measurementStore in
|
||||||
// ScrollView {
|
|
||||||
EquipmentMeasurementFormView(store: measurementStore)
|
EquipmentMeasurementFormView(store: measurementStore)
|
||||||
.navigationTitle("Existing Measurements")
|
.navigationTitle("Existing Measurements")
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import SharedModels
|
|||||||
import Styleguide
|
import Styleguide
|
||||||
import SwiftUI
|
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.
|
/// Allows for rated static pressure fields to be optional values, setting their corresponding shared state values to zero when they're nilled out.
|
||||||
///
|
///
|
||||||
@Reducer
|
@Reducer
|
||||||
@@ -38,7 +37,8 @@ public struct RatedStaticPressuresSection {
|
|||||||
case minimum
|
case minimum
|
||||||
case rated
|
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",
|
"Maximum",
|
||||||
value: $store.maxPressure,
|
value: $store.maxPressure,
|
||||||
fractionLength: 2,
|
fractionLength: 2,
|
||||||
prompt: Text("Max Static Pressure")
|
prompt: prompt(for: .maximum)
|
||||||
)
|
)
|
||||||
.decimalPad()
|
.decimalPad()
|
||||||
.focused($focusedField, equals: .maximum)
|
.focused($focusedField, equals: .maximum)
|
||||||
@@ -106,7 +106,7 @@ public struct RatedStaticPressuresSectionView: View {
|
|||||||
"Minimum",
|
"Minimum",
|
||||||
value: $store.minPressure,
|
value: $store.minPressure,
|
||||||
fractionLength: 2,
|
fractionLength: 2,
|
||||||
prompt: Text("Min Static Pressure")
|
prompt: prompt(for: .minimum)
|
||||||
)
|
)
|
||||||
.decimalPad()
|
.decimalPad()
|
||||||
.focused($focusedField, equals: .minimum)
|
.focused($focusedField, equals: .minimum)
|
||||||
@@ -117,7 +117,7 @@ public struct RatedStaticPressuresSectionView: View {
|
|||||||
"Rated",
|
"Rated",
|
||||||
value: $store.ratedPressure,
|
value: $store.ratedPressure,
|
||||||
fractionLength: 2,
|
fractionLength: 2,
|
||||||
prompt: Text("Rated Static Pressure")
|
prompt: prompt(for: .rated)
|
||||||
)
|
)
|
||||||
.decimalPad()
|
.decimalPad()
|
||||||
.focused($focusedField, equals: .rated)
|
.focused($focusedField, equals: .rated)
|
||||||
@@ -138,4 +138,8 @@ public struct RatedStaticPressuresSectionView: View {
|
|||||||
private func label(for field: RatedStaticPressuresSection.State.FocusedField) -> some View {
|
private func label(for field: RatedStaticPressuresSection.State.FocusedField) -> some View {
|
||||||
TextLabel(field.label)
|
TextLabel(field.label)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func prompt(for field: RatedStaticPressuresSection.State.FocusedField) -> Text {
|
||||||
|
Text(field.prompt)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ public struct SharedPressureEstimationState: Equatable, Sendable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension PersistenceReaderKey where Self == InMemoryKey<SharedPressureEstimationState> {
|
extension PersistenceReaderKey where Self == InMemoryKey<SharedPressureEstimationState> {
|
||||||
static var sharedPressureEstimationSettings: Self {
|
static var pressureEstimationState: Self {
|
||||||
.inMemory("sharedPressureEstimationSettings")
|
.inMemory("sharedPressureEstimationState")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user