summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2022-11-01 06:44:57 +0100
committerAndrej Mihajlov <and@mullvad.net>2022-11-03 11:03:44 +0100
commit19aa248e6d5fd58ba224bfd2ed1db8214f19f67b (patch)
treea99b8c166b03a1cb7cba448d28388d2141f264c5
parentb9046b8cdda26d07671dbab7b2831c304974ff63 (diff)
downloadmullvadvpn-19aa248e6d5fd58ba224bfd2ed1db8214f19f67b.tar.xz
mullvadvpn-19aa248e6d5fd58ba224bfd2ed1db8214f19f67b.zip
Add settings interactor factory
-rw-r--r--ios/MullvadVPN.xcodeproj/project.pbxproj8
-rw-r--r--ios/MullvadVPN/SceneDelegate.swift8
-rw-r--r--ios/MullvadVPN/SettingsInteractorFactory.swift45
-rw-r--r--ios/MullvadVPN/SettingsNavigationController.swift29
4 files changed, 78 insertions, 12 deletions
diff --git a/ios/MullvadVPN.xcodeproj/project.pbxproj b/ios/MullvadVPN.xcodeproj/project.pbxproj
index 466336fc5c..b8d6b404c8 100644
--- a/ios/MullvadVPN.xcodeproj/project.pbxproj
+++ b/ios/MullvadVPN.xcodeproj/project.pbxproj
@@ -137,6 +137,7 @@
585E820327F3285E00939F0E /* SendStoreReceiptOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 585E820227F3285E00939F0E /* SendStoreReceiptOperation.swift */; };
5862805422428EF100F5A6E1 /* TranslucentButtonBlurView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5862805322428EF100F5A6E1 /* TranslucentButtonBlurView.swift */; };
5867770E29096984006F721F /* OutOfTimeInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5867770D29096984006F721F /* OutOfTimeInteractor.swift */; };
+ 58677710290975E9006F721F /* SettingsInteractorFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5867770F290975E8006F721F /* SettingsInteractorFactory.swift */; };
58677712290976FB006F721F /* SettingsInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58677711290976FB006F721F /* SettingsInteractor.swift */; };
5867771429097BCD006F721F /* PaymentState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5867771329097BCD006F721F /* PaymentState.swift */; };
5867771629097C5B006F721F /* ProductState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5867771529097C5B006F721F /* ProductState.swift */; };
@@ -161,9 +162,9 @@
587425C12299833500CA2045 /* RootContainerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587425C02299833500CA2045 /* RootContainerViewController.swift */; };
5875960A26F371FC00BF6711 /* Tunnel+Messaging.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5875960926F371FC00BF6711 /* Tunnel+Messaging.swift */; };
5877D70F282137E8002FCFC7 /* SettingsManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58FF2C02281BDE02009EF542 /* SettingsManager.swift */; };
- 5878A27329091D6D0096FC88 /* TunnelBlockObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5878A27229091D6D0096FC88 /* TunnelBlockObserver.swift */; };
5878A26F2907E7E00096FC88 /* ProblemReportInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5878A26E2907E7E00096FC88 /* ProblemReportInteractor.swift */; };
5878A27129091CF20096FC88 /* AccountInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5878A27029091CF20096FC88 /* AccountInteractor.swift */; };
+ 5878A27329091D6D0096FC88 /* TunnelBlockObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5878A27229091D6D0096FC88 /* TunnelBlockObserver.swift */; };
5878A27529093A310096FC88 /* StorePaymentEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5878A27429093A310096FC88 /* StorePaymentEvent.swift */; };
5878A27729093A4F0096FC88 /* StorePaymentBlockObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5878A27629093A4F0096FC88 /* StorePaymentBlockObserver.swift */; };
5878A279290954790096FC88 /* ConnectInteractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5878A278290954790096FC88 /* ConnectInteractor.swift */; };
@@ -629,6 +630,7 @@
5862805322428EF100F5A6E1 /* TranslucentButtonBlurView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TranslucentButtonBlurView.swift; sourceTree = "<group>"; };
5866F39B2243B82D00168AE5 /* MullvadVPN.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MullvadVPN.entitlements; sourceTree = "<group>"; };
5867770D29096984006F721F /* OutOfTimeInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OutOfTimeInteractor.swift; sourceTree = "<group>"; };
+ 5867770F290975E8006F721F /* SettingsInteractorFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsInteractorFactory.swift; sourceTree = "<group>"; };
58677711290976FB006F721F /* SettingsInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsInteractor.swift; sourceTree = "<group>"; };
5867771329097BCD006F721F /* PaymentState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentState.swift; sourceTree = "<group>"; };
5867771529097C5B006F721F /* ProductState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductState.swift; sourceTree = "<group>"; };
@@ -648,9 +650,9 @@
5875960926F371FC00BF6711 /* Tunnel+Messaging.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Tunnel+Messaging.swift"; sourceTree = "<group>"; };
58781CC822AE7CA8009B9D8E /* RelayConstraints.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayConstraints.swift; sourceTree = "<group>"; };
58781CD422AFBA39009B9D8E /* RelaySelector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelaySelector.swift; sourceTree = "<group>"; };
- 5878A27229091D6D0096FC88 /* TunnelBlockObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelBlockObserver.swift; sourceTree = "<group>"; };
5878A26E2907E7E00096FC88 /* ProblemReportInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProblemReportInteractor.swift; sourceTree = "<group>"; };
5878A27029091CF20096FC88 /* AccountInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountInteractor.swift; sourceTree = "<group>"; };
+ 5878A27229091D6D0096FC88 /* TunnelBlockObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelBlockObserver.swift; sourceTree = "<group>"; };
5878A27429093A310096FC88 /* StorePaymentEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StorePaymentEvent.swift; sourceTree = "<group>"; };
5878A27629093A4F0096FC88 /* StorePaymentBlockObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StorePaymentBlockObserver.swift; sourceTree = "<group>"; };
5878A278290954790096FC88 /* ConnectInteractor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectInteractor.swift; sourceTree = "<group>"; };
@@ -1322,6 +1324,7 @@
584D26C5270C8741004EA533 /* SettingsDNSTextCell.swift */,
580F8B88281A79A7002E0998 /* SettingsManager */,
58E6771E24ADFE7800AA26E7 /* SettingsNavigationController.swift */,
+ 5867770F290975E8006F721F /* SettingsInteractorFactory.swift */,
584D26C1270C8542004EA533 /* SettingsStaticTextFooterView.swift */,
58ACF64A26553C3F00ACE4B7 /* SettingsSwitchCell.swift */,
58CCA01122424D11004F3011 /* SettingsViewController.swift */,
@@ -2183,6 +2186,7 @@
58EE2E3A272FF814003BFF93 /* SettingsDataSource.swift in Sources */,
58421032282E42B000F24E46 /* UpdateDeviceDataOperation.swift in Sources */,
5878A27D2909657C0096FC88 /* RevokedDeviceInteractor.swift in Sources */,
+ 58677710290975E9006F721F /* SettingsInteractorFactory.swift in Sources */,
5872631D283F755900E14ADF /* IntentHandlers.swift in Sources */,
58CCA01222424D11004F3011 /* SettingsViewController.swift in Sources */,
580F8B8628197958002E0998 /* DNSSettings.swift in Sources */,
diff --git a/ios/MullvadVPN/SceneDelegate.swift b/ios/MullvadVPN/SceneDelegate.swift
index 00ac40f33f..6016af5792 100644
--- a/ios/MullvadVPN/SceneDelegate.swift
+++ b/ios/MullvadVPN/SceneDelegate.swift
@@ -345,7 +345,13 @@ extension SceneDelegate {
private func makeSettingsNavigationController(route: SettingsNavigationRoute?)
-> SettingsNavigationController
{
- let navController = SettingsNavigationController()
+ let navController = SettingsNavigationController(
+ interactorFactory: SettingsInteractorFactory(
+ storePaymentManager: .shared,
+ tunnelManager: .shared,
+ apiProxy: REST.ProxyFactory.shared.createAPIProxy()
+ )
+ )
navController.settingsDelegate = self
if UIDevice.current.userInterfaceIdiom == .pad {
diff --git a/ios/MullvadVPN/SettingsInteractorFactory.swift b/ios/MullvadVPN/SettingsInteractorFactory.swift
new file mode 100644
index 0000000000..521e587570
--- /dev/null
+++ b/ios/MullvadVPN/SettingsInteractorFactory.swift
@@ -0,0 +1,45 @@
+//
+// SettingsInteractorFactory.swift
+// MullvadVPN
+//
+// Created by pronebird on 26/10/2022.
+// Copyright © 2022 Mullvad VPN AB. All rights reserved.
+//
+
+import Foundation
+import MullvadREST
+
+final class SettingsInteractorFactory {
+ private let storePaymentManager: StorePaymentManager
+ private let tunnelManager: TunnelManager
+ private let apiProxy: REST.APIProxy
+
+ init(
+ storePaymentManager: StorePaymentManager,
+ tunnelManager: TunnelManager,
+ apiProxy: REST.APIProxy
+ ) {
+ self.storePaymentManager = storePaymentManager
+ self.tunnelManager = tunnelManager
+ self.apiProxy = apiProxy
+ }
+
+ func makeAccountInteractor() -> AccountInteractor {
+ return AccountInteractor(
+ storePaymentManager: storePaymentManager,
+ tunnelManager: tunnelManager
+ )
+ }
+
+ func makePreferencesInteractor() -> PreferencesInteractor {
+ return PreferencesInteractor(tunnelManager: tunnelManager)
+ }
+
+ func makeProblemReportInteractor() -> ProblemReportInteractor {
+ return ProblemReportInteractor(apiProxy: apiProxy, tunnelManager: tunnelManager)
+ }
+
+ func makeSettingsInteractor() -> SettingsInteractor {
+ return SettingsInteractor(tunnelManager: tunnelManager)
+ }
+}
diff --git a/ios/MullvadVPN/SettingsNavigationController.swift b/ios/MullvadVPN/SettingsNavigationController.swift
index 58993fc6c4..6656eb2acb 100644
--- a/ios/MullvadVPN/SettingsNavigationController.swift
+++ b/ios/MullvadVPN/SettingsNavigationController.swift
@@ -6,7 +6,6 @@
// Copyright © 2020 Mullvad VPN AB. All rights reserved.
//
-import Foundation
import UIKit
enum SettingsNavigationRoute {
@@ -37,6 +36,8 @@ protocol SettingsNavigationControllerDelegate: AnyObject {
class SettingsNavigationController: CustomNavigationController, SettingsViewControllerDelegate,
AccountViewControllerDelegate, UIAdaptivePresentationControllerDelegate
{
+ private let interactorFactory: SettingsInteractorFactory
+
weak var settingsDelegate: SettingsNavigationControllerDelegate?
override var childForStatusBarStyle: UIViewController? {
@@ -47,7 +48,9 @@ class SettingsNavigationController: CustomNavigationController, SettingsViewCont
return topViewController
}
- init() {
+ init(interactorFactory: SettingsInteractorFactory) {
+ self.interactorFactory = interactorFactory
+
super.init(navigationBarClass: CustomNavigationBar.self, toolbarClass: nil)
navigationBar.prefersLargeTitles = true
@@ -57,7 +60,7 @@ class SettingsNavigationController: CustomNavigationController, SettingsViewCont
}
required init?(coder aDecoder: NSCoder) {
- super.init(coder: aDecoder)
+ fatalError("init(coder:) has not been implemented")
}
override func willPop(navigationItem: UINavigationItem) {
@@ -102,23 +105,31 @@ class SettingsNavigationController: CustomNavigationController, SettingsViewCont
private func makeViewController(for route: SettingsNavigationRoute) -> UIViewController {
switch route {
case .root:
- let settingsController = SettingsViewController()
- settingsController.delegate = self
- return settingsController
+ let controller = SettingsViewController(
+ interactor: interactorFactory.makeSettingsInteractor()
+ )
+ controller.delegate = self
+ return controller
case .account:
- let controller = AccountViewController()
+ let controller = AccountViewController(
+ interactor: interactorFactory.makeAccountInteractor()
+ )
controller.delegate = self
return controller
case .preferences:
- return PreferencesViewController()
+ return PreferencesViewController(
+ interactor: interactorFactory.makePreferencesInteractor()
+ )
case .shortcuts:
return ShortcutsViewController()
case .problemReport:
- return ProblemReportViewController()
+ return ProblemReportViewController(
+ interactor: interactorFactory.makeProblemReportInteractor()
+ )
}
}