This commit was merged in pull request #75.
This commit is contained in:
@@ -2,10 +2,10 @@ package org.shahondin1624.lib.components.charactermodel.attributespage
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
@@ -13,6 +13,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.ColorFilter
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
@@ -36,13 +37,35 @@ fun Attribute(
|
||||
onEdit: (() -> Unit)? = null,
|
||||
) {
|
||||
val textColor = contrastTextColor(attribute.type.color)
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.testTag(TestTags.attributeCard(attribute.type.name))
|
||||
.then(
|
||||
if (onEdit != null) Modifier.clickable { onEdit() }
|
||||
else Modifier
|
||||
val cardModifier = Modifier.testTag(TestTags.attributeCard(attribute.type.name))
|
||||
val elevation = CardDefaults.cardElevation(
|
||||
defaultElevation = 2.dp,
|
||||
pressedElevation = 6.dp,
|
||||
hoveredElevation = 4.dp
|
||||
)
|
||||
if (onEdit != null) {
|
||||
Card(
|
||||
onClick = onEdit,
|
||||
modifier = cardModifier,
|
||||
elevation = elevation
|
||||
) {
|
||||
AttributeCardContent(attribute, textColor, onRoll)
|
||||
}
|
||||
} else {
|
||||
Card(
|
||||
modifier = cardModifier,
|
||||
elevation = elevation
|
||||
) {
|
||||
AttributeCardContent(attribute, textColor, onRoll)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AttributeCardContent(
|
||||
attribute: Attribute,
|
||||
textColor: Color,
|
||||
onRoll: (DiceRoll) -> Unit
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
@@ -98,4 +121,3 @@ fun Attribute(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.shahondin1624.lib.components.charactermodel.attributespage
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
@@ -11,6 +10,7 @@ import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
@@ -18,6 +18,7 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.ColorFilter
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
@@ -43,13 +44,36 @@ fun Talent(
|
||||
onEdit: (() -> Unit)? = null,
|
||||
) {
|
||||
val textColor = contrastTextColor(talent.attribute.color)
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.testTag(TestTags.talentCard(talent.name))
|
||||
.then(
|
||||
if (onEdit != null) Modifier.clickable { onEdit() }
|
||||
else Modifier
|
||||
val cardModifier = Modifier.testTag(TestTags.talentCard(talent.name))
|
||||
val elevation = CardDefaults.cardElevation(
|
||||
defaultElevation = 2.dp,
|
||||
pressedElevation = 6.dp,
|
||||
hoveredElevation = 4.dp
|
||||
)
|
||||
if (onEdit != null) {
|
||||
Card(
|
||||
onClick = onEdit,
|
||||
modifier = cardModifier,
|
||||
elevation = elevation
|
||||
) {
|
||||
TalentCardContent(talent, attributes, textColor, onRoll)
|
||||
}
|
||||
} else {
|
||||
Card(
|
||||
modifier = cardModifier,
|
||||
elevation = elevation
|
||||
) {
|
||||
TalentCardContent(talent, attributes, textColor, onRoll)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun TalentCardContent(
|
||||
talent: TalentDefinition,
|
||||
attributes: Attributes,
|
||||
textColor: Color,
|
||||
onRoll: (DiceRoll) -> Unit
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
@@ -119,4 +143,3 @@ fun Talent(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user