Change Skill & Alteration layout, remove the info button.
This commit is contained in:
parent
7b6f5b6430
commit
bb1575ea84
5 changed files with 56 additions and 44 deletions
|
|
@ -5,6 +5,8 @@ import android.content.res.Configuration.UI_MODE_NIGHT_YES
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||||
|
import androidx.compose.foundation.layout.FlowRow
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
|
@ -23,6 +25,7 @@ import androidx.compose.runtime.Stable
|
||||||
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.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||||
|
|
@ -32,10 +35,12 @@ import com.pixelized.rplexicon.ui.theme.LexiconTheme
|
||||||
@Stable
|
@Stable
|
||||||
data class AlterationItemUio(
|
data class AlterationItemUio(
|
||||||
val label: String,
|
val label: String,
|
||||||
|
val original: String?,
|
||||||
val subLabel: String?,
|
val subLabel: String?,
|
||||||
val checked: Boolean,
|
val checked: Boolean,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@OptIn(ExperimentalLayoutApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun AlterationItem(
|
fun AlterationItem(
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
|
@ -46,43 +51,53 @@ fun AlterationItem(
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.clickable { onClick(alteration.label) }
|
.clickable { onInfo(alteration.label) }
|
||||||
.heightIn(min = 52.dp)
|
.heightIn(min = 52.dp)
|
||||||
.padding(paddingValues = padding)
|
.padding(paddingValues = padding)
|
||||||
.then(other = modifier),
|
.then(other = modifier),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
horizontalArrangement = Arrangement.spacedBy(space = 8.dp),
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
|
modifier = Modifier.weight(weight = 1f),
|
||||||
verticalArrangement = Arrangement.spacedBy(space = 2.dp),
|
verticalArrangement = Arrangement.spacedBy(space = 2.dp),
|
||||||
) {
|
) {
|
||||||
Text(
|
FlowRow(
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
horizontalArrangement = Arrangement.spacedBy(space = 4.dp),
|
||||||
fontWeight = FontWeight.Bold,
|
) {
|
||||||
text = alteration.label,
|
Text(
|
||||||
)
|
modifier = Modifier.alignByBaseline(),
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
maxLines = 1,
|
||||||
|
text = alteration.label,
|
||||||
|
)
|
||||||
|
alteration.original?.let {
|
||||||
|
Text(
|
||||||
|
modifier = Modifier.alignByBaseline(),
|
||||||
|
style = MaterialTheme.typography.labelSmall,
|
||||||
|
fontWeight = FontWeight.Light,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
maxLines = 1,
|
||||||
|
text = it,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
alteration.subLabel?.let {
|
alteration.subLabel?.let {
|
||||||
Text(
|
Text(
|
||||||
style = MaterialTheme.typography.labelSmall,
|
style = MaterialTheme.typography.labelSmall,
|
||||||
fontWeight = FontWeight.Light,
|
fontWeight = FontWeight.Normal,
|
||||||
text = it,
|
text = it,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row {
|
Switch(
|
||||||
IconButton(onClick = { onInfo(alteration.label) }) {
|
enabled = true,
|
||||||
Icon(
|
checked = alteration.checked,
|
||||||
imageVector = Icons.Outlined.Info,
|
onCheckedChange = { onClick(alteration.label) },
|
||||||
contentDescription = null,
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
Switch(
|
|
||||||
enabled = true,
|
|
||||||
checked = alteration.checked,
|
|
||||||
onCheckedChange = { onClick(alteration.label) },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,16 +123,19 @@ private class RollAlterationPreviewProvider : PreviewParameterProvider<Alteratio
|
||||||
override val values: Sequence<AlterationItemUio> = sequenceOf(
|
override val values: Sequence<AlterationItemUio> = sequenceOf(
|
||||||
AlterationItemUio(
|
AlterationItemUio(
|
||||||
label = "Critique",
|
label = "Critique",
|
||||||
|
original = "Critical",
|
||||||
checked = false,
|
checked = false,
|
||||||
subLabel = null,
|
subLabel = null,
|
||||||
),
|
),
|
||||||
AlterationItemUio(
|
AlterationItemUio(
|
||||||
label = "Rage",
|
label = "Rage",
|
||||||
|
original = "Rage",
|
||||||
checked = true,
|
checked = true,
|
||||||
subLabel = "Barbare",
|
subLabel = "Barbare",
|
||||||
),
|
),
|
||||||
AlterationItemUio(
|
AlterationItemUio(
|
||||||
label = "Bénédiction",
|
label = "Bénédiction",
|
||||||
|
original = "Bless",
|
||||||
checked = false,
|
checked = false,
|
||||||
subLabel = "Clerc",
|
subLabel = "Clerc",
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -7,16 +7,10 @@ import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
|
||||||
import androidx.compose.foundation.layout.FlowRow
|
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.icons.Icons
|
|
||||||
import androidx.compose.material.icons.outlined.Info
|
|
||||||
import androidx.compose.material3.Icon
|
|
||||||
import androidx.compose.material3.IconButton
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
|
|
@ -67,7 +61,7 @@ fun SkillItem(
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.clickable { onSkill(skill) }
|
.clickable { onInfo(skill) }
|
||||||
.padding(paddingValues = padding)
|
.padding(paddingValues = padding)
|
||||||
.then(other = modifier),
|
.then(other = modifier),
|
||||||
contentAlignment = Alignment.Center,
|
contentAlignment = Alignment.Center,
|
||||||
|
|
@ -124,15 +118,6 @@ fun SkillItem(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skill.haveDetail) {
|
|
||||||
IconButton(onClick = { onInfo(skill) }) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Outlined.Info,
|
|
||||||
contentDescription = null,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
skill.effect?.let { effect ->
|
skill.effect?.let { effect ->
|
||||||
DiceButton(
|
DiceButton(
|
||||||
icon = effect.icon,
|
icon = effect.icon,
|
||||||
|
|
@ -145,6 +130,7 @@ fun SkillItem(
|
||||||
CounterButton(
|
CounterButton(
|
||||||
value = skill.value,
|
value = skill.value,
|
||||||
max = it,
|
max = it,
|
||||||
|
onClick = { onSkill(skill) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package com.pixelized.rplexicon.ui.screens.character.composable.actions
|
||||||
|
|
||||||
import android.content.res.Configuration.UI_MODE_NIGHT_NO
|
import android.content.res.Configuration.UI_MODE_NIGHT_NO
|
||||||
import android.content.res.Configuration.UI_MODE_NIGHT_YES
|
import android.content.res.Configuration.UI_MODE_NIGHT_YES
|
||||||
import androidx.compose.foundation.clickable
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
|
|
@ -50,11 +49,7 @@ fun SpellHeader(
|
||||||
onSpell: (level: Int, value: Int, max: Int) -> Unit,
|
onSpell: (level: Int, value: Int, max: Int) -> Unit,
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = modifier,
|
||||||
.clickable(enabled = header.count != null) {
|
|
||||||
header.count?.let { onSpell(header.level, it.value, it.max) }
|
|
||||||
}
|
|
||||||
.then(other = modifier),
|
|
||||||
) {
|
) {
|
||||||
Surface {
|
Surface {
|
||||||
Row(
|
Row(
|
||||||
|
|
@ -92,9 +87,12 @@ fun SpellHeader(
|
||||||
)
|
)
|
||||||
header.count?.let { count ->
|
header.count?.let { count ->
|
||||||
CounterButton(
|
CounterButton(
|
||||||
modifier = Modifier.alignByBaseline().offset(x = 4.dp),
|
modifier = Modifier
|
||||||
|
.alignByBaseline()
|
||||||
|
.offset(x = 4.dp),
|
||||||
value = count.value,
|
value = count.value,
|
||||||
max = count.max,
|
max = count.max,
|
||||||
|
onClick = { onSpell(header.level, count.value, count.max) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,14 @@ import com.pixelized.rplexicon.model.DiceThrow
|
||||||
import com.pixelized.rplexicon.model.Property
|
import com.pixelized.rplexicon.model.Property
|
||||||
import com.pixelized.rplexicon.repository.data.ActionRepository
|
import com.pixelized.rplexicon.repository.data.ActionRepository
|
||||||
import com.pixelized.rplexicon.repository.data.AlterationRepository
|
import com.pixelized.rplexicon.repository.data.AlterationRepository
|
||||||
|
import com.pixelized.rplexicon.repository.data.DescriptionRepository
|
||||||
import com.pixelized.rplexicon.repository.data.SkillRepository
|
import com.pixelized.rplexicon.repository.data.SkillRepository
|
||||||
import com.pixelized.rplexicon.repository.data.SpellRepository
|
import com.pixelized.rplexicon.repository.data.SpellRepository
|
||||||
import com.pixelized.rplexicon.ui.screens.character.composable.actions.AlterationItemUio
|
import com.pixelized.rplexicon.ui.screens.character.composable.actions.AlterationItemUio
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class AlterationFactory @Inject constructor(
|
class AlterationFactory @Inject constructor(
|
||||||
|
private val descriptionRepository: DescriptionRepository,
|
||||||
private val actionRepository: ActionRepository,
|
private val actionRepository: ActionRepository,
|
||||||
private val spellRepository: SpellRepository,
|
private val spellRepository: SpellRepository,
|
||||||
private val skillRepository: SkillRepository,
|
private val skillRepository: SkillRepository,
|
||||||
|
|
@ -18,8 +20,10 @@ class AlterationFactory @Inject constructor(
|
||||||
) {
|
) {
|
||||||
fun convert(character: String, alterations: List<Alteration>): List<AlterationItemUio> {
|
fun convert(character: String, alterations: List<Alteration>): List<AlterationItemUio> {
|
||||||
return alterations.map {
|
return alterations.map {
|
||||||
|
val description = descriptionRepository.find(it.name)
|
||||||
AlterationItemUio(
|
AlterationItemUio(
|
||||||
label = it.name,
|
label = it.name,
|
||||||
|
original = description?.original,
|
||||||
checked = alterationRepository.getStatus(character, it.name),
|
checked = alterationRepository.getStatus(character, it.name),
|
||||||
subLabel = it.source,
|
subLabel = it.source,
|
||||||
)
|
)
|
||||||
|
|
@ -103,8 +107,10 @@ class AlterationFactory @Inject constructor(
|
||||||
return alterationRepository
|
return alterationRepository
|
||||||
.getAlterations(character = diceThrow.character, *properties.toTypedArray())
|
.getAlterations(character = diceThrow.character, *properties.toTypedArray())
|
||||||
.map {
|
.map {
|
||||||
|
val description = descriptionRepository.find(it.name)
|
||||||
AlterationItemUio(
|
AlterationItemUio(
|
||||||
label = it.name,
|
label = it.name,
|
||||||
|
original = description?.original,
|
||||||
checked = alterationRepository.getStatus(diceThrow.character, it.name),
|
checked = alterationRepository.getStatus(diceThrow.character, it.name),
|
||||||
subLabel = it.source,
|
subLabel = it.source,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -13,21 +13,25 @@ fun rememberRollAlterations() = remember {
|
||||||
listOf(
|
listOf(
|
||||||
AlterationItemUio(
|
AlterationItemUio(
|
||||||
label = "Rage",
|
label = "Rage",
|
||||||
|
original = "Rage",
|
||||||
subLabel = "Barbare",
|
subLabel = "Barbare",
|
||||||
checked = false,
|
checked = false,
|
||||||
),
|
),
|
||||||
AlterationItemUio(
|
AlterationItemUio(
|
||||||
label = "Inspiration bardique",
|
label = "Inspiration bardique",
|
||||||
|
original = "Bardic inspiration",
|
||||||
subLabel = "Barde",
|
subLabel = "Barde",
|
||||||
checked = false
|
checked = false
|
||||||
),
|
),
|
||||||
AlterationItemUio(
|
AlterationItemUio(
|
||||||
label = "Bénédiction",
|
label = "Bénédiction",
|
||||||
|
original = "Bless",
|
||||||
subLabel = "Clerc",
|
subLabel = "Clerc",
|
||||||
checked = false,
|
checked = false,
|
||||||
),
|
),
|
||||||
AlterationItemUio(
|
AlterationItemUio(
|
||||||
label = "Cape de protection",
|
label = "Cape de protection",
|
||||||
|
original = "Cape of protection",
|
||||||
subLabel = "Équipement",
|
subLabel = "Équipement",
|
||||||
checked = true
|
checked = true
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue