Fix characteristic status on the character ribbon
This commit is contained in:
parent
6364201c6c
commit
6e1aaa10d3
2 changed files with 27 additions and 26 deletions
|
|
@ -4,7 +4,6 @@ import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.offset
|
import androidx.compose.foundation.layout.offset
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
|
@ -15,8 +14,11 @@ import androidx.compose.material.MaterialTheme
|
||||||
import androidx.compose.material.Text
|
import androidx.compose.material.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.Stable
|
import androidx.compose.runtime.Stable
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.text.buildAnnotatedString
|
||||||
|
import androidx.compose.ui.text.withStyle
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import com.pixelized.desktop.lwa.ui.theme.lwa
|
import com.pixelized.desktop.lwa.ui.theme.lwa
|
||||||
import lwacharactersheet.composeapp.generated.resources.Res
|
import lwacharactersheet.composeapp.generated.resources.Res
|
||||||
|
|
@ -37,6 +39,11 @@ fun CharacterRibbonStats(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
status: CharacterRibbonStatsUio?,
|
status: CharacterRibbonStatsUio?,
|
||||||
) {
|
) {
|
||||||
|
val typography = MaterialTheme.lwa.typography
|
||||||
|
val valueSpanStyle = remember(typography) { typography.portrait.value.toSpanStyle() }
|
||||||
|
val separatorSpanStyle = remember(typography) { typography.portrait.separator.toSpanStyle() }
|
||||||
|
val maxSpanStyle = remember(typography) { typography.portrait.max.toSpanStyle() }
|
||||||
|
|
||||||
status?.let { status ->
|
status?.let { status ->
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|
@ -58,18 +65,14 @@ fun CharacterRibbonStats(
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier.alignByBaseline(),
|
modifier = Modifier.alignByBaseline(),
|
||||||
style = MaterialTheme.lwa.typography.portrait.value,
|
style = typography.portrait.value,
|
||||||
text = "${status.hp}",
|
text = remember(status.hp, status.maxHp) {
|
||||||
)
|
buildAnnotatedString {
|
||||||
Text(
|
withStyle(style = valueSpanStyle) { append("${status.hp}") }
|
||||||
modifier = Modifier.alignByBaseline(),
|
withStyle(style = separatorSpanStyle) { append("/") }
|
||||||
style = MaterialTheme.lwa.typography.portrait.separator,
|
withStyle(style = maxSpanStyle) { append("${status.maxHp}") }
|
||||||
text = "/",
|
}
|
||||||
)
|
},
|
||||||
Text(
|
|
||||||
modifier = Modifier.alignByBaseline(),
|
|
||||||
style = MaterialTheme.lwa.typography.portrait.max,
|
|
||||||
text = "${status.maxHp}",
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Row {
|
Row {
|
||||||
|
|
@ -84,19 +87,14 @@ fun CharacterRibbonStats(
|
||||||
modifier = Modifier.width(width = 2.dp),
|
modifier = Modifier.width(width = 2.dp),
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier.alignByBaseline(),
|
style = typography.portrait.value,
|
||||||
style = MaterialTheme.lwa.typography.portrait.value,
|
text = remember(status.pp, status.maxPp) {
|
||||||
text = "${status.pp}",
|
buildAnnotatedString {
|
||||||
)
|
withStyle(style = valueSpanStyle) { append("${status.pp}") }
|
||||||
Text(
|
withStyle(style = separatorSpanStyle) { append("/") }
|
||||||
modifier = Modifier.alignByBaseline(),
|
withStyle(style = maxSpanStyle) { append("${status.maxPp}") }
|
||||||
style = MaterialTheme.lwa.typography.portrait.separator,
|
}
|
||||||
text = "/",
|
},
|
||||||
)
|
|
||||||
Text(
|
|
||||||
modifier = Modifier.alignByBaseline(),
|
|
||||||
style = MaterialTheme.lwa.typography.portrait.max,
|
|
||||||
text = "${status.maxPp}",
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -122,6 +122,7 @@ fun lwaTypography(
|
||||||
portrait = LwaTypography.Portrait(
|
portrait = LwaTypography.Portrait(
|
||||||
value = robotoMono.caption.copy(
|
value = robotoMono.caption.copy(
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
|
fontSize = 14.sp,
|
||||||
shadow = Shadow(
|
shadow = Shadow(
|
||||||
color = Color.Black,
|
color = Color.Black,
|
||||||
offset = Offset(x = 1f, y = 1f),
|
offset = Offset(x = 1f, y = 1f),
|
||||||
|
|
@ -130,6 +131,7 @@ fun lwaTypography(
|
||||||
),
|
),
|
||||||
separator = system.caption.copy(
|
separator = system.caption.copy(
|
||||||
fontWeight = FontWeight.ExtraLight,
|
fontWeight = FontWeight.ExtraLight,
|
||||||
|
fontSize = 12.sp,
|
||||||
shadow = Shadow(
|
shadow = Shadow(
|
||||||
color = Color.Black,
|
color = Color.Black,
|
||||||
offset = Offset(x = 1f, y = 1f),
|
offset = Offset(x = 1f, y = 1f),
|
||||||
|
|
@ -138,6 +140,7 @@ fun lwaTypography(
|
||||||
),
|
),
|
||||||
max = robotoMono.caption.copy(
|
max = robotoMono.caption.copy(
|
||||||
fontWeight = FontWeight.Light,
|
fontWeight = FontWeight.Light,
|
||||||
|
fontSize = 12.sp,
|
||||||
shadow = Shadow(
|
shadow = Shadow(
|
||||||
color = Color.Black,
|
color = Color.Black,
|
||||||
offset = Offset(x = 1f, y = 1f),
|
offset = Offset(x = 1f, y = 1f),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue