Hey, everyone. Why `PaddingValues.calculateLeftPad...
# compose
w
Hey, everyone. Why
PaddingValues.calculateLeftPadding
need a LayoutDirection parameter. I understand
PaddingValues.calculateStartPadding
need a LayoutDirection, but Left is left, why need LayoutDirection.
2
s
I've always wondered the same thing, that always felt odd to me 😅
m
If padding values were stored in absolute values (like
left
and
right
) then
calculateLeftPadding
could just return
left
without looking at
LayoutDirection
. But that’t not always the case. In fact the majority of cases you would use a version with relative paddings (represented by internal class
PaddingValuesImpl
) that stores values in
start
and
end
. When it’s asked to give you
left
padding it needs to know the layout direction to do the opposite translation.
👍 3
w
It makes sense. Thank you
👍 1