Skip to content

Commit

Permalink
Add toggle in connection view
Browse files Browse the repository at this point in the history
  • Loading branch information
rablador committed Dec 20, 2024
1 parent 0ce0ca6 commit f9a3da3
Show file tree
Hide file tree
Showing 27 changed files with 570 additions and 187 deletions.
36 changes: 36 additions & 0 deletions ios/MullvadMockData/MullvadREST/SelectedRelaysStub+Stubs.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// SelectedRelaysStub+Stubs.swift
// MullvadVPN
//
// Created by Jon Petersson on 2024-12-18.
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
//

import MullvadREST
import MullvadTypes
import Network

public struct SelectedRelaysStub {
public static let selectedRelays = SelectedRelays(
entry: nil,
exit: SelectedRelay(
endpoint: MullvadEndpoint(
ipv4Relay: IPv4Endpoint(ip: .loopback, port: 42),
ipv6Relay: IPv6Endpoint(ip: .loopback, port: 42),
ipv4Gateway: IPv4Address.loopback,
ipv6Gateway: IPv6Address.loopback,
publicKey: Data()
),
hostname: "se-got-wg-001",
location: Location(
country: "Sweden",
countryCode: "se",
city: "Gothenburg",
cityCode: "got",
latitude: 42,
longitude: 42
)
),
retryAttempt: 0
)
}
7 changes: 2 additions & 5 deletions ios/MullvadRustRuntimeTests/MullvadPostQuantum+Stubs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import NetworkExtension
@testable import PacketTunnelCore
@testable import WireGuardKitTypes

// swiftlint:disable function_parameter_count
class NWTCPConnectionStub: NWTCPConnection {
var _isViable = false
override var isViable: Bool {
Expand All @@ -31,8 +30,8 @@ class TunnelProviderStub: TunnelProvider {
0
}

func wgFunctions() -> MullvadTypes.WgFuncPointers {
return MullvadTypes.WgFuncPointers(
func wgFunctions() -> WgFunctionPointers {
return WgFunctionPointers(
open: { _, _, _ in return 0 },
close: { _, _ in return 0 },
receive: { _, _, _, _ in return 0 },
Expand Down Expand Up @@ -104,5 +103,3 @@ class SuccessfulNegotiatorStub: EphemeralPeerNegotiating {
onCancelKeyNegotiation?()
}
}

// swiftlint:enable function_parameter_count
24 changes: 12 additions & 12 deletions ios/MullvadVPN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,8 @@
7AF10EB42ADE85BC00C090B9 /* RelayFilterCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF10EB32ADE85BC00C090B9 /* RelayFilterCoordinator.swift */; };
7AF36A9A2CA2964200E1D497 /* AnyIPAddressTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF36A992CA2964000E1D497 /* AnyIPAddressTests.swift */; };
7AF6E5F02A95051E00F2679D /* RouterBlockDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF6E5EF2A95051E00F2679D /* RouterBlockDelegate.swift */; };
7AF84F462D12C5B000C72690 /* SelectedRelaysStub+Stubs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF84F452D12C59F00C72690 /* SelectedRelaysStub+Stubs.swift */; };
7AF84F482D12C9D400C72690 /* ConnectionViewPreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF84F472D12C9CF00C72690 /* ConnectionViewPreview.swift */; };
7AF9BE882A30C62100DBFEDB /* SelectableSettingsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A1A264A2A29D65E00B978AA /* SelectableSettingsCell.swift */; };
7AF9BE8C2A321D1F00DBFEDB /* RelayFilter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF9BE8A2A321BEF00DBFEDB /* RelayFilter.swift */; };
7AF9BE8E2A331C7B00DBFEDB /* RelayFilterViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AF9BE8D2A331C7B00DBFEDB /* RelayFilterViewModel.swift */; };
Expand Down Expand Up @@ -1003,7 +1005,7 @@
F0B0E6972AFE6E7E001DC66B /* XCTest+Async.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0B0E6962AFE6E7E001DC66B /* XCTest+Async.swift */; };
F0B495762D02025200CFEC2A /* ChipContainerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0B495752D02025200CFEC2A /* ChipContainerView.swift */; };
F0B495782D02038B00CFEC2A /* ChipViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0B495772D02038B00CFEC2A /* ChipViewModelProtocol.swift */; };
F0B4957A2D02F49200CFEC2A /* ChipFeatures.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0B495792D02F41F00CFEC2A /* ChipFeatures.swift */; };
F0B4957A2D02F49200CFEC2A /* ChipFeature.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0B495792D02F41F00CFEC2A /* ChipFeature.swift */; };
F0B4957C2D03154200CFEC2A /* FeatureIndicatorsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0B4957B2D03154200CFEC2A /* FeatureIndicatorsView.swift */; };
F0B894EF2BF751C500817A42 /* RelayWithLocation.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0B894EE2BF751C500817A42 /* RelayWithLocation.swift */; };
F0B894F12BF751E300817A42 /* RelayWithDistance.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0B894F02BF751E300817A42 /* RelayWithDistance.swift */; };
Expand Down Expand Up @@ -2022,6 +2024,8 @@
7AF10EB32ADE85BC00C090B9 /* RelayFilterCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RelayFilterCoordinator.swift; sourceTree = "<group>"; };
7AF36A992CA2964000E1D497 /* AnyIPAddressTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnyIPAddressTests.swift; sourceTree = "<group>"; };
7AF6E5EF2A95051E00F2679D /* RouterBlockDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RouterBlockDelegate.swift; sourceTree = "<group>"; };
7AF84F452D12C59F00C72690 /* SelectedRelaysStub+Stubs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SelectedRelaysStub+Stubs.swift"; sourceTree = "<group>"; };
7AF84F472D12C9CF00C72690 /* ConnectionViewPreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionViewPreview.swift; sourceTree = "<group>"; };
7AF9BE8A2A321BEF00DBFEDB /* RelayFilter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayFilter.swift; sourceTree = "<group>"; };
7AF9BE8D2A331C7B00DBFEDB /* RelayFilterViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayFilterViewModel.swift; sourceTree = "<group>"; };
7AF9BE8F2A39F26000DBFEDB /* Collection+Sorting.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Collection+Sorting.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2249,7 +2253,7 @@
F0B0E6962AFE6E7E001DC66B /* XCTest+Async.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCTest+Async.swift"; sourceTree = "<group>"; };
F0B495752D02025200CFEC2A /* ChipContainerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChipContainerView.swift; sourceTree = "<group>"; };
F0B495772D02038B00CFEC2A /* ChipViewModelProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChipViewModelProtocol.swift; sourceTree = "<group>"; };
F0B495792D02F41F00CFEC2A /* ChipFeatures.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChipFeatures.swift; sourceTree = "<group>"; };
F0B495792D02F41F00CFEC2A /* ChipFeature.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChipFeature.swift; sourceTree = "<group>"; };
F0B4957B2D03154200CFEC2A /* FeatureIndicatorsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeatureIndicatorsView.swift; sourceTree = "<group>"; };
F0B894EE2BF751C500817A42 /* RelayWithLocation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayWithLocation.swift; sourceTree = "<group>"; };
F0B894F02BF751E300817A42 /* RelayWithDistance.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayWithDistance.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3638,7 +3642,6 @@
A9D9A4C12C36D53C004088DD /* MullvadRustRuntimeTests */,
58CE5E61224146200008646E /* Products */,
584F991F2902CBDD001F858D /* Frameworks */,
7A0EAE982D01B29E00D3EB8B /* Recovered References */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -3939,13 +3942,6 @@
path = Edit;
sourceTree = "<group>";
};
7A0EAE982D01B29E00D3EB8B /* Recovered References */ = {
isa = PBXGroup;
children = (
);
name = "Recovered References";
sourceTree = "<group>";
};
7A2960F72A964A3500389B82 /* Alert */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -4082,8 +4078,9 @@
children = (
F0ADF1CF2D01B50B00299F09 /* ChipView */,
7AFBE3862D084C96002335FC /* ActivityIndicator.swift */,
F0B495792D02F41F00CFEC2A /* ChipFeatures.swift */,
F0B495792D02F41F00CFEC2A /* ChipFeature.swift */,
7AA130982CFF365A00640DF9 /* ConnectionView.swift */,
7AF84F472D12C9CF00C72690 /* ConnectionViewPreview.swift */,
7A0EAEA32D06DF8200D3EB8B /* ConnectionViewViewModel.swift */,
F0B4957B2D03154200CFEC2A /* FeatureIndicatorsView.swift */,
F0ADF1D22D01B6B400299F09 /* FeatureIndicatorsViewModel.swift */,
Expand Down Expand Up @@ -4396,6 +4393,7 @@
F0ACE32E2BE4EA8B006D5333 /* MockProxyFactory.swift */,
58FE25EF2AA77664003D1918 /* RelaySelectorStub.swift */,
A900E9B92ACC5D0600C95F67 /* RESTRequestExecutor+Stubs.swift */,
7AF84F452D12C59F00C72690 /* SelectedRelaysStub+Stubs.swift */,
);
path = MullvadREST;
sourceTree = "<group>";
Expand Down Expand Up @@ -5935,6 +5933,7 @@
7A27E3CB2CAE861D0088BCFF /* SettingsViewModel.swift in Sources */,
588527B2276B3F0700BAA373 /* LoadTunnelConfigurationOperation.swift in Sources */,
7A9F29392CABFAFC005F2089 /* InfoHeaderView.swift in Sources */,
7AF84F482D12C9D400C72690 /* ConnectionViewPreview.swift in Sources */,
58DFF7D22B0256A300F864E0 /* MarkdownStylingOptions.swift in Sources */,
5867770E29096984006F721F /* OutOfTimeInteractor.swift in Sources */,
F03580252A13842C00E5DAFD /* IncreasedHitButton.swift in Sources */,
Expand Down Expand Up @@ -6130,7 +6129,7 @@
588D7EDE2AF3A585005DF40A /* ListAccessMethodItem.swift in Sources */,
5827B0B02B0F4CCD00CCBBA1 /* ListAccessMethodViewControllerDelegate.swift in Sources */,
588D7EE02AF3A595005DF40A /* ListAccessMethodInteractor.swift in Sources */,
F0B4957A2D02F49200CFEC2A /* ChipFeatures.swift in Sources */,
F0B4957A2D02F49200CFEC2A /* ChipFeature.swift in Sources */,
58607A4D2947287800BC467D /* AccountExpiryInAppNotificationProvider.swift in Sources */,
7A8A18FD2CE4BE8D000BCB5B /* CustomToggleStyle.swift in Sources */,
58C8191829FAA2C400DEB1B4 /* NotificationConfiguration.swift in Sources */,
Expand Down Expand Up @@ -6514,6 +6513,7 @@
F0ACE3332BE516F1006D5333 /* RESTRequestExecutor+Stubs.swift in Sources */,
F0ACE32D2BE4E784006D5333 /* AccountMock.swift in Sources */,
7A52F96A2C1735AE00B133B9 /* RelaySelectorStub.swift in Sources */,
7AF84F462D12C5B000C72690 /* SelectedRelaysStub+Stubs.swift in Sources */,
F03A69F72C2AD2D6000E2E7E /* TimeInterval+Timeout.swift in Sources */,
F0ACE32F2BE4EA8B006D5333 /* MockProxyFactory.swift in Sources */,
);
Expand Down
5 changes: 3 additions & 2 deletions ios/MullvadVPN/Classes/AccessbilityIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public enum AccessibilityIdentifier: Equatable {
case purchaseButton
case redeemVoucherButton
case restorePurchasesButton
case secureConnectionButton
case connectButton
case selectLocationButton
case closeSelectLocationButton
case settingsButton
Expand Down Expand Up @@ -132,7 +132,7 @@ public enum AccessibilityIdentifier: Equatable {
case selectLocationTableView
case settingsTableView
case vpnSettingsTableView
case tunnelControlView
case connectionView
case problemReportView
case problemReportSubmittedView
case revokedDeviceView
Expand All @@ -156,6 +156,7 @@ public enum AccessibilityIdentifier: Equatable {
case logOutSpinnerAlertView
case connectionPanelInAddressRow
case connectionPanelOutAddressRow
case connectionPanelOutIpv6AddressRow
case customSwitch
case customWireGuardPortTextField
case dnsContentBlockersHeaderView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import UIKit
enum HeaderBarStyle {
case transparent, `default`, unsecured, secured

fileprivate func backgroundColor() -> UIColor {
func backgroundColor() -> UIColor {
switch self {
case .transparent:
return UIColor.clear
Expand Down
4 changes: 2 additions & 2 deletions ios/MullvadVPN/Coordinators/TunnelCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import UIKit

class TunnelCoordinator: Coordinator, Presenting {
private let tunnelManager: TunnelManager
private let controller: TunnelViewController
private let controller: FI_TunnelViewController

private var tunnelObserver: TunnelObserver?

Expand All @@ -39,7 +39,7 @@ class TunnelCoordinator: Coordinator, Presenting {
ipOverrideRepository: ipOverrideRepository
)

controller = TunnelViewController(interactor: interactor)
controller = FI_TunnelViewController(interactor: interactor)

super.init()

Expand Down
6 changes: 5 additions & 1 deletion ios/MullvadVPN/Extensions/String+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright © 2020 Mullvad VPN AB. All rights reserved.
//

import Foundation
import UIKit

extension String {
Expand All @@ -19,4 +18,9 @@ extension String {
return (0 ..< resultCount)
.map { dropFirst($0 * length).prefix(length) }
}

func width(using font: UIFont) -> CGFloat {
let fontAttributes = [NSAttributedString.Key.font: font]
return self.size(withAttributes: fontAttributes).width
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "IconReload.pdf",
"filename" : "icon-reload.svg",
"idiom" : "universal"
}
],
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
//
// ChipFeatures.swift
// ChipFeature.swift
// MullvadVPN
//
// Created by Mojgan on 2024-12-06.
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
//
import Foundation
import MullvadSettings
import SwiftUI

protocol ChipFeature {
var isEnabled: Bool { get }
var name: LocalizedStringKey { get }
var name: String { get }
}

struct DaitaFeature: ChipFeature {
Expand All @@ -21,8 +20,8 @@ struct DaitaFeature: ChipFeature {
settings.daita.daitaState.isEnabled
}

var name: LocalizedStringKey {
LocalizedStringKey("DAITA")
var name: String {
String("DAITA")
}
}

Expand All @@ -32,8 +31,8 @@ struct QuantumResistanceFeature: ChipFeature {
settings.tunnelQuantumResistance.isEnabled
}

var name: LocalizedStringKey {
LocalizedStringKey("Quantum resistance")
var name: String {
String("Quantum resistance")
}
}

Expand All @@ -43,8 +42,8 @@ struct MultihopFeature: ChipFeature {
settings.tunnelMultihopState.isEnabled
}

var name: LocalizedStringKey {
LocalizedStringKey("Multihop")
var name: String {
String("Multihop")
}
}

Expand All @@ -55,8 +54,8 @@ struct ObfuscationFeature: ChipFeature {
settings.wireGuardObfuscation.state.isEnabled
}

var name: LocalizedStringKey {
LocalizedStringKey("Obfuscation")
var name: String {
String("Obfuscation")
}
}

Expand All @@ -67,11 +66,11 @@ struct DNSFeature: ChipFeature {
settings.dnsSettings.enableCustomDNS || !settings.dnsSettings.blockingOptions.isEmpty
}

var name: LocalizedStringKey {
var name: String {
if !settings.dnsSettings.blockingOptions.isEmpty {
return LocalizedStringKey("DNS content blockers")
return String("DNS content blockers")
}
return LocalizedStringKey("Custom DNS")
return String("Custom DNS")
}
}

Expand All @@ -82,7 +81,7 @@ struct IPOverrideFeature: ChipFeature {
!overrides.isEmpty
}

var name: LocalizedStringKey {
LocalizedStringKey("Server IP override")
var name: String {
String("Server IP override")
}
}
Loading

0 comments on commit f9a3da3

Please sign in to comment.