Add icon to objects
This commit is contained in:
parent
757ad75804
commit
60c11e6192
5 changed files with 22 additions and 2 deletions
|
|
@ -1,7 +1,10 @@
|
|||
package com.pixelized.rplexicon.data.model
|
||||
|
||||
import android.net.Uri
|
||||
|
||||
data class ObjectAction(
|
||||
val prefix: String?,
|
||||
val icon: Uri?,
|
||||
val name: String,
|
||||
val effect: Throw?,
|
||||
)
|
||||
|
|
@ -24,6 +24,7 @@ class ObjectActionParser @Inject constructor(
|
|||
objects.getOrPut(character) { mutableListOf() }.add(
|
||||
ObjectAction(
|
||||
prefix = row.parse(column = PREFIX),
|
||||
icon = row.parseUri(column = ICON),
|
||||
name = name,
|
||||
effect = throwParser.parse(value = row.parse(column = EFFECT)),
|
||||
)
|
||||
|
|
@ -40,6 +41,7 @@ class ObjectActionParser @Inject constructor(
|
|||
private val PREFIX = column("Préfix")
|
||||
private val NAME = column("Nom")
|
||||
private val EFFECT = column("Effet")
|
||||
private val COLUMNS = listOf(PREFIX, NAME, EFFECT)
|
||||
private val ICON = column("Icone")
|
||||
private val COLUMNS = listOf(PREFIX, NAME, EFFECT, 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.compose.foundation.BorderStroke
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
|
|
@ -10,6 +11,7 @@ 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.material.minimumInteractiveComponentSize
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
|
|
@ -27,10 +29,12 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.unit.dp
|
||||
import com.pixelized.rplexicon.R
|
||||
import com.pixelized.rplexicon.data.model.Throw
|
||||
import com.pixelized.rplexicon.ui.composable.AsyncImage
|
||||
import com.pixelized.rplexicon.ui.theme.LexiconTheme
|
||||
|
||||
@Stable
|
||||
data class ObjectItemUio(
|
||||
val icon: Uri?,
|
||||
val prefix: String?,
|
||||
val name: String,
|
||||
val original: String?,
|
||||
|
|
@ -51,9 +55,16 @@ fun ObjectItem(
|
|||
.minimumInteractiveComponentSize()
|
||||
.padding(paddingValues = padding)
|
||||
.then(other = modifier),
|
||||
horizontalArrangement = Arrangement.spacedBy(space = 12.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(space = 8.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
item.icon?.let { uri ->
|
||||
AsyncImage(
|
||||
modifier = Modifier.size(size = 36.dp),
|
||||
model = uri,
|
||||
contentDescription = null,
|
||||
)
|
||||
}
|
||||
Column(
|
||||
modifier = Modifier.weight(weight = 1f)
|
||||
) {
|
||||
|
|
@ -101,6 +112,7 @@ private fun ObjectItemPreview() {
|
|||
ObjectItem(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
item = ObjectItemUio(
|
||||
icon = null,
|
||||
prefix = "Parchemin de ",
|
||||
name = "Bénédiction",
|
||||
original = "Blessing",
|
||||
|
|
|
|||
|
|
@ -13,12 +13,14 @@ fun rememberObjectListStatePreview() = remember {
|
|||
mutableStateOf(
|
||||
listOf(
|
||||
ObjectItemUio(
|
||||
icon = null,
|
||||
prefix = null,
|
||||
name = "Potion de guérison",
|
||||
original = "Healing potion",
|
||||
effect = null,
|
||||
),
|
||||
ObjectItemUio(
|
||||
icon = null,
|
||||
prefix = "Parchemin de",
|
||||
name = "Bénédiction",
|
||||
original = "Blessing",
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ class ObjectsViewModel @Inject constructor(
|
|||
val data = objects[character]?.map {
|
||||
ObjectItemUio(
|
||||
prefix = it.prefix,
|
||||
icon = it.icon,
|
||||
name = it.name,
|
||||
original = descriptionRepository.find(name = it.name)?.original,
|
||||
effect = it.effect,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue