diff options
Diffstat (limited to 'ios')
| -rw-r--r-- | ios/MullvadVPN/AppDelegate.swift | 33 | ||||
| -rw-r--r-- | ios/MullvadVPN/Base.lproj/Main.storyboard | 25 | ||||
| -rw-r--r-- | ios/MullvadVPN/ViewControllerIdentifier.swift | 1 |
3 files changed, 44 insertions, 15 deletions
diff --git a/ios/MullvadVPN/AppDelegate.swift b/ios/MullvadVPN/AppDelegate.swift index 94f04ef9c4..797519cd57 100644 --- a/ios/MullvadVPN/AppDelegate.swift +++ b/ios/MullvadVPN/AppDelegate.swift @@ -6,6 +6,7 @@ // Copyright © 2019 Amagicom AB. All rights reserved. // +import Combine import UIKit @UIApplicationMain @@ -15,20 +16,34 @@ class AppDelegate: UIResponder, UIApplicationDelegate { let mainStoryboard = UIStoryboard(name: "Main", bundle: nil) + private var loadTunnelSubscriber: AnyCancellable? + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - let rootViewController = window?.rootViewController as! RootContainerViewController - let loginViewController = mainStoryboard.instantiateViewController(withIdentifier: ViewControllerIdentifier.login.rawValue) + let accountToken = Account.shared.token + + loadTunnelSubscriber = TunnelManager.shared.loadTunnel(accountToken: accountToken) + .receive(on: DispatchQueue.main) + .sink(receiveCompletion: { (completion) in + if case .failure(let error) = completion { + fatalError("Failed to restore the account: \(error.localizedDescription)") + } + + let rootViewController = self.mainStoryboard.instantiateViewController(identifier: ViewControllerIdentifier.root.rawValue) as! RootContainerViewController + + let loginViewController = self.mainStoryboard.instantiateViewController(withIdentifier: ViewControllerIdentifier.login.rawValue) + + var viewControllers = [loginViewController] - var viewControllers = [UIViewController]() - viewControllers.append(loginViewController) + if accountToken != nil { + let mainViewController = self.mainStoryboard.instantiateViewController(withIdentifier: ViewControllerIdentifier.main.rawValue) - if Account.isLoggedIn { - let mainViewController = mainStoryboard.instantiateViewController(withIdentifier: ViewControllerIdentifier.main.rawValue) + viewControllers.append(mainViewController) + } - viewControllers.append(mainViewController) - } + rootViewController.setViewControllers(viewControllers, animated: false) - rootViewController.setViewControllers(viewControllers, animated: false) + self.window?.rootViewController = rootViewController + }) return true } diff --git a/ios/MullvadVPN/Base.lproj/Main.storyboard b/ios/MullvadVPN/Base.lproj/Main.storyboard index 911e1634a6..118282aaa9 100644 --- a/ios/MullvadVPN/Base.lproj/Main.storyboard +++ b/ios/MullvadVPN/Base.lproj/Main.storyboard @@ -1,18 +1,31 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="aW6-TO-kM3"> - <device id="retina4_7" orientation="portrait"> - <adaptation id="fullscreen"/> - </device> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="ZwP-1v-DUg"> + <device id="retina4_7" orientation="portrait" appearance="light"/> <dependencies> - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/> + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15510"/> <capability name="Safe area layout guides" minToolsVersion="9.0"/> <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> </dependencies> <scenes> + <!--View Controller--> + <scene sceneID="CoT-3Z-u4r"> + <objects> + <viewController id="ZwP-1v-DUg" sceneMemberID="viewController"> + <view key="view" contentMode="scaleToFill" id="wUi-kO-wH5"> + <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> + <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> + <color key="backgroundColor" red="0.16078431369999999" green="0.30196078430000001" blue="0.45098039220000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/> + <viewLayoutGuide key="safeArea" id="v9s-xL-YMl"/> + </view> + </viewController> + <placeholder placeholderIdentifier="IBFirstResponder" id="2sf-Y1-Ntj" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/> + </objects> + <point key="canvasLocation" x="-1274" y="27"/> + </scene> <!--Root Container View Controller--> <scene sceneID="euw-TF-Dd7"> <objects> - <viewController id="aW6-TO-kM3" customClass="RootContainerViewController" customModule="MullvadVPN" customModuleProvider="target" sceneMemberID="viewController"> + <viewController storyboardIdentifier="Root" id="aW6-TO-kM3" customClass="RootContainerViewController" customModule="MullvadVPN" customModuleProvider="target" sceneMemberID="viewController"> <view key="view" contentMode="scaleToFill" id="hQl-Sx-c1J"> <rect key="frame" x="0.0" y="0.0" width="375" height="667"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> diff --git a/ios/MullvadVPN/ViewControllerIdentifier.swift b/ios/MullvadVPN/ViewControllerIdentifier.swift index a81f39320b..0c9ce17092 100644 --- a/ios/MullvadVPN/ViewControllerIdentifier.swift +++ b/ios/MullvadVPN/ViewControllerIdentifier.swift @@ -9,6 +9,7 @@ import Foundation enum ViewControllerIdentifier: String { + case root = "Root" case login = "Login" case main = "Main" } |
