DropdownOptions

fun DropdownOptions(@StringRes label: Int, preSelectedOption: Int, options: List<String>, onNewOption: (Int) -> Unit, optionLabels: Map<String, String> = emptyMap(), horizontalPadding: Dp = HorizontalPadding)

Parameters

onNewOption

a callback that contains the index of in the range of options the option that's selected

preSelectedOption

the index of an option from options

optionLabels

a map where the keys are an options and the value is a custom label (could be a description) of the option instead of using the options

I did this because:

  1. The ExposedDropdownMenuBox is an ExperimentalMaterial3Api

  2. The interactive mode preview of the composable isn't working (at least occasionally)

  3. I wanted the click of the widget to have a rounded look on it, so I made the OutlinedTextField have a button inside it and it looks great.

  4. This gives more customization options

  • https://stackoverflow.com/questions/67111020/exposed-drop-down-menu-for-jetpack-compose