Skip to content

jorisbertomeu/capacitor-insets-v2

Repository files navigation

capacitor-insets-v2

Plugin that sends the device insets, works only on android, and send only top, based on an original idea from https://github.com/igorcd/capacitor-insets-plugin which works only for Capacitor 2. This project have been refactored in order to be compatible with Capacitor v3. Fell free to open a pull request

Installation:

npm install --save https://github.com/jorisbertomeu/capacitor-insets-v2
npx cap sync

Android:

// Add this line
import eu.bertom.lab.capacitor.plugin.insetsv2.InsetsV2Plugin;

public class MainActivity extends BridgeActivity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
  	// Add this line
	registerPlugin(InsetsV2Plugin.class);
    	super.onCreate(savedInstanceState);
  }
}

Usage:

const { StatusBar, InsetsV2 } = Plugins;

try {
	const insetsResp = await InsetsV2.top();
	StatusBar.setOverlaysWebView({ overlay: true });
	document.documentElement.style.setProperty('--ion-safe-area-top', `${insetsResp.value}px`);
} catch(e) {
	console.log(e);
}
   

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published