Skip to content

Commit

Permalink
Merge pull request #359 from apeun-gidaechi/feature/354-dday-plus-vis…
Browse files Browse the repository at this point in the history
…ible

Feature/Dday plus visible
  • Loading branch information
8954sood authored Nov 5, 2024
2 parents 41caff2 + 20f8254 commit f4a063d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ fun TaskCard(uiState: CommonUiState<ImmutableList<TaskModel>>, navigateToTask: (
dDay = "기한없음",
)
} else {
val dayCnt = LocalDate.now().toKotlinLocalDate().daysUntil(task.dueDate!!.date)
HomeCalendarCard(
date = "${task.dueDate!!.monthNumber}/${task.dueDate!!.dayOfMonth.toString().padStart(2, '0')}",
content = task.title,
dDay = "D-${-task.dueDate!!.date.daysUntil(LocalDate.now().toKotlinLocalDate())}",
dDay = "D" + when {
dayCnt > 0 -> "-$dayCnt"
dayCnt < 0 -> "+${-dayCnt}"
else -> " Day"
},
)
}
}
Expand Down
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 @@ -8,6 +8,7 @@ import com.seugi.task.model.CommonUiState
import com.seugi.task.model.TaskUiState
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update
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 f4a063d

Please sign in to comment.