Colton Idle
08/19/2021, 9:17 PMZach Klippenstein (he/him) [MOD]
08/19/2021, 9:30 PMColton Idle
08/19/2021, 9:48 PMZach Klippenstein (he/him) [MOD]
08/19/2021, 9:57 PMBox(Modifier.background(Color.Magenta)) {
GradientBackground(
Modifier
.fillMaxSize()
.offset { IntOffset(0, -scrollState.value) }
)
LazyColumn(…)
}
Colton Idle
08/19/2021, 10:01 PMAshu
08/20/2021, 5:11 AMColton Idle
08/20/2021, 5:51 AMAshu
08/20/2021, 3:53 PMColton Idle
09/15/2021, 12:40 AMval scrollState = rememberScrollState()
Box(modifier = Modifier.fillMaxSize()
) {
Box(
Modifier.matchParentSize().offset { IntOffset(0, scrollState.maxValue - scrollState.value) }.background(Color.Magenta)
)
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier =
Modifier.fillMaxSize()
.verticalScroll(scrollState)
Let me know if you have any other ideas for me as I feel like I'm missing something simple. Cheersval scrollState = rememberScrollState()
BoxWithConstraints(modifier = Modifier.fillMaxSize()) {
val constraintBox = this@BoxWithConstraints
Box(
Modifier.matchParentSize()
.offset {
IntOffset(
0,
if (constraintBox.maxHeight.roundToPx() -
scrollState.value >= 0)
constraintBox.maxHeight.roundToPx() -
scrollState.value
else 0)
}
Let me know if I'm overcomplicating things... but I will go with this for now. 😄Zach Klippenstein (he/him) [MOD]
09/15/2021, 3:18 PMdrawBehind
modifier. That would eliminate the need for BwC and also only require a new draw pass on each scroll instead of a new composition + layout pass.Colton Idle
09/15/2021, 3:26 PMBox(
Modifier.matchParentSize()
.drawBehind {
drawRect(
color = Color.Magenta,
topLeft = Offset(size.width, -scrollState.value.toFloat()),
size = Size(size.width, size.height))
}
Maybe something is going over my head? or I've been staring at this for too long. lolZach Klippenstein (he/him) [MOD]
09/16/2021, 12:12 PMsize.width
, the rectangle will always be off screen 😉 Also size
has a default value that I think should work here.
How about:
.drawWithCache {
// Don't trigger any more draw invalidations once scrolled past the first screen.
val colorTop = derivedStateOf { (size.height - scrollState.value.toFloat()).coerceAtLeast(0f) }
onDrawBehind {
drawRect(
color = Color.Magenta,
topLeft = Offset(0f, colorTop)
)
}
}
Colton Idle
09/20/2021, 1:14 AM