diff options
| author | Andrew Bulhak <andrew.bulhak@mullvad.net> | 2025-01-15 15:19:41 +0100 |
|---|---|---|
| committer | Andrew Bulhak <andrew.bulhak@mullvad.net> | 2025-01-21 17:27:00 +0100 |
| commit | aa9751170117272a2182bc2aeeb460ef668b8362 (patch) | |
| tree | 3ac1a6cbe0d78239167cf926f08eff3fcc96152e | |
| parent | 0a59ba099a6307d2e33e9a046651ba4bbc44ba6c (diff) | |
| download | mullvadvpn-aa9751170117272a2182bc2aeeb460ef668b8362.tar.xz mullvadvpn-aa9751170117272a2182bc2aeeb460ef668b8362.zip | |
Put custom list name or (unfmtd) location name into connect button
| -rw-r--r-- | ios/MullvadVPN/View controllers/Tunnel/ConnectionView/ConnectionViewComponentPreview.swift | 4 | ||||
| -rw-r--r-- | ios/MullvadVPN/View controllers/Tunnel/ConnectionView/ConnectionViewViewModel.swift | 25 |
2 files changed, 26 insertions, 3 deletions
diff --git a/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/ConnectionViewComponentPreview.swift b/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/ConnectionViewComponentPreview.swift index cc24537f13..c6bf8a7e8d 100644 --- a/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/ConnectionViewComponentPreview.swift +++ b/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/ConnectionViewComponentPreview.swift @@ -37,7 +37,9 @@ struct ConnectionViewComponentPreview<Content: View>: View { isDaitaEnabled: true )), state: .connected(SelectedRelaysStub.selectedRelays, isPostQuantum: true, isDaita: true) - ) + ), + relayConstraints: RelayConstraints(), + customListRepository: CustomListRepository() ) var content: (FeatureIndicatorsViewModel, ConnectionViewViewModel, Binding<Bool>) -> Content diff --git a/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/ConnectionViewViewModel.swift b/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/ConnectionViewViewModel.swift index 96a47d5ab4..d01ee1be91 100644 --- a/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/ConnectionViewViewModel.swift +++ b/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/ConnectionViewViewModel.swift @@ -7,6 +7,8 @@ // import Combine +import MullvadSettings +import MullvadTypes import SwiftUI class ConnectionViewViewModel: ObservableObject { @@ -28,6 +30,9 @@ class ConnectionViewViewModel: ObservableObject { @Published var outgoingConnectionInfo: OutgoingConnectionInfo? @Published var showsActivityIndicator = false + let relayConstraints: RelayConstraints + let customListRepository: CustomListRepositoryProtocol + var combinedState: Publishers.CombineLatest< Published<TunnelStatus>.Publisher, Published<Bool>.Publisher @@ -43,8 +48,24 @@ class ConnectionViewViewModel: ObservableObject { } } - init(tunnelStatus: TunnelStatus) { + var connectionName: String? { + if case let .only(loc) = relayConstraints.exitLocations { + loc.customListSelection.flatMap { customListRepository.fetch(by: $0.listId)?.name } ?? loc.locations.first? + .stringRepresentation + } else { + "Somewhere" + } +// nil + } + + init( + tunnelStatus: TunnelStatus, + relayConstraints: RelayConstraints, + customListRepository: CustomListRepositoryProtocol + ) { self.tunnelStatus = tunnelStatus + self.relayConstraints = relayConstraints + self.customListRepository = customListRepository } func update(tunnelStatus: TunnelStatus) { @@ -139,7 +160,7 @@ extension ConnectionViewViewModel { var localizedTitleForSelectLocationButton: LocalizedStringKey { switch tunnelStatus.state { case .disconnecting, .pendingReconnect, .disconnected, .waitingForConnectivity(.noNetwork): - LocalizedStringKey("Select location") + LocalizedStringKey(connectionName ?? "Select location") case .connecting, .connected, .reconnecting, .waitingForConnectivity(.noConnection), .negotiatingEphemeralPeer, .error: LocalizedStringKey("Switch location") |
