|
1 | 1 | ## InsetsX [🚧 Work in progress 🚧] |
2 | | -WindowInsets util for multiplatform |
| 2 | +[](https://kotlinlang.org/docs/multiplatform.html) |
| 3 | +[](https://mvnrepository.com/artifact/com.moriatsushi.insetsx/insetsx) |
| 4 | +[](https://github.com/mori-atsushi/insetsx/blob/main/LISENCE) |
| 5 | + |
| 6 | +<img src="https://user-images.githubusercontent.com/13435109/236607484-22248c02-65de-4954-97a3-349907a2343e.png" width="720px"/> |
| 7 | + |
| 8 | +InsetsX provides a [WindowInsets](https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/WindowInsets) utility for [Compose Multiplatform](https://www.jetbrains.com/lp/compose-multiplatform/). |
| 9 | + |
| 10 | +It aim to work with WindowInsets with the same interface on iOS and Android. |
| 11 | + |
| 12 | +This library will be archived when the official library can handle WindowInsets. |
| 13 | + |
| 14 | +## Setup |
| 15 | +Add the dependency as follows: |
| 16 | + |
| 17 | +```kotlin |
| 18 | +kotlin { |
| 19 | + /* ... */ |
| 20 | + |
| 21 | + sourceSets { |
| 22 | + val commonMain by getting { |
| 23 | + dependencies { |
| 24 | + implementation("com.moriatsushi.insetsx:insetsx:0.1.0-alpha01") |
| 25 | + } |
| 26 | + } |
| 27 | + } |
| 28 | +} |
| 29 | +``` |
| 30 | + |
| 31 | +## How to use |
| 32 | +This works much like Android's WindowInsets. |
| 33 | +Please note that the package name is different. |
| 34 | + |
| 35 | +```kotlin |
| 36 | +import androidx.compose.foundation.layout.windowInsetsPadding |
| 37 | +import androidx.compose.foundation.layout.WindowInsets |
| 38 | +import com.moriatsushi.insetsx.systemBars |
| 39 | + |
| 40 | +val modifier = Modifier |
| 41 | + .windowInsetsPadding(WindowInsets.systemBars) |
| 42 | +``` |
| 43 | + |
| 44 | +## APIs |
| 45 | + |
| 46 | +API|android|ios |
| 47 | +:--|:--|:-- |
| 48 | +WindowInsets.systemBars|status bar + navigation bar|SafeArea |
| 49 | +WindowInsets.navigationBars|navigation bar|bottom of SafeArea |
| 50 | +WindowInsets.statusBars|status bar|top and horizontal of SafeArea |
| 51 | +WindowInsets.ime *1|software keyboard|software keyboard |
| 52 | +WindowInsets.safeDrawing *1|system bars + software keyboard|SafeArea + software keyboard |
| 53 | + |
| 54 | +*1 is experimental |
0 commit comments