Hi Team, I am planning to create a tool that will ...
# compose
s
Hi Team, I am planning to create a tool that will display the names of the functions from which composables were created, in real time as the user navigates through the app. So far I have not come across any libraries which can do this. 1. Radiography on github creates a tree structure for the compose hierarchy, but I am not sure it can get the name of the functions that created the composables. 2. https://github.com/YvesCheung/UInspector this lib can get the source code information for the compose views. The second option seems to be the most viable one. Both libraries use reflection to accesss private compose tooling methods/variables. But before I am start working on my lib, I wanted to know if there are better and easier options to get the information that I need.
o
I couldn’t find complete solution, but I was able to dump composition hierarchy with function names by copying SlotTree.kt from AOSP and tweaking it to my needs.
s
How did you replace SlotTree with your custom SlotTree?
Did you use any library to get access to the compose hirearchy?
Are you referring to var name: String? = null on line 427
o
Just copied source :) I’m doing it in desktop, so can’t use libs directly due to Android dependencies.
s
You mean create a new file in your project but with same package name? And then modify?
o
You can get the roots from “currentComposer.compositionData” (don’t remember exactly), but not sure how it works in Android.
I think there is SourceInfo or something in the data
s
Thanks. I will have a look
o
Afk currently, can’t check the source. Yeah, explore it