Browse Source

modernize scene

master
marcoschmickler 1 week ago
parent
commit
5f2e493892
  1. 4
      kplayer.xcodeproj/project.pbxproj
  2. 53
      kplayer/AppDelegate.swift
  3. 21
      kplayer/Info.plist
  4. 6
      kplayer/detail/DetailViewController+Show.swift

4
kplayer.xcodeproj/project.pbxproj

@ -95,6 +95,7 @@
C97FE58E2FDDE6C20089D241 /* SVideoHelpView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C97FE58B2FDDE6C20089D241 /* SVideoHelpView.swift */; };
C97FE58F2FDDE6C20089D241 /* svideohelp.md in Resources */ = {isa = PBXBuildFile; fileRef = C97FE58A2FDDE6C20089D241 /* svideohelp.md */; };
C98AF5D51B124D6A00D196CC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C98AF5D41B124D6A00D196CC /* AppDelegate.swift */; };
C95CE0DE2F0000000000DE02 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C95CE0DE2F0000000000DE01 /* SceneDelegate.swift */; };
C98AF5D81B124D6A00D196CC /* kplayer.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = C98AF5D61B124D6A00D196CC /* kplayer.xcdatamodeld */; };
C98AF5DF1B124D6A00D196CC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C98AF5DD1B124D6A00D196CC /* Main.storyboard */; };
C98AF5E11B124D6A00D196CC /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C98AF5E01B124D6A00D196CC /* Images.xcassets */; };
@ -203,6 +204,7 @@
C98AF5CF1B124D6A00D196CC /* kplayer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = kplayer.app; sourceTree = BUILT_PRODUCTS_DIR; };
C98AF5D31B124D6A00D196CC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
C98AF5D41B124D6A00D196CC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
C95CE0DE2F0000000000DE01 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
C98AF5D71B124D6A00D196CC /* kplayer.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = kplayer.xcdatamodel; sourceTree = "<group>"; };
C98AF5DE1B124D6A00D196CC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
C98AF5E01B124D6A00D196CC /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
@ -418,6 +420,7 @@
isa = PBXGroup;
children = (
C98AF5D41B124D6A00D196CC /* AppDelegate.swift */,
C95CE0DE2F0000000000DE01 /* SceneDelegate.swift */,
C98AF5DD1B124D6A00D196CC /* Main.storyboard */,
C98AF5E01B124D6A00D196CC /* Images.xcassets */,
C98AF5E21B124D6A00D196CC /* LaunchScreen.xib */,
@ -621,6 +624,7 @@
files = (
C98AF5D81B124D6A00D196CC /* kplayer.xcdatamodeld in Sources */,
C98AF5D51B124D6A00D196CC /* AppDelegate.swift in Sources */,
C95CE0DE2F0000000000DE02 /* SceneDelegate.swift in Sources */,
1C736503B656C999E5E12081 /* NetworkManager.swift in Sources */,
1C736FB92B19FE17E4357C85 /* MediaItem.swift in Sources */,
1C73688D13E5A804880C8768 /* UIImageExtension.swift in Sources */,

53
kplayer/AppDelegate.swift

@ -10,29 +10,14 @@ import UIKit
import CoreData
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDelegate {
var window: UIWindow?
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// URLProtocol.registerClass(KNetworkProtocol.self)
// Override point for customization after application launch.
let splitViewController = self.window!.rootViewController as! UISplitViewController
let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController
navigationController.topViewController!.navigationItem.leftBarButtonItem = splitViewController.displayModeButtonItem
splitViewController.delegate = self
let masterNavigationController = splitViewController.viewControllers[0] as! UINavigationController
let controller = masterNavigationController.topViewController as! MasterViewController
controller.delegate = NetworkDelegate()
// App-level setup. UI/window setup lives in SceneDelegate.
LocalManager.sharedInstance.loadSettings()
NetworkManager.sharedInstance.wakeLinkstation()
controller.model.items = LocalManager.sharedInstance.model!.items
NetworkManager.sharedInstance.alive()
Timer.scheduledTimer(withTimeInterval: 60, repeats: true) { (t) in
@ -42,44 +27,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
NetworkManager.sharedInstance.alive()
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
// Called when the application is about to terminate. Save data if appropriate.
// Saves changes in the application's managed object context before the application terminates.
self.saveContext()
}
// MARK: - Split view
func splitViewController(_ splitViewController: UISplitViewController, collapseSecondary secondaryViewController:UIViewController, onto primaryViewController:UIViewController) -> Bool {
if let secondaryAsNavController = secondaryViewController as? UINavigationController {
if let topAsDetailController = secondaryAsNavController.topViewController as? DetailViewController {
if topAsDetailController.detailItem == nil {
// Return true to indicate that we have handled the collapse by doing nothing; the secondary controller will be discarded.
return true
}
}
}
return false
}
// MARK: - Core Data stack
lazy var applicationDocumentsDirectory: URL = {

21
kplayer/Info.plist

@ -41,8 +41,25 @@
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
</array>
</dict>
</dict>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>

6
kplayer/detail/DetailViewController+Show.swift

@ -172,7 +172,9 @@ extension DetailViewController {
}
func getWindow() -> UIWindow {
let delegate2 = UIApplication.shared.delegate!
return delegate2.window as! UIWindow
return UIApplication.shared.connectedScenes
.compactMap { $0 as? UIWindowScene }
.flatMap { $0.windows }
.first { $0.isKeyWindow }!
}
}
Loading…
Cancel
Save