Cards
Cardsanimated

Map Route Preview

Mini map preview animating a curved route line between two pins.

Home → Office · 12 min

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 MapRoutePreviewCard() {
  val draw = remember { Animatable(0f) }
  LaunchedEffect(Unit) { draw.animateTo(1f, tween(1200)) }
  Card(modifier = Modifier.fillMaxWidth().padding(16.dp)) {
    Column {
      Canvas(
        Modifier.fillMaxWidth().height(120.dp)
          .background(Color(0xFFE5E7EB))
      ) {
        val p = Path().apply {
          moveTo(size.width * 0.15f, size.height * 0.8f)
          cubicTo(
            size.width * 0.4f, size.height * 0.2f,
            size.width * 0.6f, size.height * 0.9f,
            size.width * 0.85f, size.height * 0.25f
          )
        }
        val m = PathMeasure().apply { setPath(p, false) }
        val seg = Path()
        m.getSegment(0f, m.length * draw.value, seg, true)
        drawPath(seg, Color(0xFF2563EB), style = Stroke(5f))
      }
      Text(
        "Home → Office · 12 min",
        style = MaterialTheme.typography.bodySmall,
        modifier = Modifier.padding(14.dp)
      )
    }
  }
}