Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
crash bug fix and snackbar disabled as for now.
Browse files Browse the repository at this point in the history
  • Loading branch information
thatsmanmeet committed Dec 1, 2023
1 parent 79105e2 commit a4b71df
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 43 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId "com.thatsmanmeet.taskyapp"
minSdk 26
targetSdk 34
versionCode 24
versionName "2.4.0"
versionCode 25
versionName "2.4.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
Expand Down
73 changes: 32 additions & 41 deletions app/src/main/java/com/thatsmanmeet/taskyapp/components/TaskList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@ import androidx.compose.material3.DismissValue
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.SnackbarDuration
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.SnackbarResult
import androidx.compose.material3.SwipeToDismiss
import androidx.compose.material3.rememberDismissState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.movableContentOf
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -98,45 +95,40 @@ fun TaskList(


if(dismissState.isDismissed(direction = DismissDirection.EndToStart)){
// isSwipeDeleteDialogShowing.value = true
// ActionDialogBox(
// isDialogShowing = isSwipeDeleteDialogShowing,
// title = "Delete Task?",
// message = "Do you want to delete this task?",
// confirmButtonText = "Delete",
// dismissButtonText = "Cancel",
// onConfirmClick = {
// todoViewModel.deleteTodo(currentItem)
// },
// onDismissClick = {
// isSwipeDeleteDialogShowing.value = false
// coroutineScope.launch {
// dismissState.reset()
// snackbarHostState.
// showSnackbar(
// "Operation Cancelled",
// actionLabel = "OK"
// )
// }
// },
// confirmButtonColor = Color(0xFFF75F5F),
// confirmButtonContentColor = Color.White
// )
LaunchedEffect(Unit){
val result = snackbarHostState.showSnackbar(
message = "Todo Deleted",
actionLabel = "Undo",
duration = SnackbarDuration.Short
)
when(result){
SnackbarResult.Dismissed -> {
todoViewModel.deleteTodo(currentItem)
}
SnackbarResult.ActionPerformed -> {
isSwipeDeleteDialogShowing.value = true
ActionDialogBox(
isDialogShowing = isSwipeDeleteDialogShowing,
title = "Delete Task?",
message = "Do you want to delete this task?",
confirmButtonText = "Delete",
dismissButtonText = "Cancel",
onConfirmClick = {
todoViewModel.deleteTodo(currentItem)
},
onDismissClick = {
isSwipeDeleteDialogShowing.value = false
coroutineScope.launch {
dismissState.reset()
}
}
}
},
confirmButtonColor = Color(0xFFF75F5F),
confirmButtonContentColor = Color.White
)
// LaunchedEffect(Unit){
// val result = snackbarHostState.showSnackbar(
// message = "Task will be deleted soon!",
// actionLabel = "Undo",
// duration = SnackbarDuration.Short
// )
// when(result){
// SnackbarResult.Dismissed -> {
// todoViewModel.deleteTodo(currentItem)
// }
// SnackbarResult.ActionPerformed -> {
// dismissState.reset()
// }
// }
// }
}

if(dismissState.isDismissed(direction = DismissDirection.StartToEnd)){
Expand All @@ -158,7 +150,6 @@ fun TaskList(
}
}else{
// cancel notification
println("Current Status completed:${currentItem.isCompleted}")
cancelNotification(context,currentItem)
}
}
Expand Down

0 comments on commit a4b71df

Please sign in to comment.