pocmo / recompose

recompose is a tool for converting Android layouts in XML to Kotlin code using Jetpack Compose.
Apache License 2.0
783 stars 49 forks source link

Edittext seems to close the parent tag #104

Open tieskedh opened 3 years ago

tieskedh commented 3 years ago

The parser seems to close a parent tag for EditText.

FrameLayout {
    EditText()
    View()
}

Will result in:

FrameLayout {
    EditText()
}
View()

Same occurs with LinearLayout.

tieskedh commented 3 years ago
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical">

    <EditText
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:inputType="text"/>
    <View
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
</FrameLayout>
    @Test
    fun `FrameLayout with EditText and View`() {
        assertAST(
            fileName = "framelayout-edittext-view.xml",
            expected = Layout(
                listOf(
                    FrameLayoutNode(
                        ViewGroupAttributes(
                            listOf(
                                EditTextNode(
                                    ViewAttributes(
                                        width = LayoutSize.MatchParent,
                                        height = LayoutSize.MatchParent
                                    ),
                                    text = "",
                                    inputType = InputType.Text
                                ),
                                ViewNode(
                                    ViewAttributes(
                                        width = LayoutSize.MatchParent,
                                        height = LayoutSize.MatchParent
                                    ),
                                )
                            )
                        ),
                        ViewAttributes(
                            width = LayoutSize.MatchParent,
                            height = LayoutSize.WrapContent,
                        ),
                    )
                )
            )
        )
    }