lesincs
10/30/2024, 11:07 PMIntrinsicSize.Max on the Row height and using fillMaxHeight on the Divider within it, is there another way to make the Divider fill the maximum height of a Row that contains other Composable elements with dynamic heights such as Text? I can’t use IntrinsicSize.Max since I’m using BoxWithConstraints within the Row, which is not allowed in Compose(will get a RuntimeException).Zach Klippenstein (he/him) [MOD]
10/31/2024, 12:42 AMZach Klippenstein (he/him) [MOD]
10/31/2024, 12:42 AMlesincs
10/31/2024, 1:24 AMBoxWithConstraints to get the max width then do some calculations… So I thought getting rid of IntrinsicSize.Max and to achieve same effect using another way.Zach Klippenstein (he/him) [MOD]
10/31/2024, 1:38 AMlesincs
10/31/2024, 1:57 AMImageRequest, so it can load network images with proper dimensions. And why Coil could not figure out the size constraint itself is because I put the Coil Image as an InlineContent of a Text, so the constraints is fixed from the PlaceHolder not parent Composable. I am basically implementing a markdown display feature that an image might be inserted inside a text. The idea is once the image is loaded successfully, I can reset size of the PlaceHolder so it can display the image properly. 😅Zach Klippenstein (he/him) [MOD]
10/31/2024, 4:30 PMlesincs
10/31/2024, 9:13 PMBoxWithConstraints? I actually thought of other solutions such as getting the width from the Modifier.onSizeChange{} callback. But I am afraid this would be after some frames and it might too late as I basically need to pass that maxWidth limitation immediately to the ImageRequest .lesincs
10/31/2024, 9:15 PMIntrinsicSize.Max is I am using Modifier.onSizeChange{} to get the maxHeight of `Divider`'s sibling Composables and then set the maxHeight to the Divider itself. It works 😅Zach Klippenstein (he/him) [MOD]
10/31/2024, 11:09 PMAsyncImage already does this itself, and there seem to be ways to get even more involved if you need (ConstraintsSizeResolver)Son Phan
11/01/2024, 4:15 AMRow with ConstraintLayout instead?
Link the `Divider`'s top and bottom to the parent's top and bottom, then add height = Dimension.fillToConstraints should work.lesincs
11/01/2024, 9:22 AMConstraintLayout for ages!🤣lesincs
11/01/2024, 9:42 AMWhy do you need to pass those constraints in manually?In a normal layout I don't need to and Coil can figure it out by the constraint from parent. But in my case the image is wrapped in an
InlineContent and then passed to the Text - so now the constraint becomes the PlaceHolder size of the InlineContent which is not ideal because the size of PlaceHolder is hardcoded initially and usually pretty small.Zach Klippenstein (he/him) [MOD]
11/01/2024, 3:54 PMSizeResolver then?lesincs
11/01/2024, 10:14 PMCouldn't you just pass a customThat's exact what I am doing now. My code to build thethen?SizeResolver
ImageRequest is like:
val request = ImageRequest.Builder(context)
.data(inlineImage.url)
.size(Dimension(maxWidthInPx), Dimension.Undefined)
.build()
The size(...) in the chain creates a custom SizeResolver under the hood. But here I need the maxWidthInPx is which coming from BoxWithConstraintsScope.constraints.maxWidth ...