Othman El Jazouli
01/19/2023, 3:09 PM@Composable
fun MyBox(yProvider: () -> Float){
    Box(
        modifier = Modifier
            .fillMaxSize()
            .graphicsLayer {
                translationY = yProvider()
            }
            .background(
                color = Color(0XFF123456),
                shape = RoundedCornerShape(
                    topStart = 16.dp,
                    topEnd = 16.dp
                )
            )
    ){...} // even with no content, same result
}MyBox(
    yProvider = { scroll offset calculated here }
)robercoding
01/19/2023, 3:12 PM{...}{...}robercoding
01/19/2023, 3:12 PMThis composable pretty much wrapping the content that is below a collapsable header
Othman El Jazouli
01/19/2023, 3:13 PMrobercoding
01/19/2023, 3:13 PMColor(0XFAFAIOS)Color.Redrobercoding
01/19/2023, 3:14 PMI can see in recomposition count that it is recomposing every time the header is showing or collapsing during scrollSo it's recomposing outside of
MyBoxOthman El Jazouli
01/19/2023, 3:16 PMrobercoding
01/19/2023, 3:20 PMOthman El Jazouli
01/19/2023, 3:21 PMrobercoding
01/19/2023, 3:22 PMyProviderrobercoding
01/19/2023, 3:22 PMyProvider = { scroll offset calculated here }Othman El Jazouli
01/19/2023, 3:28 PMrobercoding
01/19/2023, 3:29 PMMyBoxrobercoding
01/19/2023, 3:30 PMMyBoxMyBoxrobercoding
01/19/2023, 3:30 PMrobercoding
01/19/2023, 3:31 PMOthman El Jazouli
01/19/2023, 3:33 PMrobercoding
01/19/2023, 3:36 PMOthman El Jazouli
01/19/2023, 3:46 PMobject : NestedScrollConnection {
   override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset {translationYyProvider = {-state.scrollOffset + headerHeight}Othman El Jazouli
01/19/2023, 3:46 PMrobercoding
01/19/2023, 3:46 PMStaterobercoding
01/19/2023, 3:47 PMdata class CustomClass(val scrollOffset: Float)Othman El Jazouli
01/19/2023, 3:48 PMOthman El Jazouli
01/19/2023, 3:48 PMrobercoding
01/19/2023, 3:48 PM@StableOthman El Jazouli
01/19/2023, 3:48 PMOthman El Jazouli
01/19/2023, 4:32 PMrobercoding
01/19/2023, 4:36 PMStylianos Gakis
01/19/2023, 9:58 PMIm just having trouble understanding why reading it “somewhere else” would affect recomposing MyBoxIf I understood correctly what you are not sure about there, I would very strongly recommended to reading this https://dev.to/zachklipp/scoped-recomposition-jetpack-compose-what-happens-when-state-changes-l78