@@ -29,57 +29,6 @@ public struct RCTMainWindow: Scene {
29
29
public var body : some Scene {
30
30
WindowGroup {
31
31
RCTRootViewRepresentable ( moduleName: moduleName, initialProps: initialProps)
32
- . modifier ( WindowHandlingModifier ( ) )
33
- }
34
- }
35
- }
36
-
37
- /**
38
- Handles data sharing between React Native and SwiftUI views.
39
- */
40
- public struct WindowHandlingModifier : ViewModifier {
41
- typealias UserInfoType = Dictionary < String , AnyHashable >
42
-
43
- @Environment ( \. reactContext) private var reactContext
44
- @Environment ( \. openWindow) private var openWindow
45
- @Environment ( \. dismissWindow) private var dismissWindow
46
- @Environment ( \. supportsMultipleWindows) private var supportsMultipleWindows
47
-
48
- public init ( ) { }
49
-
50
- public func body( content: Content ) -> some View {
51
- // Attach listeners only if app supports multiple windows
52
- if supportsMultipleWindows {
53
- content
54
- . onReceive ( NotificationCenter . default. publisher ( for: NSNotification . Name ( " RCTOpenWindow " ) ) ) { data in
55
- guard let id = data. userInfo ? [ " id " ] as? String else { return }
56
- reactContext. scenes. updateValue ( RCTSceneData ( id: id, props: data. userInfo ? [ " userInfo " ] as? UserInfoType ) , forKey: id)
57
- openWindow ( id: id)
58
- }
59
- . onReceive ( NotificationCenter . default. publisher ( for: NSNotification . Name ( " RCTUpdateWindow " ) ) ) { data in
60
- guard
61
- let id = data. userInfo ? [ " id " ] as? String ,
62
- let userInfo = data. userInfo ? [ " userInfo " ] as? UserInfoType else { return }
63
- reactContext. scenes [ id] ? . props = userInfo
64
- }
65
- . onReceive ( NotificationCenter . default. publisher ( for: NSNotification . Name ( " RCTDismissWindow " ) ) ) { data in
66
- guard let id = data. userInfo ? [ " id " ] as? String else { return }
67
- dismissWindow ( id: id)
68
- reactContext. scenes. removeValue ( forKey: id)
69
- }
70
- . onReceive ( NotificationCenter . default. publisher ( for: NSNotification . Name ( " RCTOpenImmersiveSpace " ) ) ) { data in
71
- guard let id = data. userInfo ? [ " id " ] as? String else { return }
72
- reactContext. scenes. updateValue (
73
- RCTSceneData ( id: id, props: data. userInfo ? [ " userInfo " ] as? UserInfoType ) ,
74
- forKey: id
75
- )
76
- }
77
- . onReceive ( NotificationCenter . default. publisher ( for: NSNotification . Name ( " RCTDismissImmersiveSpace " ) ) ) { data in
78
- guard let id = data. userInfo ? [ " id " ] as? String else { return }
79
- reactContext. scenes. removeValue ( forKey: id)
80
- }
81
- } else {
82
- content
83
32
}
84
33
}
85
34
}
0 commit comments