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 @@ -25,14 +25,15 @@ fun FlintIconButton(
onClick: () -> Unit,
modifier: Modifier = Modifier,
enabled: Boolean = true,
contentPadding: PaddingValues = PaddingValues(10.dp)
) {
FlintBasicButton(
text = text,
state = state,
onClick = onClick,
enabled = enabled,
leadingIconRes = iconRes,
contentPadding = PaddingValues(10.dp),
contentPadding = contentPadding,
modifier =
modifier
.padding(vertical = 2.dp)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.flint.domain.mapper.collection

import com.flint.data.dto.collection.response.CollectionDetailResponseDto
import com.flint.domain.model.AuthorModelNew
import com.flint.domain.model.collection.CollectionDetailModelNew
import com.flint.domain.model.content.ContentModelNew
import com.flint.domain.type.UserRoleType
import kotlinx.collections.immutable.toImmutableList
import java.time.LocalDate

fun CollectionDetailResponseDto.toModel(): CollectionDetailModelNew {
return CollectionDetailModelNew(
author = author.toModel(),
contents = contents.map { it.toModel() }.toImmutableList(),
createdAt = LocalDate.parse(createdAt),
description = description,
id = id,
thumbnailUrl = thumbnailUrl,
isBookmarked = isBookmarked,
title = title,
)
}

private fun CollectionDetailResponseDto.Author.toModel(): AuthorModelNew {
return AuthorModelNew(
id = id,
nickname = nickname,
profileImageUrl = profileImageUrl,
userRole = runCatching { UserRoleType.valueOf(userRole) }.getOrDefault(UserRoleType.NONE)
)
}

private fun CollectionDetailResponseDto.Content.toModel(): ContentModelNew {
return ContentModelNew(
director = director,
bookmarkCount = bookmarkCount,
id = id,
isBookmarked = isBookmarked,
isSpoiler = isSpoiler,
reason = reason,
imageUrl = imageUrl,
title = title,
year = year,
)
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package com.flint.domain.model.collection

import com.flint.data.dto.collection.response.CollectionDetailResponseDto
import com.flint.domain.model.AuthorModelNew
import com.flint.domain.model.content.ContentModelNew
import com.flint.domain.type.UserRoleType
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList
import java.time.LocalDate

data class CollectionDetailModelNew(
Expand All @@ -17,45 +14,4 @@ data class CollectionDetailModelNew(
val thumbnailUrl: String,
val isBookmarked: Boolean,
val title: String,
private val userId: String,
) {
constructor(
collectionDetail: CollectionDetailResponseDto,
userId: String,
) : this(
author = collectionDetail.author.toModel(),
contents = collectionDetail.contents.map { it.toModel() }.toImmutableList(),
createdAt = LocalDate.parse(collectionDetail.createdAt),
description = collectionDetail.description,
id = collectionDetail.id,
thumbnailUrl = collectionDetail.thumbnailUrl,
isBookmarked = collectionDetail.isBookmarked,
title = collectionDetail.title,
userId = userId
)

val isMine: Boolean = author.id == userId
}

private fun CollectionDetailResponseDto.Author.toModel(): AuthorModelNew {
return AuthorModelNew(
id = id,
nickname = nickname,
profileImageUrl = profileImageUrl,
userRole = runCatching { UserRoleType.valueOf(userRole) }.getOrDefault(UserRoleType.NONE)
)
}

private fun CollectionDetailResponseDto.Content.toModel(): ContentModelNew {
return ContentModelNew(
director = director,
bookmarkCount = bookmarkCount,
id = id,
isBookmarked = isBookmarked,
isSpoiler = isSpoiler,
reason = reason,
imageUrl = imageUrl,
title = title,
year = year,
)
}
)
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
package com.flint.domain.repository

import com.flint.core.common.util.DataStoreKey.USER_ID
import com.flint.core.common.util.suspendRunCatching
import com.flint.data.api.CollectionApi
import com.flint.data.dto.collection.request.CollectionCreateRequestDto
import com.flint.data.dto.collection.response.CollectionDetailResponseDto
import com.flint.data.local.PreferencesManager
import com.flint.domain.mapper.collection.toModel
import com.flint.domain.model.collection.CollectionCreateModel
import com.flint.domain.model.collection.CollectionDetailModelNew
import com.flint.domain.model.collection.CollectionListModel
import com.flint.domain.model.collection.CollectionsModel
import kotlinx.coroutines.flow.first
import javax.inject.Inject

class CollectionRepository @Inject constructor(
private val apiService: CollectionApi,
private val preferencesManager: PreferencesManager,
) {
// 컬렉션 목록 조회 (페이지네이션)
suspend fun getCollections(cursor: Long?, size: Int): Result<CollectionsModel> =
Expand All @@ -29,7 +25,7 @@ class CollectionRepository @Inject constructor(

// 컬렉션 생성
suspend fun postCollectionCreate(
requestDto: CollectionCreateRequestDto
requestDto: CollectionCreateRequestDto,
): Result<CollectionCreateModel> =
suspendRunCatching {
apiService.postCollectionCreate(requestDto).data.toModel()
Expand All @@ -41,9 +37,8 @@ class CollectionRepository @Inject constructor(
suspendRunCatching {
val response: CollectionDetailResponseDto =
apiService.getCollectionDetail(collectionId).data
val userId: String = preferencesManager.getString(USER_ID).first()

CollectionDetailModelNew(response, userId)
response.toModel()
}

// 최근 본 컬렉션 목록 조회
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ fun CollectionCreateScreen(
},
onClick = { onPublicChanged(false) },
modifier = Modifier.weight(1f),
contentPadding = PaddingValues(start = 8.dp, end = 12.dp, top= 10.dp, bottom = 10.dp)
)
}
}
Expand Down Expand Up @@ -300,6 +301,7 @@ fun CollectionCreateScreen(
Modifier
.fillMaxWidth()
.defaultMinSize(minHeight = 80.dp),
contentPadding = PaddingValues(vertical = 28.dp)
)

Spacer(Modifier.height(36.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ fun CollectionDetailRoute(
paddingValues = paddingValues,
targetImageUrl = targetImageUrl,
title = collectionDetail.title,
isMine = collectionDetail.isMine,
isBookmarked = collectionDetail.isBookmarked,
authorNickname = collectionDetail.author.nickname,
authorUserRoleType = collectionDetail.author.userRole,
Expand Down Expand Up @@ -217,7 +216,6 @@ fun CollectionDetailRoute(
fun CollectionDetailScreen(
paddingValues: PaddingValues,
title: String,
isMine: Boolean,
isBookmarked: Boolean,
authorNickname: String,
authorUserRoleType: UserRoleType,
Expand Down Expand Up @@ -291,7 +289,6 @@ fun CollectionDetailScreen(
) {
Thumbnail(
title = title,
isMine = isMine,
isBookmarked = isBookmarked,
onSaveDoneButtonClick = onSaveDoneButtonClick,
onSaveNoneButtonClick = onSaveNoneButtonClick,
Expand Down Expand Up @@ -535,7 +532,6 @@ private fun PeopleWhoSavedThisCollectionPreview(
@Composable
private fun Thumbnail(
title: String,
isMine: Boolean,
isBookmarked: Boolean,
onSaveDoneButtonClick: () -> Unit,
onSaveNoneButtonClick: () -> Unit,
Expand Down Expand Up @@ -571,20 +567,18 @@ private fun Thumbnail(
maxLines = 2,
overflow = TextOverflow.Ellipsis
)
if (!isMine) {
if (isBookmarked) {
FlintSaveDoneButton(
onClick = {
onSaveDoneButtonClick()
},
)
} else {
FlintSaveNoneButton(
onClick = {
onSaveNoneButtonClick()
},
)
}
if (isBookmarked) {
FlintSaveDoneButton(
onClick = {
onSaveDoneButtonClick()
},
)
} else {
FlintSaveNoneButton(
onClick = {
onSaveNoneButtonClick()
},
)
}
}
}
Expand Down Expand Up @@ -779,7 +773,7 @@ private fun Content(
)
}

Spacer(Modifier.height(20.dp))
Spacer(Modifier.height(64.dp))
}
}
}
Expand All @@ -803,11 +797,6 @@ private class HeaderPreviewProvider : PreviewParameterProvider<HeaderPreviewData
isMine = false,
isBookmarked = false,
),
HeaderPreviewData(
title = "내가 만든 컬렉션",
isMine = true,
isBookmarked = false,
),
)
}

Expand All @@ -819,7 +808,6 @@ private fun ThumbnailPreview(
FlintTheme {
Thumbnail(
title = data.title,
isMine = data.isMine,
isBookmarked = data.isBookmarked,
onSaveDoneButtonClick = {},
onSaveNoneButtonClick = {}
Expand Down Expand Up @@ -930,7 +918,6 @@ private fun ContentPreview(

private data class ScreenPreviewData(
val title: String,
val isMine: Boolean,
val isBookmarked: Boolean,
val authorNickname: String,
val authorUserRoleType: UserRoleType,
Expand Down Expand Up @@ -978,7 +965,6 @@ private class ScreenPreviewProvider : PreviewParameterProvider<ScreenPreviewData
sequenceOf(
ScreenPreviewData(
title = "한번 보면 못 빠져나오는 여운남는 사랑이야기",
isMine = false,
isBookmarked = true,
authorNickname = "키카",
authorUserRoleType = UserRoleType.FLINER,
Expand All @@ -987,22 +973,12 @@ private class ScreenPreviewProvider : PreviewParameterProvider<ScreenPreviewData
),
ScreenPreviewData(
title = "새로운 컬렉션",
isMine = false,
isBookmarked = false,
authorNickname = "일반유저",
authorUserRoleType = UserRoleType.FLING,
contents = persistentListOf(sampleContent, sampleContent.copy(isSpoiler = true)),
people = persistentListOf(),
),
ScreenPreviewData(
title = "내가 만든 컬렉션",
isMine = true,
isBookmarked = false,
authorNickname = "나",
authorUserRoleType = UserRoleType.FLING,
contents = persistentListOf(sampleContent, sampleContent.copy(isSpoiler = true)),
people = samplePeople,
),
)
}

Expand All @@ -1016,7 +992,6 @@ private fun CollectionDetailScreenPreview(
CollectionDetailScreen(
paddingValues = paddingValues,
title = data.title,
isMine = data.isMine,
isBookmarked = data.isBookmarked,
authorNickname = data.authorNickname,
authorUserRoleType = data.authorUserRoleType,
Expand Down