@@ -22,7 +22,7 @@ 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 devMenuPlacement : OrnamentAttachmentAnchor ? = . scene ( . bottom )
26
26
var contentView : AnyView ?
27
27
28
28
var rootView : RCTRootViewRepresentable {
@@ -38,7 +38,7 @@ public struct RCTMainWindow: Scene {
38
38
public init (
39
39
moduleName: String ,
40
40
initialProps: RCTRootViewRepresentable . InitialPropsType = nil ,
41
- devMenuPlacement: ToolbarPlacement = . bottomOrnament
41
+ devMenuPlacement: OrnamentAttachmentAnchor ? = . scene ( . bottom )
42
42
) {
43
43
self . moduleName = moduleName
44
44
self . initialProps = initialProps
@@ -56,7 +56,7 @@ 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
+ devMenuPlacement: OrnamentAttachmentAnchor ? = . scene ( . bottom ) ,
60
60
@ViewBuilder contentView: @escaping ( _ view: RCTRootViewRepresentable ) -> Content
61
61
) {
62
62
self . moduleName = moduleName
@@ -73,8 +73,10 @@ public struct RCTMainWindow: Scene {
73
73
onOpenURLCallback ? ( url)
74
74
} )
75
75
#if DEBUG
76
- . toolbar {
77
- DevMenuView ( placement: . bottomOrnament)
76
+ . if( devMenuPlacement != nil ) { content in
77
+ content. ornament ( attachmentAnchor: devMenuPlacement!) {
78
+ DevMenuView ( )
79
+ }
78
80
}
79
81
#endif
80
82
}
@@ -142,18 +144,14 @@ public struct WindowHandlingModifier: ViewModifier {
142
144
/**
143
145
Toolbar which displays additional controls to easily open dev menu and trigger reload command.
144
146
*/
145
- struct DevMenuView : ToolbarContent {
146
- let placement : ToolbarItemPlacement
147
-
148
- var body : some ToolbarContent {
149
- ToolbarItem ( placement: placement) {
147
+ struct DevMenuView : View {
148
+ var body : some View {
149
+ VStack {
150
150
Button ( action: {
151
151
RCTTriggerReloadCommandListeners ( " User Reload " )
152
152
} , label: {
153
153
Image ( systemName: " arrow.clockwise " )
154
154
} )
155
- }
156
- ToolbarItem ( placement: placement) {
157
155
Button ( action: {
158
156
NotificationCenter . default. post (
159
157
Notification ( name: Notification . Name ( " RCTShowDevMenuNotification " ) , object: nil )
@@ -162,6 +160,21 @@ struct DevMenuView: ToolbarContent {
162
160
label: {
163
161
Image ( systemName: " filemenu.and.selection " )
164
162
} )
165
- }
163
+ } . glassBackgroundEffect ( )
166
164
}
167
165
}
166
+
167
+ extension View {
168
+ /// Applies the given transform if the given condition evaluates to `true`.
169
+ /// - Parameters:
170
+ /// - condition: The condition to evaluate.
171
+ /// - transform: The transform to apply to the source `View`.
172
+ /// - Returns: Either the original `View` or the modified `View` if the condition is `true`.
173
+ @ViewBuilder func `if`< Content: View > ( _ condition: @autoclosure ( ) -> Bool , transform: ( Self ) -> Content ) -> some View {
174
+ if condition ( ) {
175
+ transform ( self )
176
+ } else {
177
+ self
178
+ }
179
+ }
180
+ }
0 commit comments