Skip to content

Commit

Permalink
Merge pull request #82 from nimblehq/release/0.5.0
Browse files Browse the repository at this point in the history
Release - 0.5.0
  • Loading branch information
minhnimble authored Jan 3, 2023
2 parents e0279da + 71e5156 commit afdfa92
Show file tree
Hide file tree
Showing 67 changed files with 1,582 additions and 233 deletions.
28 changes: 14 additions & 14 deletions CryptoPrices.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
24A9D1AA2952C695007DBBCB /* NetworkCore in Frameworks */ = {isa = PBXBuildFile; productRef = 24A9D1A92952C695007DBBCB /* NetworkCore */; };
24A9D1AC2952C7AA007DBBCB /* RepositoryProtocol in Frameworks */ = {isa = PBXBuildFile; productRef = 24A9D1AB2952C7AA007DBBCB /* RepositoryProtocol */; };
4D0A1DA029349D660038624D /* CryptoPricesApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D0A1D9F29349D660038624D /* CryptoPricesApp.swift */; };
4D0A1DA229349D660038624D /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D0A1DA129349D660038624D /* ContentView.swift */; };
4D0A1DA229349D660038624D /* AppView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D0A1DA129349D660038624D /* AppView.swift */; };
4D0A1DA429349D670038624D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4D0A1DA329349D670038624D /* Assets.xcassets */; };
4D0A1DA729349D670038624D /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4D0A1DA629349D670038624D /* Preview Assets.xcassets */; };
4D0A1DB129349D670038624D /* CryptoPricesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D0A1DB029349D670038624D /* CryptoPricesTests.swift */; };
Expand Down Expand Up @@ -58,7 +58,7 @@
24A9D1A72952C54E007DBBCB /* Container+Injection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Container+Injection.swift"; sourceTree = "<group>"; };
4D0A1D9C29349D660038624D /* CryptoPrices.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CryptoPrices.app; sourceTree = BUILT_PRODUCTS_DIR; };
4D0A1D9F29349D660038624D /* CryptoPricesApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptoPricesApp.swift; sourceTree = "<group>"; };
4D0A1DA129349D660038624D /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
4D0A1DA129349D660038624D /* AppView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppView.swift; sourceTree = "<group>"; };
4D0A1DA329349D670038624D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
4D0A1DA629349D670038624D /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
4D0A1DAC29349D670038624D /* CryptoPricesTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CryptoPricesTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -114,21 +114,22 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
24A9D19F2952BF4D007DBBCB /* Navigation */ = {
24A9D19F2952BF4D007DBBCB /* AppView */ = {
isa = PBXGroup;
children = (
4D0A1DA129349D660038624D /* AppView.swift */,
1C3B441129504D8200AFCD81 /* AppState.swift */,
1C3B441329504DDD00AFCD81 /* AppCoordinator.swift */,
);
path = Navigation;
path = AppView;
sourceTree = "<group>";
};
24A9D1A02952BF91007DBBCB /* Dependencie Injection */ = {
24A9D1A02952BF91007DBBCB /* DependenciesInjection */ = {
isa = PBXGroup;
children = (
24A9D1A72952C54E007DBBCB /* Container+Injection.swift */,
);
path = "Dependencie Injection";
path = DependenciesInjection;
sourceTree = "<group>";
};
24ADAFBD29374E0C00BF72D4 /* Configurations */ = {
Expand Down Expand Up @@ -237,10 +238,9 @@
4DF07419293C8AAA00E1274D /* App */ = {
isa = PBXGroup;
children = (
24A9D1A02952BF91007DBBCB /* Dependencie Injection */,
24A9D19F2952BF4D007DBBCB /* Navigation */,
24A9D1A02952BF91007DBBCB /* DependenciesInjection */,
24A9D19F2952BF4D007DBBCB /* AppView */,
4D0A1D9F29349D660038624D /* CryptoPricesApp.swift */,
4D0A1DA129349D660038624D /* ContentView.swift */,
);
path = App;
sourceTree = "<group>";
Expand Down Expand Up @@ -430,7 +430,7 @@
files = (
1C3B441429504DDD00AFCD81 /* AppCoordinator.swift in Sources */,
1C3B441229504D8200AFCD81 /* AppState.swift in Sources */,
4D0A1DA229349D660038624D /* ContentView.swift in Sources */,
4D0A1DA229349D660038624D /* AppView.swift in Sources */,
24A9D1A82952C54E007DBBCB /* Container+Injection.swift in Sources */,
4D0A1DA029349D660038624D /* CryptoPricesApp.swift in Sources */,
);
Expand Down Expand Up @@ -551,7 +551,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.4.0;
MARKETING_VERSION = 0.5.0;
PRODUCT_BUNDLE_IDENTIFIER = "co.nimblehq.crypto-prices.staging";
PRODUCT_MODULE_NAME = CryptoPrices;
PRODUCT_NAME = "$(TARGET_NAME) Staging";
Expand Down Expand Up @@ -682,7 +682,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.4.0;
MARKETING_VERSION = 0.5.0;
PRODUCT_BUNDLE_IDENTIFIER = "co.nimblehq.crypto-prices.staging";
PRODUCT_MODULE_NAME = CryptoPrices;
PRODUCT_NAME = "$(TARGET_NAME) Staging";
Expand Down Expand Up @@ -871,7 +871,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.4.0;
MARKETING_VERSION = 0.5.0;
PRODUCT_BUNDLE_IDENTIFIER = "co.nimblehq.crypto-prices";
PRODUCT_MODULE_NAME = CryptoPrices;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -908,7 +908,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.4.0;
MARKETING_VERSION = 0.5.0;
PRODUCT_BUNDLE_IDENTIFIER = "co.nimblehq.crypto-prices";
PRODUCT_MODULE_NAME = CryptoPrices;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
37 changes: 37 additions & 0 deletions CryptoPrices/Sources/App/AppView/AppCoordinator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// AppCoordinator.swift
// CryptoPrices
//
// Created by Khanh on 19/12/2022.
//

import Combine
import Home
import MyCoin
import SwiftUI

final class AppCoordinator: ObservableObject {

@Published var homeState: HomeState = .init()
@Published var myCoinState: MyCoinState?

init() {
let myCoinStatePublisher = $homeState
.flatMap(\.$didSelectCoin)
.compactMap { $0 }
.map { Just(MyCoinState(id: $0)) }
.assertNoFailure()
.switchToLatest()
.share()

myCoinStatePublisher
.map(Optional.some)
.assign(to: &$myCoinState)

myCoinStatePublisher
.flatMap(\.$didSelectBack)
.filter { $0 }
.map { _ in nil }
.assign(to: &$myCoinState)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import Home
import MyCoin

enum AppState {
struct AppState {

case home(HomeState)
case myCoin(MyCoinState)
var home: HomeState = .init()
var myCoin: MyCoinState?
}
38 changes: 38 additions & 0 deletions CryptoPrices/Sources/App/AppView/AppView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// ContentView.swift
// CryptoPrices
//
// Created by Doan Thieu on 28/11/2022.
//

import Factory
import Home
import MyCoin
import SwiftUI

struct AppView: View {

@StateObject private var appCoordinator: AppCoordinator = .init()
@Injected(Container.homeViewModel) private var homeViewModel
@Injected(Container.myCoinViewModel) private var myCoinViewModel
@State private var showingMyCoin = false

var body: some View {
NavigationView {
ZStack {
HomeView(viewModel: homeViewModel)
.environmentObject(appCoordinator.homeState)
NavigationLink("", isActive: $showingMyCoin) {
if let myCoinState = appCoordinator.myCoinState {
MyCoinView(viewModel: myCoinViewModel)
.environmentObject(myCoinState)
}
}
.labelsHidden()
}
}
.onReceive(appCoordinator.$myCoinState) {
showingMyCoin = $0 != nil
}
}
}
27 changes: 0 additions & 27 deletions CryptoPrices/Sources/App/ContentView.swift

This file was deleted.

17 changes: 1 addition & 16 deletions CryptoPrices/Sources/App/CryptoPricesApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,9 @@ import WormholySwift
@main
struct CryptoPricesApp: App {

@StateObject var appCoordinator = AppCoordinator()

@Injected(Container.homeViewModel) private var homeViewModel

var body: some Scene {
WindowGroup {
switch appCoordinator.state {
case let .home(homeState):
HomeView(viewModel: homeViewModel)
.environmentObject(homeState)
case let .myCoin(myCoinState):
MyCoinView()
.environmentObject(myCoinState)
.transition(
.move(edge: .trailing)
.animation(.linear(duration: 1.0))
)
}
AppView()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ extension Container {

// ViewModels
static let homeViewModel = Factory {
HomeViewModel(myCoinsUseCase: myCoinsUseCase.callAsFunction())
HomeViewModel(
myCoinsUseCase: myCoinsUseCase.callAsFunction(),
trendingCoinsUseCase: trendingCoinsUseCase.callAsFunction()
)
}
static let myCoinViewModel = Factory {
MyCoinViewModel(
coinDetailUseCase: coinDetailUseCase.callAsFunction()
)
}

// Repositories
Expand All @@ -35,6 +43,11 @@ extension Container {
// UseCases
static let myCoinsUseCase = Factory<MyCoinsUseCaseProtocol> {
MyCoinsUseCase(repository: coinRepository.callAsFunction())

}
static let trendingCoinsUseCase = Factory<TrendingCoinsUseCaseProtocol> {
TrendingCoinsUseCase(repository: coinRepository.callAsFunction())
}
static let coinDetailUseCase = Factory<CoinDetailUseCaseProtocol> {
CoinDetailUseCase(repository: coinRepository.callAsFunction())
}
}
48 changes: 0 additions & 48 deletions CryptoPrices/Sources/App/Navigation/AppCoordinator.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,22 @@ struct SourceryPlugin: BuildToolPlugin {
return []
}

let sourceryExecutable = try context.tool(named: "sourcery")
let generatedDirectory = context.pluginWorkDirectory.appending("SourceryGenerated")

// Command to remove the previously-generated codes
let clearCommand = Command.prebuildCommand(
displayName: "Clear previously-generated data",
executable: .init("/bin/rm"),
arguments: [
"-rf",
generatedDirectory
],
outputFilesDirectory: generatedDirectory
)

let sourceryExecutable = try context.tool(named: "sourcery")

// Command to generate codes from latest changes
let sourceryCommand = Command.prebuildCommand(
displayName: "Generate mocked types for \(target) target",
executable: sourceryExecutable.path,
Expand All @@ -36,6 +49,6 @@ struct SourceryPlugin: BuildToolPlugin {
outputFilesDirectory: generatedDirectory
)

return [sourceryCommand]
return [clearCommand, sourceryCommand]
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// APICoin+dummy.swift
// APICoin+Dummy.swift
// Data
//
// Created by Doan Thieu on 09/12/2022.
Expand Down
Loading

0 comments on commit afdfa92

Please sign in to comment.