@@ -86,7 +86,6 @@ import kotlin.math.roundToInt
8686 * @param title The title of the [SuperDropdown].
8787 * @param items The options of the [SuperDropdown].
8888 * @param selectedIndex The index of the selected option.
89- * @param onSelectedIndexChange The callback when the index is selected.
9089 * @param modifier The modifier to be applied to the [SuperDropdown].
9190 * @param popupModifier The modifier to be applied to the popup of the [SuperDropdown].
9291 * @param titleColor The color of the title.
@@ -97,13 +96,14 @@ import kotlin.math.roundToInt
9796 * @param insideMargin The margin inside the [SuperDropdown].
9897 * @param defaultWindowInsetsPadding Whether to apply default window insets padding to the [SuperDropdown].
9998 * @param enabled Whether the [SuperDropdown] is enabled.
99+ * @param showValue Whether to show the selected value of the [SuperDropdown].
100+ * @param onSelectedIndexChange The callback when the selected index of the [SuperDropdown] is changed.
100101 */
101102@Composable
102103fun SuperDropdown (
103104 title : String ,
104105 items : List <String >,
105106 selectedIndex : Int ,
106- onSelectedIndexChange : (Int ) -> Unit ,
107107 modifier : Modifier = Modifier ,
108108 popupModifier : Modifier = Modifier ,
109109 titleColor : BasicComponentColors = BasicComponentDefaults .titleColor(),
@@ -113,7 +113,9 @@ fun SuperDropdown(
113113 horizontalPadding : Dp = 0.dp,
114114 insideMargin : PaddingValues = BasicComponentDefaults .InsideMargin ,
115115 defaultWindowInsetsPadding : Boolean = true,
116- enabled : Boolean = true
116+ enabled : Boolean = true,
117+ showValue : Boolean = true,
118+ onSelectedIndexChange : ((Int ) -> Unit )? ,
117119) {
118120 val interactionSource = remember { MutableInteractionSource () }
119121 val isDropdownExpanded = remember { mutableStateOf(false ) }
@@ -171,13 +173,15 @@ fun SuperDropdown(
171173 summary = summary,
172174 summaryColor = summaryColor,
173175 rightActions = {
174- Text (
175- modifier = Modifier .widthIn(max = 130 .dp),
176- text = items[selectedIndex],
177- fontSize = MiuixTheme .textStyles.body2.fontSize,
178- color = actionColor,
179- textAlign = TextAlign .End ,
180- )
176+ if (showValue) {
177+ Text (
178+ modifier = Modifier .widthIn(max = 130 .dp),
179+ text = items[selectedIndex],
180+ fontSize = MiuixTheme .textStyles.body2.fontSize,
181+ color = actionColor,
182+ textAlign = TextAlign .End ,
183+ )
184+ }
181185 Image (
182186 modifier = Modifier
183187 .padding(start = 8 .dp)
@@ -310,7 +314,7 @@ fun SuperDropdown(
310314 isSelected = selectedIndex == index,
311315 onSelectedIndexChange = {
312316 hapticFeedback.performHapticFeedback(HapticFeedbackType .LongPress )
313- onSelectedIndexChange(it)
317+ onSelectedIndexChange?. let { it1 -> it1 (it) }
314318 dismissPopup(isDropdownExpanded)
315319 },
316320 textWidthDp = textWidthDp,
0 commit comments