orangy
rememberScrollState
and provide inputs there (selected item in the main list), but now the scroll is not remembered at all, every switch in main list starts with initial position. How do I make scroll state in detail pane be persisted per item in the main list?Zach Klippenstein (he/him) [MOD]
04/25/2021, 2:25 PMorangy
orangy
@Composable
fun AreaDetails(area: Area?) {
if (area == null) return
val scrollState: ScrollState = rememberSaveable(area, saver = ScrollState.Saver) { ScrollState(0) }
… and somewhere down in the component …
modifier = Modifier.verticalScroll(scrollState),
Currently it just resets to zero each time component is called with different area
parameterZach Klippenstein (he/him) [MOD]
04/25/2021, 2:47 PMAreaDetails
with
key(area) {
// rest of body
}
And then don’t pass area
to rememberSaveable
?Zach Klippenstein (he/him) [MOD]
04/25/2021, 2:52 PMrememberSaveable
unregisters its registry entry when skipped. You might need to manage your own saving of detail panes’ state, or at least scroll state. The tricky bit is that the total saved state could grow to be the size of your main list multiplied by the size of whatever state your detail panes are saving, so you might also want to implement some LRU logic.Dominaezzz
04/25/2021, 2:57 PM