Skip to content

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 v5. Fell free to open a pull request

Notifications You must be signed in to change notification settings

eidanfi/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

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 v5. Fell free to open a pull request

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 39.8%
  • Swift 20.3%
  • Ruby 13.4%
  • TypeScript 10.6%
  • Objective-C 9.3%
  • JavaScript 6.6%