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
@@ -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 @@ -108,6 +108,7 @@ fun DPlayTitleButtonBottomSheet(
onButtonClick: () -> Unit,
onCloseClick: () -> Unit,
modifier: Modifier = Modifier,
isButtonEnabled: Boolean = true,
content: @Composable ColumnScope.() -> Unit,
) {
val bottomSheetShape = RoundedCornerShape(topStart = 16.dp, topEnd = 16.dp)
Expand Down Expand Up @@ -164,39 +165,36 @@ fun DPlayTitleButtonBottomSheet(
.padding(horizontal = 8.5.dp),
onClick = onButtonClick,
label = buttonText,
enabled = isButtonEnabled,
)
}
}

@Composable
fun DPlayReportBottomSheet(
onButtonClick: (selectedReasons: List<DPlayReportReason>) -> Unit,
onButtonClick: (selectedReason: DPlayReportReason) -> Unit,
onCloseClick: () -> Unit,
modifier: Modifier = Modifier,
onCheckClick: ((DPlayReportReason) -> Unit)? = null,
reasons: List<DPlayReportReason> = DPlayReportReason.entries,
) {
var selectedReasons by remember { mutableStateOf(setOf<DPlayReportReason>()) }
var selectedReason by remember { mutableStateOf<DPlayReportReason?>(null) }

DPlayTitleButtonBottomSheet(
titleText = stringResource(R.string.report_bottom_sheet_title),
buttonText = "신고하기",
onButtonClick = { onButtonClick(selectedReasons.toList()) },
onButtonClick = { selectedReason?.let { onButtonClick(it) } },
onCloseClick = onCloseClick,
modifier = modifier,
isButtonEnabled = selectedReason != null,
) {
reasons.forEach { reason ->
val isChecked = reason in selectedReasons
val isChecked = reason == selectedReason
DPlayCheck(
text = stringResource(reason.stringResId),
isChecked = isChecked,
onClick = {
selectedReasons =
if (isChecked) {
selectedReasons - reason
} else {
selectedReasons + reason
}
selectedReason = if (isChecked) null else reason
onCheckClick?.invoke(reason)
},
modifier = Modifier.fillMaxWidth(),
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.example.designsystem.theme.DPlayTheme
Expand All @@ -30,9 +31,21 @@ fun DPlayMusicGridItem(
.fillMaxWidth(),
)
Spacer(modifier = Modifier.height(5.dp))
Text(text = musicName, style = DPlayTheme.typography.bodySemi14, color = DPlayTheme.colors.dplayBlack)
Text(
text = musicName,
style = DPlayTheme.typography.bodySemi14,
color = DPlayTheme.colors.dplayBlack,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
Spacer(modifier = Modifier.height(1.dp))
Text(text = musicArtistName, style = DPlayTheme.typography.capMed12, color = DPlayTheme.colors.gray400)
Text(
text = musicArtistName,
style = DPlayTheme.typography.capMed12,
color = DPlayTheme.colors.gray400,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ fun DPlayMusicListItem(
musicName: String,
musicArtistName: String,
musicContent: String,
onMoreClick: () -> Unit,
modifier: Modifier = Modifier,
onMoreClick: (() -> Unit)? = null,
isEditorPick: Boolean = false,
onClick: () -> Unit = {},
) {
Expand Down Expand Up @@ -69,11 +69,13 @@ fun DPlayMusicListItem(
)
Spacer(modifier = Modifier.width(8.dp))
Column(modifier = Modifier.weight(1f)) {
DplayClickableIcon(
iconRes = R.drawable.ic_more_gray_20,
onClick = onMoreClick,
modifier = Modifier.align(Alignment.End),
)
onMoreClick?.let {
DplayClickableIcon(
iconRes = R.drawable.ic_more_gray_20,
onClick = it,
modifier = Modifier.align(Alignment.End),
)
}
BoxWithConstraints {
val maxTitleWidth = maxWidth * 0.5f

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 {
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 @@ -20,7 +20,7 @@ class Navigator(
val shouldShowBottomSheet: Boolean
get() = backStack.lastOrNull() is TopLevelRoute

val topLevelRoutes: ImmutableList<TopLevelRoute> = persistentListOf(Home, MyPage)
val topLevelRoutes: ImmutableList<TopLevelRoute> = persistentListOf(Home, MyPage())

fun navigateToTopLevelRoute(destination: TopLevelRoute) {
clearAndNavigateTo(destination as NavKey)
Expand Down
13 changes: 11 additions & 2 deletions core/navigation/src/main/java/com/example/navigation/Route.kt
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 All @@ -21,7 +22,15 @@ data object Home : TopLevelRoute, NavKey {
get() = R.drawable.ic_home_disabled_32
}

data object MyPage : TopLevelRoute, NavKey {
enum class MyPageTab {
REGISTERED,
BOOKMARKED,
}

data class MyPage(
val initialTab: MyPageTab = MyPageTab.REGISTERED,
) : TopLevelRoute,
NavKey {
override val selectedIconRes: Int
get() = R.drawable.ic_bookmark_active_32
override val unselectedIconRes: Int
Expand Down Expand Up @@ -62,5 +71,5 @@ data object Record : NavKey
@Serializable
data class Detail(
val postId: Long,
val date: String = "",
val badge: BADGE? = null,
) : NavKey
Loading