Skip to content

Commit af78b4f

Browse files
authored
Patch 4.0.4
fix: - Resolved problem with view state update in onAppear in app that uses popup with SceneDelegate. - Added an ability to manage the window responder state if it becomes inactive.
1 parent 11f5fff commit af78b4f

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

Sources/Public/Setup/Public+Setup+SceneDelegate.swift

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ import SwiftUI
5555
open class PopupSceneDelegate: NSObject, UIWindowSceneDelegate {
5656
open var window: UIWindow?
5757
open var configBuilder: (GlobalConfigContainer) -> (GlobalConfigContainer) = { _ in .init() }
58+
open func sceneStoppedBeingFirstResponder() { }
59+
open func makeSceneKey() { window?.makeKey() }
5860
}
5961

6062
// MARK: Create Popup Scene
@@ -65,10 +67,10 @@ extension PopupSceneDelegate {
6567
.registerPopups(configBuilder: configBuilder)
6668
)
6769
hostingController.view.backgroundColor = .clear
68-
69-
window = Window(windowScene: windowScene)
70+
window = Window(scene: self, windowScene: windowScene)
7071
window?.rootViewController = hostingController
7172
window?.isHidden = false
73+
window?.makeKey()
7274
}}
7375
}
7476

@@ -77,8 +79,21 @@ extension PopupSceneDelegate {
7779

7880

7981

80-
// MARK: Implementation
82+
8183
fileprivate class Window: UIWindow {
84+
weak var scene: PopupSceneDelegate?
85+
86+
init(scene: PopupSceneDelegate, windowScene: UIWindowScene) {
87+
super.init(windowScene: windowScene)
88+
self.scene = scene
89+
}
90+
required init?(coder: NSCoder) {
91+
fatalError("init(coder:) has not been implemented")
92+
}
93+
}
94+
95+
// MARK: Implementation
96+
extension Window {
8297
override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
8398
if #available(iOS 26, *) { point_iOS26(inside: point, with: event) }
8499
else if #available(iOS 18, *) { point_iOS18(inside: point, with: event) }
@@ -89,6 +104,11 @@ fileprivate class Window: UIWindow {
89104
else if #available(iOS 18, *) { hitTest_iOS18(point, with: event) }
90105
else { hitTest_iOS17(point, with: event) }
91106
}
107+
override func resignKey() {
108+
super.resignKey()
109+
110+
scene?.sceneStoppedBeingFirstResponder()
111+
}
92112
}
93113

94114
// MARK: Point

0 commit comments

Comments
 (0)