Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add info modals to default access methods screens #6905

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ public struct AccessMethodRepositoryStub: AccessMethodRepositoryDataSource {
public func fetchLastReachable() -> PersistentAccessMethod {
directAccess
}

public func infoHeaderConfig(for id: UUID) -> InfoHeaderConfig? {
nil
}
}
10 changes: 7 additions & 3 deletions ios/MullvadSettings/AccessMethodRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,28 @@ import MullvadLogging
import MullvadTypes

public class AccessMethodRepository: AccessMethodRepositoryProtocol {
public static let directId = UUID(uuidString: "C9DB7457-2A55-42C3-A926-C07F82131994")!
public static let bridgeId = UUID(uuidString: "8586E75A-CA7B-4432-B70D-EE65F3F95084")!
public static let encryptedDNSId = UUID(uuidString: "831CB1F8-1829-42DD-B9DC-82902F298EC0")!

private let logger = Logger(label: "AccessMethodRepository")

private let direct = PersistentAccessMethod(
id: UUID(uuidString: "C9DB7457-2A55-42C3-A926-C07F82131994")!,
id: AccessMethodRepository.directId,
name: "Direct",
isEnabled: true,
proxyConfiguration: .direct
)

private let bridge = PersistentAccessMethod(
id: UUID(uuidString: "8586E75A-CA7B-4432-B70D-EE65F3F95084")!,
id: AccessMethodRepository.bridgeId,
name: "Mullvad bridges",
isEnabled: true,
proxyConfiguration: .bridges
)

private let encryptedDNS = PersistentAccessMethod(
id: UUID(uuidString: "831CB1F8-1829-42DD-B9DC-82902F298EC0")!,
id: AccessMethodRepository.encryptedDNSId,
name: "Encrypted DNS proxy",
isEnabled: true,
proxyConfiguration: .encryptedDNS
Expand Down
17 changes: 17 additions & 0 deletions ios/MullvadSettings/InfoHeaderConfig.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// InfoHeaderConfig.swift
// MullvadVPN
//
// Created by Jon Petersson on 2024-10-01.
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
//

public struct InfoHeaderConfig {
public let body: String
public let link: String

public init(body: String, link: String) {
self.body = body
self.link = link
}
}
19 changes: 19 additions & 0 deletions ios/MullvadSettings/InfoModalConfig.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// InfoModalConfig.swift
// MullvadVPN
//
// Created by Jon Petersson on 2024-10-02.
// Copyright © 2024 Mullvad VPN AB. All rights reserved.
//

public struct InfoModalConfig {
public let header: String
public let preamble: String
public let body: [String]

public init(header: String, preamble: String, body: [String]) {
self.header = header
self.preamble = preamble
self.body = body
}
}
22 changes: 13 additions & 9 deletions ios/MullvadVPN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@
58EF581125D69DB400AEBA94 /* StatusImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58EF581025D69DB400AEBA94 /* StatusImageView.swift */; };
58EF87572B16330B00C098B2 /* ProxyConfigurationTester.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58EF87562B16330B00C098B2 /* ProxyConfigurationTester.swift */; };
58EF875D2B1638BF00C098B2 /* ProxyConfigurationTesterProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58EF875C2B1638BF00C098B2 /* ProxyConfigurationTesterProtocol.swift */; };
58EFC76A2AFAC3B800E9F4CB /* ListAccessMethodHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58EFC7692AFAC3B800E9F4CB /* ListAccessMethodHeaderView.swift */; };
58EFC76E2AFB3BDA00E9F4CB /* ListAccessMethodCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58EFC76D2AFB3BDA00E9F4CB /* ListAccessMethodCoordinator.swift */; };
58EFC7712AFB45E500E9F4CB /* SettingsChildCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58EFC7702AFB45E500E9F4CB /* SettingsChildCoordinator.swift */; };
58EFC7752AFB4CEF00E9F4CB /* AboutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58EFC7742AFB4CEF00E9F4CB /* AboutViewController.swift */; };
Expand Down Expand Up @@ -466,7 +465,6 @@
7A1A26492A29D48A00B978AA /* RelayFilterCellFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A1A26482A29D48A00B978AA /* RelayFilterCellFactory.swift */; };
7A21DACF2A30AA3700A787A9 /* UITextField+Appearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A21DACE2A30AA3700A787A9 /* UITextField+Appearance.swift */; };
7A28826A2BA8336600FD9F20 /* VPNSettingsCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A2882692BA8336600FD9F20 /* VPNSettingsCoordinator.swift */; };
7A28826D2BAAC9DE00FD9F20 /* IPOverrideHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A28826C2BAAC9DE00FD9F20 /* IPOverrideHeaderView.swift */; };
7A2960F62A963F7500389B82 /* AlertCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A2960F52A963F7500389B82 /* AlertCoordinator.swift */; };
7A2960FD2A964BB700389B82 /* AlertPresentation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A2960FC2A964BB700389B82 /* AlertPresentation.swift */; };
7A307AD92A8CD8DA0017618B /* Duration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A307AD82A8CD8DA0017618B /* Duration.swift */; };
Expand Down Expand Up @@ -573,6 +571,9 @@
7A9CCCC22A96302800DD6A34 /* SafariCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A9CCCB02A96302800DD6A34 /* SafariCoordinator.swift */; };
7A9CCCC32A96302800DD6A34 /* ApplicationCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A9CCCB12A96302800DD6A34 /* ApplicationCoordinator.swift */; };
7A9CCCC42A96302800DD6A34 /* TunnelCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A9CCCB22A96302800DD6A34 /* TunnelCoordinator.swift */; };
7A9F29392CABFAFC005F2089 /* InfoHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A9F29382CABFAEC005F2089 /* InfoHeaderView.swift */; };
7A9F293B2CAC4443005F2089 /* InfoHeaderConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A9F293A2CAC4420005F2089 /* InfoHeaderConfig.swift */; };
7A9F293D2CAD2FD5005F2089 /* InfoModalConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A9F293C2CAD2FCF005F2089 /* InfoModalConfig.swift */; };
7A9FA1422A2E3306000B728D /* CheckboxView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A9FA1412A2E3306000B728D /* CheckboxView.swift */; };
7A9FA1442A2E3FE5000B728D /* CheckableSettingsCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A9FA1432A2E3FE5000B728D /* CheckableSettingsCell.swift */; };
7AA513862BC91C6B00D081A4 /* LogRotationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AA513852BC91C6B00D081A4 /* LogRotationTests.swift */; };
Expand Down Expand Up @@ -1739,7 +1740,6 @@
58EF87562B16330B00C098B2 /* ProxyConfigurationTester.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProxyConfigurationTester.swift; sourceTree = "<group>"; };
58EF875A2B16385400C098B2 /* AccessMethodRepositoryProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessMethodRepositoryProtocol.swift; sourceTree = "<group>"; };
58EF875C2B1638BF00C098B2 /* ProxyConfigurationTesterProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProxyConfigurationTesterProtocol.swift; sourceTree = "<group>"; };
58EFC7692AFAC3B800E9F4CB /* ListAccessMethodHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListAccessMethodHeaderView.swift; sourceTree = "<group>"; };
58EFC76D2AFB3BDA00E9F4CB /* ListAccessMethodCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListAccessMethodCoordinator.swift; sourceTree = "<group>"; };
58EFC7702AFB45E500E9F4CB /* SettingsChildCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsChildCoordinator.swift; sourceTree = "<group>"; };
58EFC7742AFB4CEF00E9F4CB /* AboutViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1796,7 +1796,6 @@
7A1A264A2A29D65E00B978AA /* SelectableSettingsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectableSettingsCell.swift; sourceTree = "<group>"; };
7A21DACE2A30AA3700A787A9 /* UITextField+Appearance.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UITextField+Appearance.swift"; sourceTree = "<group>"; };
7A2882692BA8336600FD9F20 /* VPNSettingsCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VPNSettingsCoordinator.swift; sourceTree = "<group>"; };
7A28826C2BAAC9DE00FD9F20 /* IPOverrideHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IPOverrideHeaderView.swift; sourceTree = "<group>"; };
7A2960F52A963F7500389B82 /* AlertCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertCoordinator.swift; sourceTree = "<group>"; };
7A2960FC2A964BB700389B82 /* AlertPresentation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlertPresentation.swift; sourceTree = "<group>"; };
7A307AD82A8CD8DA0017618B /* Duration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Duration.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1889,6 +1888,9 @@
7A9CCCB02A96302800DD6A34 /* SafariCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SafariCoordinator.swift; sourceTree = "<group>"; };
7A9CCCB12A96302800DD6A34 /* ApplicationCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApplicationCoordinator.swift; sourceTree = "<group>"; };
7A9CCCB22A96302800DD6A34 /* TunnelCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TunnelCoordinator.swift; sourceTree = "<group>"; };
7A9F29382CABFAEC005F2089 /* InfoHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoHeaderView.swift; sourceTree = "<group>"; };
7A9F293A2CAC4420005F2089 /* InfoHeaderConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoHeaderConfig.swift; sourceTree = "<group>"; };
7A9F293C2CAD2FCF005F2089 /* InfoModalConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoModalConfig.swift; sourceTree = "<group>"; };
7A9FA1412A2E3306000B728D /* CheckboxView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxView.swift; sourceTree = "<group>"; };
7A9FA1432A2E3FE5000B728D /* CheckableSettingsCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckableSettingsCell.swift; sourceTree = "<group>"; };
7AA513852BC91C6B00D081A4 /* LogRotationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogRotationTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2901,6 +2903,7 @@
5892A45D265FABFF00890742 /* EmptyTableViewHeaderFooterView.swift */,
58FD5BF32428C67600112C88 /* InAppPurchaseButton.swift */,
F03580242A13842C00E5DAFD /* IncreasedHitButton.swift */,
7A9F29382CABFAEC005F2089 /* InfoHeaderView.swift */,
7A5869942B32E9C700640D27 /* LinkButton.swift */,
58F19E34228C15BA00C7710B /* SpinnerActivityIndicatorView.swift */,
E1FD0DF428AA7CE400299DB4 /* StatusActivityView.swift */,
Expand Down Expand Up @@ -3301,6 +3304,8 @@
F0C13FE32C64F7CB00BD087D /* DAITASettings.swift */,
A92ECC2B2A7803A50052F1B1 /* DeviceState.swift */,
580F8B8528197958002E0998 /* DNSSettings.swift */,
7A9F293A2CAC4420005F2089 /* InfoHeaderConfig.swift */,
7A9F293C2CAD2FCF005F2089 /* InfoModalConfig.swift */,
7A5869B22B5697AC00640D27 /* IPOverride.swift */,
7A5869BA2B56EE9500640D27 /* IPOverrideRepository.swift */,
06410DFD292CE18F00AFC18C /* KeychainSettingsStore.swift */,
Expand Down Expand Up @@ -3569,7 +3574,6 @@
isa = PBXGroup;
children = (
58EFC76D2AFB3BDA00E9F4CB /* ListAccessMethodCoordinator.swift */,
58EFC7692AFAC3B800E9F4CB /* ListAccessMethodHeaderView.swift */,
588D7EDF2AF3A595005DF40A /* ListAccessMethodInteractor.swift */,
588D7EDB2AF3A55E005DF40A /* ListAccessMethodInteractorProtocol.swift */,
588D7EDD2AF3A585005DF40A /* ListAccessMethodItem.swift */,
Expand Down Expand Up @@ -3760,14 +3764,14 @@
58FF9FDE2B075AA700E4C97D /* Edit */ = {
isa = PBXGroup;
children = (
5827B0992B0DC0CA00CCBBA1 /* MethodSettings */,
5827B08F2B0CAA0500CCBBA1 /* EditAccessMethodCoordinator.swift */,
5827B0A52B0F39E900CCBBA1 /* EditAccessMethodInteractor.swift */,
5827B0A32B0F38FD00CCBBA1 /* EditAccessMethodInteractorProtocol.swift */,
58FF9FE32B075BDD00E4C97D /* EditAccessMethodItemIdentifier.swift */,
58FF9FE12B075BA600E4C97D /* EditAccessMethodSectionIdentifier.swift */,
58FF9FDF2B075ABC00E4C97D /* EditAccessMethodViewController.swift */,
5827B0A92B0F4C9100CCBBA1 /* EditAccessMethodViewControllerDelegate.swift */,
5827B0992B0DC0CA00CCBBA1 /* MethodSettings */,
5827B0A72B0F49EF00CCBBA1 /* ProxyConfigurationInteractorProtocol.swift */,
);
path = Edit;
Expand Down Expand Up @@ -3796,7 +3800,6 @@
isa = PBXGroup;
children = (
7A5869AA2B55527C00640D27 /* IPOverrideCoordinator.swift */,
7A28826C2BAAC9DE00FD9F20 /* IPOverrideHeaderView.swift */,
7AB4CCBA2B691BBB006037F5 /* IPOverrideInteractor.swift */,
7A5869BE2B57D0A100640D27 /* IPOverrideStatus.swift */,
7A5869C02B57D21A00640D27 /* IPOverrideStatusView.swift */,
Expand Down Expand Up @@ -5451,6 +5454,7 @@
58B2FDDF2AA71D5C003EB5C6 /* DNSSettings.swift in Sources */,
58B2FDE02AA71D5C003EB5C6 /* TunnelSettings.swift in Sources */,
A988DF2A2ADE880300D807EF /* TunnelSettingsV3.swift in Sources */,
7A9F293D2CAD2FD5005F2089 /* InfoModalConfig.swift in Sources */,
58B2FDE42AA71D5C003EB5C6 /* SettingsManager.swift in Sources */,
F0164EBC2B482E430020268D /* AppStorage.swift in Sources */,
58B2FDE62AA71D5C003EB5C6 /* DeviceState.swift in Sources */,
Expand All @@ -5472,6 +5476,7 @@
58B2FDE22AA71D5C003EB5C6 /* StoredAccountData.swift in Sources */,
F0D7FF902B31E00B00E0FDE5 /* AccessMethodKind.swift in Sources */,
7A5869BC2B56EF3400640D27 /* IPOverrideRepository.swift in Sources */,
7A9F293B2CAC4443005F2089 /* InfoHeaderConfig.swift in Sources */,
F0E61CAB2BF2911D000C4A95 /* MultihopSettings.swift in Sources */,
58B2FDE82AA71D5C003EB5C6 /* KeychainSettingsStore.swift in Sources */,
);
Expand Down Expand Up @@ -5640,6 +5645,7 @@
7A5869972B32EA4500640D27 /* AppButton.swift in Sources */,
586C0D8F2B03D88100E7CDD7 /* ProxyProtocolConfigurationItemIdentifier.swift in Sources */,
588527B2276B3F0700BAA373 /* LoadTunnelConfigurationOperation.swift in Sources */,
7A9F29392CABFAFC005F2089 /* InfoHeaderView.swift in Sources */,
58DFF7D22B0256A300F864E0 /* MarkdownStylingOptions.swift in Sources */,
5867770E29096984006F721F /* OutOfTimeInteractor.swift in Sources */,
F03580252A13842C00E5DAFD /* IncreasedHitButton.swift in Sources */,
Expand Down Expand Up @@ -5806,7 +5812,6 @@
F0C6FA852A6A733700F521F0 /* InAppPurchaseInteractor.swift in Sources */,
58CEB2F92AFD136E00E6E088 /* UIBackgroundConfiguration+Extensions.swift in Sources */,
5878F50029CDA742003D4BE2 /* UIView+AutoLayoutBuilder.swift in Sources */,
7A28826D2BAAC9DE00FD9F20 /* IPOverrideHeaderView.swift in Sources */,
A98502032B627B120061901E /* LocalNetworkProbe.swift in Sources */,
7A6F2FA92AFD0842006D0856 /* CustomDNSDataSource.swift in Sources */,
58EF580B25D69D7A00AEBA94 /* ProblemReportSubmissionOverlayView.swift in Sources */,
Expand All @@ -5826,7 +5831,6 @@
5827B0A82B0F49EF00CCBBA1 /* ProxyConfigurationInteractorProtocol.swift in Sources */,
7A5869B92B56E7F000640D27 /* IPOverrideViewControllerDelegate.swift in Sources */,
586C0D7A2B039CE300E7CDD7 /* ShadowsocksCipherPicker.swift in Sources */,
58EFC76A2AFAC3B800E9F4CB /* ListAccessMethodHeaderView.swift in Sources */,
58B93A1326C3F13600A55733 /* TunnelState.swift in Sources */,
58FF9FEC2B07A7CB00E4C97D /* NSDirectionalEdgeInsets+Helpers.swift in Sources */,
586C0D832B03D2FF00E7CDD7 /* ShadowsocksSectionHandler.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,24 @@ extension EditAccessMethodCoordinator: EditAccessMethodViewControllerDelegate {
onFinish?(self)
}

func controllerShouldShowMethodInfo(_ controller: EditAccessMethodViewController, config: InfoModalConfig) {
let aboutController = AboutViewController(
header: config.header,
preamble: config.preamble,
body: config.body
)
let aboutNavController = UINavigationController(rootViewController: aboutController)

aboutController.navigationItem.rightBarButtonItem = UIBarButtonItem(
systemItem: .done,
primaryAction: UIAction { [weak aboutNavController] _ in
aboutNavController?.dismiss(animated: true)
}
)

navigationController.present(aboutNavController, animated: true)
}

private func getViewModelSubjectFromStore() -> CurrentValueSubject<AccessMethodViewModel, Never> {
let persistentMethod = accessMethodRepository.fetch(by: methodIdentifier)
return CurrentValueSubject<AccessMethodViewModel, Never>(persistentMethod?.toViewModel() ?? .init())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ enum EditAccessMethodSectionIdentifier: Hashable {
/// The section footer text.
var sectionFooter: String? {
switch self {
case .enableMethod:
NSLocalizedString(
"ENABLE_METHOD_FOOTER",
tableName: "APIAccess",
value: "When enabled, the app can try to communicate with a Mullvad API server using this method.",
comment: ""
)

case .testMethod:
NSLocalizedString(
"TEST_METHOD_FOOTER",
Expand All @@ -35,7 +27,7 @@ enum EditAccessMethodSectionIdentifier: Hashable {
comment: ""
)

case .methodSettings, .cancelTest, .testingStatus, .deleteMethod:
case .enableMethod, .methodSettings, .cancelTest, .testingStatus, .deleteMethod:
nil
}
}
Expand Down
Loading
Loading