mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-18 06:47:02 +05:30
Add delete operation
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
717eefad97
commit
bb80b42426
2 changed files with 12 additions and 3 deletions
|
@ -63,7 +63,11 @@ fun TodoApp() {
|
||||||
},
|
},
|
||||||
bodyContent = {
|
bodyContent = {
|
||||||
LazyColumnFor(items = items, modifier = Modifier.padding(horizontal = 16.dp)) { todoItem ->
|
LazyColumnFor(items = items, modifier = Modifier.padding(horizontal = 16.dp)) { todoItem ->
|
||||||
TodoRowItem(item = todoItem)
|
TodoRowItem(item = todoItem) {
|
||||||
|
coroutineScope.launch {
|
||||||
|
itemsDao.delete(todoItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -15,13 +15,18 @@ import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import dev.msfjarvis.todo.data.model.TodoItem
|
import dev.msfjarvis.todo.data.model.TodoItem
|
||||||
|
import kotlinx.coroutines.coroutineScope
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun LazyItemScope.TodoRowItem(item: TodoItem) {
|
fun LazyItemScope.TodoRowItem(item: TodoItem, onLongClick: () -> Unit) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.padding(vertical = 8.dp)
|
modifier = Modifier.padding(vertical = 8.dp)
|
||||||
.fillParentMaxWidth()
|
.fillParentMaxWidth()
|
||||||
.clickable(onClick = {}, indication = RippleIndication()),
|
.clickable(
|
||||||
|
onClick = {},
|
||||||
|
onLongClick = onLongClick,
|
||||||
|
indication = RippleIndication()
|
||||||
|
),
|
||||||
) {
|
) {
|
||||||
Card(
|
Card(
|
||||||
shape = RoundedCornerShape(8.dp),
|
shape = RoundedCornerShape(8.dp),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue