gsala
08/25/2022, 4:17 PMPaddingValues
. Sometimes I would like to combine padding values like WindowInsets.ime.asPaddingValues - PaddingValues(bottom = 30.dp)
. Other times I would just like to override some default padding values like BottomSheetDefaults.ContentPadding.copy(bottom = 0.dp)
. Shouldn’t this be easier in the compose APIs ? Or am I missing the right way to do this?Zach Klippenstein (he/him) [MOD]
08/29/2022, 8:04 PMQuinten Schelfhout
08/30/2022, 1:54 PMgsala
09/01/2022, 8:10 AM@Composable
operator fun PaddingValues.plus(other : PaddingValues) : PaddingValues {
return PaddingValues(
start = calculateStartPadding(LayoutDirection.Ltr) + other.calculateStartPadding(LayoutDirection.Ltr),
top = calculateTopPadding() + other.calculateTopPadding(),
end = calculateEndPadding(LayoutDirection.Ltr) + other.calculateEndPadding(LayoutDirection.Ltr),
bottom = calculateBottomPadding() + other.calculateBottomPadding(),
)
}
Adam Powell
09/15/2022, 1:36 PMZoltan Demant
09/15/2022, 1:38 PMAdam Powell
09/15/2022, 1:38 PMLocalLayoutDirection
eitherZoltan Demant
09/15/2022, 1:39 PMAdam Powell
09/15/2022, 1:40 PMgsala
09/15/2022, 1:45 PMPaddingValues
The issue I filed has people mentioning that it shouldn’t be a problem to support this. I was hoping to just have it now instead of waiting for it to be implemented in foundation and releasedZoltan Demant
09/15/2022, 1:49 PMclass CombinedPaddingValues(
val first: PaddingValues,
val second: PaddingValues,
) : PaddingValues {
override fun calculateLeftPadding(layoutDirection: LayoutDirection): Dp {
return first.calculateLeftPadding(layoutDirection) + second.calculateLeftPadding(layoutDirection)
}
}
gsala
09/15/2022, 2:03 PMZoltan Demant
09/15/2022, 2:05 PM