GithubHelp home page GithubHelp logo

trendingtechnology / composed-xml Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kacmacuna/composed-xml

0.0 1.0 0.0 586 KB

Plugin and Desktop app for parsing layout xml into Composable code

Kotlin 100.00%

composed-xml's Introduction

composed-xml

Inspired by - Recompose

composed-xml is a tool for parsing Android layouts into Jetpack Compose code. It can work as both Desktop app or Intelij/Android Studio plugin.

Docs

Examples

<androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    <TextView
            android:id="@+id/text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Current Number: 0"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintStart_toStartOf="parent"/>

    <Button
            android:id="@+id/btn"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Increase"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintStart_toEndOf="@id/text"/>

</androidx.constraintlayout.widget.ConstraintLayout>

===>

package temp

import androidx.compose.foundation.layout.ConstrainedLayoutReference
import androidx.compose.foundation.layout.ConstraintLayout
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.sp
import kotlin.Unit

@Composable
public fun Content(): Unit {
    ConstraintLayout (modifier = Modifier.fillMaxWidth().fillMaxHeight()) {
        val textRef = ConstrainedLayoutReference(Any())
        val btnRef = ConstrainedLayoutReference(Any())
        Text("Current Number: 0", modifier =
        Modifier.wrapContentWidth().wrapContentHeight().constrainAs(textRef, {
            top.linkTo(parent.top)
            start.linkTo(parent.start)
        }
        ))
        Button(onClick = {}, modifier =
        Modifier.wrapContentWidth().wrapContentHeight().constrainAs(btnRef, {
            top.linkTo(parent.top)
            start.linkTo(textRef.end)
        }
        )) {
            Text("Increase", modifier = Modifier.wrapContentWidth().wrapContentHeight())
        }
    }
}

composed-xml's People

Contributors

kacmacuna avatar

Watchers

 avatar

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.