From 846a20a7f8c19be60746007031ec0818692cc97d Mon Sep 17 00:00:00 2001 From: Juraj Hilje Date: Sat, 19 Aug 2023 13:29:23 +0200 Subject: [PATCH 01/12] feat: create ExperimentalViewController.swift --- IVPNClient.xcodeproj/project.pbxproj | 4 ++ .../ExperimentalViewController.swift | 50 +++++++++++++++++++ .../Extensions/UserDefaults+Ext.swift | 6 +++ 3 files changed, 60 insertions(+) create mode 100644 IVPNClient/Scenes/ViewControllers/ExperimentalViewController.swift diff --git a/IVPNClient.xcodeproj/project.pbxproj b/IVPNClient.xcodeproj/project.pbxproj index 0e58ec935..51034d058 100644 --- a/IVPNClient.xcodeproj/project.pbxproj +++ b/IVPNClient.xcodeproj/project.pbxproj @@ -266,6 +266,7 @@ 82DEF02A2447288100CCB5CD /* PaymentViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82DEF0292447288100CCB5CD /* PaymentViewController.swift */; }; 82DEFFA62452DE5100ECB482 /* MapConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82DEFFA52452DE5100ECB482 /* MapConstants.swift */; }; 82E01649230BE683008B0AC0 /* APIAccessManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82E01648230BE683008B0AC0 /* APIAccessManagerTests.swift */; }; + 82E0E9072A90CB110008BD3F /* ExperimentalViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82E0E9062A90CB110008BD3F /* ExperimentalViewController.swift */; }; 82E3B20B29DDCC6300998F67 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 82E3B1EF29DDC91C00998F67 /* WidgetKit.framework */; }; 82E3B20C29DDCC6300998F67 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 82E3B1F129DDC91C00998F67 /* SwiftUI.framework */; }; 82E3B20F29DDCC6400998F67 /* IVPNWidgetBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 82E3B20E29DDCC6400998F67 /* IVPNWidgetBundle.swift */; }; @@ -656,6 +657,7 @@ 82DEF0292447288100CCB5CD /* PaymentViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentViewController.swift; sourceTree = ""; }; 82DEFFA52452DE5100ECB482 /* MapConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapConstants.swift; sourceTree = ""; }; 82E01648230BE683008B0AC0 /* APIAccessManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = APIAccessManagerTests.swift; sourceTree = ""; }; + 82E0E9062A90CB110008BD3F /* ExperimentalViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExperimentalViewController.swift; sourceTree = ""; }; 82E3B1EF29DDC91C00998F67 /* WidgetKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WidgetKit.framework; path = System/Library/Frameworks/WidgetKit.framework; sourceTree = SDKROOT; }; 82E3B1F129DDC91C00998F67 /* SwiftUI.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftUI.framework; path = System/Library/Frameworks/SwiftUI.framework; sourceTree = SDKROOT; }; 82E3B20A29DDCC6300998F67 /* IVPNWidgetExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = IVPNWidgetExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -1215,6 +1217,7 @@ isa = PBXGroup; children = ( 9C3031361DB4307D00C38B0C /* SettingsViewController.swift */, + 82E0E9062A90CB110008BD3F /* ExperimentalViewController.swift */, 9C50959520FCF4C60048DBF2 /* ProtocolViewController.swift */, 820203922186EE0E00D756AA /* WireGuardSettingsViewController.swift */, 82D598A221A55210000FABDE /* NetworkProtectionViewController.swift */, @@ -2328,6 +2331,7 @@ 82E7880C22B0DA0D00A98D76 /* NETunnelProviderProtocol+Ext.swift in Sources */, 82968A35298A98C300077E0A /* KeyChain.swift in Sources */, 82F638C2217DA89000410318 /* AddressType.swift in Sources */, + 82E0E9072A90CB110008BD3F /* ExperimentalViewController.swift in Sources */, 822920A02480FA3600476FC1 /* ServersSort.swift in Sources */, 826E61482428F8E60064F195 /* AccountViewController.swift in Sources */, 820079F42407D96D00EC2062 /* ConnectionInfoBoxView.swift in Sources */, diff --git a/IVPNClient/Scenes/ViewControllers/ExperimentalViewController.swift b/IVPNClient/Scenes/ViewControllers/ExperimentalViewController.swift new file mode 100644 index 000000000..0d5bcc05d --- /dev/null +++ b/IVPNClient/Scenes/ViewControllers/ExperimentalViewController.swift @@ -0,0 +1,50 @@ +// +// ExperimentalViewController.swift +// IVPNClient +// +// Created by Juraj Hilje on 19.08.2023.. +// Copyright © 2023 IVPN. All rights reserved. +// + +import UIKit + +class ExperimentalViewController: UITableViewController { + + @IBOutlet weak var disableLanAccessSwitch: UISwitch! + + // MARK: - @IBActions - + + @IBAction func toggleDisableLanAccess(_ sender: UISwitch) { + UserDefaults.shared.set(sender.isOn, forKey: UserDefaults.Key.disableLanAccess) + disableLanAccessSwitch.isEnabled = sender.isOn + evaluateReconnect(sender: sender as UIView) + } + + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + disableLanAccessSwitch.setOn(UserDefaults.shared.disableLanAccess, animated: false) + } + +} + +// MARK: - UITableViewDelegate - + +extension ExperimentalViewController { + + override func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) { + if let header = view as? UITableViewHeaderFooterView { + header.textLabel?.textColor = UIColor.init(named: Theme.ivpnLabel6) + } + } + + override func tableView(_ tableView: UITableView, willDisplayFooterView view: UIView, forSection section: Int) { + if let footer = view as? UITableViewHeaderFooterView { + footer.textLabel?.textColor = UIColor.init(named: Theme.ivpnLabel6) + } + } + + override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { + cell.backgroundColor = UIColor.init(named: Theme.ivpnBackgroundPrimary) + } + +} diff --git a/IVPNClient/Utilities/Extensions/UserDefaults+Ext.swift b/IVPNClient/Utilities/Extensions/UserDefaults+Ext.swift index 873ef1668..af852de46 100644 --- a/IVPNClient/Utilities/Extensions/UserDefaults+Ext.swift +++ b/IVPNClient/Utilities/Extensions/UserDefaults+Ext.swift @@ -89,6 +89,7 @@ extension UserDefaults { static let selectHost = "selectHost" static let isLoggedIn = "isLoggedIn" static let antiTrackerDns = "antiTrackerDns" + static let disableLanAccess = "disableLanAccess" } @objc dynamic var wireguardTunnelProviderError: String { @@ -235,6 +236,10 @@ extension UserDefaults { return bool(forKey: Key.isLoggedIn) } + @objc dynamic var disableLanAccess: Bool { + return bool(forKey: Key.disableLanAccess) + } + static func registerUserDefaults() { shared.register(defaults: [Key.networkProtectionUntrustedConnect: true]) shared.register(defaults: [Key.networkProtectionTrustedDisconnect: true]) @@ -270,6 +275,7 @@ extension UserDefaults { shared.removeObject(forKey: Key.selectHost) shared.removeObject(forKey: Key.isLoggedIn) shared.removeObject(forKey: Key.antiTrackerDns) + shared.removeObject(forKey: Key.disableLanAccess) standard.removeObject(forKey: Key.serviceStatus) standard.removeObject(forKey: Key.selectedHost) standard.removeObject(forKey: Key.selectedExitHost) From 4de673badb3c305a07a974640633ea72af6c9421 Mon Sep 17 00:00:00 2001 From: Juraj Hilje Date: Sat, 19 Aug 2023 14:21:48 +0200 Subject: [PATCH 02/12] feat: update SettingsViewController.swift --- IVPNClient/Scenes/Base.lproj/Main.storyboard | 141 ++++++++++++++---- .../ExperimentalViewController.swift | 28 +++- .../SettingsViewController.swift | 14 +- 3 files changed, 148 insertions(+), 35 deletions(-) diff --git a/IVPNClient/Scenes/Base.lproj/Main.storyboard b/IVPNClient/Scenes/Base.lproj/Main.storyboard index 1fb8c854c..62b72073f 100644 --- a/IVPNClient/Scenes/Base.lproj/Main.storyboard +++ b/IVPNClient/Scenes/Base.lproj/Main.storyboard @@ -21,7 +21,7 @@ - +