Skip to content
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

feat: Add visionOS support #3373

Merged
merged 9 commits into from May 7, 2024
Merged

Conversation

Saadnajmi
Copy link
Contributor

@Saadnajmi Saadnajmi commented Apr 2, 2024

Summary

Add visionOS support, and an example test app via react-native-test-app.

As it turns out, most of where we ifdeffed stuff out for macOS, is also where we need to ifdef out for visionOS. So a simple conversion of the ifdefs from "if !macOS" to "if iOS" does the job.

Additionally, we needed to port uses of UIMenuController to to UIEditMenuInteraction. This is only available on iOS 16+, so I did my best to guard behind availability checks and compiler ifdefs. I am not sure what our minimum iOS/Xcode version we want to support in this repo is, so I would appreciate a sanity check.

Test Plan

Test app works. Custom menus work on both iOS 16 and visionOS 1.0
Screenshot 2024-04-01 at 11 23 23 PM
(Sorry for the compressed video)

Screen.Recording.2024-04-02.at.1.27.14.PM_compressed.mp4

@Saadnajmi Saadnajmi marked this pull request as draft April 2, 2024 06:29
@Saadnajmi Saadnajmi changed the title [Draft] Add visionOS support Add visionOS support Apr 2, 2024
@Saadnajmi Saadnajmi marked this pull request as ready for review April 2, 2024 06:38
Copy link

@TheSavior TheSavior left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know this stuff very well, so drive by comment on something that looks funky

apple/RNCWebViewImpl.m Outdated Show resolved Hide resolved
apple/RNCWebViewImpl.m Outdated Show resolved Hide resolved
@Saadnajmi
Copy link
Contributor Author

Saadnajmi commented Apr 2, 2024

EDIT: And ported. Good to go!

This PR works as far as I can tell, save custom menus. The method for showing custom actions in a context menu on iOS 16 / visionOS 1.0 changed (use UIEditMenuConfiguration instead of UIMenuController), so I'm seeing If I can refactor that bit. Otherwise, this change might be able to land without custom menu support

Comment on lines +255 to +260
if (@available(iOS 16.0, *)) {
CGPoint location = [pressSender locationInView:self];
UIEditMenuConfiguration *config = [UIEditMenuConfiguration configurationWithIdentifier:nil sourcePoint:location];
[_editMenuInteraction presentEditMenuWithConfiguration:config];
} else {
// When a long press ends, bring up our custom UIMenu if defined
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we need to support older versions of Xcode, I can put this behind a compiler macro like we do elsewhere, along with any other references.

@Saadnajmi Saadnajmi changed the title Add visionOS support feat: Add visionOS support Apr 12, 2024
@Saadnajmi
Copy link
Contributor Author

Hello @Titozzz / @jamonholmgren , I was wondering if there was anything I could do to help move this PR forward? Appreciate your time spent maintaining this repo :)

@Titozzz Titozzz merged commit dd7fb83 into react-native-webview:master May 7, 2024
10 of 11 checks passed
react-native-community-bot pushed a commit that referenced this pull request May 7, 2024
# [13.9.0](v13.8.7...v13.9.0) (2024-05-07)

### Bug Fixes

* **macos:** Fix source prop for Fabric ([#3404](#3404)) ([7fb5c3f](7fb5c3f))

### Features

* Add visionOS support ([#3373](#3373)) ([dd7fb83](dd7fb83))
@react-native-community-bot
Copy link
Collaborator

🎉 This PR is included in version 13.9.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants