Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
flare-appleuniversal/Flare/Browser Scene/FLBBrowserSceneDelegate.swift
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
60 lines (41 sloc)
1.49 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // SceneDelegate.swift | |
| // Flare | |
| // | |
| // Created by Steven Troughton-Smith on 23/08/2021. | |
| // | |
| import UIKit | |
| class FLBBrowserSceneDelegate: UIResponder, UIWindowSceneDelegate { | |
| var window: UIWindow? | |
| let browserRelay = FLBBrowserRelay() | |
| let webViewController = FLBWebViewController() | |
| #if targetEnvironment(macCatalyst) | |
| var addressFieldItem:NSToolbarItem? | |
| #endif | |
| func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | |
| if let windowScene = scene as? UIWindowScene { | |
| let userInfo = connectionOptions.userActivities.first?.userInfo as NSDictionary? | |
| var cachedAddress = userInfo?["address"] | |
| if cachedAddress == nil { | |
| cachedAddress = session.stateRestorationActivity?.userInfo?["address"] | |
| } | |
| let window = UIWindow(windowScene: windowScene) | |
| windowScene.title = NSLocalizedString("PAGE_TITLE_BLANK", comment: "") | |
| webViewController.relay = browserRelay | |
| window.rootViewController = webViewController | |
| self.window = window | |
| #if targetEnvironment(macCatalyst) | |
| buildMacToolbar() | |
| #endif | |
| window.makeKeyAndVisible() | |
| if let cachedAddress = cachedAddress as? String { | |
| webViewController.resumeAddress(cachedAddress) | |
| } | |
| } | |
| } | |
| func stateRestorationActivity(for scene: UIScene) -> NSUserActivity? { | |
| let userActivity = NSUserActivity(activityType: "Browser") | |
| userActivity.userInfo = ["address":browserRelay.address.absoluteString] | |
| return userActivity | |
| } | |
| } | |