How we should use `Modifier` that is passed to com...
# compose
m
How we should use
Modifier
that is passed to compose function. What the idea there? Should it be passed to first composable function, or to most inner function? Should we treat it like
layoutparams
, so it’s for the most outer composable? Is it okay to pass multiple
Modifiers
to different composables?
j
I think there are answers for this question in a codelab, or in docs, but I don't remember exactly where
m
Okay that is helpful, but what if we need to pass modifier to some child, is it an antipattern to do that?
m
Do you have a control over what child this will be or it's just a generic slot?
m
Considering an compose function to draw input. How should I style text over the input or error message
m
Do you have a code example in mind?
m
Not really, what I'm thinking is that we have a custom input,that shows text above and under. Just like the material one. How should we customize behavior of those additional text? Or let say a click to that text.
m
If that's a part of the child composable contract, it can just accept
onUnderTextClick : () -> Unit
or smth. What we consider an anti pattern is when you have more than 1 modifier for one child, because you want to customize more than one part of the component from the parent. Usually it's a sign that the child is not a self-contained element and it can be either more opinionated about its functionality or can be split into >1 pieces.
m
Thank you ☺️