Skip to content

Instantly share code, notes, and snippets.

@dhrrgn
Last active May 20, 2021 21:05
Show Gist options
  • Save dhrrgn/16a8dfa7581a682627c6 to your computer and use it in GitHub Desktop.
Save dhrrgn/16a8dfa7581a682627c6 to your computer and use it in GitHub Desktop.
package com.yourapp.navbar;
import android.app.Activity;
import android.view.View;
import com.facebook.react.ReactActivity;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
public class NavigationBarAndroid extends ReactContextBaseJavaModule {
public NavigationBarAndroid(ReactApplicationContext reactContext) {
super(reactContext);
}
@Override
public String getName() {
return "NavigationBarAndroid";
}
@ReactMethod
public void hide() {
Activity reactActivity = getCurrentActivity();
if (reactActivity) {
View decorView = reactActivity.getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and higher, but as
// a general rule, you should design your app to hide the status bar whenever you
// hide the navigation bar.
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
}
}
}
package com.yourapp.navbar;
import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class NavigationBarAndroidPackage implements ReactPackage {
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();
modules.add(new NavigationBarAndroid(reactContext));
return modules;
}
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
return Collections.emptyList();
}
@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}
}
@vwnb
Copy link

vwnb commented May 23, 2018

@Jijuan I would also be very interested, if you have the time. Or anyone else who knows native Android code well enough to construct those changes? Blindly jumping into using startActivityForResult isn't yielding much result :(

@hto
Copy link

hto commented Mar 13, 2019

You can also try this. (I'm use React Native Wix Navigation V2.)
https://gist.github.com/hto/7ed5ef629bd8bdf651c73f3680541ad5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment