diff --git a/Examples/xx-messenger/.swiftpm/xcode/xcshareddata/xcschemes/ChatFeature.xcscheme b/Examples/xx-messenger/.swiftpm/xcode/xcshareddata/xcschemes/ChatFeature.xcscheme new file mode 100644 index 0000000000000000000000000000000000000000..36b050b6723be25e47fd61ca191fa2b0859600da --- /dev/null +++ b/Examples/xx-messenger/.swiftpm/xcode/xcshareddata/xcschemes/ChatFeature.xcscheme @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + LastUpgradeVersion = "1400" + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + <BuildActionEntries> + <BuildActionEntry + buildForTesting = "YES" + buildForRunning = "YES" + buildForProfiling = "YES" + buildForArchiving = "YES" + buildForAnalyzing = "YES"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "ChatFeature" + BuildableName = "ChatFeature" + BlueprintName = "ChatFeature" + ReferencedContainer = "container:"> + </BuildableReference> + </BuildActionEntry> + </BuildActionEntries> + </BuildAction> + <TestAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + shouldUseLaunchSchemeArgsEnv = "YES" + codeCoverageEnabled = "YES"> + <Testables> + <TestableReference + skipped = "NO"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "ChatFeatureTests" + BuildableName = "ChatFeatureTests" + BlueprintName = "ChatFeatureTests" + ReferencedContainer = "container:"> + </BuildableReference> + </TestableReference> + </Testables> + </TestAction> + <LaunchAction + buildConfiguration = "Debug" + selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" + selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + launchStyle = "0" + useCustomWorkingDirectory = "NO" + ignoresPersistentStateOnLaunch = "NO" + debugDocumentVersioning = "YES" + debugServiceExtension = "internal" + allowLocationSimulation = "YES"> + </LaunchAction> + <ProfileAction + buildConfiguration = "Release" + shouldUseLaunchSchemeArgsEnv = "YES" + savedToolIdentifier = "" + useCustomWorkingDirectory = "NO" + debugDocumentVersioning = "YES"> + <MacroExpansion> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "ChatFeature" + BuildableName = "ChatFeature" + BlueprintName = "ChatFeature" + ReferencedContainer = "container:"> + </BuildableReference> + </MacroExpansion> + </ProfileAction> + <AnalyzeAction + buildConfiguration = "Debug"> + </AnalyzeAction> + <ArchiveAction + buildConfiguration = "Release" + revealArchiveInOrganizer = "YES"> + </ArchiveAction> +</Scheme> diff --git a/Examples/xx-messenger/Package.swift b/Examples/xx-messenger/Package.swift index 8b52ce874bc2b789a2f9e74a33311738e4bdf7d4..30fbcb51088320e8e8cfd3264b8b40e476d1ce49 100644 --- a/Examples/xx-messenger/Package.swift +++ b/Examples/xx-messenger/Package.swift @@ -20,6 +20,7 @@ let package = Package( products: [ .library(name: "AppCore", targets: ["AppCore"]), .library(name: "AppFeature", targets: ["AppFeature"]), + .library(name: "ChatFeature", targets: ["ChatFeature"]), .library(name: "CheckContactAuthFeature", targets: ["CheckContactAuthFeature"]), .library(name: "ConfirmRequestFeature", targets: ["ConfirmRequestFeature"]), .library(name: "ContactFeature", targets: ["ContactFeature"]), @@ -101,6 +102,20 @@ let package = Package( ], swiftSettings: swiftSettings ), + .target( + name: "ChatFeature", + dependencies: [ + .product(name: "ComposableArchitecture", package: "swift-composable-architecture"), + ], + swiftSettings: swiftSettings + ), + .testTarget( + name: "ChatFeatureTests", + dependencies: [ + .target(name: "ChatFeature"), + ], + swiftSettings: swiftSettings + ), .target( name: "CheckContactAuthFeature", dependencies: [ diff --git a/Examples/xx-messenger/Project/XXMessenger.xcodeproj/xcshareddata/xcschemes/XXMessenger.xcscheme b/Examples/xx-messenger/Project/XXMessenger.xcodeproj/xcshareddata/xcschemes/XXMessenger.xcscheme index 0e5e54ad091bf310eb399f185b4c8680fed98e07..65400dff681f98714be5c8db74bc82b6558dfe17 100644 --- a/Examples/xx-messenger/Project/XXMessenger.xcodeproj/xcshareddata/xcschemes/XXMessenger.xcscheme +++ b/Examples/xx-messenger/Project/XXMessenger.xcodeproj/xcshareddata/xcschemes/XXMessenger.xcscheme @@ -49,6 +49,16 @@ ReferencedContainer = "container:.."> </BuildableReference> </TestableReference> + <TestableReference + skipped = "NO"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "ChatFeatureTests" + BuildableName = "ChatFeatureTests" + BlueprintName = "ChatFeatureTests" + ReferencedContainer = "container:.."> + </BuildableReference> + </TestableReference> <TestableReference skipped = "NO"> <BuildableReference diff --git a/Examples/xx-messenger/Sources/ChatFeature/ChatFeature.swift b/Examples/xx-messenger/Sources/ChatFeature/ChatFeature.swift new file mode 100644 index 0000000000000000000000000000000000000000..d95eabcec080e576112d7f51078b4d476c485d5e --- /dev/null +++ b/Examples/xx-messenger/Sources/ChatFeature/ChatFeature.swift @@ -0,0 +1,37 @@ +import ComposableArchitecture +import Foundation +import XCTestDynamicOverlay + +public struct ChatState: Equatable, Identifiable { + public enum ID: Equatable, Hashable { + case contact(Data) + } + + public init(id: ID) { + self.id = id + } + + public var id: ID +} + +public enum ChatAction: Equatable { + case start +} + +public struct ChatEnvironment { + public init() {} +} + +#if DEBUG +extension ChatEnvironment { + public static let unimplemented = ChatEnvironment() +} +#endif + +public let chatReducer = Reducer<ChatState, ChatAction, ChatEnvironment> +{ state, action, env in + switch action { + case .start: + return .none + } +} diff --git a/Examples/xx-messenger/Sources/ChatFeature/ChatView.swift b/Examples/xx-messenger/Sources/ChatFeature/ChatView.swift new file mode 100644 index 0000000000000000000000000000000000000000..d3016743d6a7d9ab1d8610455f48761acf21edb9 --- /dev/null +++ b/Examples/xx-messenger/Sources/ChatFeature/ChatView.swift @@ -0,0 +1,37 @@ +import ComposableArchitecture +import SwiftUI + +public struct ChatView: View { + public init(store: Store<ChatState, ChatAction>) { + self.store = store + } + + let store: Store<ChatState, ChatAction> + + struct ViewState: Equatable { + init(state: ChatState) {} + } + + public var body: some View { + WithViewStore(store, observe: ViewState.init) { viewStore in + Text("ChatView") + .task { viewStore.send(.start) } + } + } +} + +#if DEBUG +public struct ChatView_Previews: PreviewProvider { + public static var previews: some View { + NavigationView { + ChatView(store: Store( + initialState: ChatState( + id: .contact("contact-id".data(using: .utf8)!) + ), + reducer: .empty, + environment: () + )) + } + } +} +#endif diff --git a/Examples/xx-messenger/Tests/ChatFeatureTests/ChatFeatureTests.swift b/Examples/xx-messenger/Tests/ChatFeatureTests/ChatFeatureTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..0068e667cc3a3dc84a0605c8d13e7843ef874eb8 --- /dev/null +++ b/Examples/xx-messenger/Tests/ChatFeatureTests/ChatFeatureTests.swift @@ -0,0 +1,17 @@ +import ComposableArchitecture +import XCTest +@testable import ChatFeature + +final class ChatFeatureTests: XCTestCase { + func testStart() { + let contactId = "contact-id".data(using: .utf8)! + + let store = TestStore( + initialState: ChatState(id: .contact(contactId)), + reducer: chatReducer, + environment: .unimplemented + ) + + store.send(.start) + } +}