1
1
import SwiftUI
2
- import React
3
2
4
3
/**
5
4
This SwiftUI struct returns main React Native scene. It should be used only once as it conains setup code.
@@ -22,11 +21,11 @@ public struct RCTMainWindow: Scene {
22
21
var moduleName : String
23
22
var initialProps : RCTRootViewRepresentable . InitialPropsType
24
23
var onOpenURLCallback : ( ( URL ) -> ( ) ) ?
25
- var devMenuPlacement : ToolbarPlacement = . bottomOrnament
24
+ var devMenuSceneAnchor : UnitPoint ?
26
25
var contentView : AnyView ?
27
26
28
27
var rootView : RCTRootViewRepresentable {
29
- RCTRootViewRepresentable ( moduleName: moduleName, initialProps: initialProps)
28
+ RCTRootViewRepresentable ( moduleName: moduleName, initialProps: initialProps, devMenuSceneAnchor : devMenuSceneAnchor )
30
29
}
31
30
32
31
/// Creates new RCTMainWindowWindow.
@@ -38,11 +37,11 @@ public struct RCTMainWindow: Scene {
38
37
public init (
39
38
moduleName: String ,
40
39
initialProps: RCTRootViewRepresentable . InitialPropsType = nil ,
41
- devMenuPlacement : ToolbarPlacement = . bottomOrnament
40
+ devMenuSceneAnchor : UnitPoint ? = . bottom
42
41
) {
43
42
self . moduleName = moduleName
44
43
self . initialProps = initialProps
45
- self . devMenuPlacement = devMenuPlacement
44
+ self . devMenuSceneAnchor = devMenuSceneAnchor
46
45
self . contentView = AnyView ( rootView)
47
46
}
48
47
@@ -56,12 +55,12 @@ public struct RCTMainWindow: Scene {
56
55
public init < Content: View > (
57
56
moduleName: String ,
58
57
initialProps: RCTRootViewRepresentable . InitialPropsType = nil ,
59
- devMenuPlacement : ToolbarPlacement = . bottomOrnament ,
58
+ devMenuSceneAnchor : UnitPoint ? = . bottom ,
60
59
@ViewBuilder contentView: @escaping ( _ view: RCTRootViewRepresentable ) -> Content
61
60
) {
62
61
self . moduleName = moduleName
63
62
self . initialProps = initialProps
64
- self . devMenuPlacement = devMenuPlacement
63
+ self . devMenuSceneAnchor = devMenuSceneAnchor
65
64
self . contentView = AnyView ( contentView ( rootView) )
66
65
}
67
66
@@ -72,11 +71,6 @@ public struct RCTMainWindow: Scene {
72
71
. onOpenURL ( perform: { url in
73
72
onOpenURLCallback ? ( url)
74
73
} )
75
- #if DEBUG
76
- . toolbar {
77
- DevMenuView ( placement: . bottomOrnament)
78
- }
79
- #endif
80
74
}
81
75
}
82
76
}
@@ -139,29 +133,3 @@ public struct WindowHandlingModifier: ViewModifier {
139
133
}
140
134
}
141
135
142
- /**
143
- Toolbar which displays additional controls to easily open dev menu and trigger reload command.
144
- */
145
- struct DevMenuView : ToolbarContent {
146
- let placement : ToolbarItemPlacement
147
-
148
- var body : some ToolbarContent {
149
- ToolbarItem ( placement: placement) {
150
- Button ( action: {
151
- RCTTriggerReloadCommandListeners ( " User Reload " )
152
- } , label: {
153
- Image ( systemName: " arrow.clockwise " )
154
- } )
155
- }
156
- ToolbarItem ( placement: placement) {
157
- Button ( action: {
158
- NotificationCenter . default. post (
159
- Notification ( name: Notification . Name ( " RCTShowDevMenuNotification " ) , object: nil )
160
- )
161
- } ,
162
- label: {
163
- Image ( systemName: " filemenu.and.selection " )
164
- } )
165
- }
166
- }
167
- }
0 commit comments