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
|
package com.pixelized.rplexicon.data.model
|
||||||
|
|
||||||
|
import android.net.Uri
|
||||||
|
|
||||||
data class ObjectAction(
|
data class ObjectAction(
|
||||||
val prefix: String?,
|
val prefix: String?,
|
||||||
|
val icon: Uri?,
|
||||||
val name: String,
|
val name: String,
|
||||||
val effect: Throw?,
|
val effect: Throw?,
|
||||||
)
|
)
|
||||||
|
|
@ -24,6 +24,7 @@ class ObjectActionParser @Inject constructor(
|
||||||
objects.getOrPut(character) { mutableListOf() }.add(
|
objects.getOrPut(character) { mutableListOf() }.add(
|
||||||
ObjectAction(
|
ObjectAction(
|
||||||
prefix = row.parse(column = PREFIX),
|
prefix = row.parse(column = PREFIX),
|
||||||
|
icon = row.parseUri(column = ICON),
|
||||||
name = name,
|
name = name,
|
||||||
effect = throwParser.parse(value = row.parse(column = EFFECT)),
|
effect = throwParser.parse(value = row.parse(column = EFFECT)),
|
||||||
)
|
)
|
||||||
|
|
@ -40,6 +41,7 @@ class ObjectActionParser @Inject constructor(
|
||||||
private val PREFIX = column("Préfix")
|
private val PREFIX = column("Préfix")
|
||||||
private val NAME = column("Nom")
|
private val NAME = column("Nom")
|
||||||
private val EFFECT = column("Effet")
|
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_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.BorderStroke
|
import androidx.compose.foundation.BorderStroke
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
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.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.material.minimumInteractiveComponentSize
|
import androidx.compose.material.minimumInteractiveComponentSize
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.OutlinedButton
|
import androidx.compose.material3.OutlinedButton
|
||||||
|
|
@ -27,10 +29,12 @@ import androidx.compose.ui.tooling.preview.Preview
|
||||||
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.data.model.Throw
|
import com.pixelized.rplexicon.data.model.Throw
|
||||||
|
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 ObjectItemUio(
|
data class ObjectItemUio(
|
||||||
|
val icon: Uri?,
|
||||||
val prefix: String?,
|
val prefix: String?,
|
||||||
val name: String,
|
val name: String,
|
||||||
val original: String?,
|
val original: String?,
|
||||||
|
|
@ -51,9 +55,16 @@ fun ObjectItem(
|
||||||
.minimumInteractiveComponentSize()
|
.minimumInteractiveComponentSize()
|
||||||
.padding(paddingValues = padding)
|
.padding(paddingValues = padding)
|
||||||
.then(other = modifier),
|
.then(other = modifier),
|
||||||
horizontalArrangement = Arrangement.spacedBy(space = 12.dp),
|
horizontalArrangement = Arrangement.spacedBy(space = 8.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
|
item.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)
|
||||||
) {
|
) {
|
||||||
|
|
@ -101,6 +112,7 @@ private fun ObjectItemPreview() {
|
||||||
ObjectItem(
|
ObjectItem(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
item = ObjectItemUio(
|
item = ObjectItemUio(
|
||||||
|
icon = null,
|
||||||
prefix = "Parchemin de ",
|
prefix = "Parchemin de ",
|
||||||
name = "Bénédiction",
|
name = "Bénédiction",
|
||||||
original = "Blessing",
|
original = "Blessing",
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,14 @@ fun rememberObjectListStatePreview() = remember {
|
||||||
mutableStateOf(
|
mutableStateOf(
|
||||||
listOf(
|
listOf(
|
||||||
ObjectItemUio(
|
ObjectItemUio(
|
||||||
|
icon = null,
|
||||||
prefix = null,
|
prefix = null,
|
||||||
name = "Potion de guérison",
|
name = "Potion de guérison",
|
||||||
original = "Healing potion",
|
original = "Healing potion",
|
||||||
effect = null,
|
effect = null,
|
||||||
),
|
),
|
||||||
ObjectItemUio(
|
ObjectItemUio(
|
||||||
|
icon = null,
|
||||||
prefix = "Parchemin de",
|
prefix = "Parchemin de",
|
||||||
name = "Bénédiction",
|
name = "Bénédiction",
|
||||||
original = "Blessing",
|
original = "Blessing",
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ class ObjectsViewModel @Inject constructor(
|
||||||
val data = objects[character]?.map {
|
val data = objects[character]?.map {
|
||||||
ObjectItemUio(
|
ObjectItemUio(
|
||||||
prefix = it.prefix,
|
prefix = it.prefix,
|
||||||
|
icon = it.icon,
|
||||||
name = it.name,
|
name = it.name,
|
||||||
original = descriptionRepository.find(name = it.name)?.original,
|
original = descriptionRepository.find(name = it.name)?.original,
|
||||||
effect = it.effect,
|
effect = it.effect,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue