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

Octave Decaux

06/24/2020, 9:04 AM
I'm trying to implement a modified WithConstraint. Linter says NodeLayout call doesn't take any argument, code compiles just fine, but it is not executed. I guess there is an internal NodeLayout Composable function which refers to the NodeLayout class, but I cannot find it. What is the proper way to use NodeLayout in my own code ?
a

Andrey Kulikov

06/24/2020, 9:35 AM
hey! yes, currently we emit LayoutNode in a bit different way, not like a composable function. and this code is currently being refactored and will be changed in the nearest future to be more understandable. I am really curious what use case are you trying to solve with your own
WithConstraints
as were planning to make such things simpler soon
o

Octave Decaux

06/24/2020, 9:43 AM
I'm trying to create a scroller with automatic anchor points for every children. I'm adding the position of every children to WithConstraintsScope. Is there a better way to do that ?
(thanks for replying btw)
z

Zach Klippenstein (he/him) [MOD]

06/24/2020, 2:21 PM
Could you just provide an Ambient to register the positions with?
o

Octave Decaux

06/24/2020, 8:20 PM
Thanks for the suggestion. My understanding was that Ambient is more of a downstream mechanism, but I guess I just learned something. I'm really glad this channel exists
a

Andrey Kulikov

06/24/2020, 8:32 PM
basically there are no good ways of solving this yet. creating your own WithConstraints doesnt really help here as you want to have children sizes in the composable child block of withconstraints. but this composable blocks defines the children. so for the moment of the invoking the WithConstraints block there are no children yet, not saying that they are not yet measured. what you probably want is a to-be-added-in-the-future feature for `LazyColumnItems`(renamed
AdapterList
) where we will have a functionality to scroll to the second item and so on)
something similar is solved in
TabRow
, where we scroll to the tapped
Tab
, but this code is also not super reusable at the moment
z

Zach Klippenstein (he/him) [MOD]

06/24/2020, 8:37 PM
I think I misunderstood what you are trying to do.
o

Octave Decaux

06/24/2020, 8:42 PM
Ok, thanks for taking the time guys
I just had a look at TabRow. This does indeed feels like a hack, but it will do for now.
Copy code
// Delay indicator composition until we know tab positions
if (tabPositions.isNotEmpty()) {
    indicatorContainer(tabPositions)
}
Hey, just to let you know that I eventually found a solution (by bolting together different things, mainly) https://gist.github.com/odecaux/808c71b646c0a170cfeb2cb0686858e0
4 Views