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 @@ -2,20 +2,25 @@ package com.ninecraft.booket.core.designsystem

import androidx.compose.ui.graphics.Color
import com.ninecraft.booket.core.designsystem.theme.Blue300
import com.ninecraft.booket.core.designsystem.theme.OtherBgColor
import com.ninecraft.booket.core.designsystem.theme.OtherTextColor
import com.ninecraft.booket.core.designsystem.theme.Blue500
import com.ninecraft.booket.core.designsystem.theme.InsightBgColor
import com.ninecraft.booket.core.designsystem.theme.InsightTextColor
import com.ninecraft.booket.core.designsystem.theme.JoyBgColor
import com.ninecraft.booket.core.designsystem.theme.JoyTextColor
import com.ninecraft.booket.core.designsystem.theme.Neutral300
import com.ninecraft.booket.core.designsystem.theme.Neutral500
import com.ninecraft.booket.core.designsystem.theme.Orange300
import com.ninecraft.booket.core.designsystem.theme.Orange400
import com.ninecraft.booket.core.designsystem.theme.OtherBgColor
import com.ninecraft.booket.core.designsystem.theme.OtherTextColor
import com.ninecraft.booket.core.designsystem.theme.SadnessBgColor
import com.ninecraft.booket.core.designsystem.theme.SadnessTextColor
import com.ninecraft.booket.core.designsystem.theme.Violet300
import com.ninecraft.booket.core.designsystem.theme.Violet500
import com.ninecraft.booket.core.designsystem.theme.WarmthBgColor
import com.ninecraft.booket.core.designsystem.theme.WarmthTextColor
import com.ninecraft.booket.core.designsystem.theme.Yellow300
import com.ninecraft.booket.core.designsystem.theme.Yellow700
import com.ninecraft.booket.core.model.EmotionCode

val EmotionCode.bgColor: Color
Expand All @@ -36,6 +41,15 @@ val EmotionCode.textColor: Color
EmotionCode.OTHER -> OtherTextColor
}

val EmotionCode.primaryEmotionColor: Color
get() = when (this) {
EmotionCode.WARMTH -> Yellow700
EmotionCode.JOY -> Orange400
EmotionCode.SADNESS -> Blue500
EmotionCode.INSIGHT -> Violet500
EmotionCode.OTHER -> Neutral500
}

val EmotionCode.ratioBarColor: Color
get() = when (this) {
EmotionCode.WARMTH -> Yellow300
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,36 @@ import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.unit.dp
import com.ninecraft.booket.core.designsystem.ComponentPreview
import com.ninecraft.booket.core.designsystem.graphicRes
import com.ninecraft.booket.core.designsystem.primaryEmotionColor
import com.ninecraft.booket.core.designsystem.ratioBarColor
import com.ninecraft.booket.core.designsystem.theme.ReedTheme
import com.ninecraft.booket.core.designsystem.theme.Yellow700
import com.ninecraft.booket.core.model.EmotionCode
import com.ninecraft.booket.core.model.EmotionModel
import com.ninecraft.booket.core.model.PrimaryEmotionModel
import com.ninecraft.booket.feature.detail.R
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import com.ninecraft.booket.core.designsystem.R as designR

private val EMOTION_DISPLAY_ORDER = listOf(
EmotionCode.WARMTH,
EmotionCode.JOY,
EmotionCode.SADNESS,
EmotionCode.INSIGHT,
EmotionCode.OTHER,
)

@Composable
internal fun CollectedSeeds(
seedsStats: ImmutableList<EmotionModel>,
Expand Down Expand Up @@ -85,17 +96,23 @@ internal fun CollectedSeeds(

Spacer(modifier = Modifier.height(ReedTheme.spacing.spacing4))

Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(ReedTheme.spacing.spacing1),
) {
EmotionCode.entries.forEach { emotionCode ->
val emotionModel = seedsStats.find { it.code == emotionCode }
?: EmotionModel(emotionCode, 0)
EmotionStatCard(
emotion = emotionModel,
modifier = Modifier.weight(1f),
)
val displayEmotions = remember(seedsStats) {
EMOTION_DISPLAY_ORDER.mapNotNull { emotionCode ->
seedsStats.find { it.code == emotionCode && it.count > 0 }
}
}

if (displayEmotions.isNotEmpty()) {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(ReedTheme.spacing.spacing1),
) {
displayEmotions.forEach { emotionModel ->
EmotionStatCard(
emotion = emotionModel,
modifier = Modifier.weight(1f),
)
}
}
}
}
Expand Down Expand Up @@ -132,15 +149,28 @@ private fun CollectedSeedsHeader(
Spacer(modifier = Modifier.width(ReedTheme.spacing.spacing2))
}

Row {
Row(
verticalAlignment = Alignment.CenterVertically,
) {
val emotionDisplayName = if (primaryEmotion.code == EmotionCode.OTHER) {
stringResource(R.string.collected_seed_other_emotion_name)
} else {
primaryEmotion.code.displayName
}
Text(
text = "'${primaryEmotion.code.displayName}'",
color = Yellow700,
text = "'$emotionDisplayName'",
color = primaryEmotion.code.primaryEmotionColor,
style = ReedTheme.typography.label1SemiBold,
)
Spacer(modifier = Modifier.width(ReedTheme.spacing.spacing1))
Text(
text = "감정을 많이 느꼈어요",
text = stringResource(
if (primaryEmotion.code == EmotionCode.OTHER) {
R.string.collected_seed_other_emotion_description
} else {
R.string.collected_seed_emotion_description
},
),
color = ReedTheme.colors.contentSecondary,
style = ReedTheme.typography.label1Medium,
)
Expand All @@ -163,7 +193,9 @@ private fun EmotionRatioBar(
seedsStats: ImmutableList<EmotionModel>,
modifier: Modifier = Modifier,
) {
val totalCount = seedsStats.sumOf { it.count }.coerceAtLeast(1)
val totalCount = remember(seedsStats) {
seedsStats.sumOf { it.count }.coerceAtLeast(1)
}

Row(
modifier = modifier
Expand Down Expand Up @@ -231,13 +263,13 @@ private fun CollectedSeedsCollapsedPreview() {
ReedTheme {
CollectedSeeds(
seedsStats = persistentListOf(
EmotionModel(EmotionCode.WARMTH, 4),
EmotionModel(EmotionCode.WARMTH, 2),
EmotionModel(EmotionCode.JOY, 2),
EmotionModel(EmotionCode.SADNESS, 2),
EmotionModel(EmotionCode.SADNESS, 4),
EmotionModel(EmotionCode.INSIGHT, 2),
EmotionModel(EmotionCode.OTHER, 2),
),
representativeEmotion = PrimaryEmotionModel(EmotionCode.WARMTH, "기쁨"),
representativeEmotion = PrimaryEmotionModel(EmotionCode.SADNESS, "슬픔"),
isStatsExpanded = false,
onToggleClick = {},
)
Expand All @@ -250,13 +282,13 @@ private fun CollectedSeedsExpandedPreview() {
ReedTheme {
CollectedSeeds(
seedsStats = persistentListOf(
EmotionModel(EmotionCode.WARMTH, 4),
EmotionModel(EmotionCode.WARMTH, 2),
EmotionModel(EmotionCode.JOY, 2),
EmotionModel(EmotionCode.SADNESS, 2),
EmotionModel(EmotionCode.INSIGHT, 2),
EmotionModel(EmotionCode.OTHER, 2),
EmotionModel(EmotionCode.OTHER, 4),
),
representativeEmotion = PrimaryEmotionModel(EmotionCode.WARMTH, "기쁨"),
representativeEmotion = PrimaryEmotionModel(EmotionCode.OTHER, "기타"),
isStatsExpanded = true,
onToggleClick = {},
)
Expand All @@ -275,7 +307,7 @@ private fun CollectedSeedsExpandedDuplicatedPreview() {
EmotionModel(EmotionCode.INSIGHT, 2),
EmotionModel(EmotionCode.OTHER, 2),
),
representativeEmotion = PrimaryEmotionModel(EmotionCode.WARMTH, "기쁨"),
representativeEmotion = PrimaryEmotionModel(EmotionCode.WARMTH, "따뜻함"),
isStatsExpanded = true,
onToggleClick = {},
)
Expand Down
3 changes: 3 additions & 0 deletions feature/detail/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<string name="record_sort_title">정렬</string>
<string name="record_collection">내 기록 모음</string>
<string name="collected_seed_title">내가 모은 씨앗</string>
<string name="collected_seed_emotion_description">감정을 많이 느꼈어요</string>
<string name="collected_seed_other_emotion_name">여러</string>
<string name="collected_seed_other_emotion_description">감정을 느꼈어요</string>
<string name="records_collection_empty">첫 기록을 남겨 보세요!\n나만의 아카이브를 만들 수 있어요.</string>
<string name="register_book_record">독서 기록 추가</string>
<string name="record_detail_share">공유하기</string>
Expand Down
Loading