Skip to content

Instantly share code, notes, and snippets.

@hsleedevelop
Last active April 11, 2022 02:10
Show Gist options
  • Save hsleedevelop/17761bb74cb5a4778f88f280009a79c2 to your computer and use it in GitHub Desktop.
Save hsleedevelop/17761bb74cb5a4778f88f280009a79c2 to your computer and use it in GitHub Desktop.
composable example
@Composable
fun ProfileInput(
profile: UserProfileUi,
modifier: Modifier = Modifier
) {
Scaffold(modifier = modifier) {
// Require to go at the next input from the keyboard.
val focusManager = LocalFocusManager.current
LazyColumn {
if (profile.qrCode != null) {
item {
Image(bitmap = profile.qrCode!!.asImageBitmap())
}
}
item {
TextField(
value = profile.email,
label = { Text("Your email address*") },
keyboardOptions = KeyboardOptions(
imeAction = ImeAction.Next,
keyboardType = KeyboardType.Email
)
)
}
item {
TextField(
value = profile.firstName,
label = { Text("Your first name*") },
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next)
)
}
item {
TextField(
value = profile.lastName,
label = { Text("Your last name*") },
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Next)
)
}
item {
TextField(
value = profile.company,
label = { Text("Your company") },
keyboardActions = KeyboardActions(onDone = {
focusManager.clearFocus()
}),
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done)
)
}
item {
Button(
onClick = {
focusManager.clearFocus()
}
) {
Text("Generate your QR code")
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment