summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBug Magnet <marco.nikic@mullvad.net>2024-05-14 11:55:15 +0200
committerBug Magnet <marco.nikic@mullvad.net>2024-05-14 11:55:15 +0200
commitbdbbc6249a25d72f057e3e1e2ca6bb661c7aafaa (patch)
treebdd21669efea10ebd0b5e228289fd6b84d8d3dce
parent7c94b962f33f068b73c4d0bb605057e3143f1df8 (diff)
parent7d392eb2d4a2dd9e007c6b31780e13e3b58f30dc (diff)
downloadmullvadvpn-bdbbc6249a25d72f057e3e1e2ca6bb661c7aafaa.tar.xz
mullvadvpn-bdbbc6249a25d72f057e3e1e2ca6bb661c7aafaa.zip
Merge branch 'location-node-cleanup'
-rw-r--r--ios/MullvadVPN/View controllers/SelectLocation/AllLocationDataSource.swift6
-rw-r--r--ios/MullvadVPN/View controllers/SelectLocation/LocationCell.swift25
-rw-r--r--ios/MullvadVPN/View controllers/SelectLocation/LocationNode.swift6
-rw-r--r--ios/MullvadVPNTests/MullvadVPN/View controllers/SelectLocation/LocationNodeTests.swift6
4 files changed, 21 insertions, 22 deletions
diff --git a/ios/MullvadVPN/View controllers/SelectLocation/AllLocationDataSource.swift b/ios/MullvadVPN/View controllers/SelectLocation/AllLocationDataSource.swift
index f57e980dea..578deeddd2 100644
--- a/ios/MullvadVPN/View controllers/SelectLocation/AllLocationDataSource.swift
+++ b/ios/MullvadVPN/View controllers/SelectLocation/AllLocationDataSource.swift
@@ -60,7 +60,7 @@ class AllLocationDataSource: LocationDataSourceProtocol {
) {
switch location {
case let .country(countryCode):
- let countryNode = CountryLocationNode(
+ let countryNode = LocationNode(
name: serverLocation.country,
code: LocationNode.combineNodeCodes([countryCode]),
locations: [location],
@@ -73,7 +73,7 @@ class AllLocationDataSource: LocationDataSourceProtocol {
}
case let .city(countryCode, cityCode):
- let cityNode = CityLocationNode(
+ let cityNode = LocationNode(
name: serverLocation.city,
code: LocationNode.combineNodeCodes([countryCode, cityCode]),
locations: [location],
@@ -88,7 +88,7 @@ class AllLocationDataSource: LocationDataSourceProtocol {
}
case let .hostname(countryCode, cityCode, hostCode):
- let hostNode = HostLocationNode(
+ let hostNode = LocationNode(
name: relay.hostname,
code: LocationNode.combineNodeCodes([hostCode]),
locations: [location],
diff --git a/ios/MullvadVPN/View controllers/SelectLocation/LocationCell.swift b/ios/MullvadVPN/View controllers/SelectLocation/LocationCell.swift
index e777ca5e21..a51cebf59c 100644
--- a/ios/MullvadVPN/View controllers/SelectLocation/LocationCell.swift
+++ b/ios/MullvadVPN/View controllers/SelectLocation/LocationCell.swift
@@ -316,18 +316,23 @@ extension LocationCell {
checkboxButton.accessibilityIdentifier = .customListLocationCheckmarkButton
checkboxButton.isSelected = item.isSelected
checkboxButton.tintColor = item.isSelected ? .successColor : .white
+ accessibilityValue = item.node.code
- if item.node is CountryLocationNode {
- accessibilityIdentifier = .countryLocationCell
- accessibilityValue = item.node.code
- } else if item.node is CityLocationNode {
- accessibilityIdentifier = .cityLocationCell
- accessibilityValue = item.node.code
- } else if item.node is HostLocationNode {
- accessibilityIdentifier = .relayLocationCell
- accessibilityValue = item.node.code
- } else if item.node is CustomListLocationNode {
+ if item.node is CustomListLocationNode {
accessibilityIdentifier = .customListLocationCell
+ } else {
+ // Only custom list nodes have more than one location. Therefore checking first
+ // location here is fine.
+ switch item.node.locations.first {
+ case .country:
+ accessibilityIdentifier = .countryLocationCell
+ case .city:
+ accessibilityIdentifier = .cityLocationCell
+ case .hostname:
+ accessibilityIdentifier = .relayLocationCell
+ case nil:
+ break
+ }
}
setBehavior(behavior)
diff --git a/ios/MullvadVPN/View controllers/SelectLocation/LocationNode.swift b/ios/MullvadVPN/View controllers/SelectLocation/LocationNode.swift
index 4534ac4d8e..8a43493f0b 100644
--- a/ios/MullvadVPN/View controllers/SelectLocation/LocationNode.swift
+++ b/ios/MullvadVPN/View controllers/SelectLocation/LocationNode.swift
@@ -168,9 +168,3 @@ class CustomListLocationNode: LocationNode {
)
}
}
-
-class CountryLocationNode: LocationNode {}
-
-class CityLocationNode: LocationNode {}
-
-class HostLocationNode: LocationNode {}
diff --git a/ios/MullvadVPNTests/MullvadVPN/View controllers/SelectLocation/LocationNodeTests.swift b/ios/MullvadVPNTests/MullvadVPN/View controllers/SelectLocation/LocationNodeTests.swift
index 9495129d00..c1ba7c57be 100644
--- a/ios/MullvadVPNTests/MullvadVPN/View controllers/SelectLocation/LocationNodeTests.swift
+++ b/ios/MullvadVPNTests/MullvadVPN/View controllers/SelectLocation/LocationNodeTests.swift
@@ -16,9 +16,9 @@ class LocationNodeTests: XCTestCase {
showsChildren: false,
customList: CustomList(name: "List", locations: [])
)
- let countryNode = CountryLocationNode(name: "Country", code: "country", showsChildren: false)
- let cityNode = CityLocationNode(name: "City", code: "city", showsChildren: false)
- let hostNode = HostLocationNode(name: "Host", code: "host", showsChildren: false)
+ let countryNode = LocationNode(name: "Country", code: "country", showsChildren: false)
+ let cityNode = LocationNode(name: "City", code: "city", showsChildren: false)
+ let hostNode = LocationNode(name: "Host", code: "host", showsChildren: false)
override func setUp() async throws {
createNodeTree()