Marco Pierucci
03/17/2023, 2:05 PMColumn(
modifier = modifier,
horizontalAlignment = Alignment.End,
) {
val dropDownIcon =
if (expanded) Icons.Filled.KeyboardArrowUp else Icons.Filled.KeyboardArrowDown
TextFieldItem(
value = selections[currentSelection],
trailingIcon = {
Icon(
dropDownIcon,
contentDescription = "",
modifier = Modifier.clickable(onClick = onExpandClick)
)
},
isError = isError,
readOnly = true,
label = label
)
Box {
DropdownMenu(
offset = dropDownOffset,
expanded = expanded,
onDismissRequest = onDismissRequest
) {
selections.forEach { selectionEntry ->
DropdownMenuItem(
onClick = { onSelected(selectionEntry.key) }
) {
TextItem(text = selectionEntry.value, style = TextItem.Style.Body2)
}
}
}
}
}
Would this be the right approach or am I missing something. It feels weird to have to rely on columns plus extra boxesBox(modifier = modifier) {
val dropDownIcon =
if (expanded) Icons.Filled.KeyboardArrowUp else Icons.Filled.KeyboardArrowDown
TextFieldItem(
value = selections[currentSelection],
trailingIcon = {
Icon(
dropDownIcon,
contentDescription = "",
modifier = Modifier.clickable(onClick = onExpandClick)
)
},
isError = isError,
readOnly = true,
label = label
)
DropdownMenu(
expanded = expanded,
onDismissRequest = onDismissRequest
) {
selections.forEach { selectionEntry ->
DropdownMenuItem(
onClick = { onSelected(selectionEntry.key) }
) {
TextItem(text = selectionEntry.value, style = TextItem.Style.Body2)
}
}
}
}