Add Icon to Alteration
This commit is contained in:
parent
49ee7d59e3
commit
757ad75804
5 changed files with 26 additions and 1 deletions
|
|
@ -1,6 +1,9 @@
|
||||||
package com.pixelized.rplexicon.data.model
|
package com.pixelized.rplexicon.data.model
|
||||||
|
|
||||||
|
import android.net.Uri
|
||||||
|
|
||||||
data class Alteration(
|
data class Alteration(
|
||||||
|
val icon: Uri?,
|
||||||
val name: String,
|
val name: String,
|
||||||
val source: String,
|
val source: String,
|
||||||
val target: String,
|
val target: String,
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ class AlterationParser @Inject constructor(
|
||||||
val target = row.parse(column = TARGET)
|
val target = row.parse(column = TARGET)
|
||||||
val alteration = if (name != null && source != null && target != null) {
|
val alteration = if (name != null && source != null && target != null) {
|
||||||
Alteration(
|
Alteration(
|
||||||
|
icon = row.parseUri(column = ICON),
|
||||||
name = name,
|
name = name,
|
||||||
source = source,
|
source = source,
|
||||||
target = target,
|
target = target,
|
||||||
|
|
@ -114,10 +115,11 @@ class AlterationParser @Inject constructor(
|
||||||
private const val CRITICAL = "crit"
|
private const val CRITICAL = "crit"
|
||||||
private const val EFFECT = "Effet"
|
private const val EFFECT = "Effet"
|
||||||
|
|
||||||
|
private val ICON = column("Icone")
|
||||||
private val NAME = column("Altération")
|
private val NAME = column("Altération")
|
||||||
private val TARGET = column("Cible")
|
private val TARGET = column("Cible")
|
||||||
private val SOURCE = column("Source")
|
private val SOURCE = column("Source")
|
||||||
private val COLUMNS
|
private val COLUMNS
|
||||||
get() = listOf(NAME, SOURCE, TARGET) + Property.entries.map { column(it.key) }
|
get() = listOf(NAME, SOURCE, TARGET, ICON) + Property.entries.map { column(it.key) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -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_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.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
|
||||||
|
|
@ -10,6 +11,7 @@ import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.heightIn
|
import androidx.compose.foundation.layout.heightIn
|
||||||
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.Switch
|
import androidx.compose.material3.Switch
|
||||||
|
|
@ -24,10 +26,12 @@ 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
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import com.pixelized.rplexicon.ui.composable.AsyncImage
|
||||||
import com.pixelized.rplexicon.ui.theme.LexiconTheme
|
import com.pixelized.rplexicon.ui.theme.LexiconTheme
|
||||||
|
|
||||||
@Stable
|
@Stable
|
||||||
data class AlterationItemUio(
|
data class AlterationItemUio(
|
||||||
|
val icon: Uri?,
|
||||||
val label: String,
|
val label: String,
|
||||||
val source: String,
|
val source: String,
|
||||||
val subLabel: String?,
|
val subLabel: String?,
|
||||||
|
|
@ -51,6 +55,14 @@ fun AlterationItem(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.spacedBy(space = 8.dp),
|
horizontalArrangement = Arrangement.spacedBy(space = 8.dp),
|
||||||
) {
|
) {
|
||||||
|
alteration.icon?.let { uri ->
|
||||||
|
AsyncImage(
|
||||||
|
modifier = Modifier.size(size = 36.dp),
|
||||||
|
model = uri,
|
||||||
|
contentDescription = null,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.weight(weight = 1f),
|
modifier = Modifier.weight(weight = 1f),
|
||||||
verticalArrangement = Arrangement.spacedBy(space = 2.dp),
|
verticalArrangement = Arrangement.spacedBy(space = 2.dp),
|
||||||
|
|
@ -101,12 +113,14 @@ private fun RollAlterationPreview(
|
||||||
private class RollAlterationPreviewProvider : PreviewParameterProvider<AlterationItemUio> {
|
private class RollAlterationPreviewProvider : PreviewParameterProvider<AlterationItemUio> {
|
||||||
override val values: Sequence<AlterationItemUio> = sequenceOf(
|
override val values: Sequence<AlterationItemUio> = sequenceOf(
|
||||||
AlterationItemUio(
|
AlterationItemUio(
|
||||||
|
icon = null,
|
||||||
label = "Bénédiction",
|
label = "Bénédiction",
|
||||||
subLabel = "Bless",
|
subLabel = "Bless",
|
||||||
source = "Clerc",
|
source = "Clerc",
|
||||||
checked = false,
|
checked = false,
|
||||||
),
|
),
|
||||||
AlterationItemUio(
|
AlterationItemUio(
|
||||||
|
icon = null,
|
||||||
label = "Assistance",
|
label = "Assistance",
|
||||||
subLabel = "Guidance",
|
subLabel = "Guidance",
|
||||||
source = "Clerc",
|
source = "Clerc",
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ 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 {
|
||||||
AlterationItemUio(
|
AlterationItemUio(
|
||||||
|
icon = it.icon,
|
||||||
label = it.name,
|
label = it.name,
|
||||||
source = it.source,
|
source = it.source,
|
||||||
subLabel = descriptionRepository.find(
|
subLabel = descriptionRepository.find(
|
||||||
|
|
@ -141,6 +142,7 @@ class AlterationFactory @Inject constructor(
|
||||||
.getAlterations(character = diceThrow.character, *properties.toTypedArray())
|
.getAlterations(character = diceThrow.character, *properties.toTypedArray())
|
||||||
.map {
|
.map {
|
||||||
AlterationItemUio(
|
AlterationItemUio(
|
||||||
|
icon = it.icon,
|
||||||
label = it.name,
|
label = it.name,
|
||||||
source = it.source,
|
source = it.source,
|
||||||
checked = firebaseRepository.getStatus(
|
checked = firebaseRepository.getStatus(
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ fun rememberRollAlterations() = remember {
|
||||||
name = "Barbarian",
|
name = "Barbarian",
|
||||||
alterations = listOf(
|
alterations = listOf(
|
||||||
AlterationItemUio(
|
AlterationItemUio(
|
||||||
|
icon = null,
|
||||||
label = "Rage",
|
label = "Rage",
|
||||||
subLabel = "Rage",
|
subLabel = "Rage",
|
||||||
source = "Barbare",
|
source = "Barbare",
|
||||||
|
|
@ -27,12 +28,14 @@ fun rememberRollAlterations() = remember {
|
||||||
name = "Barbarian",
|
name = "Barbarian",
|
||||||
alterations = listOf(
|
alterations = listOf(
|
||||||
AlterationItemUio(
|
AlterationItemUio(
|
||||||
|
icon = null,
|
||||||
label = "Inspiration bardique",
|
label = "Inspiration bardique",
|
||||||
subLabel = "Bardic inspiration",
|
subLabel = "Bardic inspiration",
|
||||||
source = "Barde",
|
source = "Barde",
|
||||||
checked = false
|
checked = false
|
||||||
),
|
),
|
||||||
AlterationItemUio(
|
AlterationItemUio(
|
||||||
|
icon = null,
|
||||||
label = "Bénédiction",
|
label = "Bénédiction",
|
||||||
subLabel = "Bless",
|
subLabel = "Bless",
|
||||||
source = "Barde",
|
source = "Barde",
|
||||||
|
|
@ -44,6 +47,7 @@ fun rememberRollAlterations() = remember {
|
||||||
name = "Barbarian",
|
name = "Barbarian",
|
||||||
alterations = listOf(
|
alterations = listOf(
|
||||||
AlterationItemUio(
|
AlterationItemUio(
|
||||||
|
icon = null,
|
||||||
label = "Cape de protection",
|
label = "Cape de protection",
|
||||||
subLabel = "Cape of protection",
|
subLabel = "Cape of protection",
|
||||||
source = "Equipement",
|
source = "Equipement",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue