Fix layout of throw detail card.

This commit is contained in:
Andres Gomez, Thomas (ITDV RL) 2024-05-30 15:59:33 +02:00
parent be6d5c0063
commit bff28578fb

View file

@ -9,6 +9,7 @@ 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.clickable import androidx.compose.foundation.clickable
import androidx.compose.foundation.horizontalScroll
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 +19,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.rememberScrollState
import androidx.compose.foundation.shape.CutCornerShape 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
@ -154,7 +156,8 @@ fun ThrowsCard(
Text( Text(
modifier = Modifier modifier = Modifier
.weight(1f) .weight(1f)
.padding(start = 8.dp), .padding(start = 8.dp)
.horizontalScroll(state = rememberScrollState()),
maxLines = 1, maxLines = 1,
overflow = TextOverflow.Ellipsis, overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.titleLarge, style = MaterialTheme.typography.titleLarge,
@ -210,7 +213,19 @@ private fun ThrowsRollDetail(
resultWidth: Dp, resultWidth: Dp,
) { ) {
Row( Row(
modifier = modifier, modifier = Modifier
.fillMaxWidth()
.then(other = modifier),
horizontalArrangement = Arrangement.spacedBy(
space = 4.dp,
alignment = Alignment.End,
),
) {
Row(
modifier = Modifier
.alignByBaseline()
.weight(1f, false)
.horizontalScroll(state = rememberScrollState()),
horizontalArrangement = Arrangement.spacedBy(space = 4.dp), horizontalArrangement = Arrangement.spacedBy(space = 4.dp),
) { ) {
Text( Text(
@ -228,10 +243,7 @@ private fun ThrowsRollDetail(
text = "(${it.roll})", text = "(${it.roll})",
) )
Icon( Icon(
modifier = Modifier modifier = Modifier.size(16.dp),
.size(16.dp)
.align(alignment = Alignment.Bottom)
.padding(bottom = 2.dp),
tint = when (it.type) { tint = when (it.type) {
Type.ADVANTAGE -> MaterialTheme.lexicon.colorScheme.throwsColor.advantage Type.ADVANTAGE -> MaterialTheme.lexicon.colorScheme.throwsColor.advantage
Type.DISADVANTAGE -> MaterialTheme.lexicon.colorScheme.throwsColor.disadvantage Type.DISADVANTAGE -> MaterialTheme.lexicon.colorScheme.throwsColor.disadvantage
@ -242,14 +254,13 @@ private fun ThrowsRollDetail(
contentDescription = null, contentDescription = null,
) )
Text( Text(
modifier = Modifier modifier = Modifier.alignByBaseline(),
.alignByBaseline()
.weight(1f, false),
color = MaterialTheme.colorScheme.onSurface, color = MaterialTheme.colorScheme.onSurface,
style = MaterialTheme.typography.bodySmall, style = MaterialTheme.typography.bodySmall,
text = it.result, text = it.result,
) )
} }
}
Text( Text(
modifier = Modifier.alignByBaseline(), modifier = Modifier.alignByBaseline(),
color = MaterialTheme.colorScheme.onSurface, color = MaterialTheme.colorScheme.onSurface,
@ -328,14 +339,14 @@ private class RollToastPreviewProvider : PreviewParameterProvider<ThrowsCardUio>
isCriticalSuccess = true, isCriticalSuccess = true,
details = listOf( details = listOf(
ThrowsCardUio.Detail( ThrowsCardUio.Detail(
title = "Hit Check \"Advantage\"", title = "Jet d'attaque : \"Hache de guerre\"",
throws = ThrowsCardUio.Throw( throws = ThrowsCardUio.Throw(
dice = R.drawable.ic_d20_24, dice = R.drawable.ic_d20_24,
type = Type.ADVANTAGE, type = Type.ADVANTAGE,
roll = "1d20", roll = "1d20",
result = "20 ~ 5", result = "8~5 + 4~6 + 2~5",
), ),
result = "20", result = "17",
), ),
ThrowsCardUio.Detail( ThrowsCardUio.Detail(
title = "Benediction", title = "Benediction",