Cards
Cardsanimated

Multi-Leg Trip

Multi-leg trip card with animated connecting segments across three cities.

NYCLONDXB

Installation

caveui components are copy-paste Jetpack Compose built entirely on Material 3 — there's no caveui dependency to add. Make sure Material 3 is on your classpath (it ships with the Compose BOM), then copy the Usage snippet below into your project.

kotlin
// build.gradle.kts (module)
dependencies {
    implementation(platform("androidx.compose:compose-bom:2025.06.00"))
    implementation("androidx.compose.material3:material3")
}

Usage

kotlin
@Composable
fun MultiLegTripCard() {
  val legs = listOf("NYC", "LON", "DXB")
  val prog = remember { Animatable(0f) }
  LaunchedEffect(Unit) { prog.animateTo(1f, tween(1500)) }
  ElevatedCard(
    modifier = Modifier.fillMaxWidth().padding(16.dp)
  ) {
    Column(Modifier.padding(20.dp)) {
      Canvas(Modifier.fillMaxWidth().height(30.dp)) {
        val y = size.height / 2
        val gap = size.width / (legs.size - 1)
        drawLine(
          Color(0xFF6366F1), Offset(0f, y),
          Offset(size.width * prog.value, y), 3f,
          pathEffect = PathEffect.dashPathEffect(
            floatArrayOf(10f, 8f)
          )
        )
        legs.indices.forEach { i ->
          drawCircle(
            Color(0xFF6366F1), 6f, Offset(gap * i, y)
          )
        }
      }
      Spacer(Modifier.height(8.dp))
      Row(
        Modifier.fillMaxWidth(),
        horizontalArrangement = Arrangement.SpaceBetween
      ) { legs.forEach { Text(it,
        style = MaterialTheme.typography.labelMedium) } }
    }
  }
}