Skip to content

Commit

Permalink
Fixed mainView Model issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mehrankmlf committed Jan 12, 2024
1 parent 9ab80bc commit bfe8fd9
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 9 deletions.
12 changes: 11 additions & 1 deletion EasyCrypto.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,6 @@
isa = PBXGroup;
children = (
A81742C2297E593800023B28 /* EasyCryptoApp.swift */,
A8D4A114299E45D300C11107 /* AppDependencyContainer.swift */,
0250EA6F29B27F4200AA6040 /* AppDependencyContainer + Injection.swift */,
);
path = App;
Expand Down Expand Up @@ -515,6 +514,14 @@
path = Coordinator;
sourceTree = "<group>";
};
02B004542B518B0D00AB7B6C /* DIManager */ = {
isa = PBXGroup;
children = (
A8D4A114299E45D300C11107 /* AppDependencyContainer.swift */,
);
path = DIManager;
sourceTree = "<group>";
};
02B22A8629CC476800A04929 /* Persistance */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -833,6 +840,7 @@
A8D4A10A299E0DFA00C11107 /* Base */,
A803DFB7297E918900357A7F /* Theme */,
A803DFCD297E93F600357A7F /* Support */,
02B004542B518B0D00AB7B6C /* DIManager */,
02B22A8629CC476800A04929 /* Persistance */,
A803DFBA297E91BF00357A7F /* Core */,
A803DFBB297E91C600357A7F /* Data */,
Expand Down Expand Up @@ -1103,6 +1111,8 @@
Base,
);
mainGroup = A81742B6297E593800023B28;
packageReferences = (
);
productRefGroup = A81742C0297E593800023B28 /* Products */;
projectDirPath = "";
projectRoot = "";
Expand Down
4 changes: 3 additions & 1 deletion EasyCrypto/App/EasyCryptoApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ struct EasyCryptoApp: App {

let coreDataManager = CoreDataManager.preview

@StateObject var viewModel: MainViewModel = MainViewModel()

init() {
DIContainer.shared.registration()
}

var body: some Scene {
WindowGroup {
MainCoordinator(viewModel: MainViewModel())
MainCoordinator(viewModel: viewModel)
.environment(\.managedObjectContext, coreDataManager.container.viewContext)
}
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Combine

struct CoinDetailCoordinator: CoordinatorProtocol {

@StateObject var viewModel: CoinDetailViewModel
@ObservedObject var viewModel: CoinDetailViewModel
@State var activeRoute: Destination? = Destination(route: .first(url: nil))
@State var transition: Transition?
let id: String
Expand Down
11 changes: 6 additions & 5 deletions EasyCrypto/Presentation/Main/Coordinator/MainCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import SwiftUI
import Combine

struct MainCoordinator: CoordinatorProtocol {

@StateObject var viewModel: MainViewModel

@StateObject var viewModel = MainViewModel()
@State var activeRoute: Destination? = Destination(route: .first(item: MarketsPrice()))
@State var transition: Transition?

Expand All @@ -31,15 +32,15 @@ struct MainCoordinator: CoordinatorProtocol {
}

var mainView: MainView {
return MainView(viewModel: viewModel)
MainView(viewModel: viewModel)
}
}

extension MainCoordinator {
struct Destination: DestinationProtocol {

var route: MainView.Routes

@ViewBuilder
var content: some View {
switch route {
Expand All @@ -49,7 +50,7 @@ extension MainCoordinator {
CoinDetailCoordinator(viewModel: CoinDetailViewModel(), id: data)
}
}

var transition: Transition {
switch route {
case .first: return .push
Expand Down
2 changes: 1 addition & 1 deletion EasyCrypto/Presentation/Main/View/SortView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import SwiftUI

struct SortView: View {

@State var viewModel: MainViewModel
@ObservedObject var viewModel: MainViewModel
@State var viewState: Bool = false

var body: some View {
Expand Down

0 comments on commit bfe8fd9

Please sign in to comment.