diff options
| author | Andrew Bulhak <andrew.bulhak@mullvad.net> | 2025-04-08 16:55:41 +0200 |
|---|---|---|
| committer | Bug Magnet <marco.nikic@mullvad.net> | 2025-04-09 16:22:50 +0200 |
| commit | 42bf4e153f896db1de5a369ca3fefa88f828b6a1 (patch) | |
| tree | 1c3aa3148434d2ffb97ef96f34a454b4c1910941 /ios | |
| parent | 9deb88512f898ed5dcfbf3a2dbedae55220c72a1 (diff) | |
| download | mullvadvpn-42bf4e153f896db1de5a369ca3fefa88f828b6a1.tar.xz mullvadvpn-42bf4e153f896db1de5a369ca3fefa88f828b6a1.zip | |
Display Obfuscation chip iff current connection state is obfuscated
Diffstat (limited to 'ios')
4 files changed, 31 insertions, 5 deletions
diff --git a/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/ChipView/ChipFeature.swift b/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/ChipView/ChipFeature.swift index 71b864bc85..5130d51764 100644 --- a/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/ChipView/ChipFeature.swift +++ b/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/ChipView/ChipFeature.swift @@ -6,6 +6,7 @@ // Copyright © 2025 Mullvad VPN AB. All rights reserved. // import MullvadSettings +import PacketTunnelCore import SwiftUI // Opting to use NSLocalizedString instead of LocalizedStringKey here in order @@ -69,12 +70,26 @@ struct MultihopFeature: ChipFeature { struct ObfuscationFeature: ChipFeature { let settings: LatestTunnelSettings + let state: ObservedState + + var actualObfuscationMethod: WireGuardObfuscationState { + state.connectionState.map { $0.obfuscationMethod } ?? .off + } var isEnabled: Bool { - settings.wireGuardObfuscation.state.isEnabled + actualObfuscationMethod != .off + } + + var isAutomatic: Bool { + settings.wireGuardObfuscation.state == .automatic } var name: String { + // This just currently says "Obfuscation". + // To add an automaticity indicator (a trailing " (automatic)" + // or a colour/border style or whatever), use the `isAutomatic` field. + // To say what type of obfuscation it is, + // we can look at `actualObfuscationMethod` NSLocalizedString( "FEATURE_INDICATORS_CHIP_OBFUSCATION", tableName: "FeatureIndicatorsChip", diff --git a/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/ConnectionViewComponentPreview.swift b/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/ConnectionViewComponentPreview.swift index 1dd83fc6cf..c773902f16 100644 --- a/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/ConnectionViewComponentPreview.swift +++ b/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/ConnectionViewComponentPreview.swift @@ -70,7 +70,8 @@ struct ConnectionViewComponentPreview<Content: View>: View { FeatureIndicatorsViewModel( tunnelSettings: tunnelSettings, ipOverrides: [], - tunnelState: connectedTunnelStatus.state + tunnelState: connectedTunnelStatus.state, + observedState: connectedTunnelStatus.observedState ), viewModel, $isExpanded diff --git a/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/FeatureIndicatorsViewModel.swift b/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/FeatureIndicatorsViewModel.swift index 39a18c987a..76f6d04423 100644 --- a/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/FeatureIndicatorsViewModel.swift +++ b/ios/MullvadVPN/View controllers/Tunnel/ConnectionView/FeatureIndicatorsViewModel.swift @@ -7,17 +7,25 @@ // import MullvadSettings +import PacketTunnelCore import SwiftUI class FeatureIndicatorsViewModel: ChipViewModelProtocol { @Published var tunnelSettings: LatestTunnelSettings @Published var ipOverrides: [IPOverride] @Published var tunnelState: TunnelState + @Published var observedState: ObservedState - init(tunnelSettings: LatestTunnelSettings, ipOverrides: [IPOverride], tunnelState: TunnelState) { + init( + tunnelSettings: LatestTunnelSettings, + ipOverrides: [IPOverride], + tunnelState: TunnelState, + observedState: ObservedState + ) { self.tunnelSettings = tunnelSettings self.ipOverrides = ipOverrides self.tunnelState = tunnelState + self.observedState = observedState } var chips: [ChipModel] { @@ -30,7 +38,7 @@ class FeatureIndicatorsViewModel: ChipViewModelProtocol { DaitaFeature(settings: tunnelSettings), QuantumResistanceFeature(settings: tunnelSettings), MultihopFeature(settings: tunnelSettings, state: tunnelState), - ObfuscationFeature(settings: tunnelSettings), + ObfuscationFeature(settings: tunnelSettings, state: observedState), DNSFeature(settings: tunnelSettings), IPOverrideFeature(overrides: ipOverrides), ] diff --git a/ios/MullvadVPN/View controllers/Tunnel/TunnelViewController.swift b/ios/MullvadVPN/View controllers/Tunnel/TunnelViewController.swift index bb6cebdc3c..5524ff5865 100644 --- a/ios/MullvadVPN/View controllers/Tunnel/TunnelViewController.swift +++ b/ios/MullvadVPN/View controllers/Tunnel/TunnelViewController.swift @@ -74,7 +74,8 @@ class TunnelViewController: UIViewController, RootContainment { indicatorsViewViewModel = FeatureIndicatorsViewModel( tunnelSettings: interactor.tunnelSettings, ipOverrides: interactor.ipOverrides, - tunnelState: tunnelState + tunnelState: tunnelState, + observedState: interactor.tunnelStatus.observedState ) connectionView = ConnectionView( @@ -100,6 +101,7 @@ class TunnelViewController: UIViewController, RootContainment { self?.connectionViewViewModel.update(tunnelStatus: tunnelStatus) self?.setTunnelState(tunnelStatus.state, animated: true) self?.indicatorsViewViewModel.tunnelState = tunnelStatus.state + self?.indicatorsViewViewModel.observedState = tunnelStatus.observedState self?.view.setNeedsLayout() } |
