bevyengine / bevyengine/bevy

Device safe area insets (for iOS and Android)

Open
#23,003 5 comments 0 reactions 0 assignees View on GitHub
A-UI A-Windowing C-Feature D-Straightforward O-Android O-iOS S-Blocked X-Uncontroversial
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?

On most modern mobile devices the display has rounded corners and there is a notch at the top of the screen. UI and other elements need to often not be drawn in awkward positions due to these.

## What solution would you like?

A built-in resource `SafeAreaInsets` with pixel inset values for `top`, `right`, `bottom`, and `left`. It should use the platform specific APIs to get the values and it must update the values e.g. when the device is rotated (but Android has more cases that require the values to also be updated so maybe they should just be queried each frame).

Even on devices which don't have any concept of safe area insets, the resource should exist and just have default values as zero.

## What alternative(s) have you considered?

1. Hard coded values, which breaks quickly because of the very high number of different kinds of devices in the market.
2. Building it myself.

## Additional context

- https://developer.apple.com/documentation/uikit/uiview/safeareainsets
- https://developer.apple.com/documentation/swiftui/geometryproxy/safeareainsets
- https://developer.android.com/develop/ui/compose/system/insets
- https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/package-summary#(androidx.compose.foundation.layout.WindowInsets.Companion).safeContent()

Contributor guide

Open the contributing guide

Research direction

Start by reading the linked Apple UIKit/SwiftUI and Android WindowInsets documentation to compare the platform APIs and update behavior on rotation. Define the SafeAreaInsets resource with top, right, bottom, and left pixel values, ensure zero defaults on unsupported devices, and verify that values can update for the Android cases described.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, ios, rust
Domain
mobile
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.