Skip to content

Commit

Permalink
Expose more scene delegate events
Browse files Browse the repository at this point in the history
  • Loading branch information
basememara committed Nov 2, 2019
1 parent 9c936cf commit 73dc053
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import UIKit
/// log.warn("App will terminate.")
/// }
/// }
open class ApplicationPluggableDelegate: UIResponder, UIApplicationDelegate {
open class ApplicationPluggableDelegate: UIResponder, UIApplicationDelegate, WindowDelegate {
public var window: UIWindow?

/// List of application plugins for binding to `AppDelegate` events
Expand Down
17 changes: 16 additions & 1 deletion Sources/ZamzamCore/Application/ScenePluggableDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import UIKit
/// }
/// }
@available(iOS 13.0, *)
open class ScenePluggableDelegate: UIResponder, UIWindowSceneDelegate {
open class ScenePluggableDelegate: UIResponder, UIWindowSceneDelegate, WindowDelegate {
public var window: UIWindow?

/// List of scene plugins for binding to `SceneDelegate` events
Expand All @@ -54,6 +54,10 @@ open class ScenePluggableDelegate: UIResponder, UIWindowSceneDelegate {
@available(iOS 13.0, *)
extension ScenePluggableDelegate {

open func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
pluginInstances.forEach { $0.scene(scene, willConnectTo: session, options: connectionOptions) }
}

open func sceneWillEnterForeground(_ scene: UIScene) {
pluginInstances.forEach { $0.sceneWillEnterForeground() }
}
Expand Down Expand Up @@ -92,6 +96,10 @@ public protocol ScenePlugin {

/// Tells the delegate that UIKit removed a scene from your app.
func sceneDidDisconnect()

/// Tells the delegate about the addition of a scene to the app.
@available(iOS 13.0, *)
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions)
}

// MARK: - Optionals
Expand All @@ -102,5 +110,12 @@ public extension ScenePlugin {
func sceneDidBecomeActive() {}
func sceneWillResignActive() {}
func sceneDidDisconnect() {}

@available(iOS 13.0, *)
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {}
}

public protocol WindowDelegate: class {
var window: UIWindow? { get set }
}
#endif

0 comments on commit 73dc053

Please sign in to comment.