diff options
| author | Andrej Mihajlov <and@mullvad.net> | 2020-07-21 18:52:20 +0300 |
|---|---|---|
| committer | Andrej Mihajlov <and@mullvad.net> | 2020-07-22 18:35:43 +0300 |
| commit | 4f01cf0253fe74838825e4c40208fa9ca9c3268c (patch) | |
| tree | 1c9ce82f060d53dcd5246f13bc4bd6bebc7376d7 | |
| parent | 646001fbd96e7955a3d672357c42bc398a91c241 (diff) | |
| download | mullvadvpn-4f01cf0253fe74838825e4c40208fa9ca9c3268c.tar.xz mullvadvpn-4f01cf0253fe74838825e4c40208fa9ca9c3268c.zip | |
Prefetch relays before showing the SelectLocationController
| -rw-r--r-- | ios/MullvadVPN/Base.lproj/Main.storyboard | 50 | ||||
| -rw-r--r-- | ios/MullvadVPN/ConnectViewController.swift | 26 | ||||
| -rw-r--r-- | ios/MullvadVPN/SegueIdentifier.swift | 1 | ||||
| -rw-r--r-- | ios/MullvadVPN/SelectLocationController.swift | 13 | ||||
| -rw-r--r-- | ios/MullvadVPN/ViewControllerIdentifier.swift | 1 |
5 files changed, 49 insertions, 42 deletions
diff --git a/ios/MullvadVPN/Base.lproj/Main.storyboard b/ios/MullvadVPN/Base.lproj/Main.storyboard index db5a927b89..164513734b 100644 --- a/ios/MullvadVPN/Base.lproj/Main.storyboard +++ b/ios/MullvadVPN/Base.lproj/Main.storyboard @@ -280,7 +280,6 @@ <outlet property="connectionPanel" destination="ocV-9f-WDZ" id="Uad-bl-KFU"/> <outlet property="countryLabel" destination="9Yf-sl-l3q" id="L3N-Jn-zlr"/> <outlet property="secureLabel" destination="HNy-mU-nui" id="QBg-mR-Z6g"/> - <segue destination="hOC-Ab-N3D" kind="presentation" identifier="ShowRelaySelector" id="mui-V1-CK4"/> </connections> </viewController> <placeholder placeholderIdentifier="IBFirstResponder" id="gkg-dm-hcG" userLabel="First Responder" sceneMemberID="firstResponder"/> @@ -299,20 +298,20 @@ <color key="separatorColor" name="Secondary"/> <prototypes> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="Account" id="ghE-jC-RWf" customClass="SettingsAccountCell" customModule="MullvadVPN" customModuleProvider="target"> - <rect key="frame" x="0.0" y="55.5" width="375" height="43"/> + <rect key="frame" x="0.0" y="55.5" width="375" height="43.5"/> <autoresizingMask key="autoresizingMask"/> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="ghE-jC-RWf" id="sTl-gI-g2a"> - <rect key="frame" x="0.0" y="0.0" width="348" height="43"/> + <rect key="frame" x="0.0" y="0.0" width="348" height="43.5"/> <autoresizingMask key="autoresizingMask"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Account" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Lve-Kd-qTr"> - <rect key="frame" x="16" y="11" width="63.5" height="21"/> + <rect key="frame" x="16" y="11" width="63.5" height="21.5"/> <fontDescription key="fontDescription" type="system" pointSize="17"/> <color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <nil key="highlightedColor"/> </label> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="252" verticalHuggingPriority="251" text="A YEAR LEFT" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QeD-EQ-Ruo"> - <rect key="frame" x="259" y="11" width="81" height="21"/> + <rect key="frame" x="259" y="11" width="81" height="21.5"/> <fontDescription key="fontDescription" type="system" weight="medium" pointSize="13"/> <color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <nil key="highlightedColor"/> @@ -337,20 +336,20 @@ </connections> </tableViewCell> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="AppVersion" id="pbd-iC-Emm" customClass="SettingsAppVersionCell" customModule="MullvadVPN" customModuleProvider="target"> - <rect key="frame" x="0.0" y="98.5" width="375" height="43"/> + <rect key="frame" x="0.0" y="99" width="375" height="43.5"/> <autoresizingMask key="autoresizingMask"/> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="pbd-iC-Emm" id="lYp-Z8-1sN"> - <rect key="frame" x="0.0" y="0.0" width="375" height="43"/> + <rect key="frame" x="0.0" y="0.0" width="375" height="43.5"/> <autoresizingMask key="autoresizingMask"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="App version" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pYC-Zb-8N9"> - <rect key="frame" x="16" y="11" width="91" height="21"/> + <rect key="frame" x="16" y="11" width="91" height="21.5"/> <fontDescription key="fontDescription" type="system" pointSize="17"/> <color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <nil key="highlightedColor"/> </label> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="252" verticalHuggingPriority="251" text="2018.3" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="sOr-vj-cg7"> - <rect key="frame" x="316.5" y="11" width="42.5" height="21"/> + <rect key="frame" x="316.5" y="11" width="42.5" height="21.5"/> <fontDescription key="fontDescription" type="system" weight="medium" pointSize="13"/> <color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <nil key="highlightedColor"/> @@ -372,14 +371,14 @@ </connections> </tableViewCell> <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" accessoryType="disclosureIndicator" indentationWidth="10" reuseIdentifier="BasicDisclosure" id="Ahs-gu-nTM" customClass="SettingsBasicCell" customModule="MullvadVPN" customModuleProvider="target"> - <rect key="frame" x="0.0" y="141.5" width="375" height="43"/> + <rect key="frame" x="0.0" y="142.5" width="375" height="43.5"/> <autoresizingMask key="autoresizingMask"/> <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Ahs-gu-nTM" id="Drq-vk-8F2"> - <rect key="frame" x="0.0" y="0.0" width="348" height="43"/> + <rect key="frame" x="0.0" y="0.0" width="348" height="43.5"/> <autoresizingMask key="autoresizingMask"/> <subviews> <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Amw-A3-ePS"> - <rect key="frame" x="16" y="11" width="324" height="21"/> + <rect key="frame" x="16" y="11" width="324" height="21.5"/> <fontDescription key="fontDescription" type="system" pointSize="17"/> <color key="textColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> <nil key="highlightedColor"/> @@ -1012,32 +1011,12 @@ </objects> <point key="canvasLocation" x="-551" y="27"/> </scene> - <!--Navigation Controller--> - <scene sceneID="oT4-Ap-qrZ"> - <objects> - <navigationController id="hOC-Ab-N3D" sceneMemberID="viewController"> - <navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" barStyle="black" largeTitles="YES" id="kmu-Ab-x1c" customClass="CustomNavigationBar" customModule="MullvadVPN" customModuleProvider="target"> - <rect key="frame" x="0.0" y="0.0" width="375" height="108"/> - <autoresizingMask key="autoresizingMask"/> - <color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> - <textAttributes key="largeTitleTextAttributes"> - <offsetWrapper key="textShadowOffset" horizontal="0.0" vertical="0.0"/> - </textAttributes> - </navigationBar> - <connections> - <segue destination="FxZ-7F-3yi" kind="relationship" relationship="rootViewController" id="cFv-eb-G19"/> - </connections> - </navigationController> - <placeholder placeholderIdentifier="IBFirstResponder" id="GCK-Z5-Jwh" userLabel="First Responder" sceneMemberID="firstResponder"/> - </objects> - <point key="canvasLocation" x="1690" y="841"/> - </scene> <!--Select location--> <scene sceneID="Kar-Ys-a6u"> <objects> - <tableViewController id="FxZ-7F-3yi" customClass="SelectLocationController" customModule="MullvadVPN" customModuleProvider="target" sceneMemberID="viewController"> + <tableViewController storyboardIdentifier="SelectLocation" id="FxZ-7F-3yi" customClass="SelectLocationController" customModule="MullvadVPN" customModuleProvider="target" sceneMemberID="viewController"> <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="56" sectionHeaderHeight="28" sectionFooterHeight="28" id="LKX-4h-vIx"> - <rect key="frame" x="0.0" y="0.0" width="375" height="647"/> + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <color key="backgroundColor" name="Secondary"/> <color key="separatorColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> @@ -1130,6 +1109,7 @@ </connections> </barButtonItem> </navigationItem> + <simulatedNavigationBarMetrics key="simulatedTopBarMetrics" prompted="NO"/> <connections> <segue destination="6Lc-ZQ-E4P" kind="unwind" identifier="ReturnToConnectWithNewRelay" unwindAction="unwindFromSelectLocationWithSegue:" id="SPT-Ay-Cy3"/> </connections> @@ -1137,7 +1117,7 @@ <placeholder placeholderIdentifier="IBFirstResponder" id="EvX-LH-gOg" userLabel="First Responder" sceneMemberID="firstResponder"/> <exit id="6Lc-ZQ-E4P" userLabel="Exit" sceneMemberID="exit"/> </objects> - <point key="canvasLocation" x="2649" y="841"/> + <point key="canvasLocation" x="1689" y="779"/> </scene> <!--Tunnel Control View Controller--> <scene sceneID="Zzn-S1-fVu"> diff --git a/ios/MullvadVPN/ConnectViewController.swift b/ios/MullvadVPN/ConnectViewController.swift index c2bcaf0e95..ace0eb198b 100644 --- a/ios/MullvadVPN/ConnectViewController.swift +++ b/ios/MullvadVPN/ConnectViewController.swift @@ -97,9 +97,7 @@ class ConnectViewController: UIViewController, disconnectTunnel() case .selectLocation: - performSegue( - withIdentifier: SegueIdentifier.Connect.showRelaySelector.rawValue, - sender: self) + showSelectLocation() } } @@ -194,6 +192,28 @@ class ConnectViewController: UIViewController, } } + private func showSelectLocation() { + let contentController = self.storyboard?.instantiateViewController(withIdentifier: ViewControllerIdentifier.selectLocation.rawValue) as! SelectLocationController + contentController.navigationItem.title = NSLocalizedString("Select location", comment: "") + contentController.navigationItem.largeTitleDisplayMode = .always + + let navController = UINavigationController(navigationBarClass: CustomNavigationBar.self, toolbarClass: nil) + navController.viewControllers = [contentController] + navController.navigationBar.prefersLargeTitles = true + navController.navigationBar.barStyle = .black + navController.navigationBar.tintColor = .white + + // Disable root controller interaction + rootContainerController?.view.isUserInteractionEnabled = false + + contentController.prefetchData { + self.present(navController, animated: true) + + // Re-enable root controller interaction + self.rootContainerController?.view.isUserInteractionEnabled = true + } + } + // MARK: - Actions @objc func handleConnectionPanelButton(_ sender: Any) { diff --git a/ios/MullvadVPN/SegueIdentifier.swift b/ios/MullvadVPN/SegueIdentifier.swift index fa7a3cbc33..d6345a4e06 100644 --- a/ios/MullvadVPN/SegueIdentifier.swift +++ b/ios/MullvadVPN/SegueIdentifier.swift @@ -24,7 +24,6 @@ extension SegueIdentifier { enum Connect: String, SegueConvertible { case embedTunnelControls = "EmbedTunnelControls" - case showRelaySelector = "ShowRelaySelector" } enum SelectLocation: String, SegueConvertible { diff --git a/ios/MullvadVPN/SelectLocationController.swift b/ios/MullvadVPN/SelectLocationController.swift index fe00bee887..affb127003 100644 --- a/ios/MullvadVPN/SelectLocationController.swift +++ b/ios/MullvadVPN/SelectLocationController.swift @@ -64,7 +64,10 @@ class SelectLocationController: UITableViewController, RelayCacheObserver { tableView.dataSource = dataSource RelayCache.shared.addObserver(self) - loadData() + + updateDataSource(animateDifferences: false) { + self.updateTableViewSelection(scroll: true, animated: false) + } } override func viewDidLayoutSubviews() { @@ -113,9 +116,9 @@ class SelectLocationController: UITableViewController, RelayCacheObserver { } } - // MARK: - Relay list handling + // MARK: - Public - private func loadData() { + func prefetchData(completionHandler: @escaping () -> Void) { fetchRelays { (result) in DispatchQueue.main.async { switch result { @@ -125,10 +128,14 @@ class SelectLocationController: UITableViewController, RelayCacheObserver { case .failure(let error): error.logChain() } + + completionHandler() } } } + // MARK: - Relay list handling + private func fetchRelays(completionHandler: @escaping (Result<(CachedRelays, RelayConstraints), Error>) -> Void) { RelayCache.shared.read { (result) in switch result { diff --git a/ios/MullvadVPN/ViewControllerIdentifier.swift b/ios/MullvadVPN/ViewControllerIdentifier.swift index dd4e8cbcff..d2eaad74bb 100644 --- a/ios/MullvadVPN/ViewControllerIdentifier.swift +++ b/ios/MullvadVPN/ViewControllerIdentifier.swift @@ -13,4 +13,5 @@ enum ViewControllerIdentifier: String { case login = "Login" case main = "Main" case settings = "Settings" + case selectLocation = "SelectLocation" } |
