From 2708f07f4ee6aac961257f3ce1e48b8abc0d0b8e Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Thu, 8 Sep 2022 13:00:35 +0200 Subject: [PATCH] Add ContactsFeature library --- .../xcschemes/ContactsFeature.xcscheme | 78 +++++++++++++++++++ Examples/xx-messenger/Package.swift | 18 +++++ .../xcschemes/XXMessenger.xcscheme | 10 +++ .../ContactsFeature/ContactsFeature.swift | 28 +++++++ .../ContactsFeature/ContactsView.swift | 38 +++++++++ .../ContactsFeatureTests.swift | 15 ++++ 6 files changed, 187 insertions(+) create mode 100644 Examples/xx-messenger/.swiftpm/xcode/xcshareddata/xcschemes/ContactsFeature.xcscheme create mode 100644 Examples/xx-messenger/Sources/ContactsFeature/ContactsFeature.swift create mode 100644 Examples/xx-messenger/Sources/ContactsFeature/ContactsView.swift create mode 100644 Examples/xx-messenger/Tests/ContactsFeatureTests/ContactsFeatureTests.swift diff --git a/Examples/xx-messenger/.swiftpm/xcode/xcshareddata/xcschemes/ContactsFeature.xcscheme b/Examples/xx-messenger/.swiftpm/xcode/xcshareddata/xcschemes/ContactsFeature.xcscheme new file mode 100644 index 00000000..feb1a490 --- /dev/null +++ b/Examples/xx-messenger/.swiftpm/xcode/xcshareddata/xcschemes/ContactsFeature.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 = "ContactsFeature" + BuildableName = "ContactsFeature" + BlueprintName = "ContactsFeature" + 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 = "ContactsFeatureTests" + BuildableName = "ContactsFeatureTests" + BlueprintName = "ContactsFeatureTests" + 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 = "ContactsFeature" + BuildableName = "ContactsFeature" + BlueprintName = "ContactsFeature" + 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 77b97a0f..54f5035c 100644 --- a/Examples/xx-messenger/Package.swift +++ b/Examples/xx-messenger/Package.swift @@ -21,6 +21,7 @@ let package = Package( .library(name: "AppCore", targets: ["AppCore"]), .library(name: "AppFeature", targets: ["AppFeature"]), .library(name: "ContactFeature", targets: ["ContactFeature"]), + .library(name: "ContactsFeature", targets: ["ContactsFeature"]), .library(name: "HomeFeature", targets: ["HomeFeature"]), .library(name: "RegisterFeature", targets: ["RegisterFeature"]), .library(name: "RestoreFeature", targets: ["RestoreFeature"]), @@ -111,6 +112,23 @@ let package = Package( ], swiftSettings: swiftSettings ), + .target( + name: "ContactsFeature", + dependencies: [ + .target(name: "AppCore"), + .product(name: "ComposableArchitecture", package: "swift-composable-architecture"), + .product(name: "ComposablePresentation", package: "swift-composable-presentation"), + .product(name: "XXModels", package: "client-ios-db"), + ], + swiftSettings: swiftSettings + ), + .testTarget( + name: "ContactsFeatureTests", + dependencies: [ + .target(name: "ContactsFeature"), + ], + swiftSettings: swiftSettings + ), .target( name: "HomeFeature", 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 0d7cb106..9d31f6f7 100644 --- a/Examples/xx-messenger/Project/XXMessenger.xcodeproj/xcshareddata/xcschemes/XXMessenger.xcscheme +++ b/Examples/xx-messenger/Project/XXMessenger.xcodeproj/xcshareddata/xcschemes/XXMessenger.xcscheme @@ -59,6 +59,16 @@ ReferencedContainer = "container:.."> </BuildableReference> </TestableReference> + <TestableReference + skipped = "NO"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "ContactsFeatureTests" + BuildableName = "ContactsFeatureTests" + BlueprintName = "ContactsFeatureTests" + ReferencedContainer = "container:.."> + </BuildableReference> + </TestableReference> <TestableReference skipped = "NO"> <BuildableReference diff --git a/Examples/xx-messenger/Sources/ContactsFeature/ContactsFeature.swift b/Examples/xx-messenger/Sources/ContactsFeature/ContactsFeature.swift new file mode 100644 index 00000000..e7f98fe7 --- /dev/null +++ b/Examples/xx-messenger/Sources/ContactsFeature/ContactsFeature.swift @@ -0,0 +1,28 @@ +import ComposableArchitecture +import XCTestDynamicOverlay + +public struct ContactsState: Equatable { + public init() {} +} + +public enum ContactsAction: Equatable { + case start +} + +public struct ContactsEnvironment { + public init() {} +} + +#if DEBUG +extension ContactsEnvironment { + public static let unimplemented = ContactsEnvironment() +} +#endif + +public let contactsReducer = Reducer<ContactsState, ContactsAction, ContactsEnvironment> +{ state, action, env in + switch action { + case .start: + return .none + } +} diff --git a/Examples/xx-messenger/Sources/ContactsFeature/ContactsView.swift b/Examples/xx-messenger/Sources/ContactsFeature/ContactsView.swift new file mode 100644 index 00000000..870889f2 --- /dev/null +++ b/Examples/xx-messenger/Sources/ContactsFeature/ContactsView.swift @@ -0,0 +1,38 @@ +import ComposableArchitecture +import SwiftUI + +public struct ContactsView: View { + public init(store: Store<ContactsState, ContactsAction>) { + self.store = store + } + + let store: Store<ContactsState, ContactsAction> + + struct ViewState: Equatable { + init(state: ContactsState) {} + } + + public var body: some View { + WithViewStore(store.scope(state: ViewState.init)) { viewStore in + Form { + + } + .navigationTitle("Contacts") + .task { viewStore.send(.start) } + } + } +} + +#if DEBUG +public struct ContactsView_Previews: PreviewProvider { + public static var previews: some View { + NavigationView { + ContactsView(store: Store( + initialState: ContactsState(), + reducer: .empty, + environment: () + )) + } + } +} +#endif diff --git a/Examples/xx-messenger/Tests/ContactsFeatureTests/ContactsFeatureTests.swift b/Examples/xx-messenger/Tests/ContactsFeatureTests/ContactsFeatureTests.swift new file mode 100644 index 00000000..3b521768 --- /dev/null +++ b/Examples/xx-messenger/Tests/ContactsFeatureTests/ContactsFeatureTests.swift @@ -0,0 +1,15 @@ +import ComposableArchitecture +import XCTest +@testable import ContactsFeature + +final class ContactsFeatureTests: XCTestCase { + func testStart() { + let store = TestStore( + initialState: ContactsState(), + reducer: contactsReducer, + environment: .unimplemented + ) + + store.send(.start) + } +} -- GitLab