2020-07-22 19:29:38 -07:00
|
|
|
//
|
|
|
|
|
// SceneDelegate.swift
|
|
|
|
|
// SBrowser
|
|
|
|
|
//
|
|
|
|
|
// Created by James Magahern on 7/21/20.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
2021-03-03 16:17:54 -08:00
|
|
|
public enum SessionActivityType: String {
|
|
|
|
|
case BrowserWindow = "net.buzzert.rossler-attix.browser"
|
|
|
|
|
case SettingsWindow = "net.buzzert.rossler-attix.settings"
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-22 19:29:38 -07:00
|
|
|
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|
|
|
|
var window: UIWindow?
|
2021-03-03 16:17:54 -08:00
|
|
|
|
|
|
|
|
var browserViewController: BrowserViewController?
|
|
|
|
|
var settingsViewController: SettingsViewController?
|
2020-07-22 19:29:38 -07:00
|
|
|
|
|
|
|
|
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions)
|
|
|
|
|
{
|
|
|
|
|
guard let windowScene = (scene as? UIWindowScene) else { return }
|
|
|
|
|
|
|
|
|
|
let window = UIWindow(windowScene: windowScene)
|
2021-03-03 16:17:54 -08:00
|
|
|
if let userActivity = connectionOptions.userActivities.first {
|
|
|
|
|
if userActivity.activityType == SessionActivityType.SettingsWindow.rawValue {
|
2021-06-29 18:09:42 -07:00
|
|
|
let settingsViewController = SettingsViewController(windowScene: windowScene)
|
2021-03-03 16:17:54 -08:00
|
|
|
self.settingsViewController = settingsViewController
|
|
|
|
|
window.rootViewController = settingsViewController
|
2021-06-29 18:09:42 -07:00
|
|
|
windowScene.sizeRestrictions?.maximumSize = CGSize(width: 760.0, height: 400.0)
|
2021-03-03 16:17:54 -08:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
let browserViewController = BrowserViewController()
|
|
|
|
|
self.browserViewController = browserViewController
|
|
|
|
|
window.rootViewController = browserViewController
|
|
|
|
|
|
|
|
|
|
if let urlContext = connectionOptions.urlContexts.first {
|
|
|
|
|
let url = urlContext.url
|
|
|
|
|
browserViewController.tab.beginLoadingURL(url)
|
|
|
|
|
}
|
2021-06-29 18:09:42 -07:00
|
|
|
|
|
|
|
|
#if targetEnvironment(macCatalyst)
|
|
|
|
|
windowScene.titlebar?.titleVisibility = .hidden
|
|
|
|
|
windowScene.titlebar?.separatorStyle = .none
|
|
|
|
|
#endif
|
2021-03-03 16:17:54 -08:00
|
|
|
}
|
|
|
|
|
|
2020-07-22 19:29:38 -07:00
|
|
|
window.makeKeyAndVisible()
|
|
|
|
|
self.window = window
|
|
|
|
|
}
|
2020-09-30 15:23:05 -07:00
|
|
|
|
|
|
|
|
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>)
|
|
|
|
|
{
|
|
|
|
|
for urlContext in URLContexts {
|
2021-03-03 16:17:54 -08:00
|
|
|
browserViewController?.createNewTab(withURL: urlContext.url)
|
2020-09-30 15:23:05 -07:00
|
|
|
}
|
|
|
|
|
}
|
2020-07-22 19:29:38 -07:00
|
|
|
}
|
|
|
|
|
|