Matej Drobnič
06/18/2019, 5:32 AMViewDragHelper
and noticed that this code has a lot of state and calbacks interacting with each other (for example see all the touch callbacks in androidx.drawerlayout.widget.DrawerLayout
from androidx). I cannot fanthem how could such monstrosity be implemented with just composable functions.
Will there be a way to create classes for views or some other way to properly manage complex views like this?kioba
06/18/2019, 2:18 PMval drawer = @Composable { Drawer {
for(i in 0 until 3) {
DrawerItem(icon = iconName, title = iconTitle)
}
}
}
and use it as the following:
Scaffold(
drawer = drawer
body = @Composable { /* ... */ }
)
That is quite hypothetical.kioba
06/18/2019, 2:20 PMkioba
06/18/2019, 2:32 PMViewDragHelper
I had the leverage to avoid using this api but I presume they will provide a GestureDetector
where we can update a Model with the detected swipe and calculate the percentage of the drawerMatej Drobnič
06/19/2019, 5:14 AMMatej Drobnič
06/19/2019, 5:14 AMLeland Richardson [G]
06/19/2019, 3:58 PMMatej Drobnič
06/20/2019, 5:26 AMViewDragHelper
(or similar helper classes) is used as field. I guess this helper need to be converted into composable view later to allow for it to use state? How would we access it since composable functions do not return anything? For example, at the moment you have to get the touch callback, filter it if necessary and then pass it to ViewDragHelper
. But with compose, I cannot pass it to VDH, because I don't have its instance.
3. Does compose have notion of view IDs? Since VDH works by calling back and checking whether view should be dragged on touch events.Leland Richardson [G]
06/21/2019, 7:18 PMval vdh = memo { ViewDragHelper() }
and vdh
will be the same instance across composes.
3) Compose has no specific notion of View IDs. If you are composing normal android views, you can pass ids into them (ie, TextView(id=R.id.my_text_view)
), but this is just because TextView itself knows what view ids are. For Compose UI (ie, composables coming from androidx.ui.*) do not have such a notion, and APIs that we build around them will be structured in a way to avoid them since we think it goes against the grain / best practices of Compose’s architectureMatej Drobnič
06/22/2019, 5:10 PMvdh
from your example in 2 really be? Some sort of view type?Matej Drobnič
06/22/2019, 5:22 PMViewDragHelper
) and composable function would just be bunch of callbacks that trigger this model class?