-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
I'm submitting a ... (check one with "x")
[ ] bug report
[X] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or https://ionicworldwide.herokuapp.com/
Current behavior:
Some Android devices, such as Samsung Galaxy S10, have a cutout or notch (e.g. because of their front camera). However, there is any wrapper for cordova-plugin-android-notch that could be use in Ionic projects.
Expected behavior:
I have decide to develop a wrapper from the above cordova plugin and I would like to submit a PR with the code. For instance, It could be used to apply certain styles (e.g. modify css custom properties)
Steps to reproduce:
To test the wrapper, it is possible to do it using Ionic webpage examples and guidelines for setting up a project:
- Create a new Ionic project with Angular (Ionic webpage guidelines might be used).
- Install the cordova plugin in your project:
ionic cordova plugin add cordova-plugin-android-notch
- Install the wrapper
- Install Android Studio and configure its environmental variables following the guidelines.
- Set up a virtual device and its notch (unblock developer options in the device is needed).
- See Related code section to examples of use.
Related code:
- Import the dependency
import { AndroidNotch } from "@ionic-native/android-notch/ngx";
- Add it to your provides list at the module config
providers: [AndroidNotch]
- Add it in the class you want to use it
constructor(private androidNotch: AndroidNotch) {}
- Wrapper use examples:
this.platform.ready().then(() => {
this.androidNotch.hasCutout().then(
(hasCutout: boolean) => console.log('hasCutout: ',hasCutout),
(err: any) => console.error("Failed to get cutout", err)
);
this.androidNotch.getInsetTop().then(
(px: number) => console.log('getInsetTop: ',px),
(err: any) => console.error("Failed to get insets top:", err)
);
this.androidNotch.getInsetRight().then(
(px: number) => console.log('getInsetRight: ',px),
(err: any) => console.error("Failed to get insets right:", err)
);
this.androidNotch.getInsetBottom().then(
(px: number) => console.log('getInsetBottom: ',px),
(err: any) => console.error("Failed to get insets bottom:", err)
);
this.androidNotch.getInsetLeft().then(
(px: number) => console.log('getInsetLeft: ', px),
(err: any) => console.error("Failed to get insets left:", err)
);
});
Other information:
Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):
Ionic:
Ionic CLI : 6.12.2
Utility:
cordova-res : 0.15.2
native-run : 1.3.0
System:
NodeJS : v12.18.3
npm : 6.14.9
See submited PR.