From c6c45ffa7e4245a7b059db2217eaf47b2cd837d6 Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Tue, 11 Jun 2024 13:06:25 -0400 Subject: [PATCH] feat: Moves info view feature to it's own module. --- Package.swift | 12 ++++++++- .../CalculateAtFeature/CalculateAtView.swift | 25 ++++++++++--------- .../InfoView.swift | 1 + .../EquipmentMeasurementForm.swift | 1 + .../EquipmentSettingsForm.swift | 1 + Sources/Styleguide/KeyboardStyles.swift | 4 +-- .../EstimatedPressureTests.swift | 2 ++ .../PercentageTests.swift | 5 +++- Tests/EstimatedPressureTests/Tags.swift | 6 +++++ 9 files changed, 40 insertions(+), 17 deletions(-) rename Sources/{Styleguide => InfoViewFeature}/InfoView.swift (98%) create mode 100644 Tests/EstimatedPressureTests/Tags.swift diff --git a/Package.swift b/Package.swift index c1e668c..c897afb 100644 --- a/Package.swift +++ b/Package.swift @@ -18,6 +18,7 @@ let package = Package( .library(name: "CalculateAtFeature", targets: ["CalculateAtFeature"]), .library(name: "EstimatedPressureDependency", targets: ["EstimatedPressureDependency"]), .library(name: "FlaggedViews", targets: ["FlaggedViews"]), + .library(name: "InfoViewFeature", targets: ["InfoViewFeature"]), .library(name: "PressureEstimationsFeature", targets: ["PressureEstimationsFeature"]), .library(name: "SharedModels", targets: ["SharedModels"]), .library(name: "Styleguide", targets: ["Styleguide"]), @@ -45,6 +46,7 @@ let package = Package( name: "CalculateAtFeature", dependencies: [ "EstimatedPressureDependency", + "InfoViewFeature", "SharedModels", "Styleguide", .product(name: "ComposableArchitecture", package: "swift-composable-architecture"), @@ -69,6 +71,14 @@ let package = Package( ], swiftSettings: settings ), + .target( + name: "InfoViewFeature", + dependencies: [ + "Styleguide", + .product(name: "ComposableArchitecture", package: "swift-composable-architecture"), + ], + swiftSettings: settings + ), .target( name: "SharedModels", swiftSettings: settings @@ -77,7 +87,6 @@ let package = Package( name: "Styleguide", dependencies: [ "SharedModels", - .product(name: "ComposableArchitecture", package: "swift-composable-architecture"), ], swiftSettings: settings ), @@ -93,6 +102,7 @@ let package = Package( dependencies: [ "EstimatedPressureDependency", "FlaggedViews", + "InfoViewFeature", "SharedModels", "Styleguide", .product(name: "ComposableArchitecture", package: "swift-composable-architecture"), diff --git a/Sources/CalculateAtFeature/CalculateAtView.swift b/Sources/CalculateAtFeature/CalculateAtView.swift index 1497c33..c847abd 100644 --- a/Sources/CalculateAtFeature/CalculateAtView.swift +++ b/Sources/CalculateAtFeature/CalculateAtView.swift @@ -1,14 +1,15 @@ import ComposableArchitecture import DependenciesAdditions import EstimatedPressureDependency +import InfoViewFeature import SharedModels import Styleguide import SwiftUI import TCAExtras @Reducer -public struct CalculateAtFeature { - +public struct CalculateAtFeature: Sendable { + @Reducer(state: .equatable) public enum Destination { case infoView(InfoViewFeature) @@ -16,7 +17,7 @@ public struct CalculateAtFeature { @ObservableState @dynamicMemberLookup - public struct State: Equatable { + public struct State: Equatable, Sendable { @Presents public var destination: Destination.State? public var focus: Focus? = nil public var values: ValueContainer @@ -53,7 +54,7 @@ public struct CalculateAtFeature { case targetValue } - public struct ValueContainer: Equatable { + public struct ValueContainer: Equatable, Sendable { public var existingAirflow: Double? public var existingPressure: Double? public var targetValue: Double? @@ -72,7 +73,7 @@ public struct CalculateAtFeature { } } - public enum CalculationType: Hashable, CaseIterable, Identifiable { + public enum CalculationType: Hashable, CaseIterable, Identifiable, Sendable { case airflowAtNewPressure case pressureAtNewAirflow @@ -145,7 +146,7 @@ public struct CalculateAtFeature { case view(View) @CasePathable - public enum ReceiveAction { + public enum ReceiveAction: Sendable { case calculatedValue(Positive?) } @@ -365,19 +366,19 @@ fileprivate extension InfoViewFeature.State { switch calculationType { case .airflowAtNewPressure: self.init( - title: """ - Calculate the airflow at the target pressure from the existing airflow and existing pressure. - """, + title: "Airflow at Pressure", body: """ + Calculate the airflow at the target pressure from the existing airflow and existing pressure. + This can be useful to determine the effect of a different blower speed on a specific measurement location (generally the supply or return plenum). """ ) case .pressureAtNewAirflow: self.init( - title: """ - Calculate the pressure at the target airflow from the existing airflow and existing pressure. - """, + title: "Pressure at Airflow", body: """ + Calculate the pressure at the target airflow from the existing airflow and existing pressure. + This can be useful to determine the effect of a different blower speed on a specific measurement location (generally the supply or return plenum). """ ) diff --git a/Sources/Styleguide/InfoView.swift b/Sources/InfoViewFeature/InfoView.swift similarity index 98% rename from Sources/Styleguide/InfoView.swift rename to Sources/InfoViewFeature/InfoView.swift index 8ddadc5..3f9adbf 100644 --- a/Sources/Styleguide/InfoView.swift +++ b/Sources/InfoViewFeature/InfoView.swift @@ -1,4 +1,5 @@ import ComposableArchitecture +import Styleguide import SwiftUI @Reducer diff --git a/Sources/PressureEstimationsFeature/EquipmentMeasurementForm.swift b/Sources/PressureEstimationsFeature/EquipmentMeasurementForm.swift index 2aca088..45ff928 100644 --- a/Sources/PressureEstimationsFeature/EquipmentMeasurementForm.swift +++ b/Sources/PressureEstimationsFeature/EquipmentMeasurementForm.swift @@ -1,5 +1,6 @@ import ComposableArchitecture import DependenciesAdditions +import InfoViewFeature import SharedModels import Styleguide import SwiftUI diff --git a/Sources/PressureEstimationsFeature/EquipmentSettingsForm.swift b/Sources/PressureEstimationsFeature/EquipmentSettingsForm.swift index 8e78e01..b1aa1f0 100644 --- a/Sources/PressureEstimationsFeature/EquipmentSettingsForm.swift +++ b/Sources/PressureEstimationsFeature/EquipmentSettingsForm.swift @@ -1,5 +1,6 @@ import ComposableArchitecture import FlaggedViews +import InfoViewFeature import SharedModels import Styleguide import SwiftUI diff --git a/Sources/Styleguide/KeyboardStyles.swift b/Sources/Styleguide/KeyboardStyles.swift index c3d3e7f..e76db80 100644 --- a/Sources/Styleguide/KeyboardStyles.swift +++ b/Sources/Styleguide/KeyboardStyles.swift @@ -10,13 +10,11 @@ extension View { #endif } - #warning("Fix me.") // The decimal pad autocompletes too quickly in the simulator, needs tested on an actual // device. public func decimalPad() -> some View { #if os(iOS) -// self.keyboardType(.decimalPad) - self.keyboardType(.numberPad) + self.keyboardType(.decimalPad) #else self #endif diff --git a/Tests/EstimatedPressureTests/EstimatedPressureTests.swift b/Tests/EstimatedPressureTests/EstimatedPressureTests.swift index c7447d3..5f7b173 100644 --- a/Tests/EstimatedPressureTests/EstimatedPressureTests.swift +++ b/Tests/EstimatedPressureTests/EstimatedPressureTests.swift @@ -71,6 +71,7 @@ final class PositiveNumericTests: XCTestCase { @Test( "Values are positive only", + .tags(.sharedModel), arguments: [ 0.1, -0.1 @@ -83,6 +84,7 @@ final class PositiveNumericTests: XCTestCase { @Test( "PlenumDimension area calculation", + .tags(.sharedModel), arguments: [ (PlenumDimension.rectangular(width: 24, height: 12), 2), (PlenumDimension.round(16), 1.4) diff --git a/Tests/EstimatedPressureTests/PercentageTests.swift b/Tests/EstimatedPressureTests/PercentageTests.swift index 838ea0a..0d1b98f 100644 --- a/Tests/EstimatedPressureTests/PercentageTests.swift +++ b/Tests/EstimatedPressureTests/PercentageTests.swift @@ -2,6 +2,7 @@ import SharedModels import Testing import XCTest +@Suite(.tags(.sharedModel, .percentage)) struct PercentagePostfixOperatorTests { static let arguments: [(Percentage, Double)] = [ (50%, 50), @@ -15,6 +16,7 @@ struct PercentagePostfixOperatorTests { } } +@Suite(.tags(.sharedModel, .percentage)) struct PercentageInitializationTests { @Test("Percentage expressible tests") @@ -34,6 +36,7 @@ struct PercentageInitializationTests { } } +@Suite(.tags(.sharedModel, .percentage)) struct PercentageMathTests { let first = 2% @@ -66,7 +69,7 @@ struct PercentageMathTests { } } -@Test("Percentage custom string convertible") +@Test("Percentage custom string convertible", .tags(.sharedModel, .percentage)) func percentageString() { #expect(50%.description == "50%") } diff --git a/Tests/EstimatedPressureTests/Tags.swift b/Tests/EstimatedPressureTests/Tags.swift new file mode 100644 index 0000000..e55d6a3 --- /dev/null +++ b/Tests/EstimatedPressureTests/Tags.swift @@ -0,0 +1,6 @@ +import Testing + +extension Tag { + @Tag static var sharedModel: Self + @Tag static var percentage: Self +}