Change Skill & Alteration layout, remove the info button.
This commit is contained in:
		
							parent
							
								
									7b6f5b6430
								
							
						
					
					
						commit
						bb1575ea84
					
				
					 5 changed files with 56 additions and 44 deletions
				
			
		| 
						 | 
				
			
			@ -5,6 +5,8 @@ import android.content.res.Configuration.UI_MODE_NIGHT_YES
 | 
			
		|||
import androidx.compose.foundation.clickable
 | 
			
		||||
import androidx.compose.foundation.layout.Arrangement
 | 
			
		||||
import androidx.compose.foundation.layout.Column
 | 
			
		||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
 | 
			
		||||
import androidx.compose.foundation.layout.FlowRow
 | 
			
		||||
import androidx.compose.foundation.layout.PaddingValues
 | 
			
		||||
import androidx.compose.foundation.layout.Row
 | 
			
		||||
import androidx.compose.foundation.layout.fillMaxWidth
 | 
			
		||||
| 
						 | 
				
			
			@ -23,6 +25,7 @@ import androidx.compose.runtime.Stable
 | 
			
		|||
import androidx.compose.ui.Alignment
 | 
			
		||||
import androidx.compose.ui.Modifier
 | 
			
		||||
import androidx.compose.ui.text.font.FontWeight
 | 
			
		||||
import androidx.compose.ui.text.style.TextOverflow
 | 
			
		||||
import androidx.compose.ui.tooling.preview.Preview
 | 
			
		||||
import androidx.compose.ui.tooling.preview.PreviewParameter
 | 
			
		||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
 | 
			
		||||
| 
						 | 
				
			
			@ -32,10 +35,12 @@ import com.pixelized.rplexicon.ui.theme.LexiconTheme
 | 
			
		|||
@Stable
 | 
			
		||||
data class AlterationItemUio(
 | 
			
		||||
    val label: String,
 | 
			
		||||
    val original: String?,
 | 
			
		||||
    val subLabel: String?,
 | 
			
		||||
    val checked: Boolean,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@OptIn(ExperimentalLayoutApi::class)
 | 
			
		||||
@Composable
 | 
			
		||||
fun AlterationItem(
 | 
			
		||||
    modifier: Modifier = Modifier,
 | 
			
		||||
| 
						 | 
				
			
			@ -46,43 +51,53 @@ fun AlterationItem(
 | 
			
		|||
) {
 | 
			
		||||
    Row(
 | 
			
		||||
        modifier = Modifier
 | 
			
		||||
            .clickable { onClick(alteration.label) }
 | 
			
		||||
            .clickable { onInfo(alteration.label) }
 | 
			
		||||
            .heightIn(min = 52.dp)
 | 
			
		||||
            .padding(paddingValues = padding)
 | 
			
		||||
            .then(other = modifier),
 | 
			
		||||
        verticalAlignment = Alignment.CenterVertically,
 | 
			
		||||
        horizontalArrangement = Arrangement.SpaceBetween,
 | 
			
		||||
        horizontalArrangement = Arrangement.spacedBy(space = 8.dp),
 | 
			
		||||
    ) {
 | 
			
		||||
        Column(
 | 
			
		||||
            modifier = Modifier.weight(weight = 1f),
 | 
			
		||||
            verticalArrangement = Arrangement.spacedBy(space = 2.dp),
 | 
			
		||||
        ) {
 | 
			
		||||
            Text(
 | 
			
		||||
                style = MaterialTheme.typography.bodyMedium,
 | 
			
		||||
                fontWeight = FontWeight.Bold,
 | 
			
		||||
                text = alteration.label,
 | 
			
		||||
            )
 | 
			
		||||
            FlowRow(
 | 
			
		||||
                horizontalArrangement = Arrangement.spacedBy(space = 4.dp),
 | 
			
		||||
            ) {
 | 
			
		||||
                Text(
 | 
			
		||||
                    modifier = Modifier.alignByBaseline(),
 | 
			
		||||
                    style = MaterialTheme.typography.bodyMedium,
 | 
			
		||||
                    fontWeight = FontWeight.Bold,
 | 
			
		||||
                    overflow = TextOverflow.Ellipsis,
 | 
			
		||||
                    maxLines = 1,
 | 
			
		||||
                    text = alteration.label,
 | 
			
		||||
                )
 | 
			
		||||
                alteration.original?.let {
 | 
			
		||||
                    Text(
 | 
			
		||||
                        modifier = Modifier.alignByBaseline(),
 | 
			
		||||
                        style = MaterialTheme.typography.labelSmall,
 | 
			
		||||
                        fontWeight = FontWeight.Light,
 | 
			
		||||
                        overflow = TextOverflow.Ellipsis,
 | 
			
		||||
                        maxLines = 1,
 | 
			
		||||
                        text = it,
 | 
			
		||||
                    )
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            alteration.subLabel?.let {
 | 
			
		||||
                Text(
 | 
			
		||||
                    style = MaterialTheme.typography.labelSmall,
 | 
			
		||||
                    fontWeight = FontWeight.Light,
 | 
			
		||||
                    fontWeight = FontWeight.Normal,
 | 
			
		||||
                    text = it,
 | 
			
		||||
                )
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Row {
 | 
			
		||||
            IconButton(onClick = { onInfo(alteration.label) }) {
 | 
			
		||||
                Icon(
 | 
			
		||||
                    imageVector = Icons.Outlined.Info,
 | 
			
		||||
                    contentDescription = null,
 | 
			
		||||
                )
 | 
			
		||||
            }
 | 
			
		||||
            Switch(
 | 
			
		||||
                enabled = true,
 | 
			
		||||
                checked = alteration.checked,
 | 
			
		||||
                onCheckedChange = { onClick(alteration.label) },
 | 
			
		||||
            )
 | 
			
		||||
        }
 | 
			
		||||
        Switch(
 | 
			
		||||
            enabled = true,
 | 
			
		||||
            checked = alteration.checked,
 | 
			
		||||
            onCheckedChange = { onClick(alteration.label) },
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -108,16 +123,19 @@ private class RollAlterationPreviewProvider : PreviewParameterProvider<Alteratio
 | 
			
		|||
    override val values: Sequence<AlterationItemUio> = sequenceOf(
 | 
			
		||||
        AlterationItemUio(
 | 
			
		||||
            label = "Critique",
 | 
			
		||||
            original = "Critical",
 | 
			
		||||
            checked = false,
 | 
			
		||||
            subLabel = null,
 | 
			
		||||
        ),
 | 
			
		||||
        AlterationItemUio(
 | 
			
		||||
            label = "Rage",
 | 
			
		||||
            original = "Rage",
 | 
			
		||||
            checked = true,
 | 
			
		||||
            subLabel = "Barbare",
 | 
			
		||||
        ),
 | 
			
		||||
        AlterationItemUio(
 | 
			
		||||
            label = "Bénédiction",
 | 
			
		||||
            original = "Bless",
 | 
			
		||||
            checked = false,
 | 
			
		||||
            subLabel = "Clerc",
 | 
			
		||||
        ),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,16 +7,10 @@ import androidx.compose.foundation.clickable
 | 
			
		|||
import androidx.compose.foundation.layout.Arrangement
 | 
			
		||||
import androidx.compose.foundation.layout.Box
 | 
			
		||||
import androidx.compose.foundation.layout.Column
 | 
			
		||||
import androidx.compose.foundation.layout.ExperimentalLayoutApi
 | 
			
		||||
import androidx.compose.foundation.layout.FlowRow
 | 
			
		||||
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.material.icons.Icons
 | 
			
		||||
import androidx.compose.material.icons.outlined.Info
 | 
			
		||||
import androidx.compose.material3.Icon
 | 
			
		||||
import androidx.compose.material3.IconButton
 | 
			
		||||
import androidx.compose.material3.MaterialTheme
 | 
			
		||||
import androidx.compose.material3.Surface
 | 
			
		||||
import androidx.compose.material3.Text
 | 
			
		||||
| 
						 | 
				
			
			@ -67,7 +61,7 @@ fun SkillItem(
 | 
			
		|||
) {
 | 
			
		||||
    Box(
 | 
			
		||||
        modifier = Modifier
 | 
			
		||||
            .clickable { onSkill(skill) }
 | 
			
		||||
            .clickable { onInfo(skill) }
 | 
			
		||||
            .padding(paddingValues = padding)
 | 
			
		||||
            .then(other = modifier),
 | 
			
		||||
        contentAlignment = Alignment.Center,
 | 
			
		||||
| 
						 | 
				
			
			@ -124,15 +118,6 @@ fun SkillItem(
 | 
			
		|||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (skill.haveDetail) {
 | 
			
		||||
                IconButton(onClick = { onInfo(skill) }) {
 | 
			
		||||
                    Icon(
 | 
			
		||||
                        imageVector = Icons.Outlined.Info,
 | 
			
		||||
                        contentDescription = null,
 | 
			
		||||
                    )
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            skill.effect?.let { effect ->
 | 
			
		||||
                DiceButton(
 | 
			
		||||
                    icon = effect.icon,
 | 
			
		||||
| 
						 | 
				
			
			@ -145,6 +130,7 @@ fun SkillItem(
 | 
			
		|||
                CounterButton(
 | 
			
		||||
                    value = skill.value,
 | 
			
		||||
                    max = it,
 | 
			
		||||
                    onClick = { onSkill(skill) }
 | 
			
		||||
                )
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,7 +2,6 @@ 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 androidx.compose.foundation.clickable
 | 
			
		||||
import androidx.compose.foundation.layout.Arrangement
 | 
			
		||||
import androidx.compose.foundation.layout.Column
 | 
			
		||||
import androidx.compose.foundation.layout.PaddingValues
 | 
			
		||||
| 
						 | 
				
			
			@ -50,11 +49,7 @@ fun SpellHeader(
 | 
			
		|||
    onSpell: (level: Int, value: Int, max: Int) -> Unit,
 | 
			
		||||
) {
 | 
			
		||||
    Column(
 | 
			
		||||
        modifier = Modifier
 | 
			
		||||
            .clickable(enabled = header.count != null) {
 | 
			
		||||
                header.count?.let { onSpell(header.level, it.value, it.max) }
 | 
			
		||||
            }
 | 
			
		||||
            .then(other = modifier),
 | 
			
		||||
        modifier = modifier,
 | 
			
		||||
    ) {
 | 
			
		||||
        Surface {
 | 
			
		||||
            Row(
 | 
			
		||||
| 
						 | 
				
			
			@ -92,9 +87,12 @@ fun SpellHeader(
 | 
			
		|||
                )
 | 
			
		||||
                header.count?.let { count ->
 | 
			
		||||
                    CounterButton(
 | 
			
		||||
                        modifier = Modifier.alignByBaseline().offset(x = 4.dp),
 | 
			
		||||
                        modifier = Modifier
 | 
			
		||||
                            .alignByBaseline()
 | 
			
		||||
                            .offset(x = 4.dp),
 | 
			
		||||
                        value = count.value,
 | 
			
		||||
                        max = count.max,
 | 
			
		||||
                        onClick = { onSpell(header.level, count.value, count.max) }
 | 
			
		||||
                    )
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -5,12 +5,14 @@ import com.pixelized.rplexicon.model.DiceThrow
 | 
			
		|||
import com.pixelized.rplexicon.model.Property
 | 
			
		||||
import com.pixelized.rplexicon.repository.data.ActionRepository
 | 
			
		||||
import com.pixelized.rplexicon.repository.data.AlterationRepository
 | 
			
		||||
import com.pixelized.rplexicon.repository.data.DescriptionRepository
 | 
			
		||||
import com.pixelized.rplexicon.repository.data.SkillRepository
 | 
			
		||||
import com.pixelized.rplexicon.repository.data.SpellRepository
 | 
			
		||||
import com.pixelized.rplexicon.ui.screens.character.composable.actions.AlterationItemUio
 | 
			
		||||
import javax.inject.Inject
 | 
			
		||||
 | 
			
		||||
class AlterationFactory @Inject constructor(
 | 
			
		||||
    private val descriptionRepository: DescriptionRepository,
 | 
			
		||||
    private val actionRepository: ActionRepository,
 | 
			
		||||
    private val spellRepository: SpellRepository,
 | 
			
		||||
    private val skillRepository: SkillRepository,
 | 
			
		||||
| 
						 | 
				
			
			@ -18,8 +20,10 @@ class AlterationFactory @Inject constructor(
 | 
			
		|||
) {
 | 
			
		||||
    fun convert(character: String, alterations: List<Alteration>): List<AlterationItemUio> {
 | 
			
		||||
        return alterations.map {
 | 
			
		||||
            val description = descriptionRepository.find(it.name)
 | 
			
		||||
            AlterationItemUio(
 | 
			
		||||
                label = it.name,
 | 
			
		||||
                original = description?.original,
 | 
			
		||||
                checked = alterationRepository.getStatus(character, it.name),
 | 
			
		||||
                subLabel = it.source,
 | 
			
		||||
            )
 | 
			
		||||
| 
						 | 
				
			
			@ -103,8 +107,10 @@ class AlterationFactory @Inject constructor(
 | 
			
		|||
        return alterationRepository
 | 
			
		||||
            .getAlterations(character = diceThrow.character, *properties.toTypedArray())
 | 
			
		||||
            .map {
 | 
			
		||||
                val description = descriptionRepository.find(it.name)
 | 
			
		||||
                AlterationItemUio(
 | 
			
		||||
                    label = it.name,
 | 
			
		||||
                    original = description?.original,
 | 
			
		||||
                    checked = alterationRepository.getStatus(diceThrow.character, it.name),
 | 
			
		||||
                    subLabel = it.source,
 | 
			
		||||
                )
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,21 +13,25 @@ fun rememberRollAlterations() = remember {
 | 
			
		|||
        listOf(
 | 
			
		||||
            AlterationItemUio(
 | 
			
		||||
                label = "Rage",
 | 
			
		||||
                original = "Rage",
 | 
			
		||||
                subLabel = "Barbare",
 | 
			
		||||
                checked = false,
 | 
			
		||||
            ),
 | 
			
		||||
            AlterationItemUio(
 | 
			
		||||
                label = "Inspiration bardique",
 | 
			
		||||
                original = "Bardic inspiration",
 | 
			
		||||
                subLabel = "Barde",
 | 
			
		||||
                checked = false
 | 
			
		||||
            ),
 | 
			
		||||
            AlterationItemUio(
 | 
			
		||||
                label = "Bénédiction",
 | 
			
		||||
                original = "Bless",
 | 
			
		||||
                subLabel = "Clerc",
 | 
			
		||||
                checked = false,
 | 
			
		||||
            ),
 | 
			
		||||
            AlterationItemUio(
 | 
			
		||||
                label = "Cape de protection",
 | 
			
		||||
                original = "Cape of protection",
 | 
			
		||||
                subLabel = "Équipement",
 | 
			
		||||
                checked = true
 | 
			
		||||
            ),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue