Add icons to skills

This commit is contained in:
Andres Gomez, Thomas (ITDV RL) 2024-05-29 17:54:39 +02:00
parent 78701b5d6a
commit 49ee7d59e3
4 changed files with 26 additions and 5 deletions

View file

@ -1,6 +1,9 @@
package com.pixelized.rplexicon.data.model package com.pixelized.rplexicon.data.model
import android.net.Uri
data class Skill( data class Skill(
val icon: Uri?,
val name: String, val name: String,
val amount: Int?, val amount: Int?,
val rest: String?, val rest: String?,

View file

@ -26,8 +26,9 @@ class SkillParser @Inject constructor(
val name = row.parse(column = NAME) val name = row.parse(column = NAME)
if (characterSheet != null && name != null) { if (characterSheet != null && name != null) {
val skill = Skill( val skill = Skill(
icon = row.parseUri(column = ICON),
name = name, name = name,
amount = row.parse(column = AMOUNT)?.toIntOrNull(), amount = row.parseInt(column = AMOUNT),
rest = row.parse(column = REST), rest = row.parse(column = REST),
cost = row.parse(column = COST), cost = row.parse(column = COST),
effect = throwParser.parse(row.parse(column = EFFECT)), effect = throwParser.parse(row.parse(column = EFFECT)),
@ -44,6 +45,7 @@ class SkillParser @Inject constructor(
companion object { companion object {
private val CHARACTER = column("") private val CHARACTER = column("")
private val ICON = column("Icone")
private val NAME = column("Nom") private val NAME = column("Nom")
private val AMOUNT = column("Quantité") private val AMOUNT = column("Quantité")
private val REST = column("Récupération") private val REST = column("Récupération")
@ -51,6 +53,6 @@ class SkillParser @Inject constructor(
private val EFFECT = column("Effect") private val EFFECT = column("Effect")
private val PASSIVE = column("Passif") private val PASSIVE = column("Passif")
private val COLUMNS get() = listOf(CHARACTER, NAME, AMOUNT, REST, COST, EFFECT, PASSIVE) private val COLUMNS get() = listOf(CHARACTER, ICON, NAME, AMOUNT, REST, COST, EFFECT, PASSIVE)
} }
} }

View file

@ -2,15 +2,16 @@ 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 android.net.Uri
import androidx.annotation.DrawableRes import androidx.annotation.DrawableRes
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.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
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.foundation.layout.size
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
@ -29,12 +30,14 @@ import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.tooling.preview.PreviewParameterProvider import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.pixelized.rplexicon.R import com.pixelized.rplexicon.R
import com.pixelized.rplexicon.ui.composable.AsyncImage
import com.pixelized.rplexicon.ui.screens.character.composable.common.CounterButton import com.pixelized.rplexicon.ui.screens.character.composable.common.CounterButton
import com.pixelized.rplexicon.ui.screens.character.composable.common.DiceButton import com.pixelized.rplexicon.ui.screens.character.composable.common.DiceButton
import com.pixelized.rplexicon.ui.theme.LexiconTheme import com.pixelized.rplexicon.ui.theme.LexiconTheme
@Stable @Stable
data class SkillItemUio( data class SkillItemUio(
val icon: Uri?,
val label: String, val label: String,
val translate: String?, val translate: String?,
val rest: String?, val rest: String?,
@ -59,13 +62,22 @@ fun SkillItem(
onThrow: (SkillItemUio) -> Unit, onThrow: (SkillItemUio) -> Unit,
onSkill: (SkillItemUio) -> Unit, onSkill: (SkillItemUio) -> Unit,
) { ) {
Box( Row(
modifier = Modifier modifier = Modifier
.clickable { onInfo(skill) } .clickable { onInfo(skill) }
.padding(paddingValues = padding) .padding(paddingValues = padding)
.then(other = modifier), .then(other = modifier),
contentAlignment = Alignment.Center, horizontalArrangement = Arrangement.spacedBy(space = 8.dp),
verticalAlignment = Alignment.CenterVertically,
) { ) {
skill.icon?.let { uri ->
AsyncImage(
modifier = Modifier.size(size = 36.dp),
model = uri,
contentDescription = null,
)
}
Row( Row(
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
@ -165,6 +177,7 @@ fun rememberSkillsListStatePreview(): State<List<SkillItemUio>> = remember {
private class CounterItemPreviewProvider : PreviewParameterProvider<SkillItemUio> { private class CounterItemPreviewProvider : PreviewParameterProvider<SkillItemUio> {
override val values: Sequence<SkillItemUio> = sequenceOf( override val values: Sequence<SkillItemUio> = sequenceOf(
SkillItemUio( SkillItemUio(
icon = null,
label = "Endurance Implacable", label = "Endurance Implacable",
translate = "Relentless Endurance", translate = "Relentless Endurance",
rest = "Récupération repos long", rest = "Récupération repos long",
@ -175,6 +188,7 @@ private class CounterItemPreviewProvider : PreviewParameterProvider<SkillItemUio
haveDetail = true, haveDetail = true,
), ),
SkillItemUio( SkillItemUio(
icon = null,
label = "Apparence inspirante", label = "Apparence inspirante",
translate = "Mantle of Inspiration", translate = "Mantle of Inspiration",
rest = null, rest = null,
@ -185,6 +199,7 @@ private class CounterItemPreviewProvider : PreviewParameterProvider<SkillItemUio
haveDetail = true, haveDetail = true,
), ),
SkillItemUio( SkillItemUio(
icon = null,
label = "Renvoi des morts-vivants", label = "Renvoi des morts-vivants",
translate = "Turn Undead", translate = "Turn Undead",
rest = "Récupération repos long", rest = "Récupération repos long",

View file

@ -39,6 +39,7 @@ class SkillFactoryUioFactory @Inject constructor(
val modifier = effectModifier + effectFlat val modifier = effectModifier + effectFlat
SkillItemUio( SkillItemUio(
icon = skill.icon,
label = skill.name, label = skill.name,
translate = description?.original, translate = description?.original,
rest = skill.rest, rest = skill.rest,