Skip to content

Commit

Permalink
Merge branch 'update-connection-details-on-main-view-to-indicate-that…
Browse files Browse the repository at this point in the history
…-ios-775'
  • Loading branch information
pinkisemils committed Sep 6, 2024
2 parents 8953c78 + aab3dd7 commit b0b7db0
Showing 1 changed file with 32 additions and 9 deletions.
41 changes: 32 additions & 9 deletions ios/MullvadVPN/View controllers/Tunnel/TunnelControlView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,7 @@ final class TunnelControlView: UIView {

updateSecureLabel(tunnelState: tunnelState)
updateActionButtons(tunnelState: tunnelState)
if tunnelState.isSecured {
updateTunnelRelays(tunnelRelays: tunnelState.relays)
} else {
updateTunnelRelays(tunnelRelays: nil)
}
updateTunnelRelays(tunnelStatus: model.tunnelStatus)
}

func setAnimatingActivity(_ isAnimating: Bool) {
Expand Down Expand Up @@ -226,18 +222,45 @@ final class TunnelControlView: UIView {
connectButtonBlurView.isEnabled = shouldEnableButtons
}

private func updateTunnelRelays(tunnelRelays: SelectedRelays?) {
if let tunnelRelays {
private func updateTunnelRelays(tunnelStatus: TunnelStatus) {
let tunnelState = tunnelStatus.state
let observedState = tunnelStatus.observedState

if tunnelState.isSecured, let tunnelRelays = tunnelState.relays {
cityLabel.attributedText = attributedStringForLocation(
string: tunnelRelays.exit.location.city
)
countryLabel.attributedText = attributedStringForLocation(
string: tunnelRelays.exit.location.country
)

let exitName = tunnelRelays.exit.hostname
let entryName = tunnelRelays.entry?.hostname
let usingDaita = observedState.connectionState?.isDaitaEnabled == true

let connectedRelayName = if let entryName {
String(format: NSLocalizedString(
"CONNECT_PANEL_TITLE",
tableName: "Main",
value: "%@ via %@ \(usingDaita ? "using DAITA" : "")",
comment: ""
), exitName, entryName)
} else {
String(format: NSLocalizedString(
"CONNECT_PANEL_TITLE",
tableName: "Main",
value: "%@ \(usingDaita ? "using DAITA" : "")",
comment: ""
), exitName)
}

connectionPanel.isHidden = false
connectionPanel.connectedRelayName = tunnelRelays.exit
.hostname + "\(tunnelRelays.entry.flatMap { " via \($0.hostname)" } ?? "")"
connectionPanel.connectedRelayName = NSLocalizedString(
"CONNECT_PANEL_TITLE",
tableName: "Main",
value: connectedRelayName,
comment: ""
)
} else {
countryLabel.attributedText = attributedStringForLocation(string: " ")
cityLabel.attributedText = attributedStringForLocation(string: " ")
Expand Down

0 comments on commit b0b7db0

Please sign in to comment.