diff --git a/Apps/Locations/Sources/Coordinators/LocationsAddCoordinator.swift b/Apps/Locations/Sources/Coordinators/LocationsAddCoordinator.swift index 7d8891d..7666f15 100644 --- a/Apps/Locations/Sources/Coordinators/LocationsAddCoordinator.swift +++ b/Apps/Locations/Sources/Coordinators/LocationsAddCoordinator.swift @@ -42,7 +42,7 @@ extension LocationsAddCoordinator: LocationsAddCoordination { // MARK: Functions - func closeAddLocation() { + func closeLocationsAddScreen() { router.dismiss(animated: true) } diff --git a/Apps/Locations/Sources/Coordinators/LocationsListCoordinator.swift b/Apps/Locations/Sources/Coordinators/LocationsListCoordinator.swift index a7d2592..32e4988 100644 --- a/Apps/Locations/Sources/Coordinators/LocationsListCoordinator.swift +++ b/Apps/Locations/Sources/Coordinators/LocationsListCoordinator.swift @@ -48,7 +48,7 @@ extension LocationsListCoordinator: LocationsListCoordination { // MARK: Functions - func openAddLocation() { + func openLocationsAddScreen() { guard let viewController else { return } diff --git a/Apps/Locations/Sources/Protocols/Coordination/LocationsAddCoordination.swift b/Apps/Locations/Sources/Protocols/Coordination/LocationsAddCoordination.swift index 9819245..52354a3 100644 --- a/Apps/Locations/Sources/Protocols/Coordination/LocationsAddCoordination.swift +++ b/Apps/Locations/Sources/Protocols/Coordination/LocationsAddCoordination.swift @@ -10,6 +10,6 @@ protocol LocationsAddCoordination: AnyObject { // MARK: Functions - func closeAddLocation() + func closeLocationsAddScreen() } diff --git a/Apps/Locations/Sources/Protocols/Coordination/LocationsListCoordination.swift b/Apps/Locations/Sources/Protocols/Coordination/LocationsListCoordination.swift index bafe329..f47b443 100644 --- a/Apps/Locations/Sources/Protocols/Coordination/LocationsListCoordination.swift +++ b/Apps/Locations/Sources/Protocols/Coordination/LocationsListCoordination.swift @@ -10,6 +10,6 @@ protocol LocationsListCoordination: AnyObject { // MARK: Functions - func openAddLocation() + func openLocationsAddScreen() } diff --git a/Apps/Locations/Sources/Protocols/ViewModeling/LocationsListViewModeling.swift b/Apps/Locations/Sources/Protocols/ViewModeling/LocationsListViewModeling.swift index 385b599..324278d 100644 --- a/Apps/Locations/Sources/Protocols/ViewModeling/LocationsListViewModeling.swift +++ b/Apps/Locations/Sources/Protocols/ViewModeling/LocationsListViewModeling.swift @@ -17,14 +17,14 @@ protocol LocationsListViewModeling: AnyObject { var coordinator: LocationsListCoordination? { get set } var locationsDidChangePublisher: PassthroughSubject<[Change], Never> { get } + var numberOfLocationSections: Int { get } var viewStatusPublisher: Published.Publisher { get } - var numberOfSectionsInData: Int { get } - + // MARK: Functions - - func openAddLocation() + func loadLocations() - func numberOfDataItems(in section: Int) -> Int - func dataItem(at indexPath: IndexPath) -> Location + func location(at indexPath: IndexPath) -> Location + func numberOfLocations(in section: Int) -> Int + func openLocationsAdd() } diff --git a/Apps/Locations/Sources/Screens/LocationsAdd/LocationsAddViewModel.swift b/Apps/Locations/Sources/Screens/LocationsAdd/LocationsAddViewModel.swift index b447c1c..78e8294 100644 --- a/Apps/Locations/Sources/Screens/LocationsAdd/LocationsAddViewModel.swift +++ b/Apps/Locations/Sources/Screens/LocationsAdd/LocationsAddViewModel.swift @@ -54,7 +54,7 @@ extension LocationsAddViewModel: LocationsAddViewModeling { longitude: location.longitude ) - coordinator?.closeAddLocation() + coordinator?.closeLocationsAddScreen() } func setLocation(latitude: Float, longitude: Float) { diff --git a/Apps/Locations/Sources/Screens/LocationsList/LocationsListViewController.swift b/Apps/Locations/Sources/Screens/LocationsList/LocationsListViewController.swift index e20b00e..16e17f4 100644 --- a/Apps/Locations/Sources/Screens/LocationsList/LocationsListViewController.swift +++ b/Apps/Locations/Sources/Screens/LocationsList/LocationsListViewController.swift @@ -67,14 +67,14 @@ extension LocationsListViewController: UITableViewDataSource { // MARK: Functions func numberOfSections(in tableView: UITableView) -> Int { - viewModel.numberOfSectionsInData + viewModel.numberOfLocationSections } func tableView( _ tableView: UITableView, numberOfRowsInSection section: Int ) -> Int { - viewModel.numberOfDataItems(in: section) + viewModel.numberOfLocations(in: section) } func tableView( @@ -88,7 +88,7 @@ extension LocationsListViewController: UITableViewDataSource { return .init() } - let entity = viewModel.dataItem(at: indexPath) + let entity = viewModel.location(at: indexPath) cell.update( iconName: entity.source == .remote ? "network" : "house", @@ -163,7 +163,7 @@ private extension LocationsListViewController { .store(in: &cancellables) viewModel - .controllerDidChangePublisher + .locationsDidChangePublisher .sink(receiveValue: { [weak self] updates in var movedToIndexPaths = [IndexPath]() @@ -199,7 +199,7 @@ private extension LocationsListViewController { } @objc func addLocationPressed() { - viewModel.openAddLocation() + viewModel.openLocationsAdd() } } diff --git a/Apps/Locations/Sources/Screens/LocationsList/LocationsListViewModel.swift b/Apps/Locations/Sources/Screens/LocationsList/LocationsListViewModel.swift index b5e2384..8413775 100644 --- a/Apps/Locations/Sources/Screens/LocationsList/LocationsListViewModel.swift +++ b/Apps/Locations/Sources/Screens/LocationsList/LocationsListViewModel.swift @@ -42,15 +42,11 @@ extension LocationsListViewModel: LocationsListViewModeling { // MARK: Properties var locationsDidChangePublisher: PassthroughSubject<[Persistence.Change], Never> { locationProvider.didChangePublisher } - var numberOfSectionsInData: Int { locationProvider.numberOfSections } + var numberOfLocationSections: Int { locationProvider.numberOfSections } var viewStatusPublisher: Published.Publisher { $viewStatus } // MARK: Functions - func openAddLocation() { - coordinator?.openAddLocation() - } - func loadLocations() { Task { do { @@ -67,12 +63,19 @@ extension LocationsListViewModel: LocationsListViewModeling { } } - func numberOfDataItems(in section: Int) -> Int { + + func location(at indexPath: IndexPath) -> Location { + locationProvider.location(at: indexPath) + } + + func numberOfLocations(in section: Int) -> Int { locationProvider.numberOfLocationsInSection(section) } - func dataItem(at indexPath: IndexPath) -> Location { - locationProvider.location(at: indexPath) + func openLocationsAdd() { + coordinator?.openLocationsAddScreen() + } + } }