Skip to content

Commit

Permalink
Document LocalModalWindow
Browse files Browse the repository at this point in the history
  • Loading branch information
alexstyl committed Aug 18, 2024
1 parent 1a2e4bd commit d1150e1
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/dialog.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,30 @@ Dialog(state = rememberDialogState(visible = true)) {
}
```

### Styling the system bars

**Android only**

Dialogs will not change the color of your system UI when displayed. We provide a `LocalModalWindow` composition local, which provides you with the Android `Window` that hosts the dialog, so that you can customize the System UI according to your needs:

```kotlin
Dialog(rememberDialogState()) {
DialogPanel {
val window = LocalModalWindow.current
LaunchedEffect(Unit) {
// change system bars to transparent
window.navigationBarColor = Color.TRANSPARENT
window.statusBarColor = Color.TRANSPARENT

// don't forget to update the icons too
WindowInsetsControllerCompat(window, window.decorView).isAppearanceLightStatusBars = true
WindowInsetsControllerCompat(window, window.decorView).isAppearanceLightNavigationBars = true
}
BasicText("Transparent bars. So cool 😎 ", modifier = Modifier.navigationBarsPadding())
}
}
```

## Keyboard Interactions

<style>
Expand Down
26 changes: 26 additions & 0 deletions docs/modal-bottom-sheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,32 @@ ModalBottomSheet(state = sheetState) {
}
```

### Styling the system bars

**Android only**

Modal bottom sheets will darken the navigation bar when displayed by default. This will work for most designs, but there might need more customizations.

We provide a `LocalModalWindow` composition local, which provides you with the Android `Window` that hosts the modal sheet, so that you can customize the System UI according to your needs:

```kotlin
ModalBottomSheet(rememberModalBottomSheetState(initialDetent = SheetDetent.FullyExpanded)) {
Sheet(Modifier.fillMaxWidth()) {
val window = LocalModalWindow.current
LaunchedEffect(Unit) {
// change system bars to transparent
window.navigationBarColor = Color.TRANSPARENT
window.statusBarColor = Color.TRANSPARENT

// don't forget to update the icons too
WindowInsetsControllerCompat(window, window.decorView).isAppearanceLightStatusBars = true
WindowInsetsControllerCompat(window, window.decorView).isAppearanceLightNavigationBars = true
}
BasicText("Transparent bars. So cool 😎 ", modifier = Modifier.navigationBarsPadding())
}
}
```

## Keyboard Interactions

The `BottomSheet` component does not have any keyboard interactions, as it is 100% controlled by touch input.
Expand Down

0 comments on commit d1150e1

Please sign in to comment.