Can you expose contentPadding param for TopAppBar ...
# compose
r
Can you expose contentPadding param for TopAppBar function with this option?
We can pass contentPadding when used without actions and nav icon
s
Accompanist’s insets-ui provides one such method https://google.github.io/accompanist/insets/#inset-aware-layouts-insets-ui see if this one suits you
1
r
I'm talking about passing content padding for inner content
s
And by inner content you’re referring to inside the TopAppBar right? How is it that the accompanist one doesn’t fit that purpose?
r
I posted two screenshots. Compare them one accepts contentPadding the other doesn't accept
l
We decided not to expose content padding here because there are multiple ‘content paddings’ inside. There is the outer padding, then there is the inset for the title, which changes depending on whether there is a navigation icon or not, etc. Having a
contentPadding
parameter would be confusing as it’s unclear what this would actually change, and it probably doesn’t help in most cases
s
Isn’t this one the same as the first picture but with a contentPadding?
But Louis, in that case, how would one deal with the case that accompanist insets-ui is dealing with. Which is dealing with insets?
l
Yes, there is no support in the Material libraries for insets currently, only in Accompanist
s
Yeah so isn’t the plan to have support for them eventually? What’s the long term plan if you’ve “decided not to expose content padding here”?
r
@Louis Pullen-Freilich [G] Is there a workaround if I want to implement edge-to-edge top bar for compose app?
s
Isn’t “contentPadding” universal language for “Padding around the entire current composable”? Why is this different in this case that just happens to be using the slots API?
@rsktash Isn’t the picture I posted 6 messages up the API you’re looking for?
r
@Stylianos Gakis Yes in the screenshot you have posted we can't pass actions and nav icon
l
Why is this different in this case that just happens to be using the slots API?
Because there are multiple pieces of ‘content’ - the title / navigation icon / actions are all separate, and have their own padding. It’s misleading that you can set contentPadding to 0, and there will still be padding applied to the start of the nav icon and title
Is there a workaround if I want to implement edge-to-edge top bar for compose app?
Accompanist provides APIs for this as linked above
s
What do you mean you “can’t pass actions and nav icon”?
r
@Stylianos Gakis sorry I think my version and your version of compose differs I couldn't find it
s
I see now @Louis Pullen-Freilich [G], the implicit padding could potentially be surprising indeed. So the question is what is the long term plan? Isn’t supporting edge-to-edge content a goal of the material library too? Will it just never support it in the version that accepts those slots?
@rsktash It’s not from the compose core dependencies, but from accompanist’s insets-ui as I’ve linked in the very first message.
l
It’s a known area for future work, for now accompanist works well for this use case
s
Interesting, good to know. It seems like we won’t be getting rid of Accompanist anytime soon then. If it always serves as the place to put all the “ugly” APIs that make our lives easier.
r
@Stylianos Gakis Oh sorry. Thanks. I'm using Desktop Compose for my project for that reason I'm copying the code to app common module via expect/actual functions
👍 1