I found this when updating to 1.4
Consider this case:
@Composable
fun Foo(
state: FooState,
toolbar: @Composable () -> Unit,
modifier: Modifier = Modifier,
bottomBar: @Composable () -> Unit = {},
showFab: Boolean = false,
content: @Composable () -> Unit,
)
The current rule requires me to move toolbar down. But I can't see anything on the guidelines about that: https://android.googlesource.com/platform/frameworks/support/+/androidx-main/compose/docs/compose-component-api-guidelines.md#parameters-order
- Required parameters.
- Single
modifier: Modifier = Modifier.
- Optional parameters.
- (optional) trailing
@Composable lambda.
In point 4 they refer to only one trailing lambda, no more.
So I'd say that if there is already one @Composable function at the bottom it shouldn't complain.
We could also "work" with this:
(optional) trailing @Composable lambda representing the main content of the component, usually named content.
We could check for the name of the components and only ask them to move it down if it's called content. Because I have other cases like this:
@Composable
fun User(
name: String,
followers: Int,
avatar: @Composable () -> Unit,
modifier: Modifier = Modifier
)
It's true, that I could move avatar down. But it's not the main content of that composable so it's a bit odd to have something like this:
User(
name = "Brais",
followers = "1",
) {
Image(...)
}
I think that it's better like this:
User(
name = "Brais",
followers = "1",
avatar = { Image(...) },
)
But this last case, for me, is less obvious and probably this case can just have a @Suppress.
I found this when updating to 1.4
Consider this case:
The current rule requires me to move
toolbardown. But I can't see anything on the guidelines about that: https://android.googlesource.com/platform/frameworks/support/+/androidx-main/compose/docs/compose-component-api-guidelines.md#parameters-orderIn point 4 they refer to only one trailing lambda, no more.
So I'd say that if there is already one
@Composablefunction at the bottom it shouldn't complain.We could also "work" with this:
We could check for the name of the components and only ask them to move it down if it's called
content. Because I have other cases like this:It's true, that I could move
avatardown. But it's not the main content of that composable so it's a bit odd to have something like this:I think that it's better like this:
But this last case, for me, is less obvious and probably this case can just have a
@Suppress.