Skip to content

Instantly share code, notes, and snippets.

@ShikaSD
Created July 31, 2020 21:19
Show Gist options
  • Save ShikaSD/12ee78509db3b85c0bbc4c64b6083bb4 to your computer and use it in GitHub Desktop.
Save ShikaSD/12ee78509db3b85c0bbc4c64b6083bb4 to your computer and use it in GitHub Desktop.
@Composable
fun TodoList() {
h1 { text("TodoList") }
p(modifier = Modifier.lineHeight(1.5f)) {
text("Classic example interacting with a list of items.")
br()
text("Use input below to add more items to a list (submit using Enter)")
}
val todos = remember {
mutableStateListOf(
Todo("Wash some dishes", isDone = true),
Todo("Finally inject heater into that thermosiphon", isDone = false),
Todo("Cleanup the rest of the code", isDone = false)
)
}
Column {
TodoInput {
todos += Todo(it, isDone = false)
}
todos.forEachIndexed { i, todo ->
TodoItem(
todo,
onCompleted = { todos[i] = todo.copy(isDone = !todo.isDone) },
onRemoved = { todos.removeAt(i) }
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment