Update the ThrowCard border design.

This commit is contained in:
Thomas Andres Gomez 2023-10-07 18:43:41 +02:00
parent 5e7be483e2
commit d8f79b92f9
2 changed files with 16 additions and 14 deletions

View file

@ -12,7 +12,6 @@ import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInVertically import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically import androidx.compose.animation.slideOutVertically
import androidx.compose.animation.togetherWith import androidx.compose.animation.togetherWith
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.PaddingValues
@ -268,13 +267,12 @@ private fun RollOverlayContent(
) )
else -> ThrowsCard( else -> ThrowsCard(
modifier = Modifier modifier = Modifier.padding(
.fillMaxWidth() bottom = if (enableDrawer.value) 32.dp else 0.dp
.padding(all = 16.dp) ),
.padding(bottom = 32.dp)
.clickable(onClick = onCard),
throws = it, throws = it,
showDetail = showDetail, showDetail = showDetail,
onClick = onCard,
) )
} }
} }
@ -363,7 +361,7 @@ private class RollOverlayPreviewProvider : PreviewParameterProvider<RollOverlayP
title = "PERCEPTION CHECK", title = "PERCEPTION CHECK",
highlight = "CHECK", highlight = "CHECK",
dice = R.drawable.ic_d20_24, dice = R.drawable.ic_d20_24,
roll = "$20 + 2 + 2", roll = "20 + 2 + 2",
result = "20", result = "20",
isCriticalSuccess = true, isCriticalSuccess = true,
details = listOf( details = listOf(

View file

@ -8,7 +8,7 @@ import androidx.compose.animation.expandVertically
import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut import androidx.compose.animation.fadeOut
import androidx.compose.animation.shrinkVertically import androidx.compose.animation.shrinkVertically
import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.clickable
import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
@ -18,6 +18,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.shape.CutCornerShape
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
@ -46,6 +47,7 @@ import androidx.compose.ui.unit.dp
import com.pixelized.rplexicon.R import com.pixelized.rplexicon.R
import com.pixelized.rplexicon.ui.theme.LexiconTheme import com.pixelized.rplexicon.ui.theme.LexiconTheme
import com.pixelized.rplexicon.utilitary.extentions.annotatedSpan import com.pixelized.rplexicon.utilitary.extentions.annotatedSpan
import com.pixelized.rplexicon.utilitary.extentions.ddBorder
import com.pixelized.rplexicon.utilitary.extentions.highlightRegex import com.pixelized.rplexicon.utilitary.extentions.highlightRegex
import java.util.UUID import java.util.UUID
@ -83,6 +85,7 @@ fun ThrowsCard(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
throws: ThrowsCardUio, throws: ThrowsCardUio,
showDetail: State<Boolean>, showDetail: State<Boolean>,
onClick: () -> Unit,
) { ) {
val density = LocalDensity.current val density = LocalDensity.current
val isDarkMode = isSystemInDarkTheme() val isDarkMode = isSystemInDarkTheme()
@ -95,14 +98,14 @@ fun ThrowsCard(
val measurer = textMeasurer.measure(text = "00", style = typography.displayMedium) val measurer = textMeasurer.measure(text = "00", style = typography.displayMedium)
with(density) { measurer.size.width.toDp() } with(density) { measurer.size.width.toDp() }
} }
val inner = remember { RoundedCornerShape(size = 8.dp) }
Surface( Surface(
modifier = modifier, modifier = modifier
shape = RoundedCornerShape(size = 16.dp), .fillMaxWidth()
border = BorderStroke( .padding(all = 16.dp)
width = 1.dp, .clickable(onClick = onClick)
color = MaterialTheme.colorScheme.onSurface.copy(0.25f) .ddBorder(inner = inner, outline = remember { CutCornerShape(size = 16.dp) }),
),
tonalElevation = if (isDarkMode) 4.dp else 0.dp, tonalElevation = if (isDarkMode) 4.dp else 0.dp,
) { ) {
Column( Column(
@ -269,6 +272,7 @@ fun RollToastPreview(
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
throws = preview, throws = preview,
showDetail = showDetail, showDetail = showDetail,
onClick = { },
) )
} }
} }