callstack / react-native-visionos

A framework for building native visionOS applications using React
https://callstack.github.io/react-native-visionos-docs/
MIT License
1.02k stars 30 forks source link

feat: add multi-window support #117

Closed okwasniewski closed 9 months ago

okwasniewski commented 9 months ago

Summary:

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

Changes

New

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 commented 9 months ago

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