Add icone to spells
This commit is contained in:
parent
1c3d1a1036
commit
78701b5d6a
5 changed files with 50 additions and 15 deletions
|
|
@ -1,6 +1,9 @@
|
|||
package com.pixelized.rplexicon.data.model
|
||||
|
||||
import android.net.Uri
|
||||
|
||||
data class Spell(
|
||||
val icon: Uri?,
|
||||
val name: String,
|
||||
val school: School,
|
||||
val level: Int,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,14 @@
|
|||
package com.pixelized.rplexicon.data.parser.spell
|
||||
|
||||
import android.util.Log
|
||||
import androidx.core.net.toUri
|
||||
import com.google.api.services.sheets.v4.model.ValueRange
|
||||
import com.pixelized.rplexicon.data.model.Spell
|
||||
import com.pixelized.rplexicon.data.parser.column
|
||||
import com.pixelized.rplexicon.data.parser.parserScope
|
||||
import com.pixelized.rplexicon.utilitary.exceptions.IncompatibleSheetStructure
|
||||
import com.pixelized.rplexicon.utilitary.extentions.local.icon
|
||||
import com.pixelized.rplexicon.utilitary.extentions.uri
|
||||
import javax.inject.Inject
|
||||
|
||||
class SpellBookParser @Inject constructor() {
|
||||
|
|
@ -24,6 +27,7 @@ class SpellBookParser @Inject constructor() {
|
|||
val range = row.parse(column = RANGE)
|
||||
val requirement = row.parse(column = REQUIREMENT)
|
||||
val duration = row.parse(column = DURATION)
|
||||
val icon = row.parseUri(column = ICON)
|
||||
if (name != null
|
||||
&& level != null
|
||||
&& school != null
|
||||
|
|
@ -33,6 +37,7 @@ class SpellBookParser @Inject constructor() {
|
|||
&& duration != null
|
||||
) {
|
||||
val spell = Spell(
|
||||
icon = icon,
|
||||
name = name,
|
||||
level = level,
|
||||
school = school,
|
||||
|
|
@ -66,8 +71,19 @@ class SpellBookParser @Inject constructor() {
|
|||
private val REQUIREMENT = column("Composantes")
|
||||
private val DURATION = column("Durée")
|
||||
private val RITUAL = column("Rituel")
|
||||
private val ICON = column("Icone")
|
||||
|
||||
private val COLUMNS
|
||||
get() = listOf(NAME, LEVEL, SCHOOL, CASTING_TIME, RANGE, REQUIREMENT, DURATION, RITUAL)
|
||||
get() = listOf(
|
||||
NAME,
|
||||
LEVEL,
|
||||
SCHOOL,
|
||||
CASTING_TIME,
|
||||
RANGE,
|
||||
REQUIREMENT,
|
||||
DURATION,
|
||||
RITUAL,
|
||||
ICON
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ 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.BorderStroke
|
||||
import androidx.compose.foundation.clickable
|
||||
|
|
@ -14,7 +15,6 @@ import androidx.compose.foundation.layout.Row
|
|||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material.minimumInteractiveComponentSize
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.Surface
|
||||
|
|
@ -23,7 +23,7 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.runtime.Stable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.graphics.ColorFilter
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
|
|
@ -32,15 +32,19 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.net.toUri
|
||||
import com.pixelized.rplexicon.R
|
||||
import com.pixelized.rplexicon.data.model.Spell
|
||||
import com.pixelized.rplexicon.ui.composable.AsyncImage
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.common.DiceButton
|
||||
import com.pixelized.rplexicon.ui.theme.LexiconTheme
|
||||
import com.pixelized.rplexicon.utilitary.extentions.local.icon
|
||||
import com.pixelized.rplexicon.utilitary.extentions.uri
|
||||
|
||||
@Stable
|
||||
data class SpellUio(
|
||||
@DrawableRes val icon: Int,
|
||||
val icon: Uri?,
|
||||
val school: Spell.School,
|
||||
val name: String,
|
||||
val translated: String?,
|
||||
val castingTime: String,
|
||||
|
|
@ -74,12 +78,13 @@ fun Spell(
|
|||
.minimumInteractiveComponentSize()
|
||||
.padding(paddingValues = padding)
|
||||
.then(other = modifier),
|
||||
horizontalArrangement = Arrangement.spacedBy(space = 12.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(space = 8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Icon(
|
||||
modifier = Modifier.size(size = 28.dp),
|
||||
painter = painterResource(id = spell.icon),
|
||||
AsyncImage(
|
||||
modifier = Modifier.size(size = 36.dp),
|
||||
model = spell.icon ?: spell.school.icon.uri.toUri(),
|
||||
colorFilter = if (spell.icon == null) ColorFilter.tint(MaterialTheme.colorScheme.onSurface) else null,
|
||||
contentDescription = null,
|
||||
)
|
||||
|
||||
|
|
@ -223,7 +228,8 @@ private fun SpellPreview(
|
|||
private class SpellPreviewProvider : PreviewParameterProvider<SpellUio> {
|
||||
override val values: Sequence<SpellUio> = sequenceOf(
|
||||
SpellUio(
|
||||
icon = Spell.School.EVOCATION.icon,
|
||||
icon = null,
|
||||
school = Spell.School.EVOCATION,
|
||||
name = "Trait de feu",
|
||||
translated = "Fire Bolt",
|
||||
castingTime = "1 action",
|
||||
|
|
@ -241,7 +247,8 @@ private class SpellPreviewProvider : PreviewParameterProvider<SpellUio> {
|
|||
ritual = false,
|
||||
),
|
||||
SpellUio(
|
||||
icon = Spell.School.ENCHANTMENT.icon,
|
||||
icon = null,
|
||||
school = Spell.School.ENCHANTMENT,
|
||||
name = "Moquerie cruelle",
|
||||
translated = "Vicious Mockery",
|
||||
castingTime = "1 action",
|
||||
|
|
@ -256,7 +263,8 @@ private class SpellPreviewProvider : PreviewParameterProvider<SpellUio> {
|
|||
ritual = false,
|
||||
),
|
||||
SpellUio(
|
||||
icon = Spell.School.EVOCATION.icon,
|
||||
icon = null,
|
||||
school = Spell.School.EVOCATION,
|
||||
name = "Soins",
|
||||
translated = "Cure Wounds",
|
||||
castingTime = "1 action",
|
||||
|
|
|
|||
|
|
@ -5,11 +5,13 @@ import androidx.compose.runtime.Stable
|
|||
import androidx.compose.runtime.State
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.core.net.toUri
|
||||
import com.pixelized.rplexicon.R
|
||||
import com.pixelized.rplexicon.data.model.Spell
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.actions.SpellHeaderUio
|
||||
import com.pixelized.rplexicon.ui.screens.character.composable.actions.SpellUio
|
||||
import com.pixelized.rplexicon.utilitary.extentions.local.icon
|
||||
import com.pixelized.rplexicon.utilitary.extentions.uri
|
||||
|
||||
@Stable
|
||||
@Composable
|
||||
|
|
@ -21,7 +23,8 @@ fun rememberSpellListStatePreview(): State<List<Pair<SpellHeaderUio, List<SpellU
|
|||
count = null,
|
||||
) to listOf(
|
||||
SpellUio(
|
||||
icon = Spell.School.EVOCATION.icon,
|
||||
icon = null,
|
||||
school = Spell.School.EVOCATION,
|
||||
name = "Trait de feu",
|
||||
translated = "Fire Bolt",
|
||||
castingTime = "1 action",
|
||||
|
|
@ -39,7 +42,8 @@ fun rememberSpellListStatePreview(): State<List<Pair<SpellHeaderUio, List<SpellU
|
|||
ritual = true,
|
||||
),
|
||||
SpellUio(
|
||||
icon = Spell.School.ENCHANTMENT.icon,
|
||||
icon = null,
|
||||
school = Spell.School.ENCHANTMENT,
|
||||
name = "Moquerie cruelle",
|
||||
translated = "Vicious Mockery",
|
||||
castingTime = "1 action",
|
||||
|
|
@ -59,7 +63,8 @@ fun rememberSpellListStatePreview(): State<List<Pair<SpellHeaderUio, List<SpellU
|
|||
count = SpellHeaderUio.Count(value = 2, max = 3),
|
||||
) to listOf(
|
||||
SpellUio(
|
||||
icon = Spell.School.EVOCATION.icon,
|
||||
icon = null,
|
||||
school = Spell.School.EVOCATION,
|
||||
name = "Soins",
|
||||
translated = "Cure Wounds",
|
||||
castingTime = "1 action",
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.pixelized.rplexicon.ui.screens.character.factory
|
||||
|
||||
import androidx.core.net.toUri
|
||||
import com.pixelized.rplexicon.data.model.AssignedSpell
|
||||
import com.pixelized.rplexicon.data.model.CharacterSheet
|
||||
import com.pixelized.rplexicon.data.model.Property
|
||||
|
|
@ -8,6 +9,7 @@ import com.pixelized.rplexicon.ui.screens.character.composable.actions.SpellUio
|
|||
import com.pixelized.rplexicon.utilitary.extentions.icon
|
||||
import com.pixelized.rplexicon.utilitary.extentions.local.icon
|
||||
import com.pixelized.rplexicon.utilitary.extentions.modifier
|
||||
import com.pixelized.rplexicon.utilitary.extentions.uri
|
||||
import javax.inject.Inject
|
||||
|
||||
class SpellUioFactory @Inject constructor(
|
||||
|
|
@ -49,7 +51,8 @@ class SpellUioFactory @Inject constructor(
|
|||
)
|
||||
}
|
||||
return SpellUio(
|
||||
icon = assignedSpell.spell.school.icon,
|
||||
icon = assignedSpell.spell.icon,
|
||||
school = assignedSpell.spell.school,
|
||||
name = assignedSpell.spell.name,
|
||||
translated = descriptionRepository.find(name = assignedSpell.spell.name)?.original,
|
||||
castingTime = assignedSpell.spell.castingTime,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue