Add icons to skills
This commit is contained in:
parent
78701b5d6a
commit
49ee7d59e3
4 changed files with 26 additions and 5 deletions
|
|
@ -1,6 +1,9 @@
|
|||
package com.pixelized.rplexicon.data.model
|
||||
|
||||
import android.net.Uri
|
||||
|
||||
data class Skill(
|
||||
val icon: Uri?,
|
||||
val name: String,
|
||||
val amount: Int?,
|
||||
val rest: String?,
|
||||
|
|
|
|||
|
|
@ -26,8 +26,9 @@ class SkillParser @Inject constructor(
|
|||
val name = row.parse(column = NAME)
|
||||
if (characterSheet != null && name != null) {
|
||||
val skill = Skill(
|
||||
icon = row.parseUri(column = ICON),
|
||||
name = name,
|
||||
amount = row.parse(column = AMOUNT)?.toIntOrNull(),
|
||||
amount = row.parseInt(column = AMOUNT),
|
||||
rest = row.parse(column = REST),
|
||||
cost = row.parse(column = COST),
|
||||
effect = throwParser.parse(row.parse(column = EFFECT)),
|
||||
|
|
@ -44,6 +45,7 @@ class SkillParser @Inject constructor(
|
|||
|
||||
companion object {
|
||||
private val CHARACTER = column("")
|
||||
private val ICON = column("Icone")
|
||||
private val NAME = column("Nom")
|
||||
private val AMOUNT = column("Quantité")
|
||||
private val REST = column("Récupération")
|
||||
|
|
@ -51,6 +53,6 @@ class SkillParser @Inject constructor(
|
|||
private val EFFECT = column("Effect")
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
@ -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_YES
|
||||
import android.net.Uri
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
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.unit.dp
|
||||
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.DiceButton
|
||||
import com.pixelized.rplexicon.ui.theme.LexiconTheme
|
||||
|
||||
@Stable
|
||||
data class SkillItemUio(
|
||||
val icon: Uri?,
|
||||
val label: String,
|
||||
val translate: String?,
|
||||
val rest: String?,
|
||||
|
|
@ -59,13 +62,22 @@ fun SkillItem(
|
|||
onThrow: (SkillItemUio) -> Unit,
|
||||
onSkill: (SkillItemUio) -> Unit,
|
||||
) {
|
||||
Box(
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.clickable { onInfo(skill) }
|
||||
.padding(paddingValues = padding)
|
||||
.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(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
|
|
@ -165,6 +177,7 @@ fun rememberSkillsListStatePreview(): State<List<SkillItemUio>> = remember {
|
|||
private class CounterItemPreviewProvider : PreviewParameterProvider<SkillItemUio> {
|
||||
override val values: Sequence<SkillItemUio> = sequenceOf(
|
||||
SkillItemUio(
|
||||
icon = null,
|
||||
label = "Endurance Implacable",
|
||||
translate = "Relentless Endurance",
|
||||
rest = "Récupération repos long",
|
||||
|
|
@ -175,6 +188,7 @@ private class CounterItemPreviewProvider : PreviewParameterProvider<SkillItemUio
|
|||
haveDetail = true,
|
||||
),
|
||||
SkillItemUio(
|
||||
icon = null,
|
||||
label = "Apparence inspirante",
|
||||
translate = "Mantle of Inspiration",
|
||||
rest = null,
|
||||
|
|
@ -185,6 +199,7 @@ private class CounterItemPreviewProvider : PreviewParameterProvider<SkillItemUio
|
|||
haveDetail = true,
|
||||
),
|
||||
SkillItemUio(
|
||||
icon = null,
|
||||
label = "Renvoi des morts-vivants",
|
||||
translate = "Turn Undead",
|
||||
rest = "Récupération repos long",
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ class SkillFactoryUioFactory @Inject constructor(
|
|||
val modifier = effectModifier + effectFlat
|
||||
|
||||
SkillItemUio(
|
||||
icon = skill.icon,
|
||||
label = skill.name,
|
||||
translate = description?.original,
|
||||
rest = skill.rest,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue