This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
add4a2b
commit 3a9064f
Showing
6 changed files
with
153 additions
and
39 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
87 changes: 87 additions & 0 deletions
87
app/src/main/java/com/thatsmanmeet/taskyapp/components/DeletedTodoItem.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package com.thatsmanmeet.taskyapp.components | ||
|
||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.clickable | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.Row | ||
import androidx.compose.foundation.layout.Spacer | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.height | ||
import androidx.compose.foundation.layout.heightIn | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.material3.MaterialTheme | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Alignment | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.text.style.TextDecoration | ||
import androidx.compose.ui.unit.dp | ||
import androidx.compose.ui.unit.sp | ||
import androidx.lifecycle.ViewModel | ||
import com.thatsmanmeet.taskyapp.room.Todo | ||
import com.thatsmanmeet.taskyapp.room.TodoViewModel | ||
import com.thatsmanmeet.taskyapp.room.deletedtodo.DeletedTodo | ||
import com.thatsmanmeet.taskyapp.room.deletedtodo.DeletedTodoViewModel | ||
|
||
|
||
@Composable | ||
fun DeletedTodoItem( | ||
deletedTodo: DeletedTodo, | ||
todoViewModel: TodoViewModel, | ||
deletedTodoViewModel: DeletedTodoViewModel, | ||
modifier: Modifier = Modifier | ||
) { | ||
val isShowing = remember { | ||
mutableStateOf(false) | ||
} | ||
Row( | ||
modifier = modifier | ||
.fillMaxWidth() | ||
.padding(10.dp) | ||
.heightIn(60.dp) | ||
.clip(RoundedCornerShape(10.dp)) | ||
.clickable { | ||
isShowing.value = true | ||
} | ||
.background(MaterialTheme.colorScheme.inverseOnSurface), | ||
verticalAlignment = Alignment.CenterVertically | ||
) { | ||
Box(modifier = modifier.fillMaxWidth().padding(10.dp)){ | ||
Text( | ||
text = deletedTodo.title!!, | ||
fontSize = 16.sp, | ||
textDecoration = if(deletedTodo.isCompleted) TextDecoration.LineThrough else TextDecoration.None | ||
) | ||
} | ||
} | ||
if(isShowing.value){ | ||
ActionDialogBox( | ||
isDialogShowing = isShowing, | ||
title = "Choose Action", | ||
message = "Do you want to restore or delete this task?", | ||
confirmButtonText = "Restore" , | ||
dismissButtonText = "Delete", | ||
onConfirmClick = { | ||
todoViewModel.insertTodo(Todo( | ||
ID = deletedTodo.ID, | ||
title = deletedTodo.title, | ||
todoDescription = deletedTodo.todoDescription, | ||
isCompleted = deletedTodo.isCompleted, | ||
date = deletedTodo.date, | ||
time = deletedTodo.time, | ||
notificationID = deletedTodo.notificationID, | ||
isRecurring = deletedTodo.isRecurring | ||
)) | ||
deletedTodoViewModel.deleteDeletedTodo(deletedTodo) | ||
}, | ||
onDismissClick = { | ||
deletedTodoViewModel.deleteDeletedTodo(deletedTodo) | ||
}, | ||
|
||
) | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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