Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
#import <react/renderer/runtimescheduler/RuntimeSchedulerCallInvoker.h>
#import <react/runtime/JSRuntimeFactory.h>

#if RCT_DEV_MENU // [macOS
#import "RCTDevMenu.h"
#endif // macOS]

@implementation RCTRootViewFactoryConfiguration

- (instancetype)initWithBundleURL:(NSURL *)bundleURL newArchEnabled:(BOOL)newArchEnabled
Expand Down Expand Up @@ -151,6 +155,14 @@ - (RCTPlatformView *)viewWithModuleName:(NSString *)moduleName // [macOS]
#if !TARGET_OS_OSX // [macOS]
surfaceHostingProxyRootView.backgroundColor = [UIColor systemBackgroundColor];
#endif // [macOS]

#if RCT_DEV_MENU // [macOS
RCTDevMenu *devMenu = [self.reactHost.moduleRegistry moduleForClass:[RCTDevMenu class]];
if (devMenu) {
surfaceHostingProxyRootView.devMenu = devMenu;
}
#endif // macOS]

if (_configuration.customizeRootView != nil) {
_configuration.customizeRootView(surfaceHostingProxyRootView);
}
Expand Down Expand Up @@ -183,6 +195,16 @@ - (RCTPlatformView *)createRootViewWithBridge:(RCTBridge *)bridge
{
BOOL enableFabric = _configuration.fabricEnabled;
RCTPlatformView *rootView = RCTAppSetupDefaultRootView(bridge, moduleName, initProps, enableFabric); // [macOS]

#if RCT_DEV_MENU // [macOS
if (enableFabric && [rootView isKindOfClass:[RCTSurfaceHostingView class]]) {
RCTDevMenu *devMenu = [bridge moduleForClass:[RCTDevMenu class]];
if (devMenu) {
[(RCTSurfaceHostingView *)rootView setDevMenu:devMenu];
}
}
#endif // macOS]

#if !TARGET_OS_OSX // [macOS]
rootView.backgroundColor = [UIColor systemBackgroundColor];
#endif // [macOS]
Expand Down Expand Up @@ -327,4 +349,4 @@ - (NSURL *)bundleURL
return self->_configuration.bundleURLBlock();
}

@end
@end
4 changes: 2 additions & 2 deletions packages/react-native/React/Base/RCTRootView.m
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,9 @@ - (void)containingWindowDidResignKey {
- (NSMenu *)menuForEvent:(NSEvent *)event
{
NSMenu *menu = nil;
#if __has_include("RCTDevMenu.h") && RCT_DEV
#if RCT_DEV_MENU
menu = [[_bridge devMenu] menu];
#endif
#endif // RCT_DEV_MENU
if (menu == nil) {
menu = [super menuForEvent:event];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

@class RCTBridge;
@class RCTSurface;
#if RCT_DEV_MENU // [macOS
@class RCTDevMenu;
#endif // macOS]

typedef RCTPlatformView *_Nullable (^RCTSurfaceHostingViewActivityIndicatorViewFactory)(void); // [macOS]

Expand Down Expand Up @@ -63,6 +66,14 @@ NS_ASSUME_NONNULL_BEGIN
* @param disabled if `YES`, the auto-hide is disabled. Otherwise the loading view will be hidden automatically
*/
- (void)disableActivityIndicatorAutoHide:(BOOL)disabled;

#if RCT_DEV_MENU // [macOS
/**
* Dev menu for macOS context menu access.
*/
@property (nonatomic, strong, nullable) RCTDevMenu *devMenu;
#endif // macOS]

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
#import "RCTSurfaceView.h"
#import "RCTUtils.h"

#if RCT_DEV_MENU // [macOS
#import "RCTDevMenu.h"
#endif // macOS]

@interface RCTSurfaceHostingView ()

@property (nonatomic, assign) BOOL isActivityIndicatorViewVisible;
Expand Down Expand Up @@ -134,6 +138,7 @@ - (void)setSizeMeasureMode:(RCTSurfaceSizeMeasureMode)sizeMeasureMode
_sizeMeasureMode = sizeMeasureMode;
[self _invalidateLayout];
}

- (void)disableActivityIndicatorAutoHide:(BOOL)disabled
{
_autoHideDisabled = disabled;
Expand Down Expand Up @@ -278,4 +283,23 @@ - (void)surface:(__unused RCTSurface *)surface didChangeIntrinsicSize:(__unused
});
}

#if TARGET_OS_OSX // [macOS

#pragma mark - Context Menu

- (NSMenu *)menuForEvent:(NSEvent *)event
{
#if __has_include("RCTDevMenu.h") && RCT_DEV
// Try direct dev menu property first (simplest approach)
if (_devMenu) {
return [_devMenu menu];
}


#endif

return [super menuForEvent:event];
}
#endif // macOS]

@end
Loading