Skip to content

Commit d872cce

Browse files
markdevochtd4vidimobileossliatnetachgosha212
authored
Edge2edge android (#8262)
* Apply color animations on tab-switching (Android-only) (#7975) * Update package.json version to 7.44.0 [buildkite skip] * Fix npm registry and recreate package-lock.json (#7987) * fix(sdk35): Apply inset over bottom-tabs (#7991) * Update package.json version to 7.45.0 [buildkite skip] * Revert "Feat/rn76 oldarch (#7967)" (#8003) * Update package.json version to 7.46.0 [buildkite skip] * Mocked side-menus - support (#8017) * Update package.json version to 7.47.0 [buildkite skip] * Support drawer menus opening as overlay instead of pushing content in ios (#7986) * Update package.json version to 7.48.0 [buildkite skip] * Patch-fix some recent side-menu overlay mode changes (#8039) * Introduce options to make a floating bottom-tabs (Android) (#8064) * Update package.json version to 7.49.0 [buildkite skip] * fix: top bar buttons disappeared when lock screen then unlock sreen (#8053) (#8076) Co-authored-by: NormanWangEndeavor <145947285+NormanWangEndeavor@users.noreply.github.com> * Update package.json version to 7.50.0 [buildkite skip] * Back-compat edge2edge for standard layout, incl. drawBehind * merge master into me * first config to get it running * bottom bar edge2edge complete? * statusbar e2e * cleanup * backward compatiblility * final touches * Fix yarn registry to use public npmjs.org instead of internal wixpress Made-with: Cursor * #8080 * conflict fixes * snapshot updates * more updates * update e2e android * snapsot update * documentation * added * codex fixes * 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) --------- Co-authored-by: d4vidi <amit.d4vidi@gmail.com> Co-authored-by: mobileoss <mobileoss@wix.com> Co-authored-by: Liat Netach <60575762+liatnetach@users.noreply.github.com> Co-authored-by: Georgy Steshin <gosha212@gmail.com> Co-authored-by: NormanWangEndeavor <145947285+NormanWangEndeavor@users.noreply.github.com>
1 parent e1ca88b commit d872cce

31 files changed

Lines changed: 567 additions & 95 deletions

android/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ dependencies {
130130
implementation "androidx.constraintlayout:constraintlayout:2.0.4"
131131

132132
implementation 'androidx.appcompat:appcompat:1.7.0'
133+
implementation 'androidx.activity:activity:1.9.0'
133134
implementation 'androidx.annotation:annotation:1.2.0'
134135
implementation 'com.google.android.material:material:1.2.0-alpha03'
135136

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

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.os.Bundle;
88
import android.view.KeyEvent;
99
import android.view.View;
10+
import android.view.ViewGroup;
1011

1112
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
1213
import com.facebook.react.modules.core.PermissionAwareActivity;
@@ -17,10 +18,12 @@
1718
import com.reactnativenavigation.react.JsDevReloadHandler;
1819
import com.reactnativenavigation.react.ReactGateway;
1920
import com.reactnativenavigation.react.CommandListenerAdapter;
21+
import com.reactnativenavigation.utils.SystemUiUtils;
2022
import com.reactnativenavigation.viewcontrollers.child.ChildControllersRegistry;
2123
import com.reactnativenavigation.viewcontrollers.modal.ModalStack;
2224
import com.reactnativenavigation.viewcontrollers.navigator.Navigator;
2325

26+
import androidx.activity.EdgeToEdge;
2427
import androidx.activity.OnBackPressedCallback;
2528
import androidx.annotation.NonNull;
2629
import androidx.annotation.Nullable;
@@ -36,6 +39,7 @@ public class NavigationActivity extends AppCompatActivity implements DefaultHard
3639

3740
@Override
3841
protected void onCreate(@Nullable Bundle savedInstanceState) {
42+
enableEdgeToEdge();
3943
super.onCreate(savedInstanceState);
4044
if (isFinishing()) {
4145
return;
@@ -63,7 +67,9 @@ public void onConfigurationChanged(@NonNull Configuration newConfig) {
6367
@Override
6468
public void onPostCreate(@Nullable Bundle savedInstanceState) {
6569
super.onPostCreate(savedInstanceState);
66-
navigator.setContentLayout(findViewById(android.R.id.content));
70+
ViewGroup contentLayout = findViewById(android.R.id.content);
71+
navigator.setContentLayout(contentLayout);
72+
SystemUiUtils.setupSystemBarBackgrounds(this, contentLayout);
6773
}
6874

6975
@Override
@@ -88,6 +94,7 @@ protected void onPause() {
8894
@Override
8995
protected void onDestroy() {
9096
super.onDestroy();
97+
SystemUiUtils.tearDown();
9198
if (navigator != null) {
9299
navigator.destroy();
93100
}
@@ -146,6 +153,36 @@ public void onReload() {
146153
navigator.destroyViews();
147154
}
148155

156+
/**
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
161+
* {@code windowOptOutEdgeToEdgeEnforcement} to {@code false} (API 35+).
162+
* Called at the start of onCreate, before super.onCreate.
163+
*/
164+
protected void enableEdgeToEdge() {
165+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
166+
android.content.res.TypedArray a = getTheme().obtainStyledAttributes(
167+
new int[]{android.R.attr.windowOptOutEdgeToEdgeEnforcement});
168+
boolean optOut = a.getBoolean(0, true);
169+
a.recycle();
170+
if (!optOut) {
171+
activateEdgeToEdge();
172+
}
173+
}
174+
}
175+
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+
149186
protected void addDefaultSplashLayout() {
150187
View view = new View(this);
151188
setContentView(view);

android/src/main/java/com/reactnativenavigation/react/modal/ModalHostLayout.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ open class ModalHostLayout(reactContext: ThemedReactContext) : ViewGroup(reactCo
3434
}
3535

3636
@TargetApi(23)
37-
override fun dispatchProvideStructure(structure: ViewStructure) {
38-
mHostView.dispatchProvideStructure(structure)
37+
override fun dispatchProvideStructure(structure: ViewStructure?) {
38+
structure?.let { mHostView.dispatchProvideStructure(it) }
3939
}
4040

4141
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {}

android/src/main/java/com/reactnativenavigation/utils/ReactTypefaceUtils.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
import android.text.TextUtils;
1919
import androidx.annotation.Nullable;
2020
import com.facebook.react.bridge.ReadableArray;
21-
import com.facebook.react.common.ReactConstants;
2221
import com.facebook.react.views.text.ReactFontManager;
23-
import com.facebook.react.views.text.ReactTextShadowNode;
22+
import com.facebook.react.common.ReactConstants;
2423
import java.util.ArrayList;
2524
import java.util.List;
2625

0 commit comments

Comments
 (0)