Skip to content

Commit 5c60904

Browse files
committed
fix ci errors
1 parent c7c1604 commit 5c60904

File tree

3 files changed

+19
-110
lines changed

3 files changed

+19
-110
lines changed

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

Lines changed: 17 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,12 @@ - (instancetype)initWithCustomButtonTitles:(NSArray<NSString *> *)customButtonTi
120120
_customButtonTitles = customButtonTitles;
121121
_customButtonHandlers = customButtonHandlers;
122122

123+
#if TARGET_OS_OSX // [macOS
123124
_window = [[NSWindow alloc] initWithContentRect:NSZeroRect styleMask:NSWindowStyleMaskTitled backing:NSBackingStoreBuffered defer:YES];
124125
_window.backgroundColor = [NSColor colorWithRed:0.8 green:0 blue:0 alpha:1];
125126
_window.animationBehavior = NSWindowAnimationBehaviorDocumentWindow;
126127
_window.contentViewController = self;
128+
#endif // macOS]
127129
}
128130

129131
return self;
@@ -303,13 +305,16 @@ - (void)viewDidLoad
303305
[NSLayoutConstraint activateConstraints:@[
304306
[topBorder.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
305307
[topBorder.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor],
306-
[topBorder.bottomAnchor constraintEqualToAnchor:buttonStackView.topAnchor],
307-
[NSLayoutConstraint constraintWithItem:scrollView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeading multiplier:1 constant:0],
308-
[NSLayoutConstraint constraintWithItem:scrollView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1 constant:0],
309-
[NSLayoutConstraint constraintWithItem:scrollView attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTrailing multiplier:1 constant:0],
310-
[scrollView.bottomAnchor constraintEqualToAnchor:topBorder.topAnchor]
311-
308+
[topBorder.bottomAnchor constraintEqualToAnchor:buttonStackView.topAnchor]
312309
]];
310+
311+
#if TARGET_OS_OSX // [macOS
312+
[NSLayoutConstraint activateConstraints:@[
313+
[NSLayoutConstraint constraintWithItem:scrollView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeading multiplier:1 constant:0],
314+
[NSLayoutConstraint constraintWithItem:scrollView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1 constant:0],
315+
[NSLayoutConstraint constraintWithItem:scrollView attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTrailing multiplier:1 constant:0],
316+
[scrollView.bottomAnchor constraintEqualToAnchor:topBorder.topAnchor]]];
317+
#endif // macOS]
313318
}
314319

315320
#if !TARGET_OS_OSX // [macOS]
@@ -435,7 +440,7 @@ - (void)showErrorMessage:(NSString *)message
435440
}
436441
}
437442

438-
#if TARGET_OS_OSX // [macOS]
443+
#if TARGET_OS_OSX // [macOS
439444
- (void)showModal
440445
{
441446
NSModalSession session = [NSApp beginModalSessionForWindow:_window];
@@ -447,7 +452,7 @@ - (void)showModal
447452

448453
[NSApp endModalSession:session];
449454
}
450-
#endif
455+
#endif // macOS]
451456

452457
- (void)dismiss
453458
{
@@ -749,118 +754,22 @@ - (NSAttributedString *)attributedStringForRow:(NSUInteger)row
749754
return frameSource;
750755
}
751756

752-
#endif // macoS]
753-
@end
754-
755-
756-
#if TARGET_OS_OSX
757-
@interface RCTRedBoxWindow : NSObject
758-
759-
760-
@property (nonatomic, weak) id<RCTRedBoxControllerActionDelegate> actionDelegate;
761-
762-
@end
763-
764-
@implementation RCTRedBoxWindow
765-
{
766-
NSWindow *_window;
767-
BOOL _visible;
768-
}
769-
770-
- (instancetype)init
771-
{
772-
if ((self = [super init])) {
773757
/*
774-
NSButton *dismissButton = [[NSButton alloc] initWithFrame:NSZeroRect];
775-
dismissButton.accessibilityIdentifier = @"redbox-dismiss";
776-
dismissButton.translatesAutoresizingMaskIntoConstraints = NO;
777-
dismissButton.target = self;
778-
dismissButton.action = @selector(dismiss:);
779-
[dismissButton setButtonType:NSButtonTypeMomentaryPushIn];
780-
dismissButton.bezelStyle = NSBezelStyleRounded;
781-
dismissButton.title = @"Dismiss (Esc)";
782-
dismissButton.keyEquivalent = @"\e";
783-
[dismissButton setContentCompressionResistancePriority:NSLayoutPriorityRequired forOrientation:NSLayoutConstraintOrientationHorizontal];
784-
785-
NSButton *reloadButton = [[NSButton alloc] initWithFrame:NSZeroRect];
786-
reloadButton.accessibilityIdentifier = @"redbox-reload";
787-
reloadButton.translatesAutoresizingMaskIntoConstraints = NO;
788-
reloadButton.target = self;
789-
reloadButton.action = @selector(reload:);
790-
reloadButton.bezelStyle = NSBezelStyleRounded;
791-
reloadButton.title = @"Reload JS (\u2318R)";
792-
[reloadButton setButtonType:NSButtonTypeMomentaryPushIn];
793-
reloadButton.keyEquivalent = @"r";
794-
reloadButton.keyEquivalentModifierMask = NSEventModifierFlagCommand;
795-
[reloadButton setContentCompressionResistancePriority:NSLayoutPriorityRequired forOrientation:NSLayoutConstraintOrientationHorizontal];
796-
[reloadButton setContentCompressionResistancePriority:NSLayoutPriorityRequired forOrientation:NSLayoutConstraintOrientationVertical];
797-
798-
NSButton *copyButton = [[NSButton alloc] initWithFrame:NSZeroRect];
799-
copyButton.accessibilityIdentifier = @"redbox-copy";
800-
copyButton.translatesAutoresizingMaskIntoConstraints = NO;
801-
copyButton.target = self;
802-
copyButton.action = @selector(copyStack:);
803-
copyButton.title = @"Copy (\u2325\u2318C)";
804-
copyButton.bezelStyle = NSBezelStyleRounded;
805-
[copyButton setButtonType:NSButtonTypeMomentaryPushIn];
806-
copyButton.keyEquivalent = @"c";
807-
copyButton.keyEquivalentModifierMask = NSEventModifierFlagOption | NSEventModifierFlagCommand;
808-
[copyButton setContentCompressionResistancePriority:NSLayoutPriorityRequired forOrientation:NSLayoutConstraintOrientationHorizontal];
809-
810-
NSView *contentView = _window.contentView;
811-
[contentView addSubview:scrollView];
812-
[contentView addSubview:dismissButton];
813-
[contentView addSubview:reloadButton];
814-
[contentView addSubview:copyButton];
815-
816-
[NSLayoutConstraint activateConstraints:@[
817-
// the window shouldn't be any bigger than 375x643 points
818-
[NSLayoutConstraint constraintWithItem:contentView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1 constant:375],
819-
[NSLayoutConstraint constraintWithItem:contentView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationLessThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1 constant:643],
820-
// scroll view hugs the left, top, and right sides of the window, and the buttons at the bottom
821-
[NSLayoutConstraint constraintWithItem:scrollView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:contentView attribute:NSLayoutAttributeLeading multiplier:1 constant:16],
822-
[NSLayoutConstraint constraintWithItem:scrollView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:contentView attribute:NSLayoutAttributeTop multiplier:1 constant:16],
823-
[NSLayoutConstraint constraintWithItem:scrollView attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:contentView attribute:NSLayoutAttributeTrailing multiplier:1 constant:-16],
824-
[NSLayoutConstraint constraintWithItem:scrollView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:reloadButton attribute:NSLayoutAttributeTop multiplier:1 constant:-8],
825-
// buttons have equal widths
826-
[NSLayoutConstraint constraintWithItem:dismissButton attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:reloadButton attribute:NSLayoutAttributeWidth multiplier:1 constant:0],
827-
[NSLayoutConstraint constraintWithItem:dismissButton attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:copyButton attribute:NSLayoutAttributeWidth multiplier:1 constant:0],
828-
// buttons are centered horizontally in the window
829-
[NSLayoutConstraint constraintWithItem:dismissButton attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:contentView attribute:NSLayoutAttributeLeading multiplier:1 constant:16],
830-
[NSLayoutConstraint constraintWithItem:copyButton attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationLessThanOrEqual toItem:contentView attribute:NSLayoutAttributeTrailing multiplier:1 constant:-16],
831-
[NSLayoutConstraint constraintWithItem:dismissButton attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:reloadButton attribute:NSLayoutAttributeLeading multiplier:1 constant:-8],
832-
[NSLayoutConstraint constraintWithItem:reloadButton attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:contentView attribute:NSLayoutAttributeCenterX multiplier:1 constant:0],
833-
[NSLayoutConstraint constraintWithItem:copyButton attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:reloadButton attribute:NSLayoutAttributeTrailing multiplier:1 constant:8],
834-
// buttons are baseline aligned
835-
[NSLayoutConstraint constraintWithItem:dismissButton attribute:NSLayoutAttributeBaseline relatedBy:NSLayoutRelationEqual toItem:reloadButton attribute:NSLayoutAttributeBaseline multiplier:1 constant:0],
836-
[NSLayoutConstraint constraintWithItem:dismissButton attribute:NSLayoutAttributeBaseline relatedBy:NSLayoutRelationEqual toItem:copyButton attribute:NSLayoutAttributeBaseline multiplier:1 constant:0],
837-
// buttons appear at the bottom of the window
838-
[NSLayoutConstraint constraintWithItem:reloadButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:contentView attribute:NSLayoutAttributeBottom multiplier:1 constant:-16],
839-
]];
840-
*/
841-
}
842-
return self;
843-
}
844-
845758
- (void)dealloc
846759
{
847760
// VSO#1878643: On macOS the RedBox can be dealloc'd on the JS thread causing the Main Thread Checker to throw when the NSTableView properties below are accessed.
848-
/* NSTableView *stackTraceTableView = _stackTraceTableView;
761+
NSTableView *stackTraceTableView = _stackTraceTableView;
849762
RCTUnsafeExecuteOnMainQueueSync(^{
850763
stackTraceTableView.dataSource = nil;
851764
stackTraceTableView.delegate = nil;
852765
});
853-
TBD */
766+
854767
}
768+
TBD */
855769

856-
857-
858-
859-
770+
#endif // macoS]
860771
@end
861772

862-
#endif // macOS]
863-
864773
@interface RCTRedBox () <
865774
RCTInvalidating,
866775
RCTRedBoxControllerActionDelegate,

packages/rn-tester/IntegrationTests/LayoutEventsTest.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
'use strict';
1212

13-
const {Platform} = ReactNative; // [macOS]
1413
import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
1514
import type {
1615
Layout,
@@ -21,7 +20,7 @@ const React = require('react');
2120
const ReactNative = require('react-native');
2221
const deepDiffer = require('react-native/Libraries/Utilities/differ/deepDiffer');
2322

24-
const {Image, LayoutAnimation, StyleSheet, Text, View} = ReactNative;
23+
const {Image, LayoutAnimation, Platform, StyleSheet, Text, View} = ReactNative; // [macOS Platform]
2524
const {TestModule} = ReactNative.NativeModules;
2625
function debug(...args: Array<void | Layout | string>) {
2726
// console.log.apply(null, arguments);

packages/rn-tester/js/examples/FocusOnMount/FocusOnMount.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class FocusOnMountExample extends React.Component<{}> {
2222
const commands = UIManager.getViewManagerConfig('RCTView').Commands;
2323
if ('focus' in commands) {
2424
UIManager.dispatchViewManagerCommand(
25+
// $FlowFixMe
2526
findNodeHandle(this.ref.current),
2627
UIManager.getViewManagerConfig('RCTView').Commands.focus,
2728
undefined,

0 commit comments

Comments
 (0)