Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
wfg-react-native-immersive
Advanced tools
Readme
Add Toggle for Android Immersive FullScreen Layout
Note:
v1.0.0
and above should be used with react-native@>=0.47
v0.0.5
should be used with react-native@<=0.46
Download from npm: npm i react-native-immersive
Run react-native link
to automatically link the library.
Edit android/settings.gradle
:
+ include ':react-native-immersive'
+ project(':react-native-immersive').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-immersive/android')
Edit android/app/build.gradle
:
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
compile "com.facebook.react:react-native:+" // From node_modules
+ compile project(':react-native-immersive')
}
Edit android/app/src/main/java/.../MainApplication.java
:
+ import com.rnimmersive.RNImmersivePackage;
...
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage()
+ , new RNImmersivePackage()
);
}
import { Immersive } from 'react-native-immersive'
// methods (Android only, will throw Error on iOS in __DEV__ mode)
Immersive.on()
Immersive.setImmersive(true)
Immersive.off()
Immersive.setImmersive(false)
The Immersive State do not last forever (SYSTEM_UI_FLAG_IMMERSIVE_STICKY is not sticky enough). The Immersive State will get reset when:
To restore the Immersive State, add an additional listener.
// listener for Immersive State recover
const restoreImmersive = () => {
__DEV__ && console.warn('Immersive State Changed!')
Immersive.on()
}
Immersive.addImmersiveListener(restoreImmersive)
Immersive.removeImmersiveListener(restoreImmersive)
The Native Module itself will cover some basic Immersive State change (but not something like Modal + Alert).
To get all Immersive State change, edit android/app/src/main/java/.../MainActivity.java
:
+ import com.rnimmersive.RNImmersiveModule;
...
public class MainActivity extends ReactActivity {
...
+ @Override
+ public void onWindowFocusChanged(boolean hasFocus) {
+ super.onWindowFocusChanged(hasFocus);
+
+ if (hasFocus && RNImmersiveModule.getInstance() != null) {
+ RNImmersiveModule.getInstance().emitImmersiveStateChangeEvent();
+ }
+ }
}
Change the code of index.js
for testing:
example/index.sample.js
When compile ReactNative android, different package may set different compileSdkVersion and buildToolsVersion.
To force all the submodules to use the specified compileSdkVersion and buildToolsVersion,
add the following code to android/build.gradle
:
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
}
}
}
}
FAQs
Add Toggle for Android Immersive FullScreen Layout
The npm package wfg-react-native-immersive receives a total of 3 weekly downloads. As such, wfg-react-native-immersive popularity was classified as not popular.
We found that wfg-react-native-immersive demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.