repositories {
maven {
url = uri("https://jitpack.io")
}
}
dependencies {
implementation "com.github.baec23.ludwig:morpher:1.0.4"
}
morpherDemo.webm
VectorSource.fromImageVector(Icons.Outlined.Star)
VectorSource.fromImageVector(ImageVector.vectorResource(R.drawable.androidlogo))
VectorSource.fromPathString("m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z")
When vectorSource changes, AnimatedVector will morph animate the change.
AnimatedVector(
vectorSource = selectedVectorSource
)
@Composable
fun MorpherSample() {
//VectorSource can be created from ImageVector
// Icons
// Imported drawable resources - VectorSource.fromImageVector(ImageVector.vectorResource(R.drawable.imported_vector))
val vectorSource1 = VectorSource.fromImageVector(Icons.Outlined.Star)
//VectorSource can also be created from a path string (the 'd' attribute of a <path> element)
val vectorSource2 =
VectorSource.fromPathString("m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z")
var selectedVectorSource by remember { mutableStateOf(vectorSource1) }
Column(
modifier = Modifier.fillMaxWidth()
) {
//AnimatedVector will automatically animate morph when 'vectorSource' changes
// AnimatedVector can be customized with optional params
// animationSpec: AnimationSpec<Float>
// strokeWidth: Float
// strokeColor: Color
AnimatedVector(
modifier = Modifier
.fillMaxWidth()
.aspectRatio(1f)
.padding(36.dp),
vectorSource = selectedVectorSource,
)
Row(modifier = Modifier.fillMaxWidth()) {
Button(
modifier = Modifier.weight(1f),
onClick = { selectedVectorSource = vectorSource1 }) {
Text(text = "Source 1")
}
Button(
modifier = Modifier.weight(1f),
onClick = { selectedVectorSource = vectorSource2 }) {
Text(text = "Source 2")
}
}
}
}
- Only Stroke is supported for now
- Fills will be weird
dependencies {
implementation "com.github.baec23.ludwig:component:1.0.3"
}
Static and expandable display sections to organize content - examples shown in demos for other components
iOS style time pickers
timePickers.webm
Animated Material3 date picker
datePicker.webm
Customizable animated input fields with optional error states
inputField.webm
Customizable animated buttons with state
statefulButton.webm
LazyRow / LazyColumn / LazyHorizontalGrid / LazyVerticalGrid with customizable fading edges to represent scrollability