Compare commits
8 Commits
main
...
feature/lo
Author | SHA1 | Date | |
---|---|---|---|
4ebd954176 | |||
e17c407af4 | |||
2d91edd38b | |||
fa6ae4863e | |||
1683347c1a | |||
5f0c6640cc | |||
9b04d3601c | |||
2783dd56d0 |
@ -1,53 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1430"
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
shouldAutocreateTestPlan = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "APICoreTests"
|
||||
BuildableName = "APICoreTests"
|
||||
BlueprintName = "APICoreTests"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
@ -1,53 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1430"
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
shouldAutocreateTestPlan = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "CoreTests"
|
||||
BuildableName = "CoreTests"
|
||||
BlueprintName = "CoreTests"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
@ -1,53 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1430"
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
shouldAutocreateTestPlan = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "DependencyTests"
|
||||
BuildableName = "DependencyTests"
|
||||
BlueprintName = "DependencyTests"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
@ -1,66 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1430"
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "Libraries"
|
||||
BuildableName = "Libraries"
|
||||
BlueprintName = "Libraries"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
shouldAutocreateTestPlan = "YES">
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "Libraries"
|
||||
BuildableName = "Libraries"
|
||||
BlueprintName = "Libraries"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
@ -1,53 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1430"
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
shouldAutocreateTestPlan = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "PersistenceTests"
|
||||
BuildableName = "PersistenceTests"
|
||||
BlueprintName = "PersistenceTests"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
@ -1,53 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1430"
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
shouldAutocreateTestPlan = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "RemoteTests"
|
||||
BuildableName = "RemoteTests"
|
||||
BlueprintName = "RemoteTests"
|
||||
ReferencedContainer = "container:">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
@ -1,23 +0,0 @@
|
||||
//
|
||||
// Application.swift
|
||||
// Core
|
||||
//
|
||||
// Created by Javier Cicchelli on 13/04/2023.
|
||||
// Copyright © 2023 Röck+Cöde. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
public protocol Application {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
func canOpenURL(_ url: URL) -> Bool
|
||||
func open(
|
||||
_ url: URL,
|
||||
options: [UIApplication.OpenExternalURLOptionsKey : Any],
|
||||
completionHandler completion: ((Bool) -> Void)?
|
||||
)
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
//
|
||||
// Service.swift
|
||||
// Persistence
|
||||
//
|
||||
// Created by Javier Cicchelli on 13/04/2023.
|
||||
// Copyright © 2023 Röck+Cöde. All rights reserved.
|
||||
//
|
||||
|
||||
import CoreData
|
||||
|
||||
public protocol Service {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// The main managed object context.
|
||||
var viewContext: NSManagedObjectContext { get }
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
/// Create a private queue context.
|
||||
/// - Returns: A concurrent `NSManagedObjectContext` context instance ready to use.
|
||||
func makeTaskContext() -> NSManagedObjectContext
|
||||
|
||||
/// Create a child context of the view context.
|
||||
/// - Returns: A generated child `NSManagedObjectContext` context instance ready to use.
|
||||
func makeChildContext() -> NSManagedObjectContext
|
||||
|
||||
/// Save a given context,
|
||||
/// - Parameter context: A `NSManagedObjectContext` context instance to save.
|
||||
func save(context: NSManagedObjectContext)
|
||||
|
||||
/// Save a given child context as well as its respective parent context.
|
||||
/// - Parameter context: A child `NSManagedObjectContext` context instance to save.
|
||||
func save(childContext context: NSManagedObjectContext)
|
||||
|
||||
}
|
@ -26,7 +26,7 @@ public struct PersistenceService {
|
||||
else {
|
||||
fatalError("Could not load the model from the library.")
|
||||
}
|
||||
|
||||
|
||||
container = NSPersistentContainer(
|
||||
name: .Model.name,
|
||||
managedObjectModel: managedObjectModel
|
||||
@ -35,18 +35,10 @@ public struct PersistenceService {
|
||||
setContainer(inMemory)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Service
|
||||
|
||||
extension PersistenceService: Service {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
public var viewContext: NSManagedObjectContext { container.viewContext }
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
|
||||
/// Create a private queue context.
|
||||
/// - Returns: A concurrent `NSManagedObjectContext` context instance ready to use.
|
||||
public func makeTaskContext() -> NSManagedObjectContext {
|
||||
let taskContext = container.newBackgroundContext()
|
||||
|
||||
@ -56,6 +48,8 @@ extension PersistenceService: Service {
|
||||
return taskContext
|
||||
}
|
||||
|
||||
/// Create a child context of the view context.
|
||||
/// - Returns: A generated child `NSManagedObjectContext` context instance ready to use.
|
||||
public func makeChildContext() -> NSManagedObjectContext {
|
||||
let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
|
||||
|
||||
@ -66,6 +60,8 @@ extension PersistenceService: Service {
|
||||
return context
|
||||
}
|
||||
|
||||
/// Save a given context,
|
||||
/// - Parameter context: A `NSManagedObjectContext` context instance to save.
|
||||
public func save(context: NSManagedObjectContext) {
|
||||
guard context.hasChanges else {
|
||||
return
|
||||
@ -79,6 +75,8 @@ extension PersistenceService: Service {
|
||||
}
|
||||
}
|
||||
|
||||
/// Save a given child context as well as its respective parent context.
|
||||
/// - Parameter context: A child `NSManagedObjectContext` context instance to save.
|
||||
public func save(childContext context: NSManagedObjectContext) {
|
||||
guard context.hasChanges else {
|
||||
return
|
||||
@ -102,7 +100,7 @@ extension PersistenceService: Service {
|
||||
fatalError("Unresolved error \(nserror), \(nserror.userInfo)")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
|
@ -1,19 +0,0 @@
|
||||
//
|
||||
// Service.swift
|
||||
// Remote
|
||||
//
|
||||
// Created by Javier Cicchelli on 13/04/2023.
|
||||
// Copyright © 2023 Röck+Cöde. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public protocol Service {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
/// Retrieve a set of locations.
|
||||
/// - Returns: The set of locations represented as a `Location` instances.
|
||||
func getLocations() async throws -> [Location]
|
||||
|
||||
}
|
@ -21,12 +21,6 @@ public struct RemoteService {
|
||||
self.client = RemoteClient(configuration: configuration)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Service
|
||||
|
||||
extension RemoteService: Service {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
public func getLocations() async throws -> [Location] {
|
||||
@ -35,7 +29,7 @@ extension RemoteService: Service {
|
||||
for: Locations.self
|
||||
).locations
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// MARK: - Models
|
||||
|
@ -1,10 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>LSApplicationQueriesSchemes</key>
|
||||
<array>
|
||||
<string>wikipedia</string>
|
||||
</array>
|
||||
</dict>
|
||||
<dict/>
|
||||
</plist>
|
||||
|
@ -42,7 +42,7 @@ extension LocationsAddCoordinator: LocationsAddCoordination {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
func closeLocationsAddScreen() {
|
||||
func closeAddLocation() {
|
||||
router.dismiss(animated: true)
|
||||
}
|
||||
|
||||
|
@ -7,15 +7,10 @@
|
||||
//
|
||||
|
||||
import Core
|
||||
import Dependency
|
||||
import UIKit
|
||||
|
||||
class LocationsListCoordinator: Coordinator {
|
||||
|
||||
// MARK: Dependencies
|
||||
|
||||
@Dependency(\.app) private var app
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
var children: [Coordinator] = []
|
||||
@ -53,7 +48,7 @@ extension LocationsListCoordinator: LocationsListCoordination {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
func openLocationsAddScreen() {
|
||||
func openAddLocation() {
|
||||
guard let viewController else {
|
||||
return
|
||||
}
|
||||
@ -66,12 +61,4 @@ extension LocationsListCoordinator: LocationsListCoordination {
|
||||
)
|
||||
}
|
||||
|
||||
func openWikipediaApp(with url: URL) {
|
||||
guard app.canOpenURL(url) else {
|
||||
return
|
||||
}
|
||||
|
||||
app.open(url, options: [:], completionHandler: nil)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,26 +6,19 @@
|
||||
// Copyright © 2023 Röck+Cöde. All rights reserved.
|
||||
//
|
||||
|
||||
import Core
|
||||
import Dependency
|
||||
import Persistence
|
||||
import Remote
|
||||
import UIKit
|
||||
|
||||
// MARK: - DependencyService+Keys
|
||||
|
||||
extension DependencyService {
|
||||
var app: Core.Application {
|
||||
get { Self[ApplicationKey.self] }
|
||||
set { Self[ApplicationKey.self] = newValue }
|
||||
}
|
||||
|
||||
var persistence: Persistence.Service {
|
||||
var persistence: PersistenceService {
|
||||
get { Self[PersistenceKey.self] }
|
||||
set { Self[PersistenceKey.self] = newValue }
|
||||
}
|
||||
|
||||
var remote: Remote.Service {
|
||||
var remote: RemoteService {
|
||||
get { Self[RemoteKey.self] }
|
||||
set { Self[RemoteKey.self] = newValue }
|
||||
}
|
||||
@ -33,14 +26,10 @@ extension DependencyService {
|
||||
|
||||
// MARK: - Dependency keys
|
||||
|
||||
struct ApplicationKey: DependencyKey {
|
||||
static var currentValue: Core.Application = UIApplication.shared
|
||||
}
|
||||
|
||||
struct PersistenceKey: DependencyKey {
|
||||
static var currentValue: Persistence.Service = PersistenceService.shared
|
||||
static var currentValue: PersistenceService = .shared
|
||||
}
|
||||
|
||||
struct RemoteKey: DependencyKey {
|
||||
static var currentValue: Remote.Service = RemoteService()
|
||||
static var currentValue: RemoteService = .init()
|
||||
}
|
||||
|
@ -1,46 +0,0 @@
|
||||
//
|
||||
// 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"
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
//
|
||||
// UIApplication+Conformances.swift
|
||||
// Locations
|
||||
//
|
||||
// Created by Javier Cicchelli on 13/04/2023.
|
||||
// Copyright © 2023 Röck+Cöde. All rights reserved.
|
||||
//
|
||||
|
||||
import Core
|
||||
import UIKit
|
||||
|
||||
extension UIApplication: Application {}
|
@ -10,6 +10,6 @@ protocol LocationsAddCoordination: AnyObject {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
func closeLocationsAddScreen()
|
||||
func closeAddLocation()
|
||||
|
||||
}
|
||||
|
@ -6,13 +6,10 @@
|
||||
// Copyright © 2023 Röck+Cöde. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
protocol LocationsListCoordination: AnyObject {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
func openLocationsAddScreen()
|
||||
func openWikipediaApp(with url: URL)
|
||||
func openAddLocation()
|
||||
|
||||
}
|
||||
|
@ -17,15 +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 location(at indexPath: IndexPath) -> Location
|
||||
func numberOfLocations(in section: Int) -> Int
|
||||
func openLocationsAdd()
|
||||
func openWikipedia(at indexPath: IndexPath)
|
||||
func numberOfDataItems(in section: Int) -> Int
|
||||
func dataItem(at indexPath: IndexPath) -> Location
|
||||
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ extension LocationsAddViewModel: LocationsAddViewModeling {
|
||||
longitude: location.longitude
|
||||
)
|
||||
|
||||
coordinator?.closeLocationsAddScreen()
|
||||
coordinator?.closeAddLocation()
|
||||
}
|
||||
|
||||
func setLocation(latitude: Float, longitude: Float) {
|
||||
|
@ -67,14 +67,14 @@ extension LocationsListViewController: UITableViewDataSource {
|
||||
// MARK: Functions
|
||||
|
||||
func numberOfSections(in tableView: UITableView) -> Int {
|
||||
viewModel.numberOfLocationSections
|
||||
viewModel.numberOfSectionsInData
|
||||
}
|
||||
|
||||
func tableView(
|
||||
_ tableView: UITableView,
|
||||
numberOfRowsInSection section: Int
|
||||
) -> Int {
|
||||
viewModel.numberOfLocations(in: section)
|
||||
viewModel.numberOfDataItems(in: section)
|
||||
}
|
||||
|
||||
func tableView(
|
||||
@ -88,7 +88,7 @@ extension LocationsListViewController: UITableViewDataSource {
|
||||
return .init()
|
||||
}
|
||||
|
||||
let entity = viewModel.location(at: indexPath)
|
||||
let entity = viewModel.dataItem(at: indexPath)
|
||||
|
||||
cell.update(
|
||||
iconName: entity.source == .remote ? "network" : "house",
|
||||
@ -104,20 +104,7 @@ extension LocationsListViewController: UITableViewDataSource {
|
||||
|
||||
// MARK: - UITableViewDelegate
|
||||
|
||||
extension LocationsListViewController: UITableViewDelegate {
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
func tableView(
|
||||
_ tableView: UITableView,
|
||||
didSelectRowAt indexPath: IndexPath
|
||||
) {
|
||||
viewModel.openWikipedia(at: indexPath)
|
||||
|
||||
tableView.deselectRow(at: indexPath, animated: true)
|
||||
}
|
||||
|
||||
}
|
||||
extension LocationsListViewController: UITableViewDelegate {}
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
@ -176,7 +163,7 @@ private extension LocationsListViewController {
|
||||
.store(in: &cancellables)
|
||||
|
||||
viewModel
|
||||
.locationsDidChangePublisher
|
||||
.controllerDidChangePublisher
|
||||
.sink(receiveValue: { [weak self] updates in
|
||||
var movedToIndexPaths = [IndexPath]()
|
||||
|
||||
@ -212,7 +199,7 @@ private extension LocationsListViewController {
|
||||
}
|
||||
|
||||
@objc func addLocationPressed() {
|
||||
viewModel.openLocationsAdd()
|
||||
viewModel.openAddLocation()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ class LocationsListViewModel: ObservableObject {
|
||||
|
||||
weak var coordinator: LocationsListCoordination?
|
||||
|
||||
private lazy var locationProvider = LocationProvider(managedContext: persistence.viewContext)
|
||||
private lazy var locationProvider = LocationProvider(managedContext: persistence.container.viewContext)
|
||||
|
||||
@Published private var viewStatus: LocationsListViewStatus = .initialised
|
||||
|
||||
@ -42,11 +42,15 @@ extension LocationsListViewModel: LocationsListViewModeling {
|
||||
// MARK: Properties
|
||||
|
||||
var locationsDidChangePublisher: PassthroughSubject<[Persistence.Change], Never> { locationProvider.didChangePublisher }
|
||||
var numberOfLocationSections: Int { locationProvider.numberOfSections }
|
||||
var numberOfSectionsInData: Int { locationProvider.numberOfSections }
|
||||
var viewStatusPublisher: Published<LocationsListViewStatus>.Publisher { $viewStatus }
|
||||
|
||||
// MARK: Functions
|
||||
|
||||
func openAddLocation() {
|
||||
coordinator?.openAddLocation()
|
||||
}
|
||||
|
||||
func loadLocations() {
|
||||
Task {
|
||||
do {
|
||||
@ -63,25 +67,12 @@ extension LocationsListViewModel: LocationsListViewModeling {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func location(at indexPath: IndexPath) -> Location {
|
||||
locationProvider.location(at: indexPath)
|
||||
}
|
||||
|
||||
func numberOfLocations(in section: Int) -> Int {
|
||||
func numberOfDataItems(in section: Int) -> Int {
|
||||
locationProvider.numberOfLocationsInSection(section)
|
||||
}
|
||||
|
||||
func openLocationsAdd() {
|
||||
coordinator?.openLocationsAddScreen()
|
||||
}
|
||||
|
||||
func openWikipedia(at indexPath: IndexPath) {
|
||||
guard let url = locationProvider.location(at: indexPath).wikipediaPlacesURL else {
|
||||
return
|
||||
}
|
||||
|
||||
coordinator?.openWikipediaApp(with: url)
|
||||
func dataItem(at indexPath: IndexPath) -> Location {
|
||||
locationProvider.location(at: indexPath)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,14 +15,14 @@ struct LoadRemoteLocationsUseCase {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
private let persistence: Persistence.Service
|
||||
private let remoteService: Remote.Service
|
||||
private let persistence: PersistenceService
|
||||
private let remoteService: RemoteService
|
||||
|
||||
// MARK: Initialisers
|
||||
|
||||
init(
|
||||
persistence: Persistence.Service,
|
||||
remoteService: Remote.Service
|
||||
persistence: PersistenceService,
|
||||
remoteService: RemoteService
|
||||
) {
|
||||
self.persistence = persistence
|
||||
self.remoteService = remoteService
|
||||
|
@ -13,11 +13,11 @@ struct SaveLocalLocationUseCase {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
private let persistence: Persistence.Service
|
||||
private let persistence: PersistenceService
|
||||
|
||||
// MARK: Initialisers
|
||||
|
||||
init(persistence: Persistence.Service) {
|
||||
init(persistence: PersistenceService) {
|
||||
self.persistence = persistence
|
||||
}
|
||||
|
||||
|
@ -456,6 +456,7 @@
|
||||
41FCAA3721C844CB001D8411 /* ReadingListEntryCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41FCAA3521C844CB001D8411 /* ReadingListEntryCollectionViewController.swift */; };
|
||||
41FCAA3821C844CB001D8411 /* ReadingListEntryCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41FCAA3521C844CB001D8411 /* ReadingListEntryCollectionViewController.swift */; };
|
||||
41FCAA3921C844CB001D8411 /* ReadingListEntryCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41FCAA3521C844CB001D8411 /* ReadingListEntryCollectionViewController.swift */; };
|
||||
46EB334829E1D204001D5EAF /* Shared in Frameworks */ = {isa = PBXBuildFile; productRef = 46EB334729E1D204001D5EAF /* Shared */; };
|
||||
533AB8AE259792A9003A43D9 /* wikipedia-language-variants.json in Resources */ = {isa = PBXBuildFile; fileRef = 533AB8AD259792A9003A43D9 /* wikipedia-language-variants.json */; };
|
||||
535F16D625CE11A300875AAD /* MWKDataStore+LanguageVariantMigration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 535F16D525CE11A300875AAD /* MWKDataStore+LanguageVariantMigration.swift */; };
|
||||
53A575FA2602C845009835E6 /* WMFAppViewController+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53A575F92602C845009835E6 /* WMFAppViewController+Extensions.swift */; };
|
||||
@ -5775,6 +5776,7 @@
|
||||
D8D553621DF1B63200B90177 /* QuartzCore.framework in Frameworks */,
|
||||
D4E6D9121A5C65F9004916C1 /* CoreData.framework in Frameworks */,
|
||||
D499143B181D51DE00E6073C /* CoreGraphics.framework in Frameworks */,
|
||||
46EB334829E1D204001D5EAF /* Shared in Frameworks */,
|
||||
D499143D181D51DE00E6073C /* UIKit.framework in Frameworks */,
|
||||
D4991439181D51DE00E6073C /* Foundation.framework in Frameworks */,
|
||||
041EFC371996A1F800B2CB28 /* MapKit.framework in Frameworks */,
|
||||
@ -10077,6 +10079,7 @@
|
||||
);
|
||||
name = Wikipedia;
|
||||
packageProductDependencies = (
|
||||
46EB334729E1D204001D5EAF /* Shared */,
|
||||
);
|
||||
productName = "Wikipedia-iOS";
|
||||
productReference = D4991435181D51DE00E6073C /* Wikipedia.app */;
|
||||
@ -20143,6 +20146,10 @@
|
||||
/* End XCRemoteSwiftPackageReference section */
|
||||
|
||||
/* Begin XCSwiftPackageProductDependency section */
|
||||
46EB334729E1D204001D5EAF /* Shared */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
productName = Shared;
|
||||
};
|
||||
67A770C7251BFE0400F94EF9 /* CocoaLumberjackSwift */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
package = 67A770C6251BFE0400F94EF9 /* XCRemoteSwiftPackageReference "CocoaLumberjack" */;
|
||||
|
@ -12,10 +12,9 @@
|
||||
02031EC929E60B29003C108C /* DependencyService+Keys.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02031EC829E60B29003C108C /* DependencyService+Keys.swift */; };
|
||||
02031EE829E68D9B003C108C /* LoadingSpinnerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02031EE729E68D9B003C108C /* LoadingSpinnerView.swift */; };
|
||||
02031EEA29E6B495003C108C /* ErrorMessageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02031EE929E6B495003C108C /* ErrorMessageView.swift */; };
|
||||
02031F0829E75EF0003C108C /* SaveLocalLocationUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02031F0729E75EED003C108C /* SaveLocalLocationUseCase.swift */; };
|
||||
02031F0A29E7645F003C108C /* Location+URLs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02031F0929E7645F003C108C /* Location+URLs.swift */; };
|
||||
4656CBC229E6D33C00600EE6 /* LoadRemoteLocationsUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4656CBC129E6D33C00600EE6 /* LoadRemoteLocationsUseCase.swift */; };
|
||||
4656CBC829E6F2E400600EE6 /* LocationViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4656CBC729E6F2E400600EE6 /* LocationViewCell.swift */; };
|
||||
4656CBE629E7360B00600EE6 /* SaveLocalLocationUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4656CBE529E7360B00600EE6 /* SaveLocalLocationUseCase.swift */; };
|
||||
46C3B7C629E5BF1500F8F57C /* LocationsListCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46C3B7C529E5BF1500F8F57C /* LocationsListCoordinator.swift */; };
|
||||
46C3B7CB29E5CD3200F8F57C /* LocationsListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46C3B7CA29E5CD3200F8F57C /* LocationsListViewModel.swift */; };
|
||||
46C3B7CF29E5D00E00F8F57C /* LocationsAddViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46C3B7CE29E5D00E00F8F57C /* LocationsAddViewModel.swift */; };
|
||||
@ -24,12 +23,12 @@
|
||||
46C3B7D829E5E55000F8F57C /* LocationsListCoordination.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46C3B7D729E5E55000F8F57C /* LocationsListCoordination.swift */; };
|
||||
46C3B7DC29E5ED2300F8F57C /* LocationsAddCoordination.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46C3B7DB29E5ED2300F8F57C /* LocationsAddCoordination.swift */; };
|
||||
46C3B7DE29E5ED2E00F8F57C /* LocationsAddCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46C3B7DD29E5ED2E00F8F57C /* LocationsAddCoordinator.swift */; };
|
||||
46DF736D29E82A1500AA6D21 /* UIApplication+Conformances.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46DF736C29E82A1500AA6D21 /* UIApplication+Conformances.swift */; };
|
||||
46EB331B29E1CE04001D5EAF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46EB331A29E1CE04001D5EAF /* AppDelegate.swift */; };
|
||||
46EB331F29E1CE04001D5EAF /* LocationsListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46EB331E29E1CE04001D5EAF /* LocationsListViewController.swift */; };
|
||||
46EB332729E1CE05001D5EAF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 46EB332629E1CE05001D5EAF /* Assets.xcassets */; };
|
||||
46EB332A29E1CE05001D5EAF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 46EB332829E1CE05001D5EAF /* LaunchScreen.storyboard */; };
|
||||
46EB334429E1D1EC001D5EAF /* Libraries in Frameworks */ = {isa = PBXBuildFile; productRef = 46EB334329E1D1EC001D5EAF /* Libraries */; };
|
||||
46EB334629E1D1F0001D5EAF /* Shared in Frameworks */ = {isa = PBXBuildFile; productRef = 46EB334529E1D1F0001D5EAF /* Shared */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@ -132,10 +131,9 @@
|
||||
02031EC829E60B29003C108C /* DependencyService+Keys.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DependencyService+Keys.swift"; sourceTree = "<group>"; };
|
||||
02031EE729E68D9B003C108C /* LoadingSpinnerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadingSpinnerView.swift; sourceTree = "<group>"; };
|
||||
02031EE929E6B495003C108C /* ErrorMessageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorMessageView.swift; sourceTree = "<group>"; };
|
||||
02031F0729E75EED003C108C /* SaveLocalLocationUseCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SaveLocalLocationUseCase.swift; sourceTree = "<group>"; };
|
||||
02031F0929E7645F003C108C /* Location+URLs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Location+URLs.swift"; sourceTree = "<group>"; };
|
||||
4656CBC129E6D33C00600EE6 /* LoadRemoteLocationsUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadRemoteLocationsUseCase.swift; sourceTree = "<group>"; };
|
||||
4656CBC729E6F2E400600EE6 /* LocationViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationViewCell.swift; sourceTree = "<group>"; };
|
||||
4656CBE529E7360B00600EE6 /* SaveLocalLocationUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SaveLocalLocationUseCase.swift; sourceTree = "<group>"; };
|
||||
46C3B7C529E5BF1500F8F57C /* LocationsListCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationsListCoordinator.swift; sourceTree = "<group>"; };
|
||||
46C3B7CA29E5CD3200F8F57C /* LocationsListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationsListViewModel.swift; sourceTree = "<group>"; };
|
||||
46C3B7CE29E5D00E00F8F57C /* LocationsAddViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationsAddViewModel.swift; sourceTree = "<group>"; };
|
||||
@ -144,7 +142,6 @@
|
||||
46C3B7D729E5E55000F8F57C /* LocationsListCoordination.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationsListCoordination.swift; sourceTree = "<group>"; };
|
||||
46C3B7DB29E5ED2300F8F57C /* LocationsAddCoordination.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationsAddCoordination.swift; sourceTree = "<group>"; };
|
||||
46C3B7DD29E5ED2E00F8F57C /* LocationsAddCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationsAddCoordinator.swift; sourceTree = "<group>"; };
|
||||
46DF736C29E82A1500AA6D21 /* UIApplication+Conformances.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIApplication+Conformances.swift"; sourceTree = "<group>"; };
|
||||
46EB325829E1BD5C001D5EAF /* Wikipedia.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Wikipedia.xcodeproj; path = Wikipedia/Wikipedia.xcodeproj; sourceTree = "<group>"; };
|
||||
46EB331829E1CE04001D5EAF /* Locations.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Locations.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
46EB331A29E1CE04001D5EAF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
@ -153,6 +150,7 @@
|
||||
46EB332929E1CE05001D5EAF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
46EB332B29E1CE05001D5EAF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
46EB333229E1CFD9001D5EAF /* Libraries */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Libraries; sourceTree = "<group>"; };
|
||||
46EB333429E1D158001D5EAF /* Shared */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Shared; sourceTree = "<group>"; };
|
||||
46EB334929E1D34B001D5EAF /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
|
||||
46EB334A29E1D3C0001D5EAF /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
@ -163,6 +161,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
46EB334429E1D1EC001D5EAF /* Libraries in Frameworks */,
|
||||
46EB334629E1D1F0001D5EAF /* Shared in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -181,8 +180,6 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
02031EC829E60B29003C108C /* DependencyService+Keys.swift */,
|
||||
02031F0929E7645F003C108C /* Location+URLs.swift */,
|
||||
46DF736C29E82A1500AA6D21 /* UIApplication+Conformances.swift */,
|
||||
);
|
||||
path = Extensions;
|
||||
sourceTree = "<group>";
|
||||
@ -228,7 +225,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4656CBC129E6D33C00600EE6 /* LoadRemoteLocationsUseCase.swift */,
|
||||
02031F0729E75EED003C108C /* SaveLocalLocationUseCase.swift */,
|
||||
4656CBE529E7360B00600EE6 /* SaveLocalLocationUseCase.swift */,
|
||||
);
|
||||
path = "Use Cases";
|
||||
sourceTree = "<group>";
|
||||
@ -272,6 +269,7 @@
|
||||
46EB325029E1BBD1001D5EAF = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
46EB333429E1D158001D5EAF /* Shared */,
|
||||
46EB325729E1BCAB001D5EAF /* Apps */,
|
||||
46EB334B29E1D3D2001D5EAF /* Others */,
|
||||
46EB32EE29E1CD20001D5EAF /* Products */,
|
||||
@ -385,6 +383,7 @@
|
||||
name = Locations;
|
||||
packageProductDependencies = (
|
||||
46EB334329E1D1EC001D5EAF /* Libraries */,
|
||||
46EB334529E1D1F0001D5EAF /* Shared */,
|
||||
);
|
||||
productName = Locations;
|
||||
productReference = 46EB331829E1CE04001D5EAF /* Locations.app */;
|
||||
@ -548,12 +547,10 @@
|
||||
02031EBF29E5F949003C108C /* LocationsAddViewModeling.swift in Sources */,
|
||||
4656CBC829E6F2E400600EE6 /* LocationViewCell.swift in Sources */,
|
||||
46C3B7DE29E5ED2E00F8F57C /* LocationsAddCoordinator.swift in Sources */,
|
||||
02031F0A29E7645F003C108C /* Location+URLs.swift in Sources */,
|
||||
02031F0829E75EF0003C108C /* SaveLocalLocationUseCase.swift in Sources */,
|
||||
4656CBE629E7360B00600EE6 /* SaveLocalLocationUseCase.swift in Sources */,
|
||||
02031EEA29E6B495003C108C /* ErrorMessageView.swift in Sources */,
|
||||
46C3B7DC29E5ED2300F8F57C /* LocationsAddCoordination.swift in Sources */,
|
||||
46C3B7D829E5E55000F8F57C /* LocationsListCoordination.swift in Sources */,
|
||||
46DF736D29E82A1500AA6D21 /* UIApplication+Conformances.swift in Sources */,
|
||||
46C3B7D629E5E50500F8F57C /* LocationsListViewModeling.swift in Sources */,
|
||||
4656CBC229E6D33C00600EE6 /* LoadRemoteLocationsUseCase.swift in Sources */,
|
||||
46C3B7CF29E5D00E00F8F57C /* LocationsAddViewModel.swift in Sources */,
|
||||
@ -786,6 +783,10 @@
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
productName = Libraries;
|
||||
};
|
||||
46EB334529E1D1F0001D5EAF /* Shared */ = {
|
||||
isa = XCSwiftPackageProductDependency;
|
||||
productName = Shared;
|
||||
};
|
||||
/* End XCSwiftPackageProductDependency section */
|
||||
};
|
||||
rootObject = 46EB325129E1BBD1001D5EAF /* Project object */;
|
||||
|
@ -1,77 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1430"
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "46EB331729E1CE04001D5EAF"
|
||||
BuildableName = "Locations.app"
|
||||
BlueprintName = "Locations"
|
||||
ReferencedContainer = "container:DeepLinking.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
shouldAutocreateTestPlan = "YES">
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "46EB331729E1CE04001D5EAF"
|
||||
BuildableName = "Locations.app"
|
||||
BlueprintName = "Locations"
|
||||
ReferencedContainer = "container:DeepLinking.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<BuildableProductRunnable
|
||||
runnableDebuggingMode = "0">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "46EB331729E1CE04001D5EAF"
|
||||
BuildableName = "Locations.app"
|
||||
BlueprintName = "Locations"
|
||||
ReferencedContainer = "container:DeepLinking.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
42
README.md
42
README.md
@ -1,44 +1,2 @@
|
||||
# Deep linking: Wikipedia
|
||||
|
||||
## App
|
||||
|
||||
The ultimate purpose of this application is to open the **Wikipedia** app in the right location when a user tap on one of the locations listed in the **Locations** app.
|
||||
|
||||
<center>
|
||||
<video controls>
|
||||
<source src="https://static.rock-n-code.com/mp4/deep-linking-app-demo.mp4" type="video/mp4">
|
||||
</video>
|
||||
</center>
|
||||
|
||||
Of course, to accomplish such goal the app therefore shows a list of locations (which are either fetched from a remote server or created by the user) and also, allows the user to add new location coordinates to this list by selecting them from a map.
|
||||
|
||||
## Features
|
||||
|
||||
In its current state, the **Locations** app does:
|
||||
|
||||
- [x] fetch locations from a remote server;
|
||||
- [x] handle `loading`, `loaded` and `error` states reactively when loading data;
|
||||
- [x] add locations manually to the list by obtaining locations from map;
|
||||
- [x] clean map of selected location if required;
|
||||
- [x] open the **Wikipedia** app when location is selected from a list;
|
||||
|
||||
While the **Wikipedia** app does:
|
||||
- [x] open a location in the right position on the map of *Places* screen from a deep link;
|
||||
|
||||
## Design
|
||||
|
||||
<object data="https://static.rock-n-code.com/pdf/deep-linking-app-design.pdf" type="application/pdf" width="100%" height="800px">
|
||||
<p>Unable to display a PDF file with some design considerations. Please <a href="https://static.rock-n-code.com/pdf/deep-linking-app-design.pdf">Download the file</a> instead.</p>
|
||||
</object>
|
||||
|
||||
## Implementation
|
||||
|
||||
This application was built as a `UIKit` application given that the [assignment](https://repo.rock-n-code.com/rock-n-code/deep-linking-assignment/wiki/Assignment) explicitedly indicates the app should target the `iOS` platform (**iPhone** app only, in this particular case) and also, because it disallow the use of the `SwiftUI` framework. It is out of discussion that the `UIKit` framework has been battle-tested for over a decade now and [Apple](https://apple.com) keeps updating and adding features to it on a regular basis. The imperative nature of the framework, which is based in implementing how the `iOS` platform UI components should work, is perfectly suitable the developer who want absolute control over the UI, at a cost of maintaining platform-specific, more complex codebases.
|
||||
|
||||
With regards to the choice of framework to built this app, it also comes the question of the type of architecture pattern to use in it: for this particular case, and given the limitations of how the view controllers have been defined in the Apple platforms, [MVVM](https://en.wikipedia.org/wiki/Model–view–viewmodel)-C is the chosen architecrture as it facilitates the separation between logic and UI components while also, decoupling the navigation logic by using coordinates (and routers) from them.
|
||||
|
||||
Now that design patterns have been mentioned, in this exercise some well-known patterns are being used in some degree. For example, the *Singleton* pattern is used to initialise the `PersistenceService` service in the `Persistence` library. Both public and internal *Interfaces* that either describe an entity or how the entity should behave are used throughout this codebase, as this pattern is essential to create decoupled components that can be easily plugged as dependencies whenever needed as this forces the developer to think about (single) responsibilites and, as a consequence, these components are also easy to test in isolation as mocks, stubs and spies can be easily created out of them. Last, but definitely not least, the *Use cases* are a pattern from Android that basically execute a function based on some given input, and provides an output after that particular function is finished. This pattern is particularly useful to encapsulate in a simple way some certain logic from view models.
|
||||
|
||||
This application was built with scalability in terms of the codebase in mind, which tries to address how this codebase could grow in a controllable, organised manner. For this very reason, this application uses the [Swift Package Manager](https://www.swift.org/package-manager/) (or simply **SwiftPM**) to define the `Core`, `Dependency`, `Persistence` and `Remote` libraries of the `Library` package, that the **Locations** target should use extensively. These libraries focus on a specific purpose, and they can be self-contained, like in the case of the `Persistence` library that contains its own **CoreData** data model definitons and respective assets inside. Packages could use 3rd party dependencies if needed. This approach forces the developer to think about actual separation of concerns, as the different dependencies are grouped as independent, reusable building blocks, and to move the code into the SPM packages out of the main app target, reducing compiling time and overall weight of the application.
|
||||
|
||||
As a (indirect) consequence for the use of **SwiftPM** packages, the [dependency injection](https://en.wikipedia.org/wiki/Dependency_injection) pattern comes into question. I implemented my own simple **DI** mechanism that uses extensively the dynamic property wrapper functionality in the last versions of the [Swift](https://www.swift.org) language rather than using a 3rd party dependency for this case.
|
||||
|
28
Shared/Package.swift
Normal file
28
Shared/Package.swift
Normal file
@ -0,0 +1,28 @@
|
||||
// swift-tools-version: 5.8
|
||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "Shared",
|
||||
products: [
|
||||
// Products define the executables and libraries a package produces, and make them visible to other packages.
|
||||
.library(
|
||||
name: "Shared",
|
||||
targets: ["Shared"]),
|
||||
],
|
||||
dependencies: [
|
||||
// Dependencies declare other packages that this package depends on.
|
||||
// .package(url: /* package url */, from: "1.0.0"),
|
||||
],
|
||||
targets: [
|
||||
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
|
||||
// Targets can depend on other targets in this package, and on products in packages this package depends on.
|
||||
.target(
|
||||
name: "Shared",
|
||||
dependencies: []),
|
||||
.testTarget(
|
||||
name: "SharedTests",
|
||||
dependencies: ["Shared"]),
|
||||
]
|
||||
)
|
6
Shared/Sources/Shared/Shared.swift
Normal file
6
Shared/Sources/Shared/Shared.swift
Normal file
@ -0,0 +1,6 @@
|
||||
public struct Shared {
|
||||
public private(set) var text = "Hello, World!"
|
||||
|
||||
public init() {
|
||||
}
|
||||
}
|
11
Shared/Tests/SharedTests/SharedTests.swift
Normal file
11
Shared/Tests/SharedTests/SharedTests.swift
Normal file
@ -0,0 +1,11 @@
|
||||
import XCTest
|
||||
@testable import Shared
|
||||
|
||||
final class SharedTests: XCTestCase {
|
||||
func testExample() throws {
|
||||
// This is an example of a functional test case.
|
||||
// Use XCTAssert and related functions to verify your tests produce the correct
|
||||
// results.
|
||||
XCTAssertEqual(Shared().text, "Hello, World!")
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user