Skip to content
/ ludwig Public

A collection of UI libraries for Android using Jetpack Compose

Notifications You must be signed in to change notification settings

baec23/ludwig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ludwig for Jetpack Compose

Installation

Add JitPack repository (settings.gradle.kts)

repositories {
    maven {
        url = uri("https://jitpack.io")
    }
}

Morpher

Add Gradle dependency (build.gradle.kts (app))

dependencies {
    implementation "com.github.baec23.ludwig:morpher:1.0.4"
}
morpherDemo.webm

Getting Started

Create VectorSource from ImageVector or path String

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")

Use AnimatedVector component

When vectorSource changes, AnimatedVector will morph animate the change.

AnimatedVector(
    vectorSource = selectedVectorSource
)

Full sample

@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")
            }
        }
    }
}

Issues

  • Only Stroke is supported for now
  • Fills will be weird

UI Components

Add Gradle dependency (build.gradle.kts (app))

dependencies {
    implementation "com.github.baec23.ludwig:component:1.0.3"
}

Component Showcase

DisplaySection / ExpandableDisplaySection / PreferenceSection

Static and expandable display sections to organize content - examples shown in demos for other components

TimePicker

iOS style time pickers

timePickers.webm

DatePicker

Animated Material3 date picker

datePicker.webm

InputFields

Customizable animated input fields with optional error states

inputField.webm

Buttons

Customizable animated buttons with state

statefulButton.webm

FadingLazy

LazyRow / LazyColumn / LazyHorizontalGrid / LazyVerticalGrid with customizable fading edges to represent scrollability

fadingLazy.webm