Skip to content

feat: add multi-window support - #117

Merged
okwasniewski merged 2 commits into
mainfrom
feat/multi-window
Feb 26, 2024
Merged

feat: add multi-window support#117
okwasniewski merged 2 commits into
mainfrom
feat/multi-window

Conversation

@okwasniewski

@okwasniewskiokwasniewski commented Feb 16, 2024

Copy link
Copy Markdown

Summary:

This PR adds multi-window support with data sharing from React Native to SwiftUI.

Changes

  • XR.requestSession now accepts additional object which can be retrieved from the SwiftUI side.

New

  • WindowManager API

Example usage:

constsecondWindow=WindowManager.getWindow('SecondWindow');constExample=()=>{return(<Viewstyle={styles.container}><Buttontitle="Open Second Window"onPress={()=>{secondWindow.open({title: 'React Native Window'});}}/><Buttontitle="Update Second Window"onPress={()=>{secondWindow.update({title: 'Updated Window'});}}/><Buttontitle="Close Second Window"onPress={()=>{secondWindow.close();}}/></View>);};

This design allows other platforms to adapt this pattern and extend the returned window object instead of adding more static methods on theWindowManager object

Changelog:

[VISIONOS] [ADDED] - Multi window support

Test Plan:

CI Green / Test multi window apis

@billyjacoby

Copy link
Copy Markdown

I’m really excited about this PR - if there’s anything I can contribute to help get this in please ping me!

@okwasniewski
okwasniewskiforce-pushed the feat/multi-window branch 7 times, most recently from 555306b to d88f4ecCompareFebruary 21, 2024 15:13
@okwasniewski
okwasniewski marked this pull request as ready for review February 21, 2024 15:14
@okwasniewskiokwasniewski changed the title [WIP] feat: add multi-window supportfeat: add multi-window supportFeb 21, 2024
Comment threadpackages/react-native/Libraries/XR/RCTXRModule.mm Outdated
Comment threadpackages/react-native/Libraries/SwiftExtensions/RCTMainWindow.swift Outdated
Comment threadpackages/react-native/Libraries/SwiftExtensions/RCTMainWindow.swift Outdated
Comment threadpackages/react-native/Libraries/SwiftExtensions/RCTWindow.swift Outdated
Comment threadpackages/react-native/Libraries/XR/RCTXRModule.mm

id<UIApplicationDelegate> delegate = RCTSharedApplication().delegate;

SEL lastFocusedWindowSelector = NSSelectorFromString(@"lastFocusedWindow");

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This solution is not ideal but I didn't find anything better that's available publicly.

I found private API that allows to retrieve "key" window scene (the last interacted with), but usage of private APIs is not allowed.

I'm leaving this for reference:

SEL isKeyWindowSceneSelector = NSSelectorFromString(@"_isKeyWindowScene");
if ([windowScene respondsToSelector:isKeyWindowSceneSelector]) {
BOOL isKeyWindowScene = [windowScene performSelector:isKeyWindowSceneSelector];
if (!isKeyWindowScene) {
continue;
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Post on the Apple dev forums and see if you can get an official response, some folks have gotten private iOS APIs made public via discussions there.

var body: some Scene {
RCTMainWindow(moduleName: "RNTesterApp")

RCTWindow(id: "SecondWindow", sceneData: reactContext.getSceneData(id: "SecondWindow"))

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

[Question] How can we make declaring new windows possible without users touching native code?

Comment threadpackages/rn-tester/js/examples/SecondWindow/SecondWindow.js Outdated
@okwasniewski
okwasniewskiforce-pushed the feat/multi-window branch 5 times, most recently from 1a97f77 to 838e7e5CompareFebruary 26, 2024 10:46
@okwasniewski
okwasniewski merged commit 45fcce8 into mainFeb 26, 2024
@okwasniewski
okwasniewski deleted the feat/multi-window branch February 26, 2024 11:14
okwasniewski added a commit that referenced this pull request Feb 26, 2024
* feat: add multi-window support
* feat: introduce WindowManager
# Conflicts:
#	packages/react-native/Libraries/XR/RCTXRModule.mm
#	packages/react-native/src/private/specs/visionos_modules/NativeXRModule.js
#	packages/rn-tester/Podfile.lock
#	packages/rn-tester/js/examples/XR/XRExample.js
fix: creating second root view instance crash
okwasniewski added a commit that referenced this pull request Mar 6, 2024
* feat: add multi-window support
* feat: introduce WindowManager
okwasniewski added a commit that referenced this pull request Mar 19, 2024
* feat: add multi-window support
* feat: introduce WindowManager
fix: RCTReactViewController properly check props to update
fix: use clearColor instead of systemBackgroundColor for visionOS (#125)
# Conflicts:
#	packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.mm
okwasniewski added a commit that referenced this pull request Mar 22, 2024
* feat: add multi-window support
* feat: introduce WindowManager
fix: RCTReactViewController properly check props to update
fix: use clearColor instead of systemBackgroundColor for visionOS (#125)
okwasniewski added a commit that referenced this pull request Jun 21, 2024
* feat: add multi-window support
* feat: introduce WindowManager
fix: RCTReactViewController properly check props to update
fix: use clearColor instead of systemBackgroundColor for visionOS (#125)
okwasniewski added a commit that referenced this pull request Jun 24, 2024
* feat: add multi-window support
* feat: introduce WindowManager
fix: RCTReactViewController properly check props to update
fix: use clearColor instead of systemBackgroundColor for visionOS (#125)
okwasniewski added a commit that referenced this pull request Jun 24, 2024
* feat: add multi-window support
* feat: introduce WindowManager
fix: RCTReactViewController properly check props to update
fix: use clearColor instead of systemBackgroundColor for visionOS (#125)
okwasniewski added a commit that referenced this pull request Jun 24, 2024
* feat: add multi-window support
* feat: introduce WindowManager
fix: creating second root view instance crash
okwasniewski added a commit that referenced this pull request Jul 29, 2024
* feat: add multi-window support
* feat: introduce WindowManager
fix: RCTReactViewController properly check props to update
fix: use clearColor instead of systemBackgroundColor for visionOS (#125)
okwasniewski added a commit that referenced this pull request Jul 31, 2024
* feat: add multi-window support
* feat: introduce WindowManager
fix: RCTReactViewController properly check props to update
fix: use clearColor instead of systemBackgroundColor for visionOS (#125)
okwasniewski added a commit that referenced this pull request Aug 5, 2024
* feat: add multi-window support
* feat: introduce WindowManager
fix: RCTReactViewController properly check props to update
fix: use clearColor instead of systemBackgroundColor for visionOS (#125)
okwasniewski added a commit that referenced this pull request Aug 23, 2024
* feat: add multi-window support
* feat: introduce WindowManager
fix: RCTReactViewController properly check props to update
fix: use clearColor instead of systemBackgroundColor for visionOS (#125)
okwasniewski added a commit that referenced this pull request Aug 23, 2024
* feat: add multi-window support
* feat: introduce WindowManager
fix: RCTReactViewController properly check props to update
fix: use clearColor instead of systemBackgroundColor for visionOS (#125)
okwasniewski added a commit that referenced this pull request Aug 26, 2024
* feat: add multi-window support
* feat: introduce WindowManager
fix: RCTReactViewController properly check props to update
fix: use clearColor instead of systemBackgroundColor for visionOS (#125)
okwasniewski added a commit that referenced this pull request Aug 26, 2024
* feat: add multi-window support
* feat: introduce WindowManager
fix: RCTReactViewController properly check props to update
fix: use clearColor instead of systemBackgroundColor for visionOS (#125)
okwasniewski added a commit that referenced this pull request Sep 17, 2024
* feat: add multi-window support
* feat: introduce WindowManager
fix: RCTReactViewController properly check props to update
fix: use clearColor instead of systemBackgroundColor for visionOS (#125)
feat: allow to use WindowHandlingModifier outside of RCTMainWindow
fix: deep and universal links when app is running (#140)
Co-authored-by: Thiago Brezinski <thiagobrez@gmail.com>
fix: remove window init
feat: add support for ornaments & dev menu trigger (#149)
* feat: add support for ornaments
* feat: add ornaments support to second window
fix: allow to manually move dev menu to avoid conflicts (#150)
fix: remove unnecessary diff after upstreaming changes (#151)
Make CMake 3.29.0 as minimum required version (#155)
fix: move visionOS codegen specs, sync with upstream
chore: sync with upstream
fix: remove template
Move template to a separate repo
fix: update oot-release scripts
chore: remove unnecessary diff (#159)
fix: react-native-config
chore: sync with upstream
chore: sync with upstrteam
okwasniewski added a commit that referenced this pull request Sep 17, 2024
* feat: add multi-window support
* feat: introduce WindowManager
fix: RCTReactViewController properly check props to update
fix: use clearColor instead of systemBackgroundColor for visionOS (#125)
feat: allow to use WindowHandlingModifier outside of RCTMainWindow
fix: deep and universal links when app is running (#140)
Co-authored-by: Thiago Brezinski <thiagobrez@gmail.com>
fix: remove window init
feat: add support for ornaments & dev menu trigger (#149)
* feat: add support for ornaments
* feat: add ornaments support to second window
fix: allow to manually move dev menu to avoid conflicts (#150)
fix: remove unnecessary diff after upstreaming changes (#151)
Make CMake 3.29.0 as minimum required version (#155)
fix: move visionOS codegen specs, sync with upstream
chore: sync with upstream
fix: remove template
Move template to a separate repo
fix: update oot-release scripts
chore: remove unnecessary diff (#159)
fix: react-native-config
chore: sync with upstream
chore: sync with upstrteam
okwasniewski added a commit that referenced this pull request Sep 24, 2024
* feat: add multi-window support
* feat: introduce WindowManager
fix: RCTReactViewController properly check props to update
fix: use clearColor instead of systemBackgroundColor for visionOS (#125)
feat: allow to use WindowHandlingModifier outside of RCTMainWindow
fix: deep and universal links when app is running (#140)
Co-authored-by: Thiago Brezinski <thiagobrez@gmail.com>
fix: remove window init
feat: add support for ornaments & dev menu trigger (#149)
* feat: add support for ornaments
* feat: add ornaments support to second window
fix: allow to manually move dev menu to avoid conflicts (#150)
fix: remove unnecessary diff after upstreaming changes (#151)
Make CMake 3.29.0 as minimum required version (#155)
fix: move visionOS codegen specs, sync with upstream
chore: sync with upstream
fix: remove template
Move template to a separate repo
fix: update oot-release scripts
chore: remove unnecessary diff (#159)
fix: react-native-config
chore: sync with upstream
chore: sync with upstrteam
okwasniewski added a commit that referenced this pull request Nov 18, 2024
* feat: add multi-window support
* feat: introduce WindowManager
fix: RCTReactViewController properly check props to update
fix: use clearColor instead of systemBackgroundColor for visionOS (#125)
feat: allow to use WindowHandlingModifier outside of RCTMainWindow
fix: deep and universal links when app is running (#140)
Co-authored-by: Thiago Brezinski <thiagobrez@gmail.com>
fix: remove window init
feat: add support for ornaments & dev menu trigger (#149)
* feat: add support for ornaments
* feat: add ornaments support to second window
fix: allow to manually move dev menu to avoid conflicts (#150)
fix: remove unnecessary diff after upstreaming changes (#151)
Make CMake 3.29.0 as minimum required version (#155)
fix: move visionOS codegen specs, sync with upstream
chore: sync with upstream
fix: remove template
Move template to a separate repo
fix: update oot-release scripts
chore: remove unnecessary diff (#159)
fix: react-native-config
chore: sync with upstream
chore: sync with upstrteam
okwasniewski added a commit that referenced this pull request Nov 27, 2024
* feat: add multi-window support
* feat: introduce WindowManager
fix: RCTReactViewController properly check props to update
fix: use clearColor instead of systemBackgroundColor for visionOS (#125)
feat: allow to use WindowHandlingModifier outside of RCTMainWindow
fix: deep and universal links when app is running (#140)
Co-authored-by: Thiago Brezinski <thiagobrez@gmail.com>
fix: remove window init
feat: add support for ornaments & dev menu trigger (#149)
* feat: add support for ornaments
* feat: add ornaments support to second window
fix: allow to manually move dev menu to avoid conflicts (#150)
fix: remove unnecessary diff after upstreaming changes (#151)
Make CMake 3.29.0 as minimum required version (#155)
fix: move visionOS codegen specs, sync with upstream
chore: sync with upstream
fix: remove template
Move template to a separate repo
fix: update oot-release scripts
chore: remove unnecessary diff (#159)
fix: react-native-config
chore: sync with upstream
chore: sync with upstrteam
okwasniewski added a commit that referenced this pull request Nov 27, 2024
* feat: add multi-window support
* feat: introduce WindowManager
fix: RCTReactViewController properly check props to update
fix: use clearColor instead of systemBackgroundColor for visionOS (#125)
feat: allow to use WindowHandlingModifier outside of RCTMainWindow
fix: deep and universal links when app is running (#140)
Co-authored-by: Thiago Brezinski <thiagobrez@gmail.com>
fix: remove window init
feat: add support for ornaments & dev menu trigger (#149)
* feat: add support for ornaments
* feat: add ornaments support to second window
fix: allow to manually move dev menu to avoid conflicts (#150)
fix: remove unnecessary diff after upstreaming changes (#151)
Make CMake 3.29.0 as minimum required version (#155)
fix: move visionOS codegen specs, sync with upstream
chore: sync with upstream
fix: remove template
Move template to a separate repo
fix: update oot-release scripts
chore: remove unnecessary diff (#159)
fix: react-native-config
chore: sync with upstream
chore: sync with upstrteam
okwasniewski added a commit that referenced this pull request Jan 7, 2025
* feat: add multi-window support
* feat: introduce WindowManager
fix: RCTReactViewController properly check props to update
fix: use clearColor instead of systemBackgroundColor for visionOS (#125)
feat: allow to use WindowHandlingModifier outside of RCTMainWindow
fix: deep and universal links when app is running (#140)
Co-authored-by: Thiago Brezinski <thiagobrez@gmail.com>
fix: remove window init
feat: add support for ornaments & dev menu trigger (#149)
* feat: add support for ornaments
* feat: add ornaments support to second window
fix: allow to manually move dev menu to avoid conflicts (#150)
fix: remove unnecessary diff after upstreaming changes (#151)
Make CMake 3.29.0 as minimum required version (#155)
fix: move visionOS codegen specs, sync with upstream
chore: sync with upstream
fix: remove template
Move template to a separate repo
fix: update oot-release scripts
chore: remove unnecessary diff (#159)
fix: react-native-config
chore: sync with upstream
chore: sync with upstrteam
okwasniewski added a commit that referenced this pull request Jan 23, 2025
* feat: add multi-window support
* feat: introduce WindowManager
fix: RCTReactViewController properly check props to update
fix: use clearColor instead of systemBackgroundColor for visionOS (#125)
feat: allow to use WindowHandlingModifier outside of RCTMainWindow
fix: deep and universal links when app is running (#140)
Co-authored-by: Thiago Brezinski <thiagobrez@gmail.com>
fix: remove window init
feat: add support for ornaments & dev menu trigger (#149)
* feat: add support for ornaments
* feat: add ornaments support to second window
fix: allow to manually move dev menu to avoid conflicts (#150)
fix: remove unnecessary diff after upstreaming changes (#151)
Make CMake 3.29.0 as minimum required version (#155)
fix: move visionOS codegen specs, sync with upstream
chore: sync with upstream
fix: remove template
Move template to a separate repo
fix: update oot-release scripts
chore: remove unnecessary diff (#159)
fix: react-native-config
chore: sync with upstream
chore: sync with upstrteam
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@okwasniewski@billyjacoby@matthargett