From 20f14b6af264204b75fab1254bef710920a85b82 Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Wed, 7 Sep 2022 10:57:56 +0200 Subject: [PATCH] Add ContactFeature library --- .../xcschemes/ContactFeature.xcscheme | 78 +++++++++++++++++++ Examples/xx-messenger/Package.swift | 18 +++++ .../xcschemes/XXMessenger.xcscheme | 10 +++ .../ContactFeature/ContactFeature.swift | 28 +++++++ .../Sources/ContactFeature/ContactView.swift | 35 +++++++++ .../ContactFeatureTests.swift | 15 ++++ 6 files changed, 184 insertions(+) create mode 100644 Examples/xx-messenger/.swiftpm/xcode/xcshareddata/xcschemes/ContactFeature.xcscheme create mode 100644 Examples/xx-messenger/Sources/ContactFeature/ContactFeature.swift create mode 100644 Examples/xx-messenger/Sources/ContactFeature/ContactView.swift create mode 100644 Examples/xx-messenger/Tests/ContactFeatureTests/ContactFeatureTests.swift diff --git a/Examples/xx-messenger/.swiftpm/xcode/xcshareddata/xcschemes/ContactFeature.xcscheme b/Examples/xx-messenger/.swiftpm/xcode/xcshareddata/xcschemes/ContactFeature.xcscheme new file mode 100644 index 00000000..f4e87fe1 --- /dev/null +++ b/Examples/xx-messenger/.swiftpm/xcode/xcshareddata/xcschemes/ContactFeature.xcscheme @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8"?> +<Scheme + LastUpgradeVersion = "1340" + version = "1.3"> + <BuildAction + parallelizeBuildables = "YES" + buildImplicitDependencies = "YES"> + <BuildActionEntries> + <BuildActionEntry + buildForTesting = "YES" + buildForRunning = "YES" + buildForProfiling = "YES" + buildForArchiving = "YES" + buildForAnalyzing = "YES"> + <BuildableReference + BuildableIdentifier = "primary" + BlueprintIdentifier = "ContactFeature" + BuildableName = "ContactFeature" + BlueprintName = "ContactFeature" + 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 = "ContactFeatureTests" + BuildableName = "ContactFeatureTests" + BlueprintName = "ContactFeatureTests" + 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 = "ContactFeature" + BuildableName = "ContactFeature" + BlueprintName = "ContactFeature" + 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 8070952e..5ce26cb9 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: "ContactFeature", targets: ["ContactFeature"]), .library(name: "HomeFeature", targets: ["HomeFeature"]), .library(name: "RegisterFeature", targets: ["RegisterFeature"]), .library(name: "RestoreFeature", targets: ["RestoreFeature"]), @@ -87,6 +88,23 @@ let package = Package( ], swiftSettings: swiftSettings ), + .target( + name: "ContactFeature", + dependencies: [ + .target(name: "AppCore"), + .product(name: "ComposableArchitecture", package: "swift-composable-architecture"), + .product(name: "XXMessengerClient", package: "elixxir-dapps-sdk-swift"), + .product(name: "XXModels", package: "client-ios-db"), + ], + swiftSettings: swiftSettings + ), + .testTarget( + name: "ContactFeatureTests", + dependencies: [ + .target(name: "ContactFeature"), + ], + 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 041cf3f7..0bf8b441 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 = "ContactFeatureTests" + BuildableName = "ContactFeatureTests" + BlueprintName = "ContactFeatureTests" + ReferencedContainer = "container:.."> + </BuildableReference> + </TestableReference> <TestableReference skipped = "NO"> <BuildableReference diff --git a/Examples/xx-messenger/Sources/ContactFeature/ContactFeature.swift b/Examples/xx-messenger/Sources/ContactFeature/ContactFeature.swift new file mode 100644 index 00000000..98344db8 --- /dev/null +++ b/Examples/xx-messenger/Sources/ContactFeature/ContactFeature.swift @@ -0,0 +1,28 @@ +import ComposableArchitecture +import XCTestDynamicOverlay + +public struct ContactState: Equatable { + public init() {} +} + +public enum ContactAction: Equatable { + case start +} + +public struct ContactEnvironment { + public init() {} +} + +#if DEBUG +extension ContactEnvironment { + public static let unimplemented = ContactEnvironment() +} +#endif + +public let contactReducer = Reducer<ContactState, ContactAction, ContactEnvironment> +{ state, action, env in + switch action { + case .start: + return .none + } +} diff --git a/Examples/xx-messenger/Sources/ContactFeature/ContactView.swift b/Examples/xx-messenger/Sources/ContactFeature/ContactView.swift new file mode 100644 index 00000000..2b403a21 --- /dev/null +++ b/Examples/xx-messenger/Sources/ContactFeature/ContactView.swift @@ -0,0 +1,35 @@ +import ComposableArchitecture +import SwiftUI + +public struct ContactView: View { + public init(store: Store<ContactState, ContactAction>) { + self.store = store + } + + let store: Store<ContactState, ContactAction> + + struct ViewState: Equatable { + init(state: ContactState) {} + } + + public var body: some View { + WithViewStore(store.scope(state: ViewState.init)) { viewStore in + Form { + + } + .navigationTitle("Contact") + } + } +} + +#if DEBUG +public struct ContactView_Previews: PreviewProvider { + public static var previews: some View { + ContactView(store: Store( + initialState: ContactState(), + reducer: .empty, + environment: () + )) + } +} +#endif diff --git a/Examples/xx-messenger/Tests/ContactFeatureTests/ContactFeatureTests.swift b/Examples/xx-messenger/Tests/ContactFeatureTests/ContactFeatureTests.swift new file mode 100644 index 00000000..e22cd95b --- /dev/null +++ b/Examples/xx-messenger/Tests/ContactFeatureTests/ContactFeatureTests.swift @@ -0,0 +1,15 @@ +import ComposableArchitecture +import XCTest +@testable import ContactFeature + +final class ContactFeatureTests: XCTestCase { + func testStart() { + let store = TestStore( + initialState: ContactState(), + reducer: contactReducer, + environment: .unimplemented + ) + + store.send(.start) + } +} -- GitLab