Skip to content

Commit

Permalink
feat: Add Task Add,Delete,Completion Sounds #34
Browse files Browse the repository at this point in the history
  • Loading branch information
vishal2376 committed Jan 14, 2025
1 parent 625ff6a commit 9e7cf86
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableLongStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -84,8 +85,10 @@ import com.vishal2376.snaptick.ui.theme.LightGreen
import com.vishal2376.snaptick.ui.theme.Red
import com.vishal2376.snaptick.ui.theme.SnaptickTheme
import com.vishal2376.snaptick.ui.theme.priorityColors
import com.vishal2376.snaptick.util.SoundEvent
import com.vishal2376.snaptick.util.checkValidTask
import com.vishal2376.snaptick.util.getFormattedDuration
import com.vishal2376.snaptick.util.playSound
import kotlinx.coroutines.job
import java.time.LocalDate
import java.time.LocalTime
Expand Down Expand Up @@ -118,6 +121,7 @@ fun AddTaskScreen(
val taskDuration by remember { mutableLongStateOf(60) }
var isTimeUpdated by remember { mutableStateOf(false) }

val scope = rememberCoroutineScope()
val context = LocalContext.current
val focusRequester = FocusRequester()

Expand Down Expand Up @@ -515,6 +519,7 @@ fun AddTaskScreen(
)

if (isValid) {
playSound(context, SoundEvent.TASK_ADDED)
onEvent(AddEditScreenEvent.OnAddTaskClick(task))
showCustomSnackbar(
context.getString(R.string.tasks_added_successfully),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ import com.vishal2376.snaptick.presentation.navigation.Routes
import com.vishal2376.snaptick.ui.theme.SnaptickTheme
import com.vishal2376.snaptick.util.Constants
import com.vishal2376.snaptick.util.DummyTasks
import com.vishal2376.snaptick.util.SoundEvent
import com.vishal2376.snaptick.util.playSound
import kotlinx.coroutines.launch
import java.time.LocalDate
import java.time.YearMonth
Expand Down Expand Up @@ -247,6 +249,7 @@ fun CalenderScreen(
},
onComplete = {
if (task.date >= LocalDate.now()) {
playSound(context,SoundEvent.TASK_COMPLETED)
onEvent(HomeScreenEvent.OnCompleted(it, !task.isCompleted))
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ import com.vishal2376.snaptick.ui.theme.Yellow
import com.vishal2376.snaptick.util.Constants
import com.vishal2376.snaptick.util.DummyTasks
import com.vishal2376.snaptick.util.SettingsStore
import com.vishal2376.snaptick.util.SoundEvent
import com.vishal2376.snaptick.util.getFreeTime
import com.vishal2376.snaptick.util.playSound
import com.vishal2376.snaptick.util.updateLocale
import kotlinx.coroutines.launch

Expand Down Expand Up @@ -387,6 +389,7 @@ fun HomeScreen(
modifier = Modifier.animateItemPlacement(tween(500))
) {
SwipeActionBox(item = task, onAction = {
playSound(context, SoundEvent.TASK_DELETED)
onEvent(HomeScreenEvent.OnSwipeTask(it))
showCustomSnackbar(
msg = "Task Deleted",
Expand All @@ -404,6 +407,7 @@ fun HomeScreen(
onNavigate("${Routes.EditTaskScreen.name}/$taskId")
},
onComplete = {
playSound(context, SoundEvent.TASK_COMPLETED)
onEvent(HomeScreenEvent.OnCompleted(it, true))
},
onPomodoro = { taskId ->
Expand Down

0 comments on commit 9e7cf86

Please # to comment.