-
Notifications
You must be signed in to change notification settings - Fork 162
[macOS] Introduce VibrancyView #3026
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This was referenced Aug 11, 2023
rurikoaraki
reviewed
Aug 11, 2023
rurikoaraki
reviewed
Aug 11, 2023
rurikoaraki
reviewed
Aug 11, 2023
apps/fluent-tester/src/TestComponents/VibrancyView/VibrancyViewTest.tsx
Outdated
Show resolved
Hide resolved
rurikoaraki
reviewed
Aug 11, 2023
apps/fluent-tester/src/TestComponents/VibrancyView/VibrancyViewTest.tsx
Outdated
Show resolved
Hide resolved
Only reviewed the TS |
rurikoaraki
reviewed
Aug 11, 2023
apps/fluent-tester/src/TestComponents/VibrancyView/VibrancyViewTest.tsx
Outdated
Show resolved
Hide resolved
rurikoaraki
reviewed
Aug 11, 2023
apps/fluent-tester/src/TestComponents/VibrancyView/VibrancyViewTest.tsx
Outdated
Show resolved
Hide resolved
lyzhan7
approved these changes
Aug 16, 2023
lyzhan7
reviewed
Aug 16, 2023
lyzhan7
reviewed
Aug 16, 2023
apps/fluent-tester/src/TestComponents/VibrancyView/VibrancyViewTest.tsx
Outdated
Show resolved
Hide resolved
lyzhan7
reviewed
Aug 16, 2023
apps/fluent-tester/src/TestComponents/VibrancyView/VibrancyViewTest.tsx
Outdated
Show resolved
Hide resolved
Add video for dark mode? |
updated |
4 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Platforms Impacted
Description of changes
On macOS, a large part of the design system is the concept of Vibrancy, which is largely controlled and defined by NSVisualEffectView. We don't have a generic native component exposed for NSVisualEffectView, so let's create one: VibrancyView! The name was chosen as it matches well with the iOS equivalent React Native component in @react-native-community/react-native-blur, which might be a potential place to move or copy this native component, should we want to.
This also gives us the side benefit that, with
blendingMode={behindWindow}
, we can overlay our VibrancyView on top of Callout (which had a hardcoded NSVisualEffectView with material'menu
) and effectively render a different material, making #3001 redundant.There were two special considerations taken to make our native component more usable on React Native macOS:
Our Native
VibrancyView
is actually anRCTView
with aNSVisualEffectView
subview. This is done so that our native component inherits all of ViewProps. In order to make sure all children are subviews of ourNSVisualEffectView
, we overrideinsertReactSubview
.While writing this native component, I found there were lots of issues with getting rendering and register clicks properly. This is due to differences in how UIKit (used by React Native on iOS) and Appkit (used by React Native macOS) handle hit testing and coordinate systems. In React Native macOS, we have custom code in RCTView / RCTTouchHandler/etc to mitigate that, but an arbitrary native component derived from
NSView
will not. Therefore, instead of wrappingNSVisualEffectView
directly, I wrote aFixedVisualEffectView
class with some extra code to work with React Native macOS and other RCTViews properly. I put in as much comments as I can to explain what is happening. Many thanks to @lenaic for helping me find solutions here.Verification
Wrote a test page with a lot of tests
Screen.Recording.2023-08-16.at.11.19.16.AM.mov
Pull request checklist
This PR has considered (when applicable):