Tgo1014
03/10/2023, 11:22 AMWindowInsets
with PaddingValues
? I need both for contentPadding
in a LazyColumn
Stylianos Gakis
03/10/2023, 11:56 AMcombine
? If you explain a bit better I think I might be able to help.Tgo1014
03/10/2023, 11:58 AM@Composable
operator fun PaddingValues.plus(paddingValues: PaddingValues): PaddingValues {
val layoutDirection = LocalLayoutDirection.current
return PaddingValues(
top = this.calculateTopPadding() + paddingValues.calculateTopPadding(),
bottom = this.calculateBottomPadding() + paddingValues.calculateBottomPadding(),
start = this.calculateStartPadding(layoutDirection) + paddingValues.calculateStartPadding(layoutDirection),
end = this.calculateEndPadding(layoutDirection) + paddingValues.calculateEndPadding(layoutDirection)
)
}
WindowInsets.navigationBars.asPaddingValues() + PaddingValues(16.dp)
Stylianos Gakis
03/10/2023, 12:06 PMephemient
03/10/2023, 2:49 PMoperator fun PaddingValues.plus(that: PaddingValues): PaddingValues = object : PaddingValues {
override fun calculateBottomPadding(): Dp =
this@plus.calculateBottomPadding() + that.calculateBottomPadding()
override fun calculateLeftPadding(layoutDirection: LayoutDirection): Dp =
this@plus.calculateLeftPadding(layoutDirection) + that.calculateLeftPadding(layoutDirection)
override fun calculateRightPadding(layoutDirection: LayoutDirection): Dp =
this@plus.calculateRightPadding(layoutDirection) + that.calculateRightPadding(layoutDirection)
override fun calculateTopPadding(): Dp =
this@plus.calculateTopPadding() + that.calculateTopPadding()
}
which avoids the need to make it @Composable
?Tgo1014
03/10/2023, 3:01 PMAlex Vanyo
03/10/2023, 4:40 PM@Composable
, it also delays the phase from composition to layout, which can be good for performance for animations and some inset quirksmgrazianodecastro
03/10/2023, 7:14 PMStylianos Gakis
03/10/2023, 7:23 PMephemient
03/11/2023, 1:37 AM