Last active
September 18, 2023 09:55
-
-
Save sdzshn3/4f14132222df30151b4bec6ab84d4e79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Composable | |
fun MyDropDown( | |
modifier: Modifier = Modifier, | |
onClick: () -> Unit, | |
label: String, | |
placeHolder: String, | |
value: String, | |
error: String = "" | |
) { | |
Column( | |
modifier = modifier | |
) { | |
OutlinedTextField( | |
modifier = Modifier | |
.fillMaxWidth() | |
.focusProperties { | |
canFocus = false | |
}, | |
interactionSource = remember { | |
MutableInteractionSource() | |
}.also { interactionSource -> | |
LaunchedEffect(key1 = interactionSource) { | |
interactionSource.interactions.collect { | |
if (it is PressInteraction.Release) { | |
onClick.invoke() | |
} | |
} | |
} | |
}, | |
value = value, | |
onValueChange = {}, | |
readOnly = true, | |
label = { | |
Text(text = label) | |
}, | |
placeholder = { | |
Text(text = placeHolder) | |
}, | |
trailingIcon = { | |
Icon( | |
painter = painterResource(SharedRes.images.ic_arrow_down), | |
contentDescription = "Expand $label list", | |
tint = Color(0xFF777777), | |
modifier = Modifier | |
) | |
}, | |
isError = error.isNotBlank(), | |
supportingText = { | |
if (error.isNotBlank()) { | |
Text( | |
modifier = Modifier.fillMaxWidth(), | |
text = error, | |
color = MaterialTheme.colorScheme.error | |
) | |
} | |
} | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment