Skip to content

Commit

Permalink
fix ci errors
Browse files Browse the repository at this point in the history
  • Loading branch information
FalseLobster committed Jul 23, 2024
1 parent c7c1604 commit 5c60904
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 110 deletions.
125 changes: 17 additions & 108 deletions packages/react-native/React/CoreModules/RCTRedBox.mm
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ - (instancetype)initWithCustomButtonTitles:(NSArray<NSString *> *)customButtonTi
_customButtonTitles = customButtonTitles;
_customButtonHandlers = customButtonHandlers;

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

return self;
Expand Down Expand Up @@ -303,13 +305,16 @@ - (void)viewDidLoad
[NSLayoutConstraint activateConstraints:@[
[topBorder.leadingAnchor constraintEqualToAnchor:self.view.leadingAnchor],
[topBorder.trailingAnchor constraintEqualToAnchor:self.view.trailingAnchor],
[topBorder.bottomAnchor constraintEqualToAnchor:buttonStackView.topAnchor],
[NSLayoutConstraint constraintWithItem:scrollView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeading multiplier:1 constant:0],
[NSLayoutConstraint constraintWithItem:scrollView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1 constant:0],
[NSLayoutConstraint constraintWithItem:scrollView attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTrailing multiplier:1 constant:0],
[scrollView.bottomAnchor constraintEqualToAnchor:topBorder.topAnchor]

[topBorder.bottomAnchor constraintEqualToAnchor:buttonStackView.topAnchor]
]];

#if TARGET_OS_OSX // [macOS
[NSLayoutConstraint activateConstraints:@[
[NSLayoutConstraint constraintWithItem:scrollView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeading multiplier:1 constant:0],
[NSLayoutConstraint constraintWithItem:scrollView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTop multiplier:1 constant:0],
[NSLayoutConstraint constraintWithItem:scrollView attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeTrailing multiplier:1 constant:0],
[scrollView.bottomAnchor constraintEqualToAnchor:topBorder.topAnchor]]];
#endif // macOS]
}

#if !TARGET_OS_OSX // [macOS]
Expand Down Expand Up @@ -435,7 +440,7 @@ - (void)showErrorMessage:(NSString *)message
}
}

#if TARGET_OS_OSX // [macOS]
#if TARGET_OS_OSX // [macOS
- (void)showModal
{
NSModalSession session = [NSApp beginModalSessionForWindow:_window];
Expand All @@ -447,7 +452,7 @@ - (void)showModal

[NSApp endModalSession:session];
}
#endif
#endif // macOS]

- (void)dismiss
{
Expand Down Expand Up @@ -749,118 +754,22 @@ - (NSAttributedString *)attributedStringForRow:(NSUInteger)row
return frameSource;
}

#endif // macoS]
@end


#if TARGET_OS_OSX
@interface RCTRedBoxWindow : NSObject


@property (nonatomic, weak) id<RCTRedBoxControllerActionDelegate> actionDelegate;

@end

@implementation RCTRedBoxWindow
{
NSWindow *_window;
BOOL _visible;
}

- (instancetype)init
{
if ((self = [super init])) {
/*
NSButton *dismissButton = [[NSButton alloc] initWithFrame:NSZeroRect];
dismissButton.accessibilityIdentifier = @"redbox-dismiss";
dismissButton.translatesAutoresizingMaskIntoConstraints = NO;
dismissButton.target = self;
dismissButton.action = @selector(dismiss:);
[dismissButton setButtonType:NSButtonTypeMomentaryPushIn];
dismissButton.bezelStyle = NSBezelStyleRounded;
dismissButton.title = @"Dismiss (Esc)";
dismissButton.keyEquivalent = @"\e";
[dismissButton setContentCompressionResistancePriority:NSLayoutPriorityRequired forOrientation:NSLayoutConstraintOrientationHorizontal];
NSButton *reloadButton = [[NSButton alloc] initWithFrame:NSZeroRect];
reloadButton.accessibilityIdentifier = @"redbox-reload";
reloadButton.translatesAutoresizingMaskIntoConstraints = NO;
reloadButton.target = self;
reloadButton.action = @selector(reload:);
reloadButton.bezelStyle = NSBezelStyleRounded;
reloadButton.title = @"Reload JS (\u2318R)";
[reloadButton setButtonType:NSButtonTypeMomentaryPushIn];
reloadButton.keyEquivalent = @"r";
reloadButton.keyEquivalentModifierMask = NSEventModifierFlagCommand;
[reloadButton setContentCompressionResistancePriority:NSLayoutPriorityRequired forOrientation:NSLayoutConstraintOrientationHorizontal];
[reloadButton setContentCompressionResistancePriority:NSLayoutPriorityRequired forOrientation:NSLayoutConstraintOrientationVertical];
NSButton *copyButton = [[NSButton alloc] initWithFrame:NSZeroRect];
copyButton.accessibilityIdentifier = @"redbox-copy";
copyButton.translatesAutoresizingMaskIntoConstraints = NO;
copyButton.target = self;
copyButton.action = @selector(copyStack:);
copyButton.title = @"Copy (\u2325\u2318C)";
copyButton.bezelStyle = NSBezelStyleRounded;
[copyButton setButtonType:NSButtonTypeMomentaryPushIn];
copyButton.keyEquivalent = @"c";
copyButton.keyEquivalentModifierMask = NSEventModifierFlagOption | NSEventModifierFlagCommand;
[copyButton setContentCompressionResistancePriority:NSLayoutPriorityRequired forOrientation:NSLayoutConstraintOrientationHorizontal];
NSView *contentView = _window.contentView;
[contentView addSubview:scrollView];
[contentView addSubview:dismissButton];
[contentView addSubview:reloadButton];
[contentView addSubview:copyButton];
[NSLayoutConstraint activateConstraints:@[
// the window shouldn't be any bigger than 375x643 points
[NSLayoutConstraint constraintWithItem:contentView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1 constant:375],
[NSLayoutConstraint constraintWithItem:contentView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationLessThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1 constant:643],
// scroll view hugs the left, top, and right sides of the window, and the buttons at the bottom
[NSLayoutConstraint constraintWithItem:scrollView attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:contentView attribute:NSLayoutAttributeLeading multiplier:1 constant:16],
[NSLayoutConstraint constraintWithItem:scrollView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:contentView attribute:NSLayoutAttributeTop multiplier:1 constant:16],
[NSLayoutConstraint constraintWithItem:scrollView attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:contentView attribute:NSLayoutAttributeTrailing multiplier:1 constant:-16],
[NSLayoutConstraint constraintWithItem:scrollView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:reloadButton attribute:NSLayoutAttributeTop multiplier:1 constant:-8],
// buttons have equal widths
[NSLayoutConstraint constraintWithItem:dismissButton attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:reloadButton attribute:NSLayoutAttributeWidth multiplier:1 constant:0],
[NSLayoutConstraint constraintWithItem:dismissButton attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:copyButton attribute:NSLayoutAttributeWidth multiplier:1 constant:0],
// buttons are centered horizontally in the window
[NSLayoutConstraint constraintWithItem:dismissButton attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:contentView attribute:NSLayoutAttributeLeading multiplier:1 constant:16],
[NSLayoutConstraint constraintWithItem:copyButton attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationLessThanOrEqual toItem:contentView attribute:NSLayoutAttributeTrailing multiplier:1 constant:-16],
[NSLayoutConstraint constraintWithItem:dismissButton attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:reloadButton attribute:NSLayoutAttributeLeading multiplier:1 constant:-8],
[NSLayoutConstraint constraintWithItem:reloadButton attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:contentView attribute:NSLayoutAttributeCenterX multiplier:1 constant:0],
[NSLayoutConstraint constraintWithItem:copyButton attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:reloadButton attribute:NSLayoutAttributeTrailing multiplier:1 constant:8],
// buttons are baseline aligned
[NSLayoutConstraint constraintWithItem:dismissButton attribute:NSLayoutAttributeBaseline relatedBy:NSLayoutRelationEqual toItem:reloadButton attribute:NSLayoutAttributeBaseline multiplier:1 constant:0],
[NSLayoutConstraint constraintWithItem:dismissButton attribute:NSLayoutAttributeBaseline relatedBy:NSLayoutRelationEqual toItem:copyButton attribute:NSLayoutAttributeBaseline multiplier:1 constant:0],
// buttons appear at the bottom of the window
[NSLayoutConstraint constraintWithItem:reloadButton attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:contentView attribute:NSLayoutAttributeBottom multiplier:1 constant:-16],
]];
*/
}
return self;
}

- (void)dealloc
{
// 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.
/* NSTableView *stackTraceTableView = _stackTraceTableView;
NSTableView *stackTraceTableView = _stackTraceTableView;
RCTUnsafeExecuteOnMainQueueSync(^{
stackTraceTableView.dataSource = nil;
stackTraceTableView.delegate = nil;
});
TBD */
}
TBD */





#endif // macoS]
@end

#endif // macOS]

@interface RCTRedBox () <
RCTInvalidating,
RCTRedBoxControllerActionDelegate,
Expand Down
3 changes: 1 addition & 2 deletions packages/rn-tester/IntegrationTests/LayoutEventsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

'use strict';

const {Platform} = ReactNative; // [macOS]
import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
import type {
Layout,
Expand All @@ -21,7 +20,7 @@ const React = require('react');
const ReactNative = require('react-native');
const deepDiffer = require('react-native/Libraries/Utilities/differ/deepDiffer');

const {Image, LayoutAnimation, StyleSheet, Text, View} = ReactNative;
const {Image, LayoutAnimation, Platform, StyleSheet, Text, View} = ReactNative; // [macOS Platform]
const {TestModule} = ReactNative.NativeModules;
function debug(...args: Array<void | Layout | string>) {
// console.log.apply(null, arguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class FocusOnMountExample extends React.Component<{}> {
const commands = UIManager.getViewManagerConfig('RCTView').Commands;
if ('focus' in commands) {
UIManager.dispatchViewManagerCommand(
// $FlowFixMe
findNodeHandle(this.ref.current),
UIManager.getViewManagerConfig('RCTView').Commands.focus,
undefined,
Expand Down

0 comments on commit 5c60904

Please sign in to comment.