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>
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
CDE6A30425F023BC00E912A4 /* AmberSettingsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDE6A30325F023BC00E912A4 /* AmberSettingsViewController.swift */; };
|
||||
CDE6A30625F023EA00E912A4 /* AmberSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDE6A30525F023EA00E912A4 /* AmberSettingsView.swift */; };
|
||||
CDEDD8AA25D62ADB00862605 /* UITraitCollection+MacLike.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDEDD8A925D62ADB00862605 /* UITraitCollection+MacLike.swift */; };
|
||||
CDF3468E276C105900FB3141 /* SettingsSceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDF3468D276C105900FB3141 /* SettingsSceneDelegate.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -175,6 +176,7 @@
|
||||
CDE6A30325F023BC00E912A4 /* AmberSettingsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AmberSettingsViewController.swift; sourceTree = "<group>"; };
|
||||
CDE6A30525F023EA00E912A4 /* AmberSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AmberSettingsView.swift; sourceTree = "<group>"; };
|
||||
CDEDD8A925D62ADB00862605 /* UITraitCollection+MacLike.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITraitCollection+MacLike.swift"; sourceTree = "<group>"; };
|
||||
CDF3468D276C105900FB3141 /* SettingsSceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsSceneDelegate.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -276,6 +278,7 @@
|
||||
children = (
|
||||
1ADFF45F24C7DE53006DC7AE /* AppDelegate.swift */,
|
||||
1ADFF46124C7DE53006DC7AE /* SceneDelegate.swift */,
|
||||
CDF3468D276C105900FB3141 /* SettingsSceneDelegate.swift */,
|
||||
CD7A89162519872D0075991E /* KeyboardShortcuts.swift */,
|
||||
CD7A89132519759D0075991E /* Autocomplete */,
|
||||
1ADFF47A24C7E176006DC7AE /* Backend */,
|
||||
@@ -616,6 +619,7 @@
|
||||
CD01D5AB254A206D00189CDC /* TabBarViewController.swift in Sources */,
|
||||
1ADFF47924C7DFF8006DC7AE /* BrowserView.swift in Sources */,
|
||||
CDCE2664251AA80F007FE92A /* DocumentControlViewController.swift in Sources */,
|
||||
CDF3468E276C105900FB3141 /* SettingsSceneDelegate.swift in Sources */,
|
||||
1AB88EFF24D3BBA50006F850 /* TabPickerViewController.swift in Sources */,
|
||||
CD19576D268BE95900E8089B /* GenericContentView.swift in Sources */,
|
||||
1A14FC2324D203D9009B3F83 /* TitlebarView.swift in Sources */,
|
||||
|
||||
Reference in New Issue
Block a user