Skip to content

Commit

Permalink
fix: Task Screen Dday Visible Message
Browse files Browse the repository at this point in the history
  • Loading branch information
8954sood committed Nov 5, 2024
1 parent 47127db commit 48b92fa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
16 changes: 13 additions & 3 deletions feature-main/task/src/main/java/com/seugi/task/TaskScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,15 @@ internal fun TaskScreen(viewModel: TaskViewModel = hiltViewModel(), popBackStack
dDay = "기한없음",
)
} else {
val dayCnt = LocalDate.now().toKotlinLocalDate().daysUntil(it.dueDate!!.date)
TaskCard(
title = it.title,
description = it.description ?: "",
dDay = "D-${-it.dueDate!!.date.daysUntil(LocalDate.now().toKotlinLocalDate())}",
dDay = "D" + when {
dayCnt > 0 -> "-${dayCnt}"
dayCnt < 0 -> "+${-dayCnt}"
else -> " Day"
},
)
}
}
Expand All @@ -131,13 +136,18 @@ internal fun TaskScreen(viewModel: TaskViewModel = hiltViewModel(), popBackStack
TaskCard(
title = it.title,
description = it.description ?: "",
dDay = "D-??",
dDay = "기한없음",
)
} else {
val dayCnt = LocalDate.now().toKotlinLocalDate().daysUntil(it.dueDate!!.date)
TaskCard(
title = it.title,
description = it.description ?: "",
dDay = "D-${-it.dueDate!!.date.daysUntil(LocalDate.now().toKotlinLocalDate())}",
dDay = "D" + when {
dayCnt > 0 -> "-${dayCnt}"
dayCnt < 0 -> "+${-dayCnt}"
else -> " Day"
},
)
}
}
Expand Down
13 changes: 11 additions & 2 deletions feature-main/task/src/main/java/com/seugi/task/TaskViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.seugi.data.task.TaskRepository
import com.seugi.task.model.CommonUiState
import com.seugi.task.model.TaskUiState
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.collections.immutable.toImmutableList
import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
Expand All @@ -27,7 +28,11 @@ class TaskViewModel @Inject constructor(
is Result.Success -> {
_state.update { state ->
state.copy(
classroomTaskState = CommonUiState.Success(it.data),
classroomTaskState = CommonUiState.Success(
it.data
.sortedBy { it.dueDate }
.toImmutableList()
),
)
}
}
Expand All @@ -49,7 +54,11 @@ class TaskViewModel @Inject constructor(
is Result.Success -> {
_state.update { state ->
state.copy(
workspaceTaskState = CommonUiState.Success(it.data),
workspaceTaskState = CommonUiState.Success(
it.data
.sortedBy { it.dueDate }
.toImmutableList()
),
)
}
}
Expand Down

0 comments on commit 48b92fa

Please sign in to comment.