DrawCurvedToEdgeSample
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
@Sampled
@Composable
fun DrawCurvedToEdgeSample() {
Text("Curved Text", Modifier.drawCurvedToEdge())
}
InsetDrawCurvedToEdgeSample
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
@Sampled
@Composable
fun InsetDrawCurvedToEdgeSample() {
// Pad the parent to draw the arc further in from the edge. Padding the curved content itself
// would only shrink it.
Box(Modifier.fillMaxSize().padding(8.dp)) {
Text(
"A really long piece of curved text",
Modifier.drawCurvedToEdge(DrawCurvedToEdgeDefaults.StaticContentMaxSweepAngle),
overflow = TextOverflow.Ellipsis,
maxLines = 1,
)
}
}
IconsDrawCurvedToEdgeSample
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
@Sampled
@Composable
fun IconsDrawCurvedToEdgeSample() {
val icons =
listOf(
R.drawable.ic_favorite_rounded to "Favourite",
R.drawable.ic_headphones to "Headphones",
R.drawable.ic_wifi_on to "Wifi On",
R.drawable.ic_volume_up to "Volume Up",
R.drawable.ic_account_circle to "Avatar",
)
Row(Modifier.drawCurvedToEdge()) {
for ((resId, desc) in icons) {
Icon(
painter = painterResource(resId),
contentDescription = desc,
modifier = Modifier.size(26.dp),
)
}
}
}
MixedContentDrawCurvedToEdgeSample
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
@Sampled
@Composable
fun MixedContentDrawCurvedToEdgeSample() {
// Anything that draws can be curved, not just text.
Row(
Modifier.drawCurvedToEdge(DrawCurvedToEdgeDefaults.StaticContentMaxSweepAngle),
verticalAlignment = Alignment.CenterVertically,
) {
Icon(
painter = painterResource(R.drawable.ic_favorite_rounded),
contentDescription = "Favourite",
modifier = Modifier.size(24.dp),
)
Text("Mixed content", Modifier.padding(horizontal = 4.dp))
Box(Modifier.size(16.dp).background(Color.Red, CircleShape))
}
}