Skip to content

Instantly share code, notes, and snippets.

@mrousavy
Created May 12, 2020 14:53
Show Gist options
  • Save mrousavy/8ab7f59df622cdc94eb7f0ff83500bb1 to your computer and use it in GitHub Desktop.
Save mrousavy/8ab7f59df622cdc94eb7f0ff83500bb1 to your computer and use it in GitHub Desktop.
react-native-screens Native Stack Navigator Android Translucent StatusBar inset patch
diff --git a/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.java b/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.java
index a9779ad..36726d6 100644
--- a/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.java
+++ b/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.java
@@ -3,6 +3,7 @@ package com.swmansion.rnscreens;
import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
+import android.os.Build;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.Gravity;
@@ -153,6 +154,13 @@ public class ScreenStackHeaderConfig extends ViewGroup {
getScreenFragment().setToolbar(mToolbar);
}
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ mToolbar.setPadding(0, getRootWindowInsets().getSystemWindowInsetTop(), 0, 0);
+ } else {
+ // TODO: this is a hacky fallback for old android. change?
+ mToolbar.setPadding(0, (int)(25 * getResources().getDisplayMetrics().density), 0, 0);
+ }
+
activity.setSupportActionBar(mToolbar);
ActionBar actionBar = activity.getSupportActionBar();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment