Skip to content

Instantly share code, notes, and snippets.

@zach-klippenstein
Last active January 25, 2022 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zach-klippenstein/47cf3662a664e1e434b3c943b8232e5c to your computer and use it in GitHub Desktop.
Save zach-klippenstein/47cf3662a664e1e434b3c943b8232e5c to your computer and use it in GitHub Desktop.
Sketch of a possible chip input implementation
@Composable fun <C> ChipField(
chips: List<C>,
chipContent: @Composable (C) -> Unit.
modifier: Modifier = Modifier
) {
SelectionContainer(
allowCursor = true,
// some sort of callback or hoisted state for reading/mutating selection
modifier.textFieldFocusable()
) {
FlowRow {
chips.forEach { chip ->
key(chip) {
Box(Modifier.selectableNode(/* something */)) {
chipContent(chip)
}
}
}
// something for text field at the end, idk how that would look exactly
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment