nglauber
10/04/2021, 6:54 PMitems
in a LazyColumn
declared inside of a bottomSheet
route 😕
No errors, but the bottom sheet is not shown… If I wrap my LazyColumn
with a Scaffold
, it works… (but it has some space below the content)…
Maybe it’s a measurement issue? 🤔nglauber
10/04/2021, 7:02 PMitems
from LazyColumn
and keep static item
and stickyHeader
. It works.
• Keep the items
and use a simple Text
to represent the items… Does not work.
• Replace the LazyColumn
by a simple Column
. Does not work.
• Wrap the LazyColumn
into a Scaffold
. It worked with a extra space below the content…Ian Lake
10/04/2021, 7:18 PMIan Lake
10/04/2021, 7:20 PMcollectAsState()
on (i.e., would it be possible that you have no items at all during that first measure pass)?nglauber
10/04/2021, 7:21 PMnglauber
10/04/2021, 7:27 PMstickyHeader
and one item
as footer, but the items are loaded by the view model and update via `Flow`…nglauber
10/04/2021, 7:42 PMWill Shelor
10/04/2021, 11:49 PMWill Shelor
10/04/2021, 11:50 PMnglauber
10/05/2021, 1:25 AM@Composable
fun BottomSheetViaRoute(
navBackStackEntry: NavBackStackEntry
) {
val viewModel: MyViewModel = viewModel(navBackStackEntry)
val list by viewModel.listFlow.collectAsState(emptyList())
LaunchedEffect(Unit) {
viewModel.loadList()
}
Column(
Modifier.verticalScroll(rememberScrollState())
) {
//Text(text = "BottomSheet via route", style = MaterialTheme.typography.h3)
list.forEach {
Text(
text = it,
Modifier
.padding(16.dp)
.fillMaxWidth()
)
}
}
}
If I uncomment the Text
above, the BottomSheet content is not displayed… 😕
The loadList
above just assign a value to the listFlow
.
fun loadList() {
_listFlow.value = (0..5).map {
"Item $it"
}.toList()
}
Ian Lake
10/05/2021, 1:38 AMLaunchedEffect
will always start one composition later, so yeah, your list will be empty on that first composition, so you're in the "you have no content at all" state when you leave out the Text which I mentioned aboveIan Lake
10/05/2021, 1:38 AMnglauber
10/05/2021, 2:28 AMText
😕 I mean, without the Text
, it’s working.Will Shelor
10/05/2021, 2:45 AMnglauber
10/05/2021, 2:54 AMnglauber
10/05/2021, 3:05 AMText
only. The code works.
If I keep the “list” only. Also works…
But not both… 😱Ian Lake
10/05/2021, 3:17 AMnglauber
10/05/2021, 3:26 AMbottomSheet
(from accompanist) 😕nglauber
10/05/2021, 3:33 AMIan Lake
10/05/2021, 4:04 AMIan Lake
10/05/2021, 4:05 AMWill Shelor
10/05/2021, 5:33 AMjossiwolf
10/05/2021, 11:54 AMModalBottomSheetLayout
with the scenario Ian described. I filed an issue two weeks ago. We'll try to somehow work around it (we already are trying) but I don't have an immediate great fix for you apart from delaying the first emission of your state by 40-50 ms 😞nglauber
10/05/2021, 11:59 AMjossiwolf
10/05/2021, 12:07 PMmiqbaldc
01/04/2022, 11:02 AMAnother workaround which “worked” was put a height for the component like `fillMaxHeight(.7f)`…Does we need to apply this onto
ModalBottomSheetLayout(modifier = ...)
or which component did you mean? @nglaubernglauber
01/04/2022, 12:13 PM