Skip to content

Commit

Permalink
Merge branch 'make-it-look-like-an-iphone-ios-719'
Browse files Browse the repository at this point in the history
  • Loading branch information
buggmagnet committed Jun 24, 2024
2 parents d304842 + 3d35779 commit 5809c7c
Show file tree
Hide file tree
Showing 13 changed files with 60 additions and 650 deletions.
32 changes: 12 additions & 20 deletions ios/MullvadVPN.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
5838322B2AC3EF9600EA2071 /* EventChannel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5838322A2AC3EF9600EA2071 /* EventChannel.swift */; };
583D86482A2678DC0060D63B /* DeviceStateAccessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 583D86472A2678DC0060D63B /* DeviceStateAccessor.swift */; };
583DA21425FA4B5C00318683 /* LocationDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 583DA21325FA4B5C00318683 /* LocationDataSource.swift */; };
583FE01029C0F532006E85F9 /* CustomSplitViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 583FE00F29C0F532006E85F9 /* CustomSplitViewController.swift */; };
583FE02429C1ACB3006E85F9 /* RESTCreateApplePaymentResponse+Localization.swift in Sources */ = {isa = PBXBuildFile; fileRef = 06FAE67828F83CA50033DD93 /* RESTCreateApplePaymentResponse+Localization.swift */; };
584023222A406BF5007B27AC /* UDPOverTCPObfuscator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 584023212A406BF5007B27AC /* UDPOverTCPObfuscator.swift */; };
584023292A407F5F007B27AC /* libtunnel_obfuscator_proxy.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 584023282A407F5F007B27AC /* libtunnel_obfuscator_proxy.a */; };
Expand All @@ -138,8 +137,6 @@
58607A4D2947287800BC467D /* AccountExpiryInAppNotificationProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58607A4C2947287800BC467D /* AccountExpiryInAppNotificationProvider.swift */; };
586168692976F6BD00EF8598 /* DisplayError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 586168682976F6BD00EF8598 /* DisplayError.swift */; };
5862805422428EF100F5A6E1 /* TranslucentButtonBlurView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5862805322428EF100F5A6E1 /* TranslucentButtonBlurView.swift */; };
5864859929A0D028006C5743 /* FormsheetPresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5864859829A0D028006C5743 /* FormsheetPresentationController.swift */; };
5864859B29A0EAF2006C5743 /* SecondaryContextPresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5864859A29A0EAF2006C5743 /* SecondaryContextPresentationController.swift */; };
5864AF0729C78843005B0CD9 /* SettingsCellFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5864AF0029C7879B005B0CD9 /* SettingsCellFactory.swift */; };
5864AF0829C78849005B0CD9 /* CellFactoryProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5864AF0129C7879B005B0CD9 /* CellFactoryProtocol.swift */; };
5864AF0929C78850005B0CD9 /* VPNSettingsCellFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5864AF0229C7879B005B0CD9 /* VPNSettingsCellFactory.swift */; };
Expand Down Expand Up @@ -605,6 +602,7 @@
7ADCB2D82B6A6EB300C88F89 /* AnyRelay.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ADCB2D72B6A6EB300C88F89 /* AnyRelay.swift */; };
7ADCB2DA2B6A730400C88F89 /* IPOverrideRepositoryStub.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ADCB2D92B6A730400C88F89 /* IPOverrideRepositoryStub.swift */; };
7AE044BB2A935726003915D8 /* Routing.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A88DCD02A8FABBE00D2FF0E /* Routing.h */; settings = {ATTRIBUTES = (Public, ); }; };
7AE2414A2C20682B0076CE33 /* FormsheetPresentationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AE241482C20682B0076CE33 /* FormsheetPresentationController.swift */; };
7AED35CC2BD13F60002A67D1 /* ApplicationConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58BFA5CB22A7CE1F00A6173D /* ApplicationConfiguration.swift */; };
7AED35CD2BD13FC4002A67D1 /* ApplicationTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58C76A072A33850E00100D75 /* ApplicationTarget.swift */; };
7AEF7F1A2AD00F52006FE45D /* AppMessageHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7AEF7F192AD00F52006FE45D /* AppMessageHandler.swift */; };
Expand Down Expand Up @@ -1552,7 +1550,6 @@
583E1E292848DF67004838B3 /* OperationObserverTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OperationObserverTests.swift; sourceTree = "<group>"; };
583E60952A9F6D0800DC61EF /* ConfigurationBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigurationBuilder.swift; sourceTree = "<group>"; };
583FE00B29C0C7FD006E85F9 /* ModalPresentationConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalPresentationConfiguration.swift; sourceTree = "<group>"; };
583FE00F29C0F532006E85F9 /* CustomSplitViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomSplitViewController.swift; sourceTree = "<group>"; };
583FE01129C0F99A006E85F9 /* PresentationControllerDismissalInterceptor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PresentationControllerDismissalInterceptor.swift; sourceTree = "<group>"; };
5840231F2A406BF5007B27AC /* TunnelObfuscation.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = TunnelObfuscation.framework; sourceTree = BUILT_PRODUCTS_DIR; };
584023212A406BF5007B27AC /* UDPOverTCPObfuscator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UDPOverTCPObfuscator.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1585,8 +1582,6 @@
58607A4C2947287800BC467D /* AccountExpiryInAppNotificationProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountExpiryInAppNotificationProvider.swift; sourceTree = "<group>"; };
586168682976F6BD00EF8598 /* DisplayError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisplayError.swift; sourceTree = "<group>"; };
5862805322428EF100F5A6E1 /* TranslucentButtonBlurView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TranslucentButtonBlurView.swift; sourceTree = "<group>"; };
5864859829A0D028006C5743 /* FormsheetPresentationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormsheetPresentationController.swift; sourceTree = "<group>"; };
5864859A29A0EAF2006C5743 /* SecondaryContextPresentationController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecondaryContextPresentationController.swift; sourceTree = "<group>"; };
5864AF0029C7879B005B0CD9 /* SettingsCellFactory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsCellFactory.swift; sourceTree = "<group>"; };
5864AF0129C7879B005B0CD9 /* CellFactoryProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CellFactoryProtocol.swift; sourceTree = "<group>"; };
5864AF0229C7879B005B0CD9 /* VPNSettingsCellFactory.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VPNSettingsCellFactory.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1976,6 +1971,7 @@
7AD0AA202AD6CB0000119E10 /* URLRequestProxyStub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLRequestProxyStub.swift; sourceTree = "<group>"; };
7ADCB2D72B6A6EB300C88F89 /* AnyRelay.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnyRelay.swift; sourceTree = "<group>"; };
7ADCB2D92B6A730400C88F89 /* IPOverrideRepositoryStub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IPOverrideRepositoryStub.swift; sourceTree = "<group>"; };
7AE241482C20682B0076CE33 /* FormsheetPresentationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FormsheetPresentationController.swift; sourceTree = "<group>"; };
7AEF7F192AD00F52006FE45D /* AppMessageHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppMessageHandler.swift; sourceTree = "<group>"; };
7AF10EB12ADE859200C090B9 /* AlertViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AlertViewController.swift; sourceTree = "<group>"; };
7AF10EB32ADE85BC00C090B9 /* RelayFilterCoordinator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RelayFilterCoordinator.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3131,15 +3127,6 @@
path = RelayCacheTracker;
sourceTree = "<group>";
};
5864859729A0D012006C5743 /* Presentation controllers */ = {
isa = PBXGroup;
children = (
5864859829A0D028006C5743 /* FormsheetPresentationController.swift */,
5864859A29A0EAF2006C5743 /* SecondaryContextPresentationController.swift */,
);
path = "Presentation controllers";
sourceTree = "<group>";
};
5864AF0629C78816005B0CD9 /* Protocols */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -3402,7 +3389,6 @@
children = (
58D1560C29C0B27600749324 /* Root */,
583FE01329C102EB006E85F9 /* Navigation */,
583FE00F29C0F532006E85F9 /* CustomSplitViewController.swift */,
);
path = Containers;
sourceTree = "<group>";
Expand Down Expand Up @@ -3574,7 +3560,7 @@
F09D04B82AE94F27003D4F89 /* GeneralAPIs */,
58B26E1F2943516500D5980C /* Notifications */,
586A950B2901250A007BAF2B /* Operations */,
5864859729A0D012006C5743 /* Presentation controllers */,
7AE241492C20682B0076CE33 /* Presentation controllers */,
5864AF0629C78816005B0CD9 /* Protocols */,
585DA87526B0249A00B8C587 /* RelayCacheTracker */,
58E25F802837BBBB002CFB2C /* SceneDelegate.swift */,
Expand Down Expand Up @@ -3934,6 +3920,14 @@
path = SelectLocation;
sourceTree = "<group>";
};
7AE241492C20682B0076CE33 /* Presentation controllers */ = {
isa = PBXGroup;
children = (
7AE241482C20682B0076CE33 /* FormsheetPresentationController.swift */,
);
path = "Presentation controllers";
sourceTree = "<group>";
};
7AF9BE912A39F47D00DBFEDB /* RelayFilter */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -5667,7 +5661,6 @@
5891BF5125E66B1E006D6FB0 /* UIBarButtonItem+KeyboardNavigation.swift in Sources */,
58E511E628DDDEAC00B0BCDE /* CodingErrors+CustomErrorDescription.swift in Sources */,
58C76A0B2A338E4300100D75 /* BackgroundTask.swift in Sources */,
5864859B29A0EAF2006C5743 /* SecondaryContextPresentationController.swift in Sources */,
7A9CCCC32A96302800DD6A34 /* ApplicationCoordinator.swift in Sources */,
5864AF0729C78843005B0CD9 /* SettingsCellFactory.swift in Sources */,
587B75412668FD7800DEF7E9 /* AccountExpirySystemNotificationProvider.swift in Sources */,
Expand Down Expand Up @@ -5796,7 +5789,6 @@
586A950E290125F3007BAF2B /* ProductsRequestOperation.swift in Sources */,
7AF9BE902A39F26000DBFEDB /* Collection+Sorting.swift in Sources */,
58F19E35228C15BA00C7710B /* SpinnerActivityIndicatorView.swift in Sources */,
5864859929A0D028006C5743 /* FormsheetPresentationController.swift in Sources */,
58CEB3022AFD365600E6E088 /* SwitchCellContentConfiguration.swift in Sources */,
7A9CCCB52A96302800DD6A34 /* AddCreditSucceededCoordinator.swift in Sources */,
7A0C0F632A979C4A0058EFCE /* Coordinator+Router.swift in Sources */,
Expand Down Expand Up @@ -5876,6 +5868,7 @@
5807E2C02432038B00F5FF30 /* String+Split.swift in Sources */,
58B26E242943520C00D5980C /* NotificationProviderProtocol.swift in Sources */,
5877F94E2A0A59AA0052D9E9 /* NotificationResponse.swift in Sources */,
7AE2414A2C20682B0076CE33 /* FormsheetPresentationController.swift in Sources */,
7A6389E52B7E4247008E77E1 /* EditCustomListCoordinator.swift in Sources */,
58677712290976FB006F721F /* SettingsInteractor.swift in Sources */,
58EF875D2B1638BF00C098B2 /* ProxyConfigurationTesterProtocol.swift in Sources */,
Expand All @@ -5885,7 +5878,6 @@
5878F50029CDA742003D4BE2 /* UIView+AutoLayoutBuilder.swift in Sources */,
7A28826D2BAAC9DE00FD9F20 /* IPOverrideHeaderView.swift in Sources */,
A98502032B627B120061901E /* LocalNetworkProbe.swift in Sources */,
583FE01029C0F532006E85F9 /* CustomSplitViewController.swift in Sources */,
7A6F2FA92AFD0842006D0856 /* CustomDNSDataSource.swift in Sources */,
58EF580B25D69D7A00AEBA94 /* ProblemReportSubmissionOverlayView.swift in Sources */,
5892A45E265FABFF00890742 /* EmptyTableViewHeaderFooterView.swift in Sources */,
Expand Down
5 changes: 2 additions & 3 deletions ios/MullvadVPN/Classes/AppRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import Routing
import UIKit

/**
Enum type describing groups of routes. Each group is a modal layer with horizontal navigation
inside with exception where primary navigation is a part of root controller on iPhone.
Enum type describing groups of routes.
*/
enum AppRouteGroup: AppRouteGroupProtocol {
/**
Expand Down Expand Up @@ -47,7 +46,7 @@ enum AppRouteGroup: AppRouteGroupProtocol {
var isModal: Bool {
switch self {
case .primary:
return UIDevice.current.userInterfaceIdiom == .pad
return false

case .selectLocation, .account, .settings, .changelog, .alert:
return true
Expand Down
92 changes: 0 additions & 92 deletions ios/MullvadVPN/Classes/AutomaticKeyboardResponder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ class AutomaticKeyboardResponder {

private var lastKeyboardRect: CGRect?

private let logger = Logger(label: "AutomaticKeyboardResponder")
private var presentationFrameObserver: NSKeyValueObservation?

init<T: UIView>(targetView: T, handler: @escaping (T, CGFloat) -> Void) {
self.targetView = targetView
self.handler = { view, adjustment in
Expand All @@ -32,18 +29,6 @@ class AutomaticKeyboardResponder {
name: UIResponder.keyboardWillChangeFrameNotification,
object: nil
)
NotificationCenter.default.addObserver(
self,
selector: #selector(keyboardWillShow(_:)),
name: UIResponder.keyboardWillShowNotification,
object: nil
)
NotificationCenter.default.addObserver(
self,
selector: #selector(keyboardWillHide(_:)),
name: UIResponder.keyboardWillHideNotification,
object: nil
)
}

func updateContentInsets() {
Expand All @@ -53,14 +38,6 @@ class AutomaticKeyboardResponder {

// MARK: - Keyboard notifications

@objc private func keyboardWillShow(_ notification: Notification) {
addPresentationControllerObserver()
}

@objc private func keyboardWillHide(_ notification: Notification) {
presentationFrameObserver = nil
}

@objc private func keyboardWillChangeFrame(_ notification: Notification) {
handleKeyboardNotification(notification)
}
Expand Down Expand Up @@ -99,75 +76,6 @@ class AutomaticKeyboardResponder {
}
}

private func addPresentationControllerObserver() {
guard isFormSheetPresentation else { return }

// Presentation controller follows the keyboard on iPad.
// Install the observer to listen for the container view frame and adjust the target view
// accordingly.
guard let containerView = presentationContainerView else {
logger.warning("Cannot determine the container view in form sheet presentation.")
return
}

presentationFrameObserver = containerView.observe(
\.frame,
options: [.new],
changeHandler: { [weak self] _, _ in
guard let self,
let keyboardFrameValue = lastKeyboardRect else { return }

adjustContentInsets(convertedKeyboardFrameEnd: keyboardFrameValue)
}
)
}

/// Returns the first parent controller in the responder chain
private var parentViewController: UIViewController? {
var responder: UIResponder? = targetView
let iterator = AnyIterator { () -> UIResponder? in
responder = responder?.next
return responder
}
return iterator.first { $0 is UIViewController } as? UIViewController
}

/// Returns the presentation container view that's moved along with the keyboard on iPad
private var presentationContainerView: UIView? {
var currentView = parentViewController?.view
let iterator = AnyIterator { () -> UIView? in
currentView = currentView?.superview
return currentView
}

// Find the container view that private `_UIFormSheetPresentationController` moves
// along with the keyboard.
return iterator.first { view -> Bool in
view.description.starts(with: "<UIDropShadowView")
}
}

private var isFormSheetPresentation: Bool {
// Form sheet is only supported on iPad
guard UIDevice.current.userInterfaceIdiom == .pad else { return false }

// Find the parent controller holding the view
guard let parent = parentViewController else { return false }

// Determine presentation style within the context
let presentationStyle: UIModalPresentationStyle

// Use the presentation style of a presented controller,
// when parent controller is being presented as a child of other modal controller.
if let presented = parent.presentingViewController?.presentedViewController {
presentationStyle = presented.modalPresentationStyle
} else {
presentationStyle = parent.modalPresentationStyle
}

return presentationStyle == .formSheet
}

private func adjustContentInsets(convertedKeyboardFrameEnd: CGRect) {
guard let targetView else { return }

Expand Down
81 changes: 0 additions & 81 deletions ios/MullvadVPN/Containers/CustomSplitViewController.swift

This file was deleted.

Loading

0 comments on commit 5809c7c

Please sign in to comment.