Settings: Actually make settings scene properly
This commit is contained in:
@@ -19,7 +19,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration
|
||||
{
|
||||
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
|
||||
if let userActivity = options.userActivities.first {
|
||||
if userActivity.activityType == SessionActivityType.SettingsWindow.rawValue {
|
||||
return UISceneConfiguration(name: "Settings", sessionRole: connectingSceneSession.role)
|
||||
}
|
||||
}
|
||||
|
||||
return UISceneConfiguration(name: "Browser", sessionRole: connectingSceneSession.role)
|
||||
}
|
||||
|
||||
static func appMenuShortcuts() -> [UIKeyCommand] {
|
||||
|
||||
@@ -23,29 +23,20 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
guard let windowScene = (scene as? UIWindowScene) else { return }
|
||||
|
||||
let window = UIWindow(windowScene: windowScene)
|
||||
if let userActivity = connectionOptions.userActivities.first {
|
||||
if userActivity.activityType == SessionActivityType.SettingsWindow.rawValue {
|
||||
let settingsViewController = SettingsViewController(windowScene: windowScene)
|
||||
self.settingsViewController = settingsViewController
|
||||
window.rootViewController = settingsViewController
|
||||
windowScene.sizeRestrictions?.maximumSize = CGSize(width: 760.0, height: 400.0)
|
||||
}
|
||||
} else {
|
||||
let browserViewController = BrowserViewController()
|
||||
self.browserViewController = browserViewController
|
||||
window.rootViewController = browserViewController
|
||||
|
||||
if let urlContext = connectionOptions.urlContexts.first {
|
||||
let url = urlContext.url
|
||||
browserViewController.tab.beginLoadingURL(url)
|
||||
}
|
||||
|
||||
#if targetEnvironment(macCatalyst)
|
||||
windowScene.titlebar?.titleVisibility = .hidden
|
||||
windowScene.titlebar?.separatorStyle = .none
|
||||
#endif
|
||||
let browserViewController = BrowserViewController()
|
||||
self.browserViewController = browserViewController
|
||||
window.rootViewController = browserViewController
|
||||
|
||||
if let urlContext = connectionOptions.urlContexts.first {
|
||||
let url = urlContext.url
|
||||
browserViewController.tab.beginLoadingURL(url)
|
||||
}
|
||||
|
||||
#if targetEnvironment(macCatalyst)
|
||||
windowScene.titlebar?.titleVisibility = .hidden
|
||||
windowScene.titlebar?.separatorStyle = .none
|
||||
#endif
|
||||
|
||||
window.makeKeyAndVisible()
|
||||
self.window = window
|
||||
}
|
||||
|
||||
28
App/SettingsSceneDelegate.swift
Normal file
28
App/SettingsSceneDelegate.swift
Normal file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// SettingsSceneDelegate.swift
|
||||
// SBrowser
|
||||
//
|
||||
// Copyright © 2021 Apple Inc. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
class SettingsSceneDelegate: UIResponder, UIWindowSceneDelegate {
|
||||
var window: UIWindow?
|
||||
|
||||
var settingsViewController: SettingsViewController?
|
||||
|
||||
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions)
|
||||
{
|
||||
guard let windowScene = (scene as? UIWindowScene) else { return }
|
||||
|
||||
let window = UIWindow(windowScene: windowScene)
|
||||
let settingsViewController = SettingsViewController(windowScene: windowScene)
|
||||
self.settingsViewController = settingsViewController
|
||||
window.rootViewController = settingsViewController
|
||||
windowScene.sizeRestrictions?.maximumSize = CGSize(width: 760.0, height: 400.0)
|
||||
|
||||
window.makeKeyAndVisible()
|
||||
self.window = window
|
||||
}
|
||||
}
|
||||
@@ -50,8 +50,14 @@
|
||||
<key>UIWindowSceneSessionRoleApplication</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>UISceneDelegateClassName</key>
|
||||
<string>$(PRODUCT_MODULE_NAME).SettingsSceneDelegate</string>
|
||||
<key>UISceneConfigurationName</key>
|
||||
<string>Default Configuration</string>
|
||||
<string>Settings</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>UISceneConfigurationName</key>
|
||||
<string>Browser</string>
|
||||
<key>UISceneDelegateClassName</key>
|
||||
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
|
||||
</dict>
|
||||
|
||||
Reference in New Issue
Block a user