Skip to content
Snippets Groups Projects
Commit 53cc601b authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Add ChatFeature library

parent e15e21dd
No related branches found
No related tags found
2 merge requests!102Release 1.0.0,!87Messenger example - chat
<?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>
...@@ -20,6 +20,7 @@ let package = Package( ...@@ -20,6 +20,7 @@ let package = Package(
products: [ products: [
.library(name: "AppCore", targets: ["AppCore"]), .library(name: "AppCore", targets: ["AppCore"]),
.library(name: "AppFeature", targets: ["AppFeature"]), .library(name: "AppFeature", targets: ["AppFeature"]),
.library(name: "ChatFeature", targets: ["ChatFeature"]),
.library(name: "CheckContactAuthFeature", targets: ["CheckContactAuthFeature"]), .library(name: "CheckContactAuthFeature", targets: ["CheckContactAuthFeature"]),
.library(name: "ConfirmRequestFeature", targets: ["ConfirmRequestFeature"]), .library(name: "ConfirmRequestFeature", targets: ["ConfirmRequestFeature"]),
.library(name: "ContactFeature", targets: ["ContactFeature"]), .library(name: "ContactFeature", targets: ["ContactFeature"]),
...@@ -101,6 +102,20 @@ let package = Package( ...@@ -101,6 +102,20 @@ let package = Package(
], ],
swiftSettings: swiftSettings 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( .target(
name: "CheckContactAuthFeature", name: "CheckContactAuthFeature",
dependencies: [ dependencies: [
......
...@@ -49,6 +49,16 @@ ...@@ -49,6 +49,16 @@
ReferencedContainer = "container:.."> ReferencedContainer = "container:..">
</BuildableReference> </BuildableReference>
</TestableReference> </TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ChatFeatureTests"
BuildableName = "ChatFeatureTests"
BlueprintName = "ChatFeatureTests"
ReferencedContainer = "container:..">
</BuildableReference>
</TestableReference>
<TestableReference <TestableReference
skipped = "NO"> skipped = "NO">
<BuildableReference <BuildableReference
......
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
}
}
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
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)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment