|
1 | 1 | import AppKit |
| 2 | + |
2 | 3 | #if USE_REACT_AS_MODULE |
3 | | -import React |
4 | | -#endif // USE_REACT_AS_MODULE |
| 4 | + import React |
| 5 | +#endif // USE_REACT_AS_MODULE |
5 | 6 |
|
6 | 7 | /// React Native macOS inherits some assumptions from React Native on iOS / UIKit. |
7 | 8 | /// This serves as an issue when we want to write our own native components derived from NSView, as we don't |
8 | 9 | /// inherit the "fixes" we need from RCTView to get views working properly.. This subclass "fixes" the minimal amount |
9 | 10 | /// so that our native component works as expected. |
10 | 11 | internal class FixedVisualEffectView: NSVisualEffectView { |
11 | 12 |
|
12 | | - /// React Native macOS uses a flipped coordinate space by default. to match the other platforms. |
13 | | - /// Let's stay consistent and ensure any views hosting React Native views are also flipped. |
14 | | - /// This helps RCTTouchHandler register clicks in the right location, and ensures `layer.geometryFlipped` is true. |
15 | | - override var isFlipped: Bool { |
16 | | - return true |
17 | | - } |
18 | | - |
19 | | - /// This subclass is necessary due to differences' in hitTest()'s implementation between iOS and macOS |
20 | | - /// On iOS / UIKit, hitTest(_ point:, with event:) takes a point in the receiver's local coordinate system. |
21 | | - /// On macOS / AppKit, hitTest(_ point) takes a point in the reciever's superviews' coordinate system. |
22 | | - /// RCTView assumes the iOS implementation, so it has an override of hitTest(_ point). Let's copy the |
23 | | - /// implementatation to our native component, so that clicks for subviews of type RCTView are handled properly. |
24 | | - /// Another solution would be to add an RCTView subview that covers the full bounds of our native view |
25 | | - open override func hitTest(_ point: NSPoint) -> NSView? { |
26 | | - var pointForHitTest = point |
27 | | - for subview in subviews { |
28 | | - if let subview = subview as? RCTView { |
29 | | - pointForHitTest = subview.convert(point, from: superview) |
30 | | - } |
31 | | - let result = subview.hitTest(pointForHitTest) |
32 | | - if (result != nil) { |
33 | | - return result |
34 | | - } |
35 | | - } |
36 | | - return nil |
37 | | - } |
| 13 | + /// React Native macOS uses a flipped coordinate space by default. to match the other platforms. |
| 14 | + /// Let's stay consistent and ensure any views hosting React Native views are also flipped. |
| 15 | + /// This helps RCTTouchHandler register clicks in the right location, and ensures `layer.geometryFlipped` is true. |
| 16 | + override var isFlipped: Bool { |
| 17 | + return true |
| 18 | + } |
38 | 19 | } |
0 commit comments