https://kotlinlang.org logo
#compose
Title
# compose
a

Adam Brown

07/30/2022, 7:57 AM
I'm looking to display a tree structure, but I also need to be able to drag to reorder, and expand/collapse nodes in the tree. I've done some looking and can't seem to find any existing libraries that tick all those boxes. But thought I might poll the channel here to see if there is one I might be missing. If not, anyone have any tips on where to start making my own implementation? Maybe building it on top of LazyColumn?
o

oianmol

07/30/2022, 8:04 AM
Found this via search not sure if this is what you are looking for https://gist.github.com/antonshilov/ef8cd0a360a5cc0f823b2a4e85084720 ?
Found one but with RecyclerView https://github.com/oss-bandb/GraphView
a

Adam Brown

07/30/2022, 8:07 AM
the first one might be a good thing to base mine off of thanks, need to add drag and drop, but
this will be a multiplatform compose thing so cant use recyclerview
o

oianmol

07/30/2022, 8:09 AM
Feature Request: LazyColumn reorder items via long click drag h t tps://issuetracker.google.com/issues/181282427
a

Arkadii Ivanov

07/30/2022, 8:09 AM
I did it on my own without libraries, but without dragging either (no need for me). Maybe this could be improved for your case https://github.com/arkivanov/MVIKotlin/blob/master/mvikotlin-timetravel-client/app-desktop/src/jvmMain/kotlin/com/arkivanov/mvikotlin/timetravel/client/desktop/ui/ValueTree.kt
a

Adam Brown

07/30/2022, 8:12 AM
oh awesome thanks @Arkadii Ivanov this looks useful. I have a pure lazy column impl right now, it has drag and drop, but it doesnt have collapse, and the drag and drop doesn't understand the tree structure, so it makes for some awkward ergonomics where it's give move indices as if it were a flat list.
5 Views