This PR contains the work done to open the *Places* view of the **Wikipedia** app with the screen centered on the coordinates from a selected location in the `LocationsListViewController` view controller. To give further details about the work done: - [x] implemented the `wikipediaPlacesURL` property in the `Location+URLs` extension; - [x] improved the `LocationsListCoordination` protocol and the `LocationsListCoordinator` coordinator to support the opening of the Wikipedia app; - [x] improved the `LocationsListViewModeling` protocol and the `LocationsListViewModel` view model to support the opening of the Wikipedia app; - [x] implemented the "tableView(_: didSelectAt: )" function in the `LocationsListViewController` view controller; - [x] added the "wikipedia" to the Queried URL schemes in the Info.plist file to support querying to the Wikipedia app; - [x] improved the naming of some properties and functions in the `LocationsAddCoordination`, `LocationsListCoordination`, and `LocationsListViewModeling` protocols. Co-authored-by: Javier Cicchelli <javier@rock-n-code.com> Reviewed-on: rock-n-code/deep-linking-assignment#12
47 lines
927 B
Swift
47 lines
927 B
Swift
//
|
|
// Location+URLs.swift
|
|
// Locations
|
|
//
|
|
// Created by Javier Cicchelli on 13/04/2023.
|
|
// Copyright © 2023 Röck+Cöde. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import Persistence
|
|
|
|
extension Location {
|
|
|
|
var wikipediaPlacesURL: URL? {
|
|
var urlComponents = URLComponents()
|
|
|
|
urlComponents.scheme = .Scheme.wikipedia
|
|
urlComponents.host = .Host.places
|
|
urlComponents.queryItems = [
|
|
.init(
|
|
name: .Query.key,
|
|
value: .init(format: .Query.value, latitude, longitude)
|
|
)
|
|
]
|
|
|
|
return urlComponents.url
|
|
}
|
|
|
|
}
|
|
|
|
// MARK: - String+Constants
|
|
|
|
private extension String {
|
|
enum Scheme {
|
|
static let wikipedia = "wikipedia"
|
|
}
|
|
|
|
enum Host {
|
|
static let places = "places"
|
|
}
|
|
|
|
enum Query {
|
|
static let key = "coordinates"
|
|
static let value = "%f,%f"
|
|
}
|
|
}
|