Git Product home page Git Product logo

ludwig's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.