1
1
//
2
- // SelectLocationCoordinator .swift
2
+ // LocationCoordinator .swift
3
3
// MullvadVPN
4
4
//
5
5
// Created by pronebird on 29/01/2023.
@@ -13,7 +13,7 @@ import UIKit
13
13
14
14
import MullvadSettings
15
15
16
- class SelectLocationCoordinator : Coordinator , Presentable , Presenting , RelayCacheTrackerObserver {
16
+ class LocationCoordinator : Coordinator , Presentable , Presenting , RelayCacheTrackerObserver {
17
17
private let tunnelManager : TunnelManager
18
18
private let relayCacheTracker : RelayCacheTracker
19
19
private var cachedRelays : CachedRelays ?
@@ -24,10 +24,10 @@ class SelectLocationCoordinator: Coordinator, Presentable, Presenting, RelayCach
24
24
navigationController
25
25
}
26
26
27
- var selectLocationViewController : SelectLocationViewController ? {
27
+ var selectLocationViewController : LocationViewController ? {
28
28
return navigationController. viewControllers. first {
29
- $0 is SelectLocationViewController
30
- } as? SelectLocationViewController
29
+ $0 is LocationViewController
30
+ } as? LocationViewController
31
31
}
32
32
33
33
var relayFilter : RelayFilter {
@@ -39,7 +39,7 @@ class SelectLocationCoordinator: Coordinator, Presentable, Presenting, RelayCach
39
39
}
40
40
}
41
41
42
- var didFinish : ( ( SelectLocationCoordinator , RelayLocation ? ) -> Void ) ?
42
+ var didFinish : ( ( LocationCoordinator , [ RelayLocation ] ) -> Void ) ?
43
43
44
44
init (
45
45
navigationController: UINavigationController ,
@@ -52,22 +52,22 @@ class SelectLocationCoordinator: Coordinator, Presentable, Presenting, RelayCach
52
52
}
53
53
54
54
func start( ) {
55
- let selectLocationViewController = SelectLocationViewController ( )
55
+ let selectLocationViewController = LocationViewController ( )
56
56
57
- selectLocationViewController. didSelectRelay = { [ weak self] relay in
57
+ selectLocationViewController. didSelectRelays = { [ weak self] locations , customListId in
58
58
guard let self else { return }
59
59
60
60
var relayConstraints = tunnelManager. settings. relayConstraints
61
61
relayConstraints. locations = . only( RelayLocations (
62
- locations: [ relay ] ,
63
- customListId: nil
62
+ locations: locations ,
63
+ customListId: customListId
64
64
) )
65
65
66
66
tunnelManager. updateSettings ( [ . relayConstraints( relayConstraints) ] ) {
67
67
self . tunnelManager. startTunnel ( )
68
68
}
69
69
70
- didFinish ? ( self , relay )
70
+ didFinish ? ( self , locations )
71
71
}
72
72
73
73
selectLocationViewController. navigateToFilter = { [ weak self] in
@@ -91,7 +91,7 @@ class SelectLocationCoordinator: Coordinator, Presentable, Presenting, RelayCach
91
91
selectLocationViewController. didFinish = { [ weak self] in
92
92
guard let self else { return }
93
93
94
- didFinish ? ( self , nil )
94
+ didFinish ? ( self , [ ] )
95
95
}
96
96
97
97
relayCacheTracker. addObserver ( self )
@@ -101,8 +101,7 @@ class SelectLocationCoordinator: Coordinator, Presentable, Presenting, RelayCach
101
101
selectLocationViewController. setCachedRelays ( cachedRelays, filter: relayFilter)
102
102
}
103
103
104
- selectLocationViewController. relayLocation =
105
- tunnelManager. settings. relayConstraints. locations. value? . locations. first
104
+ selectLocationViewController. relayLocations = tunnelManager. settings. relayConstraints. locations. value
106
105
107
106
navigationController. pushViewController ( selectLocationViewController, animated: false )
108
107
}
0 commit comments