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 multi-window support #117

Merged
merged 2 commits into from
Feb 26, 2024
Merged

feat: add multi-window support #117

merged 2 commits into from
Feb 26, 2024

Conversation

okwasniewski
Copy link
Member

@okwasniewski okwasniewski commented Feb 16, 2024

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:

const secondWindow = WindowManager.getWindow('SecondWindow');

const Example = () => {
  return (
    <View style={styles.container}>
      <Button
        title="Open Second Window"
        onPress={() => {
            secondWindow.open({title: 'React Native Window'});
        }}
      />
      <Button
        title="Update Second Window"
        onPress={() => {
          secondWindow.update({title: 'Updated Window'});
        }}
      />
      <Button
        title="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

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

@okwasniewski okwasniewski force-pushed the feat/multi-window branch 7 times, most recently from 555306b to d88f4ec Compare February 21, 2024 15:13
@okwasniewski okwasniewski marked this pull request as ready for review February 21, 2024 15:14
@okwasniewski okwasniewski changed the title [WIP] feat: add multi-window support feat: add multi-window support Feb 21, 2024

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

SEL lastFocusedWindowSelector = NSSelectorFromString(@"lastFocusedWindow");
Copy link
Member 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
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.

@State private var immersionLevel: ImmersionStyle = .full

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

RCTWindow(id: "SecondWindow", sceneData: reactContext.getSceneData(id: "SecondWindow"))
Copy link
Member 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?

@okwasniewski okwasniewski force-pushed the feat/multi-window branch 5 times, most recently from 1a97f77 to 838e7e5 Compare February 26, 2024 10:46
@okwasniewski okwasniewski merged commit 45fcce8 into main Feb 26, 2024
9 checks passed
@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 6, 2024
* feat: add multi-window support

* feat: introduce WindowManager
okwasniewski added a commit that referenced this pull request Mar 18, 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)
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 Apr 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 Apr 30, 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 May 10, 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 May 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 Jun 10, 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 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 15, 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 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 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 11, 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 12, 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 <[email protected]>

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 16, 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 <[email protected]>

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 16, 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 <[email protected]>

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 <[email protected]>

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 <[email protected]>

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 <[email protected]>

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 <[email protected]>

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 <[email protected]>

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 <[email protected]>

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 <[email protected]>

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 free to 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