Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
@@ -0,0 +1,16 @@
package com.example.common.event

import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.asSharedFlow
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class HomeRefreshTrigger
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오우 이게 event bus 패턴인가요

@Inject
constructor() {
private val _refreshEvent = MutableSharedFlow<Unit>()
val refreshEvent = _refreshEvent.asSharedFlow()

suspend fun refresh() = _refreshEvent.emit(Unit)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fun PostDetailResponse.toDomain(): PostDetail =
isHost = this.isHost,
isScrapped = this.isScrapped,
content = this.content,
date = this.displayDate,
track = this.track.toDomain(),
writer = this.user.toDomain(),
like = this.like.toDomain(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.example.data.mapper.todomain

import com.example.data.model.response.BadgesResponse
import com.example.data.model.response.TodayPostItemResponse
import com.example.data.model.response.TodayPostTrackResponse
import com.example.data.model.response.TodayPostsResponse
import com.example.domain.model.Badges
import com.example.domain.model.BADGE
import com.example.domain.model.DailyQuestion
import com.example.domain.model.FeedItem
import com.example.domain.model.HomeScreenData
Expand All @@ -29,19 +28,12 @@ fun TodayPostItemResponse.toDomain(): FeedItem =
postId = postId,
isScrapped = isScrapped,
content = content,
badges = badges.toDomain(),
badge = badge?.let { BADGE.valueOf(it) },
track = track.toDomain(),
writer = user.toDomain(),
like = like.toDomain(),
)

private fun BadgesResponse.toDomain(): Badges =
Badges(
isEditorPick = isEditorPick,
isPopular = isPopular,
isNew = isNew,
)

private fun TodayPostTrackResponse.toDomain(): Track =
Track(
trackId = trackId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ data class PostDetailResponse(
val isScrapped: Boolean,
@SerialName("content")
val content: String,
@SerialName("displayDate")
val displayDate: String,
@SerialName("track")
val track: TrackResponse,
@SerialName("user")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.data.model.response

import com.example.domain.model.Badges
import com.example.domain.model.BADGE
import com.example.domain.model.FeedItem
import com.example.domain.model.Like
import com.example.domain.model.Track
Expand Down Expand Up @@ -52,12 +52,7 @@ data class QuestionPostItemResponse(
postId = postId,
isScrapped = isScrapped,
content = content,
badges =
Badges(
isEditorPick = isEditorPick,
isPopular = false,
isNew = false,
),
badge = if (isEditorPick) BADGE.EDITOR else null,
track =
Track(
trackId = track.trackId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,12 @@ data class TodayPostItemResponse(
@SerialName("postId") val postId: Long,
@SerialName("isScrapped") val isScrapped: Boolean,
@SerialName("content") val content: String,
@SerialName("badges") val badges: BadgesResponse,
@SerialName("badge") val badge: String?,
@SerialName("track") val track: TodayPostTrackResponse,
@SerialName("user") val user: UserResponse,
@SerialName("like") val like: LikeResponse,
)

@Serializable
data class BadgesResponse(
@SerialName("isEditorPick") val isEditorPick: Boolean,
@SerialName("isPopular") val isPopular: Boolean,
@SerialName("isNew") val isNew: Boolean,
)

@Serializable
data class TodayPostTrackResponse(
@SerialName("trackId") val trackId: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
Expand Down Expand Up @@ -33,11 +32,9 @@ import coil3.compose.AsyncImage
import com.dplay.designsystem.R
import com.example.designsystem.theme.DPlayTheme
import com.example.designsystem.util.noRippleClickable
import com.example.designsystem.util.roundedBackgroundWithPadding

@Composable
fun DPlayLargeCover(
isBookmarkChecked: Boolean,
isLikeChecked: Boolean,
likeCount: Int,
writerProfileImageUrl: String?,
Expand All @@ -48,10 +45,8 @@ fun DPlayLargeCover(
onWriterProfileClick: () -> Unit,
onStreamClick: () -> Unit,
onLikeClick: () -> Unit,
onBookmarkClick: () -> Unit,
modifier: Modifier = Modifier,
isLocked: Boolean = true,
bookmarkIconVisible: Boolean = true,
isStreaming: Boolean = false,
) {
val color = DPlayTheme.colors
Expand Down Expand Up @@ -91,25 +86,6 @@ fun DPlayLargeCover(
.align(Alignment.TopCenter),
)

if (bookmarkIconVisible && !isLocked) {
DplayClickableIcon(
iconRes =
if (isBookmarkChecked) {
R.drawable.ic_bookmark_filled_24
} else {
R.drawable.ic_bookmark_unfilled_24
},
modifier =
Modifier
.roundedBackgroundWithPadding(
backgroundColor = color.gray600,
padding = PaddingValues(10.dp),
cornerRadius = 12.dp,
).align(Alignment.TopEnd),
onClick = onBookmarkClick,
)
}

Column(
modifier =
Modifier
Expand Down Expand Up @@ -229,7 +205,6 @@ fun DPlayLargeCover(
private fun DPlayLargeCoverPreview() {
DPlayTheme {
DPlayLargeCover(
isBookmarkChecked = true,
isLikeChecked = false,
likeCount = 24,
writerProfileImageUrl = "",
Expand All @@ -238,7 +213,6 @@ private fun DPlayLargeCoverPreview() {
musicImageUrl = "",
onStreamClick = {},
onLikeClick = {},
onBookmarkClick = {},
onCoverClick = {},
onWriterProfileClick = {},
)
Expand Down
13 changes: 7 additions & 6 deletions core/domain/src/main/java/com/example/domain/model/FeedItem.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package com.example.domain.model


data class FeedItem(
val postId: Long,
val isScrapped: Boolean,
val content: String,
val badges: Badges,
val badge: BADGE?,
val track: Track,
val writer: Writer,
val like: Like,
)

data class Badges(
val isEditorPick: Boolean,
val isPopular: Boolean,
val isNew: Boolean,
)
enum class BADGE {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kotlin 에서 enum class의 네이밍 컨벤션은 파스칼 케이스로 알고 있습니다

EDITOR,
BEST,
NEW,
}
12 changes: 11 additions & 1 deletion core/domain/src/main/java/com/example/domain/model/PostDetail.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
package com.example.domain.model

import java.time.LocalDate
import java.time.format.DateTimeFormatter

data class PostDetail(
val postId: Long,
val isHost: Boolean,
val isScrapped: Boolean,
val content: String,
private val date: String,
val track: Track,
val writer: Writer,
val like: Like,
)
) {
val displayDate: String
get() = runCatching {
val parsedDate = LocalDate.parse(date, DateTimeFormatter.ISO_DATE)
"${parsedDate.monthValue}월 ${parsedDate.dayOfMonth}일"
}.getOrElse { "알 수 없는 날짜" }
}
1 change: 1 addition & 0 deletions core/navigation/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ dependencies {
implementation(libs.kotlinx.serialization.json)
implementation(projects.core.designsystem)
implementation(projects.core.common)
implementation(projects.core.domain)
implementation(projects.core.ui)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.example.navigation
import androidx.annotation.DrawableRes
import androidx.navigation3.runtime.NavKey
import com.dplay.designsystem.R
import com.example.domain.model.BADGE
import com.example.ui.model.TrackState
import kotlinx.serialization.Serializable

Expand Down Expand Up @@ -62,5 +63,5 @@ data object Record : NavKey
@Serializable
data class Detail(
val postId: Long,
val date: String = "",
val badge: BADGE? = null,
) : NavKey
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.example.comment

import androidx.lifecycle.viewModelScope
import com.example.common.constant.Url
import com.example.common.event.HomeRefreshTrigger
import com.example.domain.repository.PostRepository
import com.example.ui.base.BaseViewModel
import com.example.ui.model.TrackState
Expand All @@ -15,6 +16,7 @@ class CommentViewModel
@Inject
constructor(
private val postRepository: PostRepository,
private val homeRefreshTrigger: HomeRefreshTrigger,
) : BaseViewModel<CommentContract.CommentState, CommentContract.CommentIntent, CommentContract.CommentSideEffect>(
CommentContract.CommentState(),
) {
Expand Down Expand Up @@ -60,6 +62,7 @@ class CommentViewModel
track = track,
comment = currentState.commentInput,
).onSuccess {
homeRefreshTrigger.refresh()
setSideEffect(CommentContract.CommentSideEffect.NavigateToHome)
}.onFailure {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.example.detail

import com.example.designsystem.component.snackbar.type.SnackBarType
import com.example.domain.model.BADGE
import com.example.domain.model.Like
import com.example.domain.model.Track
import com.example.domain.model.Writer
Expand All @@ -12,6 +13,7 @@ class DetailContract {
val isScrapped: Boolean = false,
val content: String = "",
val isHost: Boolean = false,
val date: String = "",
val track: Track =
Track(
trackId = "",
Expand All @@ -31,18 +33,15 @@ class DetailContract {
isLiked = false,
count = 0,
),
val date: String = "2025-10-19",
val badge: BADGE? = null,
val bottomSheetVisible: Boolean = false,
val streamingTrackId: String? = null,
val currentUserId: Long = 0L,
) : BaseContract.State {
val isMyPost: Boolean get() = currentUserId != 0L && currentUserId == writer.userId
}
) : BaseContract.State

sealed interface DetailIntent : BaseContract.Intent {
data class LoadData(
val postId: Long,
val date: String = "",
val badge: BADGE? = null,
) : DetailIntent

data object OnBookmarkClick : DetailIntent
Expand All @@ -63,12 +62,16 @@ class DetailContract {

data object OnDeleteClick : DetailIntent

data object OnDeleteConfirmClick : DetailIntent

data class ChangeBottomSheetVisible(
val visible: Boolean,
) : DetailIntent
}

sealed interface DetailSideEffect : BaseContract.SideEffect {
data object ShowDeleteConfirmModal : DetailSideEffect

data object NavigateBackStack : DetailSideEffect

data object NavigateToWriterProfile : DetailSideEffect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ object DetailNavigationModule {
): EntryProviderScope<NavKey>.() -> Unit =
{
entry<Detail> { args ->
DetailRoute(postId = args.postId, navigator = navigator, date = args.date)
DetailRoute(postId = args.postId, navigator = navigator, badge = args.badge)
}
}
}
Loading