@@ -22,11 +22,11 @@ public struct RCTMainWindow: Scene {
2222 var moduleName : String
2323 var initialProps : RCTRootViewRepresentable . InitialPropsType
2424 var onOpenURLCallback : ( ( URL ) -> ( ) ) ?
25- var devMenuPlacement : ToolbarPlacement = . bottomOrnament
25+ var devMenuSceneAnchor : UnitPoint ?
2626 var contentView : AnyView ?
2727
2828 var rootView : RCTRootViewRepresentable {
29- RCTRootViewRepresentable ( moduleName: moduleName, initialProps: initialProps)
29+ RCTRootViewRepresentable ( moduleName: moduleName, initialProps: initialProps, devMenuSceneAnchor : devMenuSceneAnchor )
3030 }
3131
3232 /// Creates new RCTMainWindowWindow.
@@ -38,11 +38,11 @@ public struct RCTMainWindow: Scene {
3838 public init (
3939 moduleName: String ,
4040 initialProps: RCTRootViewRepresentable . InitialPropsType = nil ,
41- devMenuPlacement : ToolbarPlacement = . bottomOrnament
41+ devMenuSceneAnchor : UnitPoint ? = . bottom
4242 ) {
4343 self . moduleName = moduleName
4444 self . initialProps = initialProps
45- self . devMenuPlacement = devMenuPlacement
45+ self . devMenuSceneAnchor = devMenuSceneAnchor
4646 self . contentView = AnyView ( rootView)
4747 }
4848
@@ -56,12 +56,12 @@ public struct RCTMainWindow: Scene {
5656 public init < Content: View > (
5757 moduleName: String ,
5858 initialProps: RCTRootViewRepresentable . InitialPropsType = nil ,
59- devMenuPlacement : ToolbarPlacement = . bottomOrnament ,
59+ devMenuSceneAnchor : UnitPoint ? = . bottom ,
6060 @ViewBuilder contentView: @escaping ( _ view: RCTRootViewRepresentable ) -> Content
6161 ) {
6262 self . moduleName = moduleName
6363 self . initialProps = initialProps
64- self . devMenuPlacement = devMenuPlacement
64+ self . devMenuSceneAnchor = devMenuSceneAnchor
6565 self . contentView = AnyView ( contentView ( rootView) )
6666 }
6767
@@ -72,11 +72,6 @@ public struct RCTMainWindow: Scene {
7272 . onOpenURL ( perform: { url in
7373 onOpenURLCallback ? ( url)
7474 } )
75- #if DEBUG
76- . toolbar {
77- DevMenuView ( placement: . bottomOrnament)
78- }
79- #endif
8075 }
8176 }
8277}
@@ -142,18 +137,14 @@ public struct WindowHandlingModifier: ViewModifier {
142137/**
143138 Toolbar which displays additional controls to easily open dev menu and trigger reload command.
144139 */
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 {
150143 Button ( action: {
151144 RCTTriggerReloadCommandListeners ( " User Reload " )
152145 } , label: {
153146 Image ( systemName: " arrow.clockwise " )
154147 } )
155- }
156- ToolbarItem ( placement: placement) {
157148 Button ( action: {
158149 NotificationCenter . default. post (
159150 Notification ( name: Notification . Name ( " RCTShowDevMenuNotification " ) , object: nil )
@@ -163,5 +154,22 @@ struct DevMenuView: ToolbarContent {
163154 Image ( systemName: " filemenu.and.selection " )
164155 } )
165156 }
157+ . padding ( )
158+ . glassBackgroundEffect ( )
166159 }
167160}
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