From 9746b8e2438e45387ca73553a94cf453ffb30849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Ma=C5=A1a?= Date: Mon, 15 Feb 2021 23:53:19 +0100 Subject: [PATCH 1/3] Reuse SingleLineTextValue in SpellDetail --- .../core/ui/primitives/CardContainer.kt | 22 ++++++++--- .../ui/character/spells/dialog/SpellDetail.kt | 39 ++++--------------- 2 files changed, 24 insertions(+), 37 deletions(-) diff --git a/app/core/src/main/java/cz/frantisekmasa/wfrp_master/core/ui/primitives/CardContainer.kt b/app/core/src/main/java/cz/frantisekmasa/wfrp_master/core/ui/primitives/CardContainer.kt index 0f4e94705..68200c8a6 100644 --- a/app/core/src/main/java/cz/frantisekmasa/wfrp_master/core/ui/primitives/CardContainer.kt +++ b/app/core/src/main/java/cz/frantisekmasa/wfrp_master/core/ui/primitives/CardContainer.kt @@ -14,6 +14,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.ColorFilter import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.vectorResource +import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp @@ -24,14 +25,19 @@ fun CardContainer( bodyPadding: PaddingValues = PaddingValues(), content: @Composable ColumnScope.() -> Unit, ) { - Box(Modifier.padding(vertical = 6.dp).then(modifier)) { + Box( + Modifier + .padding(vertical = 6.dp) + .then(modifier)) { Card( modifier = Modifier.fillMaxWidth(), elevation = 2.dp, shape = RoundedCornerShape(4.dp) ) { Column( - Modifier.padding(vertical = 16.dp, horizontal = 8.dp).padding(bodyPadding), + Modifier + .padding(vertical = 16.dp, horizontal = 8.dp) + .padding(bodyPadding), content = content ) } @@ -54,7 +60,8 @@ fun CardTitle(text: String, @DrawableRes iconRes: Int? = null) { Image( vectorResource(iconRes), VisualOnlyIconDescription, - Modifier.padding(end = 4.dp) + Modifier + .padding(end = 4.dp) .width(24.dp) .height(24.dp), colorFilter = ColorFilter.tint(MaterialTheme.colors.onSurface), @@ -75,15 +82,20 @@ fun MultiLineTextValue(@StringRes labelRes: Int, value: String) { } @Composable -fun SingleLineTextValue(@StringRes labelRes: Int, value: String) { +fun SingleLineTextValue(@StringRes labelRes: Int, value: AnnotatedString) { if (value.isBlank()) return Row { Text( stringResource(labelRes) + ":", fontWeight = FontWeight.Bold, - modifier = Modifier.padding(end = 4.dp) + modifier = Modifier.padding(end = Spacing.tiny), ) Text(value) } +} + +@Composable +fun SingleLineTextValue(@StringRes labelRes: Int, value: String) { + SingleLineTextValue(labelRes, AnnotatedString(value)) } \ No newline at end of file diff --git a/app/src/main/java/cz/muni/fi/rpg/ui/character/spells/dialog/SpellDetail.kt b/app/src/main/java/cz/muni/fi/rpg/ui/character/spells/dialog/SpellDetail.kt index 0654f69a8..eb1115aa6 100644 --- a/app/src/main/java/cz/muni/fi/rpg/ui/character/spells/dialog/SpellDetail.kt +++ b/app/src/main/java/cz/muni/fi/rpg/ui/character/spells/dialog/SpellDetail.kt @@ -15,6 +15,7 @@ import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import cz.frantisekmasa.wfrp_master.core.ui.buttons.CloseButton +import cz.frantisekmasa.wfrp_master.core.ui.primitives.SingleLineTextValue import cz.frantisekmasa.wfrp_master.core.ui.scaffolding.SubheadBar import cz.muni.fi.rpg.R import cz.muni.fi.rpg.model.domain.spells.Spell @@ -54,9 +55,9 @@ fun SpellDetail( } Column(Modifier.padding(BodyPadding)) { - TextItem( - label = stringResource(R.string.spell_casting_number_shortcut), - value = with(AnnotatedString.Builder()) { + SingleLineTextValue( + R.string.spell_casting_number_shortcut, + with(AnnotatedString.Builder()) { if (spell.castingNumber != spell.effectiveCastingNumber) { pushStyle(SpanStyle(textDecoration = TextDecoration.LineThrough)) append(spell.castingNumber.toString()) @@ -71,20 +72,11 @@ fun SpellDetail( } ) - TextItem( - label = stringResource(R.string.label_spell_range), - value = spell.range, - ) + SingleLineTextValue(R.string.label_spell_range, spell.range) - TextItem( - label = stringResource(R.string.label_spell_target), - value = spell.target, - ) + SingleLineTextValue(R.string.label_spell_target, spell.target) - TextItem( - label = stringResource(R.string.label_spell_duration), - value = spell.duration, - ) + SingleLineTextValue(R.string.label_spell_duration, spell.duration) Text( text = spell.effect, @@ -95,23 +87,6 @@ fun SpellDetail( } } -@Composable -private fun TextItem(label: String, value: String) { - TextItem(label, AnnotatedString(value)) -} - -@Composable -private fun TextItem(label: String, value: AnnotatedString) { - Row { - Text( - text = "$label: ", - fontWeight = FontWeight.Bold, - ) - Text(value) - } -} - - @Preview @Composable fun SpellDetailPreview() { From 93d40640829479ecfbb467ec11aef5acce054016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Ma=C5=A1a?= Date: Tue, 16 Feb 2021 00:14:36 +0100 Subject: [PATCH 2/3] Add info about compendium skill to EditSkillDialog --- .../wfrp_master/core/domain/Characteristic.kt | 15 ++++ app/core/src/main/res/values/strings.xml | 14 ++++ .../fi/rpg/ui/character/skills/SkillsCard.kt | 11 +-- .../character/skills/dialog/AddSkillDialog.kt | 1 - .../character/skills/dialog/AdvancesForm.kt | 12 +-- .../skills/dialog/EditSkillDialog.kt | 25 ++++-- .../ui/character/skills/dialog/SkillDetail.kt | 81 +++++++++++++++++++ app/src/main/res/values/strings.xml | 10 --- 8 files changed, 137 insertions(+), 32 deletions(-) create mode 100644 app/src/main/java/cz/muni/fi/rpg/ui/character/skills/dialog/SkillDetail.kt diff --git a/app/core/src/main/java/cz/frantisekmasa/wfrp_master/core/domain/Characteristic.kt b/app/core/src/main/java/cz/frantisekmasa/wfrp_master/core/domain/Characteristic.kt index dca06acbe..eaf4f11ab 100644 --- a/app/core/src/main/java/cz/frantisekmasa/wfrp_master/core/domain/Characteristic.kt +++ b/app/core/src/main/java/cz/frantisekmasa/wfrp_master/core/domain/Characteristic.kt @@ -1,6 +1,7 @@ package cz.frantisekmasa.wfrp_master.core.domain import androidx.annotation.DrawableRes +import androidx.annotation.StringRes import cz.frantisekmasa.wfrp_master.core.R enum class Characteristic { @@ -56,4 +57,18 @@ enum class Characteristic { WEAPON_SKILL -> R.drawable.ic_weapon_skill WILL_POWER -> R.drawable.ic_will_power } + + @StringRes + fun getNameId(): Int = when(this) { + AGILITY -> R.string.label_agility + BALLISTIC_SKILL -> R.string.label_ballistic_skill + DEXTERITY -> R.string.label_dexterity + INITIATIVE -> R.string.label_initiative + INTELLIGENCE -> R.string.label_intelligence + FELLOWSHIP -> R.string.label_fellowship + STRENGTH -> R.string.label_strength + TOUGHNESS -> R.string.label_toughness + WEAPON_SKILL -> R.string.label_weapon_skill + WILL_POWER -> R.string.label_will_power + } } \ No newline at end of file diff --git a/app/core/src/main/res/values/strings.xml b/app/core/src/main/res/values/strings.xml index 5267baf63..16d4ae813 100644 --- a/app/core/src/main/res/values/strings.xml +++ b/app/core/src/main/res/values/strings.xml @@ -23,6 +23,18 @@ Human Gnome + + Agility + Ballistic Skill + Dexterity + Fellowship + Initiative + Intelligence + Strength + Toughness + Weapon Skill + Will Power + @@ -33,6 +45,8 @@ Open Remove Open context menu + Yes + No Cannot be empty! diff --git a/app/src/main/java/cz/muni/fi/rpg/ui/character/skills/SkillsCard.kt b/app/src/main/java/cz/muni/fi/rpg/ui/character/skills/SkillsCard.kt index 1723b4813..96fc9cd8f 100644 --- a/app/src/main/java/cz/muni/fi/rpg/ui/character/skills/SkillsCard.kt +++ b/app/src/main/java/cz/muni/fi/rpg/ui/character/skills/SkillsCard.kt @@ -21,6 +21,7 @@ import cz.muni.fi.rpg.ui.character.skills.dialog.EditSkillDialog import cz.muni.fi.rpg.ui.common.composables.* import cz.muni.fi.rpg.viewModels.CharacterViewModel import cz.muni.fi.rpg.viewModels.SkillsViewModel +import java.util.* @Composable internal fun SkillsCard( @@ -43,22 +44,22 @@ internal fun SkillsCard( size = EmptyUI.Size.Small ) } else { - var editedSkill: Skill? by savedInstanceState { null } + var editedSkillId: UUID? by savedInstanceState { null } for (skill in skills) { SkillItem( skill, characteristics, - onClick = { editedSkill = skill }, + onClick = { editedSkillId = skill.id }, onRemove = { onRemove(skill) }, ) } - editedSkill?.let { skill -> + editedSkillId?.let { skillId -> EditSkillDialog( viewModel = skillsVm, - skill = skill, - onDismissRequest = { editedSkill = null } + skillId = skillId, + onDismissRequest = { editedSkillId = null } ) } } diff --git a/app/src/main/java/cz/muni/fi/rpg/ui/character/skills/dialog/AddSkillDialog.kt b/app/src/main/java/cz/muni/fi/rpg/ui/character/skills/dialog/AddSkillDialog.kt index 81301fb52..0fc217591 100644 --- a/app/src/main/java/cz/muni/fi/rpg/ui/character/skills/dialog/AddSkillDialog.kt +++ b/app/src/main/java/cz/muni/fi/rpg/ui/character/skills/dialog/AddSkillDialog.kt @@ -29,7 +29,6 @@ fun AddSkillDialog(viewModel: SkillsViewModel, onDismissRequest: () -> Unit) { ) is FillingInAdvances -> AdvancesForm( - existingSkill = null, compendiumSkillId = currentState.compendiumSkillId, viewModel = viewModel, onDismissRequest = onDismissRequest, diff --git a/app/src/main/java/cz/muni/fi/rpg/ui/character/skills/dialog/AdvancesForm.kt b/app/src/main/java/cz/muni/fi/rpg/ui/character/skills/dialog/AdvancesForm.kt index fcfe53d1c..4bc2bf75a 100644 --- a/app/src/main/java/cz/muni/fi/rpg/ui/character/skills/dialog/AdvancesForm.kt +++ b/app/src/main/java/cz/muni/fi/rpg/ui/character/skills/dialog/AdvancesForm.kt @@ -20,7 +20,6 @@ import cz.frantisekmasa.wfrp_master.core.ui.primitives.NumberPicker import cz.frantisekmasa.wfrp_master.core.ui.primitives.Spacing import cz.frantisekmasa.wfrp_master.core.ui.scaffolding.SaveAction import cz.muni.fi.rpg.R -import cz.muni.fi.rpg.model.domain.skills.Skill import cz.muni.fi.rpg.ui.common.composables.* import cz.muni.fi.rpg.viewModels.SkillsViewModel import kotlinx.coroutines.Dispatchers @@ -31,13 +30,12 @@ import java.util.* @Composable internal fun AdvancesForm( - existingSkill: Skill?, compendiumSkillId: UUID, viewModel: SkillsViewModel, onDismissRequest: () -> Unit, ) { var saving by remember { mutableStateOf(false) } - var advances by savedInstanceState { existingSkill?.advances ?: 1 } + var advances by savedInstanceState { 1 } Scaffold( topBar = { @@ -45,11 +43,7 @@ internal fun AdvancesForm( navigationIcon = { CloseButton(onDismissRequest) }, title = { Text( - stringResource( - if (existingSkill != null) - R.string.title_skill_edit else - R.string.title_skill_new - ) + stringResource(R.string.title_skill_new) ) }, actions = { @@ -64,7 +58,7 @@ internal fun AdvancesForm( try { viewModel.saveCompendiumSkill( - skillId = existingSkill?.id ?: UUID.randomUUID(), + skillId = UUID.randomUUID(), compendiumSkillId = compendiumSkillId, advances = advances, ) diff --git a/app/src/main/java/cz/muni/fi/rpg/ui/character/skills/dialog/EditSkillDialog.kt b/app/src/main/java/cz/muni/fi/rpg/ui/character/skills/dialog/EditSkillDialog.kt index 16d6b7848..11b7e6f00 100644 --- a/app/src/main/java/cz/muni/fi/rpg/ui/character/skills/dialog/EditSkillDialog.kt +++ b/app/src/main/java/cz/muni/fi/rpg/ui/character/skills/dialog/EditSkillDialog.kt @@ -1,23 +1,34 @@ package cz.muni.fi.rpg.ui.character.skills.dialog import androidx.compose.runtime.Composable -import cz.muni.fi.rpg.model.domain.skills.Skill +import androidx.compose.runtime.livedata.observeAsState +import androidx.compose.runtime.rememberCoroutineScope import cz.frantisekmasa.wfrp_master.core.ui.dialogs.FullScreenDialog import cz.muni.fi.rpg.viewModels.SkillsViewModel +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import java.util.* @Composable fun EditSkillDialog( viewModel: SkillsViewModel, - skill: Skill, + skillId: UUID, onDismissRequest: () -> Unit ) { + val skill = viewModel.skills.observeAsState().value?.firstOrNull { it.id == skillId } ?: return + FullScreenDialog(onDismissRequest = onDismissRequest) { if (skill.compendiumId != null) { - AdvancesForm( - existingSkill = skill, - compendiumSkillId = skill.compendiumId, - viewModel = viewModel, - onDismissRequest = onDismissRequest + val coroutineScope = rememberCoroutineScope() + + SkillDetail( + skill, + onDismissRequest = onDismissRequest, + onAdvancesChange = { advances -> + coroutineScope.launch(Dispatchers.IO) { + viewModel.saveSkill(skill.copy(advances = advances)) + } + } ) } else { NonCompendiumSkillForm( diff --git a/app/src/main/java/cz/muni/fi/rpg/ui/character/skills/dialog/SkillDetail.kt b/app/src/main/java/cz/muni/fi/rpg/ui/character/skills/dialog/SkillDetail.kt new file mode 100644 index 000000000..c548ee831 --- /dev/null +++ b/app/src/main/java/cz/muni/fi/rpg/ui/character/skills/dialog/SkillDetail.kt @@ -0,0 +1,81 @@ +package cz.muni.fi.rpg.ui.character.skills.dialog + +import androidx.compose.foundation.layout.* +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +import androidx.compose.material.Scaffold +import androidx.compose.material.Text +import androidx.compose.material.TopAppBar +import androidx.compose.runtime.* +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import cz.frantisekmasa.wfrp_master.core.ui.buttons.CloseButton +import cz.frantisekmasa.wfrp_master.core.ui.primitives.NumberPicker +import cz.frantisekmasa.wfrp_master.core.ui.primitives.SingleLineTextValue +import cz.frantisekmasa.wfrp_master.core.ui.primitives.Spacing +import cz.frantisekmasa.wfrp_master.core.ui.scaffolding.SubheadBar +import cz.muni.fi.rpg.R +import cz.muni.fi.rpg.model.domain.skills.Skill + +@Composable +fun SkillDetail( + skill: Skill, + onDismissRequest: () -> Unit, + onAdvancesChange: (advances: Int) -> Unit +) { + Scaffold( + topBar = { + TopAppBar( + navigationIcon = { CloseButton(onDismissRequest) }, + title = { Text(skill.name) }, + ) + } + ) { + Column(Modifier.verticalScroll(rememberScrollState())) { + AdvancesBar(skill.advances, onAdvancesChange) + + Column(Modifier.padding(Spacing.bodyPadding)) { + SingleLineTextValue( + R.string.label_skill_characteristic, + stringResource(skill.characteristic.getNameId()), + ) + + SingleLineTextValue( + labelRes = R.string.label_skill_advanced, + value = stringResource( + if (skill.advanced) R.string.boolean_yes else R.string.boolean_no + ) + ) + + Text( + text = skill.description, + modifier = Modifier.padding(top = 8.dp), + ) + } + } + } +} + +@Composable +private fun AdvancesBar(advances: Int, onAdvancesChange: (advances: Int) -> Unit) { + SubheadBar { + Row( + Modifier.fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween, + ) { + Text(stringResource(R.string.label_advances)) + NumberPicker( + value = advances, + onIncrement = { onAdvancesChange(advances + 1) }, + onDecrement = { + if (advances > 1) { + onAdvancesChange(advances - 1) + } + } + ) + } + } +} \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f603d1bd8..645e54ef3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -105,17 +105,8 @@ Fortune Fate - Weapon Skill - Ballistic Skill - Dexterity - Fellowship - Will Power - Intelligence - Agility TB - Toughness SB - Strength Edit Edit character @@ -196,7 +187,6 @@ Required Resilience Resolve - Initiative Party ambitions From 19da1377f59f06e6ab3e2c7c645329f18b249102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Ma=C5=A1a?= Date: Tue, 16 Feb 2021 00:41:20 +0100 Subject: [PATCH 3/3] Add info about compendium talent to EditTalentDialog --- .../rpg/ui/character/talents/TalentsCard.kt | 11 ++-- .../talents/dialog/EditTalentDialog.kt | 26 ++++++-- .../character/talents/dialog/TalentDetail.kt | 66 +++++++++++++++++++ 3 files changed, 91 insertions(+), 12 deletions(-) create mode 100644 app/src/main/java/cz/muni/fi/rpg/ui/character/talents/dialog/TalentDetail.kt diff --git a/app/src/main/java/cz/muni/fi/rpg/ui/character/talents/TalentsCard.kt b/app/src/main/java/cz/muni/fi/rpg/ui/character/talents/TalentsCard.kt index 56e40e2bf..ade194248 100644 --- a/app/src/main/java/cz/muni/fi/rpg/ui/character/talents/TalentsCard.kt +++ b/app/src/main/java/cz/muni/fi/rpg/ui/character/talents/TalentsCard.kt @@ -18,6 +18,7 @@ import cz.muni.fi.rpg.ui.character.talents.dialog.AddTalentDialog import cz.muni.fi.rpg.ui.character.talents.dialog.EditTalentDialog import cz.muni.fi.rpg.ui.common.composables.* import cz.muni.fi.rpg.viewModels.TalentsViewModel +import java.util.* @Composable internal fun TalentsCard( @@ -32,21 +33,21 @@ internal fun TalentsCard( if (talents.isNotEmpty()) { Column { - var editedTalent: Talent? by savedInstanceState { null } + var editedTalentId: UUID? by savedInstanceState { null } for (talent in talents) { TalentItem( talent, - onClick = { editedTalent = talent }, + onClick = { editedTalentId = talent.id }, onRemove = { onRemove(talent) } ) } - editedTalent?.let { + editedTalentId?.let { EditTalentDialog( viewModel = viewModel, - talent = it, - onDismissRequest = { editedTalent = null }, + talentId = it, + onDismissRequest = { editedTalentId = null }, ) } } diff --git a/app/src/main/java/cz/muni/fi/rpg/ui/character/talents/dialog/EditTalentDialog.kt b/app/src/main/java/cz/muni/fi/rpg/ui/character/talents/dialog/EditTalentDialog.kt index 6bbba6ac2..ca26698a8 100644 --- a/app/src/main/java/cz/muni/fi/rpg/ui/character/talents/dialog/EditTalentDialog.kt +++ b/app/src/main/java/cz/muni/fi/rpg/ui/character/talents/dialog/EditTalentDialog.kt @@ -1,23 +1,35 @@ package cz.muni.fi.rpg.ui.character.talents.dialog import androidx.compose.runtime.Composable -import cz.muni.fi.rpg.model.domain.talents.Talent +import androidx.compose.runtime.livedata.observeAsState +import androidx.compose.runtime.rememberCoroutineScope import cz.frantisekmasa.wfrp_master.core.ui.dialogs.FullScreenDialog import cz.muni.fi.rpg.viewModels.TalentsViewModel +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import java.util.* @Composable fun EditTalentDialog( viewModel: TalentsViewModel, - talent: Talent, + talentId: UUID, onDismissRequest: () -> Unit ) { + val talent = + viewModel.talents.observeAsState().value?.firstOrNull { it.id == talentId } ?: return + FullScreenDialog(onDismissRequest = onDismissRequest) { if (talent.compendiumId != null) { - TimesTakenForm( - existingTalent = talent, - compendiumTalentId = talent.compendiumId, - viewModel = viewModel, - onDismissRequest = onDismissRequest + val coroutineScope = rememberCoroutineScope() + + TalentDetail( + talent = talent, + onDismissRequest = onDismissRequest, + onTimesTakenChange = { timesTaken -> + coroutineScope.launch(Dispatchers.IO) { + viewModel.saveTalent(talent.copy(taken = timesTaken)) + } + } ) } else { NonCompendiumTalentForm( diff --git a/app/src/main/java/cz/muni/fi/rpg/ui/character/talents/dialog/TalentDetail.kt b/app/src/main/java/cz/muni/fi/rpg/ui/character/talents/dialog/TalentDetail.kt new file mode 100644 index 000000000..d1306ed59 --- /dev/null +++ b/app/src/main/java/cz/muni/fi/rpg/ui/character/talents/dialog/TalentDetail.kt @@ -0,0 +1,66 @@ +package cz.muni.fi.rpg.ui.character.talents.dialog + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +import androidx.compose.material.Scaffold +import androidx.compose.material.Text +import androidx.compose.material.TopAppBar +import androidx.compose.runtime.* +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import cz.frantisekmasa.wfrp_master.core.ui.buttons.CloseButton +import cz.frantisekmasa.wfrp_master.core.ui.primitives.NumberPicker +import cz.frantisekmasa.wfrp_master.core.ui.primitives.Spacing +import cz.frantisekmasa.wfrp_master.core.ui.scaffolding.SubheadBar +import cz.muni.fi.rpg.R +import cz.muni.fi.rpg.model.domain.talents.Talent + +@Composable +fun TalentDetail( + talent: Talent, + onDismissRequest: () -> Unit, + onTimesTakenChange: (timesTaken: Int) -> Unit +) { + Scaffold( + topBar = { + TopAppBar( + navigationIcon = { CloseButton(onDismissRequest) }, + title = { Text(talent.name) }, + ) + } + ) { + Column(Modifier.verticalScroll(rememberScrollState())) { + TimesTakenBar(talent.taken, onTimesTakenChange) + + Column(Modifier.padding(Spacing.bodyPadding)) { + Text(talent.description) + } + } + } +} + +@Composable +private fun TimesTakenBar(timesTaken: Int, onTimesTakenChange: (timesTaken: Int) -> Unit) { + SubheadBar { + Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) { + Text( + text = stringResource(R.string.label_talent_taken), + modifier = Modifier.weight(1f), + ) + NumberPicker( + value = timesTaken, + onIncrement = { onTimesTakenChange(timesTaken + 1) }, + onDecrement = { + if (timesTaken > 1) { + onTimesTakenChange(timesTaken - 1) + } + } + ) + } + } +} \ No newline at end of file