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

Add ContactLookupFeature library

parent c1952b00
No related branches found
No related tags found
2 merge requests!112Restore contacts from backup,!102Release 1.0.0
<?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 = "ContactLookupFeature"
BuildableName = "ContactLookupFeature"
BlueprintName = "ContactLookupFeature"
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 = "ContactLookupFeatureTests"
BuildableName = "ContactLookupFeatureTests"
BlueprintName = "ContactLookupFeatureTests"
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 = "ContactLookupFeature"
BuildableName = "ContactLookupFeature"
BlueprintName = "ContactLookupFeature"
ReferencedContainer = "container:">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
......@@ -20,6 +20,7 @@ let package = Package(
.library(name: "CheckContactAuthFeature", targets: ["CheckContactAuthFeature"]),
.library(name: "ConfirmRequestFeature", targets: ["ConfirmRequestFeature"]),
.library(name: "ContactFeature", targets: ["ContactFeature"]),
.library(name: "ContactLookupFeature", targets: ["ContactLookupFeature"]),
.library(name: "ContactsFeature", targets: ["ContactsFeature"]),
.library(name: "HomeFeature", targets: ["HomeFeature"]),
.library(name: "MyContactFeature", targets: ["MyContactFeature"]),
......@@ -208,6 +209,24 @@ let package = Package(
],
swiftSettings: swiftSettings
),
.target(
name: "ContactLookupFeature",
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: "ContactLookupFeatureTests",
dependencies: [
.target(name: "ContactLookupFeature"),
.product(name: "CustomDump", package: "swift-custom-dump"),
],
swiftSettings: swiftSettings
),
.target(
name: "ContactsFeature",
dependencies: [
......
......@@ -99,6 +99,16 @@
ReferencedContainer = "container:..">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ContactLookupFeatureTests"
BuildableName = "ContactLookupFeatureTests"
BlueprintName = "ContactLookupFeatureTests"
ReferencedContainer = "container:..">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
......
import ComposableArchitecture
import Foundation
import XCTestDynamicOverlay
public struct ContactLookupState: Equatable {
public init(
id: Data,
isLookingUp: Bool = false
) {
self.id = id
self.isLookingUp = isLookingUp
}
public var id: Data
public var isLookingUp: Bool
}
public enum ContactLookupAction: Equatable {
case task
case cancelTask
case lookupTapped
}
public struct ContactLookupEnvironment {
public init() {}
}
#if DEBUG
extension ContactLookupEnvironment {
public static let unimplemented = ContactLookupEnvironment()
}
#endif
public let contactLookupReducer = Reducer<ContactLookupState, ContactLookupAction, ContactLookupEnvironment>
{ state, action, env in
switch action {
case .task:
return .none
case .cancelTask:
return .none
case .lookupTapped:
return .none
}
}
import AppCore
import ComposableArchitecture
import SwiftUI
public struct ContactLookupView: View {
public init(store: Store<ContactLookupState, ContactLookupAction>) {
self.store = store
}
let store: Store<ContactLookupState, ContactLookupAction>
struct ViewState: Equatable {
init(state: ContactLookupState) {
id = state.id
isLookingUp = state.isLookingUp
}
var id: Data
var isLookingUp: Bool
}
public var body: some View {
WithViewStore(store, observe: ViewState.init) { viewStore in
Form {
Section {
Label(viewStore.id.hexString, systemImage: "number")
.font(.footnote.monospaced())
Button {
viewStore.send(.lookupTapped)
} label: {
HStack {
Text("Lookup")
Spacer()
if viewStore.isLookingUp {
ProgressView()
} else {
Image(systemName: "magnifyingglass")
}
}
}
.disabled(viewStore.isLookingUp)
} header: {
Text("Contact ID")
}
}
.navigationTitle("Lookup")
.task {
await viewStore.send(.task).finish()
}
}
}
}
#if DEBUG
public struct ContactLookupView_Previews: PreviewProvider {
public static var previews: some View {
NavigationView {
ContactLookupView(store: Store(
initialState: ContactLookupState(
id: "1234".data(using: .utf8)!
),
reducer: .empty,
environment: ()
))
}
}
}
#endif
import ComposableArchitecture
import XCTest
@testable import ContactLookupFeature
final class ContactLookupFeatureTests: XCTestCase {
func testTask() {
let store = TestStore(
initialState: ContactLookupState(
id: "1234".data(using: .utf8)!
),
reducer: contactLookupReducer,
environment: .unimplemented
)
store.send(.task)
store.send(.cancelTask)
}
func testLookup() {
let store = TestStore(
initialState: ContactLookupState(
id: "1234".data(using: .utf8)!
),
reducer: contactLookupReducer,
environment: .unimplemented
)
store.send(.lookupTapped)
}
}
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