SafeArea: SafeArea Layout

更新时间:
2024-05-17
下载文档

SafeArea: SafeArea Layout

EdgerOS App can get current safeArea information.

Functions

edger.layout.safeArea()

  • Returns: {Promise} Promise object.

The returned object will have the following properties:

  • safeAreaInsets {Object} SafeArea information.

    The current attribute has the following properties:

    • top {Number} Top.
    • left {Number} Left.
    • right {Number} Right.
    • bottom {Number} Bottom.

Example

edger.layout.safeArea().then((data) => {
  const { safeAreaInsets } = data;
  console.log('Current safeAreaInfo:', safeAreaInsets);
}).catch(error => {
  console.error(error);
});

async / await

async function safeArea() {
  try {
    return await edger.layout.safeArea();
  } catch (error) {
    console.error(error);
  }
}

Example

edger.onAction('orientation', (data) => {
  // get new safeArea information
  edger.layout.safeArea()
  const { orientation } = data;
  console.log('Current orientation:', orientation);
});
文档内容是否对您有所帮助?
有帮助
没帮助