@@ -22,11 +22,11 @@ public struct RCTMainWindow: Scene {
22
22
var moduleName : String
23
23
var initialProps : RCTRootViewRepresentable . InitialPropsType
24
24
var onOpenURLCallback : ( ( URL ) -> ( ) ) ?
25
- var devMenuPlacement : ToolbarPlacement = . bottomOrnament
25
+ var devMenuSceneAnchor : UnitPoint ?
26
26
var contentView : AnyView ?
27
27
28
28
var rootView : RCTRootViewRepresentable {
29
- RCTRootViewRepresentable ( moduleName: moduleName, initialProps: initialProps)
29
+ RCTRootViewRepresentable ( moduleName: moduleName, initialProps: initialProps, devMenuSceneAnchor : devMenuSceneAnchor )
30
30
}
31
31
32
32
/// Creates new RCTMainWindowWindow.
@@ -38,11 +38,11 @@ public struct RCTMainWindow: Scene {
38
38
public init (
39
39
moduleName: String ,
40
40
initialProps: RCTRootViewRepresentable . InitialPropsType = nil ,
41
- devMenuPlacement : ToolbarPlacement = . bottomOrnament
41
+ devMenuSceneAnchor : UnitPoint ? = . bottom
42
42
) {
43
43
self . moduleName = moduleName
44
44
self . initialProps = initialProps
45
- self . devMenuPlacement = devMenuPlacement
45
+ self . devMenuSceneAnchor = devMenuSceneAnchor
46
46
self . contentView = AnyView ( rootView)
47
47
}
48
48
@@ -56,12 +56,12 @@ public struct RCTMainWindow: Scene {
56
56
public init < Content: View > (
57
57
moduleName: String ,
58
58
initialProps: RCTRootViewRepresentable . InitialPropsType = nil ,
59
- devMenuPlacement : ToolbarPlacement = . bottomOrnament ,
59
+ devMenuSceneAnchor : UnitPoint ? = . bottom ,
60
60
@ViewBuilder contentView: @escaping ( _ view: RCTRootViewRepresentable ) -> Content
61
61
) {
62
62
self . moduleName = moduleName
63
63
self . initialProps = initialProps
64
- self . devMenuPlacement = devMenuPlacement
64
+ self . devMenuSceneAnchor = devMenuSceneAnchor
65
65
self . contentView = AnyView ( contentView ( rootView) )
66
66
}
67
67
@@ -72,11 +72,6 @@ public struct RCTMainWindow: Scene {
72
72
. onOpenURL ( perform: { url in
73
73
onOpenURLCallback ? ( url)
74
74
} )
75
- #if DEBUG
76
- . toolbar {
77
- DevMenuView ( placement: . bottomOrnament)
78
- }
79
- #endif
80
75
}
81
76
}
82
77
}
@@ -142,18 +137,14 @@ public struct WindowHandlingModifier: ViewModifier {
142
137
/**
143
138
Toolbar which displays additional controls to easily open dev menu and trigger reload command.
144
139
*/
145
- struct DevMenuView : ToolbarContent {
146
- let placement : ToolbarItemPlacement
147
-
148
- var body : some ToolbarContent {
149
- ToolbarItem ( placement: placement) {
140
+ struct DevMenuView : View {
141
+ var body : some View {
142
+ HStack {
150
143
Button ( action: {
151
144
RCTTriggerReloadCommandListeners ( " User Reload " )
152
145
} , label: {
153
146
Image ( systemName: " arrow.clockwise " )
154
147
} )
155
- }
156
- ToolbarItem ( placement: placement) {
157
148
Button ( action: {
158
149
NotificationCenter . default. post (
159
150
Notification ( name: Notification . Name ( " RCTShowDevMenuNotification " ) , object: nil )
@@ -163,5 +154,22 @@ struct DevMenuView: ToolbarContent {
163
154
Image ( systemName: " filemenu.and.selection " )
164
155
} )
165
156
}
157
+ . padding ( )
158
+ . glassBackgroundEffect ( )
166
159
}
167
160
}
161
+
162
+ extension View {
163
+ /// Applies the given transform if the given condition evaluates to `true`.
164
+ /// - Parameters:
165
+ /// - condition: The condition to evaluate.
166
+ /// - transform: The transform to apply to the source `View`.
167
+ /// - Returns: Either the original `View` or the modified `View` if the condition is `true`.
168
+ @ViewBuilder func `if`< Content: View > ( _ condition: @autoclosure ( ) -> Bool , transform: ( Self ) -> Content ) -> some View {
169
+ if condition ( ) {
170
+ transform ( self )
171
+ } else {
172
+ self
173
+ }
174
+ }
175
+ }
0 commit comments