There is a base bottom sheet fragment class called...
# compose
s
There is a base bottom sheet fragment class called
com.projectname.consumer.ui.BaseConsumerComposeBottomSheetModalFragment
, where I am extending the class and overriding a
@Composable
function called
ComposeBottomSheetContent()
. Simply placing a
LazyColumn
, with zero items, causes the following error:
Copy code
java.lang.IllegalStateException: Vertically scrollable component was measured with an infinity maximum height constraints, which is disallowed. One of the common reasons is nesting layouts like LazyColumn and Column(Modifier.verticalScroll()). If you want to add a header before the list of items please add a header as a separate item() before the main items() inside the LazyColumn scope. There could be other reasons for this to happen: your ComposeView was added into a LinearLayout with some weight, you applied Modifier.wrapContentSize(unbounded = true) or wrote a custom layout. Please try to remove the source of infinite constraints in the hierarchy above the scrolling container.
I thought the issue was likely occurring because the bottom sheet's height isn't properly constrained when you add the
LazyColumn
so I wanted to set a fixed height but I had a requirement for the modal to be entire screen or at least 90 percent of height. Fixed height defined by
dp
wouldn't make sense with various device types. So after trying this
Copy code
LazyColumn( modifier = Modifier.fillMaxHeight(0.9f)  // Takes 90% of available height) {    // Your items here}
still seeing same issue
c
How is the
ComposeView
layout in the Fragment?
And for your 90% -> 90% of infinity is still infinity
And then, there is also #C04TPPEQKEJ for android related questions. This channel is for Compose Multiplatform
🫡 1
s
makes sense!
Copy code
val windowHeight = LocalWindowInfo.current.bounds.height.toDp()
LazyColumn(
    modifier = Modifier.height(windowHeight * 0.9f)
) {
    // Your items
}
maybe this can work? There's probably a cleaner solution
c
I would rather change the bottom sheet fragment.
s
Change specifically what over there?
c
The layout parameters of the
ComposeView
that renders your
Composable
s
by giving them a fixed height you mean?
c
Depends 😅
Please delete the other post again. Cross posting is considers spam. And as you are having a discussion here already, it makes following the suggestions made by others very hard to follow.
s
sorry makes sense...I will post future questions in the other channel
👍🏼 1