diff options
| author | Bug Magnet <marco.nikic@mullvad.net> | 2025-06-09 11:55:08 +0200 |
|---|---|---|
| committer | Bug Magnet <marco.nikic@mullvad.net> | 2025-06-12 15:53:07 +0200 |
| commit | c90fca9394d6d16392b729982bc2b7b3a1108fef (patch) | |
| tree | 544412b6769637d4e8f8734e3765e025612f6a1d | |
| parent | 92d02896f2f1ac3f42227af220c4774a903e0468 (diff) | |
| download | mullvadvpn-c90fca9394d6d16392b729982bc2b7b3a1108fef.tar.xz mullvadvpn-c90fca9394d6d16392b729982bc2b7b3a1108fef.zip | |
Introduce a generic HostingController with sensible default values
5 files changed, 41 insertions, 3 deletions
diff --git a/ios/MullvadVPN.xcodeproj/project.pbxproj b/ios/MullvadVPN.xcodeproj/project.pbxproj index 254c8288c5..7f27111634 100644 --- a/ios/MullvadVPN.xcodeproj/project.pbxproj +++ b/ios/MullvadVPN.xcodeproj/project.pbxproj @@ -906,6 +906,7 @@ A9A5FA412ACB05D90083449F /* DeviceStateAccessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 583D86472A2678DC0060D63B /* DeviceStateAccessor.swift */; }; A9A5FA422ACB05D90083449F /* DeviceStateAccessorProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 580810E42A30E13A00B74552 /* DeviceStateAccessorProtocol.swift */; }; A9A5FA432ACB05F20083449F /* UIColor+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 587CBFE222807F530028DED3 /* UIColor+Helpers.swift */; }; + A9A60ED42DF6E5AC00CD9C3D /* UIHostingRootController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9A60ED32DF6E5AC00CD9C3D /* UIHostingRootController.swift */; }; A9A8A8EB2A262AB30086D569 /* FileCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9A8A8EA2A262AB30086D569 /* FileCache.swift */; }; A9B6AC182ADE8F4300F7802A /* MigrationManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9B6AC172ADE8F4300F7802A /* MigrationManagerTests.swift */; }; A9B6AC1A2ADE8FBB00F7802A /* InMemorySettingsStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9B6AC192ADE8FBB00F7802A /* InMemorySettingsStore.swift */; }; @@ -2371,6 +2372,7 @@ A9A1DE782AD5708E0073F689 /* TransportStrategy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransportStrategy.swift; sourceTree = "<group>"; }; A9A557F42B7E3E5C0017ADA8 /* EphemeralPeerReceiver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EphemeralPeerReceiver.swift; sourceTree = "<group>"; }; A9A5F9A12ACB003D0083449F /* TunnelManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TunnelManagerTests.swift; sourceTree = "<group>"; }; + A9A60ED32DF6E5AC00CD9C3D /* UIHostingRootController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIHostingRootController.swift; sourceTree = "<group>"; }; A9A8A8EA2A262AB30086D569 /* FileCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileCache.swift; sourceTree = "<group>"; }; A9B6AC172ADE8F4300F7802A /* MigrationManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MigrationManagerTests.swift; sourceTree = "<group>"; }; A9B6AC192ADE8FBB00F7802A /* InMemorySettingsStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InMemorySettingsStore.swift; sourceTree = "<group>"; }; @@ -4040,6 +4042,7 @@ 58F3C0A3249CB069003E76BE /* HeaderBarView.swift */, 7A818F1E29F0305800C7F0F4 /* RootConfiguration.swift */, 587425C02299833500CA2045 /* RootContainerViewController.swift */, + A9A60ED32DF6E5AC00CD9C3D /* UIHostingRootController.swift */, ); path = Root; sourceTree = "<group>"; @@ -6407,6 +6410,7 @@ 58138E61294871C600684F0C /* DeviceDataThrottling.swift in Sources */, 7A6389ED2B7FADA1008E77E1 /* SettingsFieldValidationErrorConfiguration.swift in Sources */, 5878A279290954790096FC88 /* TunnelViewControllerInteractor.swift in Sources */, + A9A60ED42DF6E5AC00CD9C3D /* UIHostingRootController.swift in Sources */, 7A818F1F29F0305800C7F0F4 /* RootConfiguration.swift in Sources */, 7A9CCCBF2A96302800DD6A34 /* SettingsCoordinator.swift in Sources */, 58F70FE52AEA707800E6890E /* StoreTransactionLog.swift in Sources */, diff --git a/ios/MullvadVPN/Containers/Root/UIHostingRootController.swift b/ios/MullvadVPN/Containers/Root/UIHostingRootController.swift new file mode 100644 index 0000000000..15e98c66bc --- /dev/null +++ b/ios/MullvadVPN/Containers/Root/UIHostingRootController.swift @@ -0,0 +1,34 @@ +// +// UIHostingRootController.swift +// MullvadVPN +// +// Created by Marco Nikic on 2025-06-09. +// Copyright © 2025 Mullvad VPN AB. All rights reserved. +// + +import Foundation +import SwiftUI + +@MainActor +public final class UIHostingRootController<Content: View>: UIHostingController<Content>, RootContainment { + let preferredHeaderBarPresentation: HeaderBarPresentation + let prefersHeaderBarHidden: Bool + let prefersDeviceInfoBarHidden: Bool + + init( + preferredHeaderBarPresentation: HeaderBarPresentation = + HeaderBarPresentation(style: .default, showsDivider: false), + prefersHeaderBarHidden: Bool = false, + prefersDeviceInfoBarHidden: Bool = true, + rootView: Content + ) { + self.preferredHeaderBarPresentation = preferredHeaderBarPresentation + self.prefersHeaderBarHidden = prefersHeaderBarHidden + self.prefersDeviceInfoBarHidden = prefersDeviceInfoBarHidden + super.init(rootView: rootView) + } + + required init?(coder aDecoder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } +} diff --git a/ios/MullvadVPN/Coordinators/TermsOfServiceCoordinator.swift b/ios/MullvadVPN/Coordinators/TermsOfServiceCoordinator.swift index a34f2f0c32..042e21b7c6 100644 --- a/ios/MullvadVPN/Coordinators/TermsOfServiceCoordinator.swift +++ b/ios/MullvadVPN/Coordinators/TermsOfServiceCoordinator.swift @@ -25,7 +25,7 @@ class TermsOfServiceCoordinator: Coordinator, Presenting { func start() { let termsOfService = TermsOfServiceView(agreeToTermsAndServices: didAgreeToTermsOfService) - let hostingController = UIHostingController(rootView: termsOfService) + let hostingController = UIHostingRootController(rootView: termsOfService) hostingController.view.setAccessibilityIdentifier(.termsOfServiceView) navigationController.pushViewController(hostingController, animated: false) } diff --git a/ios/MullvadVPN/UI appearance/Color+Mullvad.swift b/ios/MullvadVPN/UI appearance/Color+Mullvad.swift index 6fad2f47b2..ab3987c722 100644 --- a/ios/MullvadVPN/UI appearance/Color+Mullvad.swift +++ b/ios/MullvadVPN/UI appearance/Color+Mullvad.swift @@ -12,6 +12,7 @@ extension Color { static let mullvadTextPrimaryDisabled: Color = .mullvadTextPrimary.opacity( 0.2 ) + static let secondaryTextColor: Color = UIColor.secondaryTextColor.color enum MullvadButton { static let primary: Color = .mullvadPrimaryColor diff --git a/ios/MullvadVPN/View controllers/TermsOfService/TermsOfServiceView.swift b/ios/MullvadVPN/View controllers/TermsOfService/TermsOfServiceView.swift index be7745622e..b95b9cb717 100644 --- a/ios/MullvadVPN/View controllers/TermsOfService/TermsOfServiceView.swift +++ b/ios/MullvadVPN/View controllers/TermsOfService/TermsOfServiceView.swift @@ -31,12 +31,11 @@ struct TermsOfServiceView: View { Text(LocalizedStringKey("Do you agree to remaining anonymous?")) .font(.mullvadLarge) .foregroundStyle(.white) - .allowsTightening(true) .frame(maxWidth: .infinity, alignment: .leading) .padding(.bottom, 16) Text(termsOfService) .font(.mullvadSmall) - .foregroundStyle(Color(UIColor.secondaryTextColor)) + .foregroundStyle(Color.secondaryTextColor) } .padding(padding) } |
