Created
July 31, 2020 21:19
-
-
Save ShikaSD/12ee78509db3b85c0bbc4c64b6083bb4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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