refactor(Android, Stack v5): separate React and native domains in header implementation#4150
Draft
kligarski wants to merge 10 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the Android (Stack v5 / “gamma”) header implementation to better separate the “React config” domain (state/props/events) from the “native header view” domain (toolbar/appbar construction and updates), while also improving teardown to avoid leaking Fabric UIManager listeners.
Changes:
- Replaces the monolithic
StackHeaderCoordinatorwith a slimmerStackHeaderCoordinatorLayout+ newStackHeaderApplicator, and introduces an observer/flags-based update pipeline (StackHeaderConfigurationObserver,StackHeaderUpdateFlags). - Reworks header config attachment to pass both a configuration provider and a native delegate (
OnHeaderConfigurationAttachListener,StackHeaderDelegate) and moves layout-to-shadow-state syncing through the delegate. - Adds explicit teardown paths for Fabric UIManager listeners in
StackHostandStackHeaderConfigviaonDropViewInstance.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| android/src/main/java/com/swmansion/rnscreens/gamma/stack/screen/StackScreen.kt | Renames/reshapes header-config attach listener API; refactors shadow-state syncing entrypoints. |
| android/src/main/java/com/swmansion/rnscreens/gamma/stack/host/StackHostViewManager.kt | Calls tearDown() on host drop to unregister UIManager listeners. |
| android/src/main/java/com/swmansion/rnscreens/gamma/stack/host/StackHost.kt | Uses getFabricUIManagerNotNull and adds tearDown() to remove UIManager listener. |
| android/src/main/java/com/swmansion/rnscreens/gamma/stack/header/toolbar/StackHeaderToolbarMenuCoordinator.kt | Deleted; toolbar menu logic moved into applicator. |
| android/src/main/java/com/swmansion/rnscreens/gamma/stack/header/subview/StackHeaderSubviewProviding.kt | Removes origin-offset update API from the provider interface. |
| android/src/main/java/com/swmansion/rnscreens/gamma/stack/header/subview/StackHeaderSubview.kt | Adjusts subview change listener naming and keeps origin shadow-state updates local to the subview. |
| android/src/main/java/com/swmansion/rnscreens/gamma/stack/header/subview/OnStackHeaderSubviewChangeListener.kt | Renames callback method to onStackHeaderSubviewChanged(). |
| android/src/main/java/com/swmansion/rnscreens/gamma/stack/header/StackHeaderCoordinatorLayout.kt | Implements new attach/observe/update flow; delegates shadow-state updates; rebuilds header via applicator. |
| android/src/main/java/com/swmansion/rnscreens/gamma/stack/header/StackHeaderCoordinator.kt | Deleted; responsibilities split into coordinator layout + applicator. |
| android/src/main/java/com/swmansion/rnscreens/gamma/stack/header/StackHeaderApplicator.kt | New; owns header view construction and incremental application of config changes. |
| android/src/main/java/com/swmansion/rnscreens/gamma/stack/header/StackHeaderAppBarLayout.kt | Adds managed title support storage to support applicator-managed title view. |
| android/src/main/java/com/swmansion/rnscreens/gamma/stack/header/config/StackHeaderUpdateFlags.kt | New; introduces bitflags describing which parts of header need updating/rebuild. |
| android/src/main/java/com/swmansion/rnscreens/gamma/stack/header/config/StackHeaderDelegate.kt | New; defines the native delegate contract for frame/subview/menu click callbacks. |
| android/src/main/java/com/swmansion/rnscreens/gamma/stack/header/config/StackHeaderConfigViewManager.kt | Stops calling legacy change notifier; adds tearDown() on drop. |
| android/src/main/java/com/swmansion/rnscreens/gamma/stack/header/config/StackHeaderConfigurationProviding.kt | Renames config provider interface and replaces delegates with a single observer setter. |
| android/src/main/java/com/swmansion/rnscreens/gamma/stack/header/config/StackHeaderConfigurationObserver.kt | Renames/reshapes observer interface to include update flags. |
| android/src/main/java/com/swmansion/rnscreens/gamma/stack/header/config/StackHeaderConfig.kt | Implements provider + delegate; adds flags-based invalidation and flush on Fabric mount completion; adds UIManager listener teardown. |
| android/src/main/java/com/swmansion/rnscreens/gamma/stack/header/config/OnHeaderConfigurationAttachListener.kt | New; attach callback that passes provider + delegate separately. |
| android/src/main/java/com/swmansion/rnscreens/gamma/stack/header/config/OnHeaderConfigAttachListener.kt | Deleted; replaced by the new attach listener contract. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes https://github.com/software-mansion/react-native-screens-labs/issues/1519.
Changes
WIP
Before & after - visual documentation
WIP
Test plan
WIP
Checklist