Skip to content

Commit 4ae9fc7

Browse files
committed
enableEdgeToEdge() is now the decision hook — override it to control when edge-to-edge activates
activateEdgeToEdge() is the action method — it does both EdgeToEdge.enable(this) and SystemUiUtils.activateEdgeToEdge(), so it's impossible to enable Android edge-to-edge without also setting RNN's internal flag The docs now show activateEdgeToEdge() in the override example instead of EdgeToEdge.enable(this)
1 parent 97e04dd commit 4ae9fc7

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

android/src/main/java/com/reactnativenavigation/NavigationActivity.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,11 @@ public void onReload() {
154154
}
155155

156156
/**
157-
* Enables edge-to-edge display only if the app theme sets
157+
* Controls when edge-to-edge is enabled. Override to customize the decision logic.
158+
* Call {@link #activateEdgeToEdge()} from your override to enable edge-to-edge.
159+
* <p>
160+
* The default implementation enables edge-to-edge only if the app theme sets
158161
* {@code windowOptOutEdgeToEdgeEnforcement} to {@code false} (API 35+).
159-
* By default, edge-to-edge is not enabled. Override to customize.
160162
* Called at the start of onCreate, before super.onCreate.
161163
*/
162164
protected void enableEdgeToEdge() {
@@ -166,12 +168,21 @@ protected void enableEdgeToEdge() {
166168
boolean optOut = a.getBoolean(0, true);
167169
a.recycle();
168170
if (!optOut) {
169-
EdgeToEdge.enable(this);
170-
SystemUiUtils.activateEdgeToEdge();
171+
activateEdgeToEdge();
171172
}
172173
}
173174
}
174175

176+
/**
177+
* Enables edge-to-edge display and notifies the navigation framework.
178+
* Call this from {@link #enableEdgeToEdge()} overrides instead of
179+
* calling {@code EdgeToEdge.enable()} directly.
180+
*/
181+
protected void activateEdgeToEdge() {
182+
EdgeToEdge.enable(this);
183+
SystemUiUtils.activateEdgeToEdge();
184+
}
185+
175186
protected void addDefaultSplashLayout() {
176187
View view = new View(this);
177188
setContentView(view);

website/docs/docs/style-edge-to-edge.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,19 @@ When edge-to-edge is not active (the default), behavior is unchanged from previo
3434

3535
## Custom behavior
3636

37-
`NavigationActivity.enableEdgeToEdge()` is a `protected` method. Override it in your `MainActivity` to customize when and how edge-to-edge is enabled:
37+
`NavigationActivity.enableEdgeToEdge()` is a `protected` method that controls when edge-to-edge is enabled. Override it in your `MainActivity` to customize the decision logic, and call `activateEdgeToEdge()` to enable it:
3838

3939
```kotlin
4040
class MainActivity : NavigationActivity() {
4141
override fun enableEdgeToEdge() {
42-
// Always enable edge-to-edge regardless of theme
43-
EdgeToEdge.enable(this)
42+
// Always enable edge-to-edge regardless of theme or API level
43+
activateEdgeToEdge()
4444
}
4545
}
4646
```
4747

48+
`activateEdgeToEdge()` handles both the Android system call and the internal navigation framework state. Always use it instead of calling `EdgeToEdge.enable()` directly.
49+
4850
## Styling system bars
4951

5052
Status bar and navigation bar colors can still be controlled per-screen via options:

0 commit comments

Comments
 (0)