diff --git a/insets/src/main/java/com/google/accompanist/insets/Padding.kt b/insets/src/main/java/com/google/accompanist/insets/Padding.kt index 45f436a56..b075411b4 100644 --- a/insets/src/main/java/com/google/accompanist/insets/Padding.kt +++ b/insets/src/main/java/com/google/accompanist/insets/Padding.kt @@ -53,6 +53,36 @@ inline fun Modifier.systemBarsPadding(enabled: Boolean = true): Modifier = compo ) } +/** + * Selectively apply additional space which matches the width/height of any system bars present + * on the respective edges of the screen. + * + * @param start Whether to apply padding to the start edge, which matches the system bars width + * (if present) on the start edge of the screen. Defaults to `true`. + * @param top Whether to apply padding to the top edge, which matches the system bars height + * (if present) at the top edge of the screen. Defaults to `true`. + * @param end Whether to apply padding to the end edge, which matches the system bars width + * (if present) on the end edge of the screen. Defaults to `true`. + * @param bottom Whether to apply padding to the bottom edge, which matches the system bars + * height (if present) at the bottom edge of the screen. Defaults to `true`. + */ +inline fun Modifier.systemBarsPadding( + start: Boolean = true, + top: Boolean = true, + end: Boolean = true, + bottom: Boolean = true, +): Modifier = composed { + padding( + rememberInsetsPaddingValues( + insets = LocalWindowInsets.current.systemBars, + applyStart = start, + applyTop = top, + applyEnd = end, + applyBottom = bottom + ) + ) +} + /** * Apply additional space which matches the height of the status bars height along the top edge * of the content.