Add description for object actions.
This commit is contained in:
parent
805a8f673f
commit
43ea748e51
4 changed files with 22 additions and 15 deletions
|
|
@ -41,12 +41,12 @@ fun ObjectItem(
|
|||
modifier: Modifier = Modifier,
|
||||
padding: PaddingValues = PaddingValues(top = 4.dp, bottom = 4.dp, start = 16.dp, end = 16.dp),
|
||||
item: ObjectItemUio,
|
||||
onObject: (String) -> Unit,
|
||||
onUse: (String) -> Unit,
|
||||
onObject: (ObjectItemUio) -> Unit,
|
||||
onUse: (ObjectItemUio) -> Unit,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.clickable { onObject(item.name) }
|
||||
.clickable { onObject(item) }
|
||||
.padding(paddingValues = padding)
|
||||
.then(other = modifier),
|
||||
horizontalArrangement = Arrangement.spacedBy(space = 12.dp),
|
||||
|
|
@ -85,7 +85,7 @@ fun ObjectItem(
|
|||
width = 1.dp,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
),
|
||||
onClick = { onUse(item.name) },
|
||||
onClick = { onUse(item) },
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.character_sheet_action_spell_cast),
|
||||
|
|
|
|||
|
|
@ -77,12 +77,12 @@ fun ActionPage(
|
|||
overlay.showOverlay()
|
||||
}
|
||||
},
|
||||
onObject = { id ->
|
||||
|
||||
onObject = {
|
||||
skillViewModel.showSkillDetailDialog(item = it.name)
|
||||
},
|
||||
onUseObject = { id ->
|
||||
objectsViewModel.onUse(id)?.let {
|
||||
overlay.prepareRoll(diceThrow = it)
|
||||
onUseObject = {
|
||||
objectsViewModel.onUse(it.name)?.let { throws ->
|
||||
overlay.prepareRoll(diceThrow = throws)
|
||||
overlay.showOverlay()
|
||||
}
|
||||
},
|
||||
|
|
@ -94,7 +94,7 @@ fun ActionPage(
|
|||
overlay.showOverlay()
|
||||
},
|
||||
onSkillInfo = {
|
||||
skillViewModel.showSkillDetailDialog(item = it)
|
||||
skillViewModel.showSkillDetailDialog(item = it.label)
|
||||
},
|
||||
onSpellLevel = { level: Int, value: Int, max: Int ->
|
||||
spellsViewModel.showSpellEditDialog(level = level, value = value, max = max)
|
||||
|
|
@ -153,8 +153,8 @@ fun ActionsPageContent(
|
|||
spells: State<List<Pair<SpellHeaderUio, List<SpellUio>>>>,
|
||||
onAttackHit: (id: String) -> Unit,
|
||||
onAttackDamage: (id: String) -> Unit,
|
||||
onObject: (id: String) -> Unit,
|
||||
onUseObject: (id: String) -> Unit,
|
||||
onObject: (ObjectItemUio) -> Unit,
|
||||
onUseObject: (ObjectItemUio) -> Unit,
|
||||
onSkillThrow: (SkillItemUio) -> Unit,
|
||||
onSkillCount: (SkillItemUio) -> Unit,
|
||||
onSkillInfo: (SkillItemUio) -> Unit,
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@ class ObjectsViewModel @Inject constructor(
|
|||
private val _objects = mutableStateOf<List<ObjectItemUio>>(emptyList())
|
||||
val objects: State<List<ObjectItemUio>> get() = _objects
|
||||
|
||||
private val _dialog = mutableStateOf<SkillDetailUio?>(null)
|
||||
val dialog: State<SkillDetailUio?> get() = _dialog
|
||||
|
||||
init {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
objectsRepository.data.collect { objects ->
|
||||
|
|
@ -44,6 +47,10 @@ class ObjectsViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
fun onDetail(name: String) {
|
||||
|
||||
}
|
||||
|
||||
fun onUse(name: String): DiceThrow? {
|
||||
val item = objectsRepository.find(character = character, item = name)
|
||||
return item?.let {
|
||||
|
|
|
|||
|
|
@ -104,12 +104,12 @@ class SkillsViewModel @Inject constructor(
|
|||
skill = name,
|
||||
)
|
||||
|
||||
fun showSkillDetailDialog(item: SkillItemUio) {
|
||||
fun showSkillDetailDialog(item: String) {
|
||||
_skillDetailDialog.value = descriptionRepository
|
||||
.find(name = item.label)
|
||||
.find(name = item)
|
||||
?.let { description ->
|
||||
SkillDetailUio(
|
||||
name = item.label,
|
||||
name = item,
|
||||
original = description.original,
|
||||
description = description.description
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue