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

Merged
shahondin1624 merged 1 commits from feature/issue-6-responsive-talent-card-layout into main 2026-03-13 13:10:52 +01:00
Showing only changes of commit bce57012cc - Show all commits

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(