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