I am trying to set the Snacksbar message and action texts with values from strings.xml. If I call .toString() on the values it will obviously be set to some random numbers, as expected. I can't get a reference to context, because it isn't a composable function, so I can't use LocalContext.current
meaning I cannot access .getString(). How do I set the value of the message and action properly?
fun onEvent(event: TaskListEvent) {
when (event) {
is TaskListEvent.OnDeleteTask -> {
viewModelScope.launch(Dispatchers.IO) {
deletedTask = event.task
repository.deleteTask(event.task)
sendUiEvent(
UiEvent.ShowSnackbar(
message = "Task successfully deleted!", action = "Undo"
)
)
}
}