Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/pr_status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
- 'Projects/DesignSystem/**'
home:
- 'Projects/Home/**'
detail:
- 'Projects/Detail/**'
- name: Generate matrix
id: matrix
run: |
Expand All @@ -45,6 +47,10 @@ jobs:
if [ "${{ steps.filter.outputs.home }}" == "true" ]; then
targets+=("Home")
fi

if [ "${{ steps.filter.outputs.detail }}" == "true" ]; then
targets+=("Detail")
fi

if [ ${#targets[@]} -gt 0 ]; then
matrix="{\"target\": [$(printf '"%s",' "${targets[@]}" | sed 's/,$//')]}"
Expand Down
4 changes: 4 additions & 0 deletions Projects/App/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ let dependecies: [TargetDependency] = [
path: "../Home"),
.project(target: "HomeInterfaces",
path: "../Home"),
.project(target: "Detail",
path: "../Detail"),
.project(target: "DetailInterfaces",
path: "../Detail"),
.project(target: "NavigationInterfaces",
path: "../Navigation"),
.external(name: "Networking"),
Expand Down
18 changes: 18 additions & 0 deletions Projects/App/Sources/Assemblies/CoordinatorAssembly.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
//
//
import DependencyInjectionInterfaces
import Detail
import DetailInterfaces
import HomeInterfaces
import Home
import NavigationInterfaces
Expand All @@ -31,5 +33,21 @@ public struct CoordinatorAssembly {
return HomeCoordinator(parentCoordinator: parentCoordinator,
navigationController: navigationController)
}

injector.register(DetailCoordinating.self) { (_, arg: (UINavigationController, Coordinator?, Exchange)) in
let (navigationController, parentCoordinator, exchange) = arg

return DetailCoordinator(parentCoordinator: parentCoordinator,
navigationController: navigationController,
exchange: exchange)
}

injector.register(DetailCoordinating.self) { (_, arg: (UINavigationController, Coordinator?, Int)) in
let (navigationController, parentCoordinator, exchangeId) = arg

return DetailCoordinator(parentCoordinator: parentCoordinator,
navigationController: navigationController,
exchangeId: exchangeId)
}
}
}
2 changes: 1 addition & 1 deletion Projects/App/Sources/Coordinator/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class AppCoordinator: AppCoordinating {

let homeCoordinator = resolver.resolve(HomeCoordinating.self,
argument: arg)

children.append(homeCoordinator)
homeCoordinator.start()
}
}
42 changes: 37 additions & 5 deletions Projects/App/Tests/Application/AppDelegateTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

import Testing
import DependencyInjectionInterfaces
import NetworkingInterfaces
import DetailInterfaces
import HomeInterfaces
import NavigationInterfaces
import NavigationTesting
import NetworkingInterfaces
import UIKit

@testable import App
Expand Down Expand Up @@ -62,15 +64,45 @@ struct AppDelegateTests {
func homeCoordinatorRegister() async throws {
#expect(throws: Never.self) {
let navigation = UINavigationController()
let parentCoordinator: Coordinator? = SharedContainer
let parentCoordinator: Coordinator? = CoordinatorSpy(children: [],
navigationController: navigation)

_ = SharedContainer
.shared
.resolver()
.resolve(AppCoordinating.self, argument: navigation)

.resolve(HomeCoordinating.self, argument: (navigation, parentCoordinator))
}
}

@Test("GIVEN AppDelegate initialize THEN it SHOULD register DI DetailCoordinating with Exchange")
func detailCoordinatorRegister() async throws {
#expect(throws: Never.self) {
let navigation = UINavigationController()
let exchange = Exchange(summary: .init(id: 0, name: "exchange"))

let parentCoordinator: Coordinator? = CoordinatorSpy(children: [],
navigationController: navigation)

_ = SharedContainer
.shared
.resolver()
.resolve(HomeCoordinating.self, argument: (navigation, parentCoordinator))
.resolve(DetailCoordinating.self, argument: (navigation, parentCoordinator, exchange))
}
}

@Test("GIVEN AppDelegate initialize THEN it SHOULD register DI DetailCoordinating with Exchange identifier")
func detailWithIdentifierCoordinatorRegister() async throws {
#expect(throws: Never.self) {
let navigation = UINavigationController()
let exchangeId: Int = 21

let parentCoordinator: Coordinator? = CoordinatorSpy(children: [],
navigationController: navigation)

_ = SharedContainer
.shared
.resolver()
.resolve(DetailCoordinating.self, argument: (navigation, parentCoordinator, exchangeId))
}
}
}
12 changes: 12 additions & 0 deletions Projects/Detail/Interfaces/DetailCoordinating.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
//
// Created by Vitor Conceicao.
//
// github.com/vitor-rc1
//
//

import NavigationInterfaces
import UIKit

public protocol DetailCoordinating: Coordinator {}
24 changes: 24 additions & 0 deletions Projects/Detail/Project.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import ProjectDescription
import ProjectDescriptionHelpers

let moduleName = "Detail"

let dependecies: [TargetDependency] = [
.project(target: "DependencyInjectionInterfaces",
path: "../DependencyInjection"),
.project(target: "DesignSystem",
path: "../DesignSystem"),
.project(target: "HomeInterfaces",
path: "../Home"),
.external(name: "NetworkingInterfaces"),
]

let interfaceDependecies: [TargetDependency] = [
.project(target: "NavigationInterfaces",
path: "../Navigation"),
]

let project = Project.templateModule(named: moduleName,
targets: [.source, .interfaces, .test],
dependencies: dependecies,
interfaceDependecies: interfaceDependecies)
42 changes: 42 additions & 0 deletions Projects/Detail/Sources/Coordinator/DetailCoordinator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import UIKit
import DetailInterfaces
import DependencyInjectionInterfaces
import HomeInterfaces
import NavigationInterfaces
import NetworkingInterfaces

@MainActor
public final class DetailCoordinator: DetailCoordinating {
// MARK: - Properties

public weak var parentCoordinator: Coordinator?
public var children: [Coordinator] = []
public var navigationController: UINavigationController

private var exchange: Exchange?
private var exchangeId: Int?

// MARK: - Initialization

public init(parentCoordinator: Coordinator?,
navigationController: UINavigationController,
exchange: Exchange) {
self.parentCoordinator = parentCoordinator
self.navigationController = navigationController
self.exchange = exchange
}

public init(parentCoordinator: Coordinator?,
navigationController: UINavigationController,
exchangeId: Int) {
self.parentCoordinator = parentCoordinator
self.navigationController = navigationController
self.exchangeId = exchangeId
}

// MARK: - DetailCoordinating

public func start() {

}
}
Empty file.
61 changes: 61 additions & 0 deletions Projects/Home/Interfaces/Model/Exchange.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
//
// Created by Vitor Conceicao.
//
// github.com/vitor-rc1
//
//

import Foundation

public struct Exchange: Equatable, Identifiable {
public let id: Int
public let name: String
public let description: String?
public let logo: String
public let spotVolumeUsd: Double?
public let makerFee: Double
public let takerFee: Double
public let dateLaunched: String
public let websiteUrl: String?
public let twitterUrl: String?

public let isLoadingDetails: Bool

public init(id: Int,
name: String,
description: String? = nil,
logo: String,
spotVolumeUsd: Double? = nil,
makerFee: Double,
takerFee: Double,
dateLaunched: String,
websiteUrl: String? = nil,
twitterUrl: String? = nil) {
self.id = id
self.name = name
self.description = description
self.logo = logo
self.spotVolumeUsd = spotVolumeUsd
self.makerFee = makerFee
self.takerFee = takerFee
self.dateLaunched = dateLaunched
self.websiteUrl = websiteUrl
self.twitterUrl = twitterUrl
self.isLoadingDetails = false
}

public init(summary: ExchangeSummary) {
self.id = summary.id
self.name = summary.name
self.description = nil
self.logo = ""
self.spotVolumeUsd = nil
self.makerFee = 0.0
self.takerFee = 0.0
self.dateLaunched = ""
self.websiteUrl = nil
self.twitterUrl = nil
self.isLoadingDetails = true
}
}
19 changes: 19 additions & 0 deletions Projects/Home/Interfaces/Model/ExchangeSummary.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
//
// Created by Vitor Conceicao.
//
// github.com/vitor-rc1
//
//

import Foundation

public struct ExchangeSummary: Sendable, Equatable, Codable {
public let id: Int
public let name: String

public init(id: Int, name: String) {
self.id = id
self.name = name
}
}
39 changes: 39 additions & 0 deletions Projects/Home/Interfaces/Model/Status.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
//
// Created by Vitor Conceicao.
//
// github.com/vitor-rc1
//
//

import Foundation

public struct Status: Equatable {
let timestamp: String
let errorCode: Int?
let errorMessage: String?
let elapsed: Int
let creditCount: Int

public init(timestamp: String,
errorCode: Int? = nil,
errorMessage: String? = nil,
elapsed: Int,
creditCount: Int) {
self.timestamp = timestamp
self.errorCode = errorCode
self.errorMessage = errorMessage
self.elapsed = elapsed
self.creditCount = creditCount
}
}

extension Status: Codable {
public enum CodingKeys: String, CodingKey {
case timestamp
case errorCode = "error_code"
case errorMessage = "error_message"
case elapsed
case creditCount = "credit_count"
}
}
4 changes: 3 additions & 1 deletion Projects/Home/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ let dependecies: [TargetDependency] = [
.project(target: "DependencyInjectionInterfaces",
path: "../DependencyInjection"),
.project(target: "DesignSystem",
path: "../DesignSystem"),
path: "../DesignSystem"),
.project(target: "DetailInterfaces",
path: "../Detail"),
.external(name: "NetworkingInterfaces"),
]

Expand Down
12 changes: 11 additions & 1 deletion Projects/Home/Sources/Coordinator/HomeCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import DependencyInjectionInterfaces
import DetailInterfaces
import HomeInterfaces
import NavigationInterfaces
import NetworkingInterfaces
Expand Down Expand Up @@ -35,5 +36,14 @@ public final class HomeCoordinator: HomeCoordinating {
}

extension HomeCoordinator: HomeViewModelCoordinatorDelegate {
func navigateToDetails(of exchange: Exchange) {}
func navigateToDetails(of exchange: Exchange) {
let resolver = SharedContainer.shared.resolver()
let arg: (UINavigationController, Coordinator?, Exchange) = (navigationController, self, exchange)

let detailCoordinator = resolver.resolve(DetailCoordinating.self,
argument: arg)

children.append(detailCoordinator)
detailCoordinator.start()
}
}
Loading
Loading