Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import androidx.paging.PagingData
import androidx.paging.cachedIn
import com.into.websoso.data.library.LibraryRepository
import com.into.websoso.data.library.model.NovelEntity
import com.into.websoso.domain.library.GetFilteredNovelUseCase
import com.into.websoso.domain.library.GetUserNovelUseCase
import com.into.websoso.domain.library.model.AttractivePoints
import com.into.websoso.domain.library.model.ReadStatus
Expand All @@ -27,7 +26,7 @@ class LibraryViewModel
@Inject
constructor(
getUserNovelUseCase: GetUserNovelUseCase,
private val getFilteredNovelUseCase: GetFilteredNovelUseCase,
// private val getFilteredNovelUseCase: GetFilteredNovelUseCase,
private val libraryRepository: LibraryRepository,
) : ViewModel() {
val novelPagingData: Flow<PagingData<NovelEntity>> =
Expand Down Expand Up @@ -76,7 +75,8 @@ class LibraryViewModel
}

fun updateSortType(selected: SortTypeUiModel) {
val newSortType = when (selected.sortType) {
val current = _uiState.value.selectedSortType.sortType
val newSortType = when (current) {
SortType.RECENT -> SortType.OLD
SortType.OLD -> SortType.RECENT
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import com.into.websoso.core.common.extensions.formatDateRange
import com.into.websoso.core.designsystem.theme.Black
import com.into.websoso.core.designsystem.theme.Gray200
import com.into.websoso.core.designsystem.theme.Gray300
Expand Down Expand Up @@ -90,12 +89,7 @@ internal fun LibraryListItem(
)

NovelInfo(
startDate = item.startDate,
endDate = item.endDate,
title = item.title,
myRating = item.userNovelRating,
totalRating = item.novelRating,
attractivePoints = item.attractivePoints,
item = item,
)
}

Expand Down Expand Up @@ -172,7 +166,8 @@ private fun ReadStatusBadge(
.background(
color = readStatus.backgroundColor,
shape = RoundedCornerShape(8.dp),
).padding(vertical = 4.dp),
)
.padding(vertical = 4.dp),
contentAlignment = Alignment.Center,
) {
Text(
Expand All @@ -194,27 +189,46 @@ private fun calculateThumbnailSize(): ThumbnailUiSize {
}

@Composable
private fun NovelInfo(
startDate: String?,
endDate: String?,
title: String,
myRating: Float?,
totalRating: Float,
attractivePoints: List<AttractivePointUiModel>,
) {
private fun NovelInfo(item: LibraryListItemModel) {
Column {
Spacer(modifier = Modifier.height(2.dp))
NovelInfoDate(item = item)
Spacer(modifier = Modifier.height(4.dp))
NovelInfoContent(
title = item.title,
myRating = item.userNovelRating,
totalRating = item.novelRating,
attractivePoints = item.attractivePoints,
)
}
}

formatDateRange(startDate, endDate)?.let {
@Composable
private fun NovelInfoDate(item: LibraryListItemModel) {
Box(modifier = Modifier.height(18.dp)) {
item.formattedDateRange?.let {
Text(
text = it,
style = WebsosoTheme.typography.body5,
color = Gray300,
)
}
}
}

Spacer(modifier = Modifier.height(12.dp))
@Composable
private fun NovelInfoContent(
title: String,
myRating: Float?,
totalRating: Float,
attractivePoints: List<AttractivePointUiModel>,
) {
val size = calculateThumbnailSize()

Column(
modifier = Modifier.height(size.height),
verticalArrangement = Arrangement.Center,
) {
Text(
text = title,
style = WebsosoTheme.typography.title2,
Expand All @@ -230,7 +244,11 @@ private fun NovelInfo(

Spacer(modifier = Modifier.height(10.dp))

AttractivePointTags(types = attractivePoints)
if (attractivePoints.isNotEmpty()) {
AttractivePointTags(types = attractivePoints)
} else {
Box(modifier = Modifier.height(18.dp))
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.into.websoso.domain.library.model.AttractivePoints
import com.into.websoso.domain.library.model.ReadStatus

data class LibraryUiState(
val isGrid: Boolean = false,
val isGrid: Boolean = true,
val selectedSortType: SortTypeUiModel = SortTypeUiModel.NEWEST,
val isInterested: Boolean = false,
val libraryFilterUiState: LibraryFilterUiState = LibraryFilterUiState(),
Expand All @@ -31,13 +31,17 @@ data class LibraryFilterUiState(

val readStatusLabelText: String
get() = buildLabel(
readStatuses.filterValues { it }.keys.map { it.name },
readStatuses.filterValues { it }.keys.map { status ->
ReadStatusUiModel.valueOf(status.name).label
},
"읽기 상태",
)

val attractivePointLabelText: String
get() = buildLabel(
attractivePoints.filterValues { it }.keys.map { it.name },
attractivePoints.filterValues { it }.keys.map { point ->
point.label
},
"매력 포인트",
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ enum class ReadStatusUiModel(
val backgroundColor: Color,
val key: String,
) {
WATCHING("보는중", Primary100, "WATCHING"),
WATCHING("보는 중", Primary100, "WATCHING"),
WATCHED("봤어요", Black, "WATCHED"),
QUIT("하차", Gray200, "QUIT"),
;
Expand Down