feat: allow setting light mode on bars
This commit is contained in:
parent
5f98a64f7a
commit
503ec8b034
|
@ -4,7 +4,7 @@ import android.app.Activity;
|
|||
import android.view.Window;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
|
||||
import android.view.View;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.Callback;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
|
@ -27,7 +27,7 @@ public class RNNavBarColorModule extends ReactContextBaseJavaModule {
|
|||
}
|
||||
|
||||
@ReactMethod
|
||||
public void setColor(final String color) {
|
||||
public void setColor(final String color, final boolean isLight) {
|
||||
final Activity activity = getCurrentActivity();
|
||||
final int colorInt = Color.parseColor(color);
|
||||
if(activity == null)
|
||||
|
@ -36,6 +36,16 @@ public class RNNavBarColorModule extends ReactContextBaseJavaModule {
|
|||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int flags = activity.getWindow().getDecorView().getSystemUiVisibility();
|
||||
if(isLight){
|
||||
flags = flags | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
|
||||
flags = flags | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
|
||||
activity.getWindow().getDecorView().setSystemUiVisibility(flags);
|
||||
} else {
|
||||
flags = flags ^ View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
|
||||
flags = flags ^ View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
|
||||
activity.getWindow().getDecorView().setSystemUiVisibility(flags);
|
||||
}
|
||||
activity.getWindow().setNavigationBarColor(colorInt);
|
||||
}
|
||||
});
|
||||
|
|
6
index.js
6
index.js
|
@ -8,9 +8,9 @@ module.exports = {
|
|||
return NavigationBar.apiLevel;
|
||||
}
|
||||
},
|
||||
setColor: (color) => {
|
||||
setColor: (color, isLight) => {
|
||||
if (Platform.OS == 'android' && NavigationBar.apiLevel >= 21) {
|
||||
return NavigationBar.setColor(color);
|
||||
return NavigationBar.setColor(color, isLight);
|
||||
}
|
||||
},
|
||||
setStatusBarColor: (color, animation) => {
|
||||
|
@ -29,4 +29,4 @@ module.exports = {
|
|||
return StatusBar.setBarStyle('default', animation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue