Fix cards visibility pre API 28

This commit is contained in:
andrew 2023-10-05 21:23:45 +10:30
parent ebbe928fd2
commit 149c81722c
2 changed files with 11 additions and 8 deletions

View file

@ -43,11 +43,10 @@ fun DisappearingMessages(
) { ) {
val scrollState = rememberScrollState() val scrollState = rememberScrollState()
Column(modifier = modifier) { Column(modifier = modifier.padding(horizontal = 32.dp)) {
Box(modifier = Modifier.weight(1f)) { Box(modifier = Modifier.weight(1f)) {
Column( Column(
modifier = Modifier modifier = Modifier
.padding(horizontal = 32.dp)
.padding(bottom = 20.dp) .padding(bottom = 20.dp)
.verticalScroll(scrollState) .verticalScroll(scrollState)
.fadingEdges(scrollState), .fadingEdges(scrollState),

View file

@ -5,6 +5,7 @@ import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.ScrollState import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
@ -115,10 +116,13 @@ fun CellWithPaddingAndMargin(
@Composable @Composable
fun TitledRadioButton(option: OptionModel, onClick: () -> Unit) { fun TitledRadioButton(option: OptionModel, onClick: () -> Unit) {
Row(modifier = Modifier Row(
horizontalArrangement = Arrangement.spacedBy(16.dp),
modifier = Modifier
.clickable { if (!option.selected) onClick() } .clickable { if (!option.selected) onClick() }
.heightIn(min = 60.dp) .heightIn(min = 60.dp)
.padding(horizontal = 34.dp)) { .padding(horizontal = 32.dp)
) {
Column(modifier = Modifier Column(modifier = Modifier
.weight(1f) .weight(1f)
.align(Alignment.CenterVertically)) { .align(Alignment.CenterVertically)) {
@ -182,7 +186,7 @@ fun Modifier.fadingEdges(
val topColors = listOf(Color.Transparent, Color.Black) val topColors = listOf(Color.Transparent, Color.Black)
val topStartY = scrollState.value.toFloat() val topStartY = scrollState.value.toFloat()
val topGradientHeight = min(topEdgeHeight.toPx(), topStartY) val topGradientHeight = min(topEdgeHeight.toPx(), topStartY)
drawRect( if (topGradientHeight > 0f) drawRect(
brush = Brush.verticalGradient( brush = Brush.verticalGradient(
colors = topColors, colors = topColors,
startY = topStartY, startY = topStartY,
@ -195,7 +199,7 @@ fun Modifier.fadingEdges(
val bottomEndY = size.height - scrollState.maxValue + scrollState.value val bottomEndY = size.height - scrollState.maxValue + scrollState.value
val bottomGradientHeight = val bottomGradientHeight =
min(bottomEdgeHeight.toPx(), scrollState.maxValue.toFloat() - scrollState.value) min(bottomEdgeHeight.toPx(), scrollState.maxValue.toFloat() - scrollState.value)
if (bottomGradientHeight != 0f) drawRect( if (bottomGradientHeight > 0f) drawRect(
brush = Brush.verticalGradient( brush = Brush.verticalGradient(
colors = bottomColors, colors = bottomColors,
startY = bottomEndY - bottomGradientHeight, startY = bottomEndY - bottomGradientHeight,