fix(item-form): make kcal label dynamic based on selected unit

Analogous to the price label, kcal now shows 'kcal pro [Einheit]'
based on the dropdown selection from #114.

Closes #115
This commit is contained in:
Jens Reinemann 2026-05-18 21:41:04 +02:00
parent 645578b66e
commit afbec03ebb

View file

@ -199,7 +199,14 @@ internal fun ItemFormScreen(
OutlinedTextField( OutlinedTextField(
value = uiState.kcalPerUnit, value = uiState.kcalPerUnit,
onValueChange = viewModel::updateKcalPerUnit, onValueChange = viewModel::updateKcalPerUnit,
label = { Text("kcal / Einheit") }, label = {
val unitLabel = if (uiState.isCustomUnit) {
uiState.customUnit.ifBlank { "Einheit" }
} else {
uiState.unit
}
Text("kcal pro $unitLabel")
},
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number), keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Number),
singleLine = true, singleLine = true,
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth()