feat: Moves info view feature to it's own module.

This commit is contained in:
2024-06-11 13:06:25 -04:00
parent 75f009ed8f
commit c6c45ffa7e
9 changed files with 40 additions and 17 deletions

View File

@@ -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"),

View File

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

View File

@@ -1,4 +1,5 @@
import ComposableArchitecture
import Styleguide
import SwiftUI
@Reducer

View File

@@ -1,5 +1,6 @@
import ComposableArchitecture
import DependenciesAdditions
import InfoViewFeature
import SharedModels
import Styleguide
import SwiftUI

View File

@@ -1,5 +1,6 @@
import ComposableArchitecture
import FlaggedViews
import InfoViewFeature
import SharedModels
import Styleguide
import SwiftUI

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,6 @@
import Testing
extension Tag {
@Tag static var sharedModel: Self
@Tag static var percentage: Self
}