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

Thierry

02/21/2020, 12:14 AM
AdapterList seems to work well 👏
z

Zach Klippenstein (he/him) [MOD]

02/21/2020, 12:17 AM
Have you had any issues with
Ripple
+
Clickable
not working after a lot of scrolling? Maybe just one or the other, I haven’t had time to dig into it.
t

Thierry

02/21/2020, 12:17 AM
nope not yet
i do have another problem
do you know how facebook messenger type of chat has a gradient on the message bubble based on the message bubble's position in the list?
the adapter list has the current element, but i dont know the position in the visible list
z

Zach Klippenstein (he/him) [MOD]

02/21/2020, 12:25 AM
Yea, I think they’re going to need some additional API there. You’d need that to implement stuff like sticky headers as well.
l

Leland Richardson [G]

02/21/2020, 12:31 AM
cc @Ryan Mentley
r

Ryan Mentley

02/21/2020, 12:46 AM
you could, as a workaround, encode positional information in the data, or look it up in the source data, etc.
but yes, we're definitely going to have some additional API here
also I haven't seen an app on Android do the gradient thing, but I do know what you're referring to
that's a little bit trickier, because it's not the position in the the list that matters, it's the position within the parent. I don't think AdapterList would have any specific support for that, but I think we should probably find a way that works regardless of what sort of scrolling container you're in
t

Thierry

02/21/2020, 12:49 AM
yes the gradient changes based on the position of the message bubble compared to the top of the view
so it's not the position the data list, but the position in the part that's currently shown
not a very common use case i suppose
r

Ryan Mentley

02/21/2020, 2:18 AM
Some sort of react-to-position support is, I think, common-ish
I'm not sure where we are on support for that, though
you could do some sort of
OnChildPositioned
thing and update the data for drawing, I think
☝️ 1
it's a little awkward, but would probably work
z

Zach Klippenstein (he/him) [MOD]

02/22/2020, 7:27 PM
I just tried putting an
OnPositioned
inside of the list item, and it definitely works!
Copy code
AdapterList(data = (1..100).toList()) { item ->
    var bounds by state { "waiting for position…" }
    Stack(modifier = DrawBorder(size = 1.dp, color = Color.Red)) {
      OnPositioned(onPositioned = { coords ->
        bounds = coords.boundsInRoot.toString()
      })
      ListItem(text = item.toString(), overlineText = bounds)
    }
  }
a

Ash

02/22/2020, 9:29 PM
Do you guys have this working with the ROOM ViewModelProvider? Can I see the example? Working on it now but if you have working code, it would save me some time. I have this in a navigation fragment.
t

Thierry

02/23/2020, 4:35 PM
That's cool @Zach Klippenstein (he/him) [MOD]
4 Views