feat: responsive talent card layout with fluid name scaling (Closes #6)

Replace hardcoded Modifier.width(150.dp) with Modifier.weight(1f) so
talent names like "Aeronautics Mechanic" display fully. Add
TextOverflow.Ellipsis + maxLines=1, widthIn(min=24.dp) for value
columns, and fillMaxWidth() for full-width spanning on compact screens.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shahondin1624
2026-03-13 13:10:36 +01:00
parent f0c0f5f80e
commit bce57012cc

View File

@@ -4,9 +4,10 @@ import androidx.compose.foundation.Image
import androidx.compose.foundation.background import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding 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.widthIn
import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Card import androidx.compose.material3.Card
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
@@ -22,6 +23,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.platform.testTag import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import org.jetbrains.compose.resources.painterResource import org.jetbrains.compose.resources.painterResource
import org.shahondin1624.lib.components.TestTags import org.shahondin1624.lib.components.TestTags
@@ -46,39 +48,50 @@ fun Talent(
Card(modifier = Modifier.testTag(TestTags.talentCard(talent.name))) { Card(modifier = Modifier.testTag(TestTags.talentCard(talent.name))) {
Row( Row(
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Start horizontalArrangement = Arrangement.Start,
modifier = Modifier.fillMaxWidth()
) { ) {
Row( Row(
modifier = Modifier modifier = Modifier
.weight(1f)
.padding(horizontal = SMALL_PADDING) .padding(horizontal = SMALL_PADDING)
.background( .background(
talent.attribute.color, talent.attribute.color,
shape = RoundedCornerShape(4.dp) shape = RoundedCornerShape(4.dp)
) )
.clip(androidx.compose.foundation.shape.RoundedCornerShape(4.dp)), .clip(RoundedCornerShape(4.dp)),
horizontalArrangement = Arrangement.SpaceBetween horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) { ) {
Text( Text(
text = talent.name, text = talent.name,
modifier = Modifier modifier = Modifier
.width(150.dp) .weight(1f)
.padding(start = SMALL_PADDING), .padding(start = SMALL_PADDING),
textAlign = TextAlign.Center, textAlign = TextAlign.Start,
color = textColor color = textColor,
maxLines = 1,
overflow = TextOverflow.Ellipsis
) )
Text( Text(
text = attributes.getAttributeByType(talent.attribute).value.toString(), text = attributes.getAttributeByType(talent.attribute).value.toString(),
modifier = Modifier modifier = Modifier
.padding(end = SMALL_PADDING), .widthIn(min = 24.dp)
textAlign = TextAlign.Center, .padding(horizontal = SMALL_PADDING),
color = textColor textAlign = TextAlign.End,
color = textColor,
maxLines = 1,
overflow = TextOverflow.Ellipsis
) )
Text( Text(
text = talent.value.toString(), text = talent.value.toString(),
modifier = Modifier modifier = Modifier
.widthIn(min = 24.dp)
.padding(end = SMALL_PADDING), .padding(end = SMALL_PADDING),
textAlign = TextAlign.Center, textAlign = TextAlign.End,
color = textColor color = textColor,
maxLines = 1,
overflow = TextOverflow.Ellipsis
) )
} }
IconButton( IconButton(
@@ -101,4 +114,4 @@ fun Talent(
} }
} }
} }
} }