Created
December 9, 2021 17:48
-
-
Save go-cristian/acb1eb44670618b90e2f0b8a426b610f 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 ExampleDialog() { | |
val scope = rememberCoroutineScope() | |
val keyboardController = LocalSoftwareKeyboardController.current | |
val focusRequester = remember { FocusRequester() } | |
val textState = remember { mutableStateOf(TextFieldValue()) } | |
LaunchedEffect(Unit) { | |
scope.launch { | |
delay(200) | |
focusRequester.requestFocus() | |
delay(200) | |
} | |
} | |
TextField( | |
value = textState.value, | |
onValueChange = { | |
textState.value = it | |
}, | |
singleLine = true, | |
modifier = Modifier.focusRequester(focusRequester), | |
) | |
BaseButton( | |
text = "Click Me", | |
variant = Variant.PRIMARY, | |
onClick = { | |
scope.launch { | |
keyboardController?.hide() | |
textState.value = TextFieldValue() | |
} | |
}, | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment