diff --git a/CamPlace/CamPlace/Coordinator/AppCoordinator.swift b/CamPlace/CamPlace/Coordinator/AppCoordinator.swift index 4553a97..1ba32b1 100644 --- a/CamPlace/CamPlace/Coordinator/AppCoordinator.swift +++ b/CamPlace/CamPlace/Coordinator/AppCoordinator.swift @@ -31,7 +31,8 @@ class AppCoordinator: Coordinator { let firstViewCoordinator = MainMapViewCoordinator() firstViewCoordinator.parentCoordinator = self - + childCoordinator.append(firstViewCoordinator) + firstViewCoordinator.start() let mainMapVC = firstViewCoordinator.navigationController @@ -40,6 +41,7 @@ class AppCoordinator: Coordinator { let secondViewCoordinator = LocationFavoriteCoordinator() secondViewCoordinator.parentCoordinator = self + childCoordinator.append(secondViewCoordinator) secondViewCoordinator.start() diff --git a/CamPlace/CamPlace/Coordinator/Coordinator.swift b/CamPlace/CamPlace/Coordinator/Coordinator.swift index 420fb58..927dff8 100644 --- a/CamPlace/CamPlace/Coordinator/Coordinator.swift +++ b/CamPlace/CamPlace/Coordinator/Coordinator.swift @@ -10,4 +10,6 @@ import Foundation protocol Coordinator: AnyObject { func start() + var childCoordinator: [Coordinator] { get set } + } diff --git a/CamPlace/CamPlace/Main/Detail/PlaceDetailViewCoordinator.swift b/CamPlace/CamPlace/Main/Detail/PlaceDetailViewCoordinator.swift index a9ffaf1..15e0f39 100644 --- a/CamPlace/CamPlace/Main/Detail/PlaceDetailViewCoordinator.swift +++ b/CamPlace/CamPlace/Main/Detail/PlaceDetailViewCoordinator.swift @@ -11,6 +11,7 @@ import UIKit class PlaceDetailViewCoordinator: Coordinator { var navigationController: UINavigationController weak var parentCoordinator: Coordinator? + var childCoordinator: [Coordinator] = [] var viewModel: PlaceDetailViewModel diff --git a/CamPlace/CamPlace/Main/Faovrite/LocationFavoriteCoordinator.swift b/CamPlace/CamPlace/Main/Faovrite/LocationFavoriteCoordinator.swift index 8450859..2ac49b7 100644 --- a/CamPlace/CamPlace/Main/Faovrite/LocationFavoriteCoordinator.swift +++ b/CamPlace/CamPlace/Main/Faovrite/LocationFavoriteCoordinator.swift @@ -11,9 +11,8 @@ import UIKit class LocationFavoriteCoordinator: Coordinator { var navigationController: UINavigationController weak var parentCoordinator: Coordinator? - - - + var childCoordinator: [Coordinator] = [] + init(){ self.navigationController = .init() } @@ -32,8 +31,8 @@ extension LocationFavoriteCoordinator: LocationFavoriteDelegate { let detailViewModel = PlaceDetailViewModel(content: content) let detailCoordinator = PlaceDetailViewCoordinator(navigationController: navigationController, viewModel: detailViewModel) detailCoordinator.parentCoordinator = self - + childCoordinator.append(detailCoordinator) + detailCoordinator.start() - } } diff --git a/CamPlace/CamPlace/Main/Faovrite/LocationFavoriteViewModel.swift b/CamPlace/CamPlace/Main/Faovrite/LocationFavoriteViewModel.swift index 319ba56..65e0bd8 100644 --- a/CamPlace/CamPlace/Main/Faovrite/LocationFavoriteViewModel.swift +++ b/CamPlace/CamPlace/Main/Faovrite/LocationFavoriteViewModel.swift @@ -13,7 +13,7 @@ protocol LocationFavoriteDelegate: AnyObject { } class LocationFavoriteViewModel: PlaceListProtocol { - + private var cancellables: Set = [] @Published var locations: [Location] = [] @@ -31,7 +31,7 @@ class LocationFavoriteViewModel: PlaceListProtocol { } .store(in: &cancellables) } - + func doFavoriteModel(locationContent: LocationBasedListModel) -> AnyPublisher? { Future { promise in @@ -53,7 +53,7 @@ class LocationFavoriteViewModel: PlaceListProtocol { func locationListCount() -> Int { return locations.count } - + func isFavorite(content: LocationBasedListModel) -> AnyPublisher? { Future { promise in diff --git a/CamPlace/CamPlace/Main/MainMap/MainMapViewCoordinator.swift b/CamPlace/CamPlace/Main/MainMap/MainMapViewCoordinator.swift index aa3f8d2..82543c4 100644 --- a/CamPlace/CamPlace/Main/MainMap/MainMapViewCoordinator.swift +++ b/CamPlace/CamPlace/Main/MainMap/MainMapViewCoordinator.swift @@ -17,10 +17,10 @@ protocol MainMapDelegate: AnyObject { class MainMapViewCoordinator: Coordinator { var navigationController: UINavigationController weak var parentCoordinator: Coordinator? - + var childCoordinator: [Coordinator] = [] + init(){ self.navigationController = .init() - } func start() { @@ -34,17 +34,24 @@ class MainMapViewCoordinator: Coordinator { extension MainMapViewCoordinator: MainMapDelegate { func pushDetialVC(content: LocationBasedListModel) { + print("pushdetail") let detailViewModel = PlaceDetailViewModel(content: content) let detailCoordinator = PlaceDetailViewCoordinator(navigationController: navigationController, viewModel: detailViewModel) detailCoordinator.parentCoordinator = self + childCoordinator.append(detailCoordinator) + detailCoordinator.start() } func presentLocationList(contents: [LocationBasedListModel]) { + print("present") let listViewModel = PlaceListViewModel(locationList: contents) let placeListCoordinator = PlaceListViewCoordinator(navigationController: navigationController, viewModel: listViewModel) placeListCoordinator.parentCoordinator = self + childCoordinator.append(placeListCoordinator) + placeListCoordinator.start() + } } diff --git a/CamPlace/CamPlace/Main/PlaceList/PlaceListViewCoordinator.swift b/CamPlace/CamPlace/Main/PlaceList/PlaceListViewCoordinator.swift index ab4f1ea..9cac107 100644 --- a/CamPlace/CamPlace/Main/PlaceList/PlaceListViewCoordinator.swift +++ b/CamPlace/CamPlace/Main/PlaceList/PlaceListViewCoordinator.swift @@ -12,7 +12,8 @@ class PlaceListViewCoordinator: Coordinator { var navigationController: UINavigationController weak var parentCoordinator: Coordinator? var viewModel: PlaceListViewModel - + var childCoordinator: [Coordinator] = [] + init(navigationController: UINavigationController, viewModel: PlaceListViewModel) { self.navigationController = navigationController self.viewModel = viewModel @@ -46,6 +47,8 @@ extension PlaceListViewCoordinator { let viewModel = PlaceDetailViewModel(content: content) let detailCoordinator = PlaceDetailViewCoordinator(navigationController: navigationController, viewModel: viewModel) detailCoordinator.parentCoordinator = self + childCoordinator.append(detailCoordinator) + detailCoordinator.startPresent() } }