Remove incorrect menu display fallback (#361)
* Remove incorrect fallback case. We can always just default to mouse location * Remove accidental change to an android patches file (whitespace) * whitespace fix * revert change * remove event code and just show the menu under the anchorview everytime we have an anchorview * Update RCTActionSheetManager.m * Update RCTActionSheetManager.m * cleanup minor improvments and patch revert * refactoring means we don't need a view var anymore
This commit is contained in:
Родитель
71dd399ddb
Коммит
edc008edcc
|
@ -149,33 +149,23 @@ RCT_EXPORT_METHOD(showActionSheetWithOptions:(NSDictionary *)options
|
|||
item.target = self;
|
||||
[menu addItem:item];
|
||||
}
|
||||
|
||||
NSPoint origin = NSZeroPoint;
|
||||
NSEvent *event = nil;
|
||||
|
||||
RCTPlatformView *view = nil;
|
||||
if (anchorViewTag) {
|
||||
view = [self.bridge.uiManager viewForReactTag:anchorViewTag];
|
||||
event = [view.window currentEvent];
|
||||
}
|
||||
NSView *superview = [view superview];
|
||||
if (event && view) {
|
||||
// On a macOS trackpad, soft taps are received as sysDefined event types. SysDefined event locations are relative to the screen so we have to convert those separately.
|
||||
NSPoint eventLocationRelativeToWindow = NSZeroPoint;
|
||||
CGPoint eventLocationInWindow = [event locationInWindow];
|
||||
if ([event type] == NSEventTypeSystemDefined) { // light tap event relative to screen
|
||||
eventLocationRelativeToWindow = [[view window] convertRectFromScreen:NSMakeRect(eventLocationInWindow.x, eventLocationInWindow.y, 0, 0)].origin;
|
||||
} else { // full click events are relative to the window
|
||||
eventLocationRelativeToWindow = eventLocationInWindow;
|
||||
}
|
||||
origin = [view convertPoint:eventLocationRelativeToWindow fromView:nil];
|
||||
} else if (view) {
|
||||
CGRect superviewFrame = [superview frame];
|
||||
origin = NSMakePoint(NSMidX(superviewFrame), NSMidY(superviewFrame));
|
||||
NSPoint location = CGPointZero;
|
||||
if (view != nil) {
|
||||
// Display under the anchorview
|
||||
CGRect bounds = [view bounds];
|
||||
|
||||
CGFloat originX = [view userInterfaceLayoutDirection] == NSUserInterfaceLayoutDirectionRightToLeft ? NSMaxX(bounds) : NSMinX(bounds);
|
||||
location = NSMakePoint(originX, NSMaxY(bounds));
|
||||
} else {
|
||||
origin = [NSEvent mouseLocation];
|
||||
// Display at mouse location if no anchorView provided
|
||||
location = [NSEvent mouseLocation];
|
||||
}
|
||||
|
||||
[menu popUpMenuPositioningItem:menu.itemArray.firstObject atLocation:origin inView:superview];
|
||||
[menu popUpMenuPositioningItem:menu.itemArray.firstObject atLocation:location inView:view];
|
||||
#endif // ]TODO(macOS ISS#2323203)
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче