Jetpack Compose migrating from dev05 to dev06
Just in the process of upgrading my apps from dev05 to dev06 and thought I would take the time to jot down some breaking changes as I fix them.
LayoutPadding changed from left/right to start/end
Simple fix, just change right
or left
to start
and end
respectively.
Alignment CentreRight and CentreLeft changed
Similar to LayoutPadding, Alignment
has had its members changed from CenterLeft
to CenterStart
and CenterRight
changed to CenterEnd
DrawShape no longer exists
You can use Box
in its place…
Box(shape = RoundedCornerShape(45.dp), backgroundColor = Color.Black)
… but you would have to specify a LayoutSize
modifier if you want it to have form (in my case DrawShape was in a container where I set LayoutSize).
Box(modifier = LayoutSize(width = 48.dp, height = 48.dp),
shape = RoundedCornerShape(45.dp),
backgroundColor = Color.Black)
ambient function now completely removed
use YourAmbient.current
now
LayoutGravity… left is start and right is end… you get the picture 😆
This lefty righty starty endy business is consistent and LayoutGravity did not get left out of the party. LayoutGravity.TopRight
becomes LayoutGravity.TopEnd
and you should expect this or its other members.
TopAppBar no more actionsData
TopAppBar
has been slightly simplified, you just need to use actions
now and actionData
has been removed.
The above code in screenshot becomes
TopAppBar(
title = { Text("Card Designer") },
actions = {
IconButton(
vectorResourceId = R.drawable.ic_save_light,
onClick = onCardSaved
)
}
)
Conclusion
These are breaking changes I encountered when updating my compose projects, maybe they might help you! Did you find any other issues not covered here? Let me know!