Skip to content

Commit d96c814

Browse files
authored
Merge branch 'main' into copilot/add-platform-color-types-implementation
2 parents 868a823 + e57e55c commit d96c814

File tree

5 files changed

+88
-47
lines changed

5 files changed

+88
-47
lines changed

packages/react-native/React/Base/RCTUIKit.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@ UIKIT_STATIC_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *
6565
return [view hitTest:point withEvent:event];
6666
}
6767

68-
UIKIT_STATIC_INLINE BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view)
69-
{
70-
return view.clipsToBounds;
71-
}
72-
7368
UIKIT_STATIC_INLINE void RCTUIViewSetContentModeRedraw(UIView *view)
7469
{
7570
view.contentMode = UIViewContentModeRedraw;
@@ -398,8 +393,6 @@ void UIBezierPathAppendPath(UIBezierPath *path, UIBezierPath *appendPath);
398393

399394
- (void)setNeedsDisplay;
400395

401-
// FUTURE: When Xcode 14 is no longer supported (CI is building with Xcode 15), we can remove this override since it's now declared on NSView
402-
@property BOOL clipsToBounds;
403396
@property (nonatomic, copy) NSColor *backgroundColor;
404397
@property (nonatomic) CGAffineTransform transform;
405398

@@ -462,8 +455,6 @@ NS_INLINE RCTPlatformView *RCTUIViewHitTestWithEvent(RCTPlatformView *view, CGPo
462455
return [view hitTest:pointInSuperview];
463456
}
464457

465-
BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view);
466-
467458
NS_INLINE void RCTUIViewSetContentModeRedraw(RCTPlatformView *view)
468459
{
469460
view.layerContentsRedrawPolicy = NSViewLayerContentsRedrawDuringViewResize;
@@ -604,8 +595,6 @@ typedef UIImageView RCTUIImageView;
604595
#else
605596
@interface RCTUIImageView : NSImageView
606597
NS_ASSUME_NONNULL_BEGIN
607-
// FUTURE: When Xcode 14 is no longer supported (CI is building with Xcode 15), we can remove this override since it's now declared on NSView
608-
@property (assign) BOOL clipsToBounds;
609598
@property (nonatomic, strong) RCTUIColor *tintColor;
610599
@property (nonatomic, assign) UIViewContentMode contentMode;
611600
NS_ASSUME_NONNULL_END

packages/react-native/React/Base/macOS/RCTUIKit.m

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -526,20 +526,6 @@ - (void)setAlwaysBounceVertical:(BOOL)alwaysBounceVertical
526526

527527
@end
528528

529-
BOOL RCTUIViewSetClipsToBounds(RCTPlatformView *view)
530-
{
531-
// NSViews are always clipped to bounds
532-
BOOL clipsToBounds = YES;
533-
534-
// But see if UIView overrides that behavior
535-
if ([view respondsToSelector:@selector(clipsToBounds)])
536-
{
537-
clipsToBounds = [(id)view clipsToBounds];
538-
}
539-
540-
return clipsToBounds;
541-
}
542-
543529
@implementation RCTClipView
544530

545531
- (instancetype)initWithFrame:(NSRect)frameRect
@@ -743,16 +729,6 @@ - (instancetype)initWithFrame:(CGRect)frame
743729
return self;
744730
}
745731

746-
- (BOOL)clipsToBounds
747-
{
748-
return [[self layer] masksToBounds];
749-
}
750-
751-
- (void)setClipsToBounds:(BOOL)clipsToBounds
752-
{
753-
[[self layer] setMasksToBounds:clipsToBounds];
754-
}
755-
756732
- (void)setContentMode:(UIViewContentMode)contentMode
757733
{
758734
_contentMode = contentMode;

packages/react-native/React/CoreModules/RCTDevMenu.mm

Lines changed: 83 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,74 @@ - (void)setDefaultJSBundle
402402
NSAlert *alert = [NSAlert new];
403403
[alert setMessageText:@"Change packager location"];
404404
[alert setInformativeText:@"Input packager IP, port and entrypoint"];
405-
[alert addButtonWithTitle:@"Use bundled JS"];
405+
406+
// Create accessory view with text fields
407+
NSView *accessoryView = [[NSView alloc] initWithFrame:NSMakeRect(0.0, 0.0, 300.0, 90.0)];
408+
409+
// IP Address text field
410+
NSTextField *ipTextField = [[NSTextField alloc] initWithFrame:NSMakeRect(0.0, 60.0, 300.0, 22.0)];
411+
ipTextField.placeholderString = @"0.0.0.0";
412+
ipTextField.cell.scrollable = YES;
413+
[accessoryView addSubview:ipTextField];
414+
415+
// Port text field
416+
NSTextField *portTextField =
417+
[[NSTextField alloc] initWithFrame:NSMakeRect(0.0, 30.0, 300.0, 22.0)];
418+
portTextField.placeholderString = @"8081";
419+
portTextField.cell.scrollable = YES;
420+
[accessoryView addSubview:portTextField];
421+
422+
// Entrypoint text field
423+
NSTextField *entrypointTextField =
424+
[[NSTextField alloc] initWithFrame:NSMakeRect(0.0, 0.0, 300.0, 22.0)];
425+
entrypointTextField.placeholderString = @"index";
426+
entrypointTextField.cell.scrollable = YES;
427+
[accessoryView addSubview:entrypointTextField];
428+
429+
alert.accessoryView = accessoryView;
430+
431+
[alert addButtonWithTitle:@"Apply Changes"];
432+
[alert addButtonWithTitle:@"Reset to Default"];
433+
[alert addButtonWithTitle:@"Cancel"];
406434
[alert setAlertStyle:NSAlertStyleWarning];
407-
[alert beginSheetModalForWindow:[NSApp keyWindow] completionHandler:nil];
435+
436+
[alert beginSheetModalForWindow:[NSApp keyWindow]
437+
completionHandler:^(NSModalResponse response) {
438+
if (response == NSAlertFirstButtonReturn) {
439+
// Apply Changes
440+
NSString *ipAddress = ipTextField.stringValue;
441+
NSString *port = portTextField.stringValue;
442+
NSString *bundleRoot = entrypointTextField.stringValue;
443+
444+
if (ipAddress.length == 0 && port.length == 0) {
445+
[weakSelf setDefaultJSBundle];
446+
return;
447+
}
448+
449+
NSNumberFormatter *formatter = [NSNumberFormatter new];
450+
formatter.numberStyle = NSNumberFormatterDecimalStyle;
451+
NSNumber *portNumber = [formatter numberFromString:port];
452+
if (portNumber == nil) {
453+
portNumber = [NSNumber numberWithInt:RCT_METRO_PORT];
454+
}
455+
456+
[RCTBundleURLProvider sharedSettings].jsLocation =
457+
[NSString stringWithFormat:@"%@:%d", ipAddress, portNumber.intValue];
458+
459+
if (bundleRoot.length == 0) {
460+
[bundleManager resetBundleURL];
461+
} else {
462+
bundleManager.bundleURL = [[RCTBundleURLProvider sharedSettings]
463+
jsBundleURLForBundleRoot:bundleRoot];
464+
}
465+
466+
RCTTriggerReloadCommandListeners(@"Dev menu - apply changes");
467+
} else if (response == NSAlertSecondButtonReturn) {
468+
// Reset to Default
469+
[weakSelf setDefaultJSBundle];
470+
}
471+
// Cancel - do nothing
472+
}];
408473
#endif // macOS]
409474
}]];
410475

@@ -452,7 +517,15 @@ - (void)setDefaultJSBundle
452517
#else // [macOS
453518
NSMenu *menu = [self menu];
454519
NSWindow *window = [NSApp keyWindow];
455-
NSEvent *event = [NSEvent mouseEventWithType:NSEventTypeLeftMouseUp location:CGPointMake(0, 0) modifierFlags:0 timestamp:NSTimeIntervalSince1970 windowNumber:[window windowNumber] context:nil eventNumber:0 clickCount:0 pressure:0.1];
520+
NSEvent *event = [NSEvent mouseEventWithType:NSEventTypeLeftMouseUp
521+
location:CGPointMake(0, 0)
522+
modifierFlags:0
523+
timestamp:NSTimeIntervalSince1970
524+
windowNumber:[window windowNumber]
525+
context:nil
526+
eventNumber:0
527+
clickCount:0
528+
pressure:0.1];
456529
[NSMenu popUpContextMenu:menu withEvent:event forView:[window contentView]];
457530
#endif // macOS]
458531

@@ -484,8 +557,9 @@ - (NSMenu *)menu
484557

485558
menu = [NSMenu new];
486559

487-
NSMutableAttributedString *attributedTitle = [[NSMutableAttributedString alloc]initWithString:title];
488-
[attributedTitle setAttributes: @{ NSFontAttributeName : [NSFont menuFontOfSize:0] } range: NSMakeRange(0, [attributedTitle length])];
560+
NSMutableAttributedString *attributedTitle = [[NSMutableAttributedString alloc] initWithString:title];
561+
[attributedTitle setAttributes:@{NSFontAttributeName : [NSFont menuFontOfSize:0]}
562+
range:NSMakeRange(0, [attributedTitle length])];
489563
NSMenuItem *titleItem = [NSMenuItem new];
490564
[titleItem setAttributedTitle:attributedTitle];
491565
[menu addItem:titleItem];
@@ -494,7 +568,9 @@ - (NSMenu *)menu
494568

495569
NSArray<RCTDevMenuItem *> *items = [self _menuItemsToPresent];
496570
for (RCTDevMenuItem *item in items) {
497-
NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:[item title] action:@selector(menuItemSelected:) keyEquivalent:@""];
571+
NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:[item title]
572+
action:@selector(menuItemSelected:)
573+
keyEquivalent:@""];
498574
[menuItem setTarget:self];
499575
[menuItem setRepresentedObject:item];
500576
[menu addItem:menuItem];
@@ -505,7 +581,7 @@ - (NSMenu *)menu
505581
return nil;
506582
}
507583

508-
-(void)menuItemSelected:(id)sender
584+
- (void)menuItemSelected:(id)sender
509585
{
510586
NSMenuItem *menuItem = (NSMenuItem *)sender;
511587
RCTDevMenuItem *item = (RCTDevMenuItem *)[menuItem representedObject];

packages/react-native/React/Views/RCTView.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ - (void)react_updateClippedSubviewsWithClipRect:(CGRect)clipRect relativeToView:
5555
// we do support clipsToBounds, so if that's enabled
5656
// we'll update the clipping
5757

58-
if (RCTUIViewSetClipsToBounds(self) && self.subviews.count > 0) { // [macOS]
58+
if (self.clipsToBounds && self.subviews.count > 0) {
5959
clipRect = [clipView convertRect:clipRect toView:self];
6060
clipRect = CGRectIntersection(clipRect, self.bounds);
6161
clipView = self;
@@ -77,7 +77,7 @@ - (RCTPlatformView *)react_findClipView // [macOS]
7777
CGRect clipRect = self.bounds;
7878
// We will only look for a clipping view up the view hierarchy until we hit the root view.
7979
while (testView) {
80-
if (RCTUIViewSetClipsToBounds(testView)) { // [macOS]
80+
if (testView.clipsToBounds) {
8181
if (clipView) {
8282
CGRect testRect = [clipView convertRect:clipRect toView:testView];
8383
if (!CGRectContainsRect(testView.bounds, testRect)) {

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12202,9 +12202,9 @@ __metadata:
1220212202
linkType: hard
1220312203

1220412204
"validator@npm:^13.7.0":
12205-
version: 13.11.0
12206-
resolution: "validator@npm:13.11.0"
12207-
checksum: 10c0/0107da3add5a4ebc6391dac103c55f6d8ed055bbcc29a4c9cbf89eacfc39ba102a5618c470bdc33c6487d30847771a892134a8c791f06ef0962dd4b7a60ae0f5
12205+
version: 13.15.20
12206+
resolution: "validator@npm:13.15.20"
12207+
checksum: 10c0/65453f0c91ef154ae2da4d5ff3c22acff239d2c15216335ba83895b6f79914708709c641119aa9fba0ec9dd69229c1cf8196aff0081584bdda8a7f50ea97b789
1220812208
languageName: node
1220912209
linkType: hard
1221012210

0 commit comments

Comments
 (0)