Skip to content

feat: add cross-platform NativeWindow implementation#11181

Draft
edusperoni wants to merge 3 commits intomainfrom
feat/unified-multi-window
Draft

feat: add cross-platform NativeWindow implementation#11181
edusperoni wants to merge 3 commits intomainfrom
feat/unified-multi-window

Conversation

@edusperoni
Copy link
Copy Markdown
Contributor

This is a draft POC implementation.

The goal is mostly to discuss the approach and refine it.

We introduce a new class (NativeWindow) which will handle most multi-window functions.

We slowly deprecate 'launch' event and other Application events in favor of the window events.

Ideally we also add something like: View.getNativeWindow() so you can get the NativeWindow of a specific view. All plugins will have to adapt to this new API, but we'll provide backwards compatibility.

In sum, we the following concept:

  1. Application: the full context. This is where JS lives. This is the browser "window"
  2. NativeWindow: A browser tab or multi-window. Multiple windows live in the same JS context.

The developer can choose how to handle this. Example from my angular background:

  1. Every window can be a fully new app bootstrapApplication(...) ("root" services are per-window, "platform" services are shared)
  2. Bootstrap a single application and every window is a different createComponent ("root" services are shared, navigation has to be similar to modal navigation)

- Introduced NativeWindow class to manage platform-specific window behavior for iOS and Android.
- Added interfaces and common functionality for NativeWindow, including event handling and lifecycle management.
- Implemented Android-specific NativeWindow logic to wrap AppCompatActivity and manage its lifecycle.
- Implemented iOS-specific NativeWindow logic to wrap UIWindowScene and UIWindow, handling view controller setup and trait collection changes.
- Updated core index files to export new NativeWindow functionality.
@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 13, 2026

View your CI Pipeline Execution ↗ for commit 50f8880

Command Status Duration Result
nx test apps-automated -c=android ✅ Succeeded 1s View ↗
nx run-many --target=test --configuration=ci --... ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-13 19:30:22 UTC

@NathanWalker
Copy link
Copy Markdown
Contributor

Great start here, it might be helpful to setup a new demo page in toolbox or repurpose multiple-scenes.ts to exercise the approach on both platforms?

…ling

- Refactored NativeWindow to separate platform-specific implementations for Android and iOS.
- Introduced AndroidNativeWindow and IOSNativeWindow classes extending a common NativeWindow base class.
- Updated lifecycle event notifications to emit events directly from NativeWindow instances instead of the Application class.
- Deprecated direct event listeners on the Application class in favor of listening on NativeWindow instances.
- Removed redundant index files for native-window on both Android and iOS platforms.
- Enhanced type definitions for NativeWindow events and interfaces to improve clarity and maintainability.
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.

2 participants