Improved the naming of some properties and functions in the LocationsAddCoordination, LocationsListCoordination, and LocationsListViewModeling protocols.
This commit is contained in:
parent
a241767c86
commit
dc7dbfb61a
@ -42,7 +42,7 @@ extension LocationsAddCoordinator: LocationsAddCoordination {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
func closeAddLocation() {
|
||||
func closeLocationsAddScreen() {
|
||||
router.dismiss(animated: true)
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ extension LocationsListCoordinator: LocationsListCoordination {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
func openAddLocation() {
|
||||
func openLocationsAddScreen() {
|
||||
guard let viewController else {
|
||||
return
|
||||
}
|
||||
|
@ -10,6 +10,6 @@ protocol LocationsAddCoordination: AnyObject {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
func closeAddLocation()
|
||||
func closeLocationsAddScreen()
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,6 @@ protocol LocationsListCoordination: AnyObject {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
func openAddLocation()
|
||||
func openLocationsAddScreen()
|
||||
|
||||
}
|
||||
|
@ -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<LocationsListViewStatus>.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()
|
||||
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ extension LocationsAddViewModel: LocationsAddViewModeling {
|
||||
longitude: location.longitude
|
||||
)
|
||||
|
||||
coordinator?.closeAddLocation()
|
||||
coordinator?.closeLocationsAddScreen()
|
||||
}
|
||||
|
||||
func setLocation(latitude: Float, longitude: Float) {
|
||||
|
@ -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()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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<LocationsListViewStatus>.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()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user