Skip to content

Commit 44fabb9

Browse files
authored
Merge pull request #269 from YAPP-Github/BOOK-504-fix/#268
fix: 감정 통계 > 가장 많이 느낀 감정 폰트 컬러 주황색으로 고정됨
2 parents 629daa8 + 9445b51 commit 44fabb9

3 files changed

Lines changed: 75 additions & 26 deletions

File tree

core/designsystem/src/main/kotlin/com/ninecraft/booket/core/designsystem/EmotionCode.kt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@ package com.ninecraft.booket.core.designsystem
22

33
import androidx.compose.ui.graphics.Color
44
import com.ninecraft.booket.core.designsystem.theme.Blue300
5-
import com.ninecraft.booket.core.designsystem.theme.OtherBgColor
6-
import com.ninecraft.booket.core.designsystem.theme.OtherTextColor
5+
import com.ninecraft.booket.core.designsystem.theme.Blue500
76
import com.ninecraft.booket.core.designsystem.theme.InsightBgColor
87
import com.ninecraft.booket.core.designsystem.theme.InsightTextColor
98
import com.ninecraft.booket.core.designsystem.theme.JoyBgColor
109
import com.ninecraft.booket.core.designsystem.theme.JoyTextColor
1110
import com.ninecraft.booket.core.designsystem.theme.Neutral300
11+
import com.ninecraft.booket.core.designsystem.theme.Neutral500
1212
import com.ninecraft.booket.core.designsystem.theme.Orange300
13+
import com.ninecraft.booket.core.designsystem.theme.Orange400
14+
import com.ninecraft.booket.core.designsystem.theme.OtherBgColor
15+
import com.ninecraft.booket.core.designsystem.theme.OtherTextColor
1316
import com.ninecraft.booket.core.designsystem.theme.SadnessBgColor
1417
import com.ninecraft.booket.core.designsystem.theme.SadnessTextColor
1518
import com.ninecraft.booket.core.designsystem.theme.Violet300
19+
import com.ninecraft.booket.core.designsystem.theme.Violet500
1620
import com.ninecraft.booket.core.designsystem.theme.WarmthBgColor
1721
import com.ninecraft.booket.core.designsystem.theme.WarmthTextColor
1822
import com.ninecraft.booket.core.designsystem.theme.Yellow300
23+
import com.ninecraft.booket.core.designsystem.theme.Yellow700
1924
import com.ninecraft.booket.core.model.EmotionCode
2025

2126
val EmotionCode.bgColor: Color
@@ -36,6 +41,15 @@ val EmotionCode.textColor: Color
3641
EmotionCode.OTHER -> OtherTextColor
3742
}
3843

44+
val EmotionCode.primaryEmotionColor: Color
45+
get() = when (this) {
46+
EmotionCode.WARMTH -> Yellow700
47+
EmotionCode.JOY -> Orange400
48+
EmotionCode.SADNESS -> Blue500
49+
EmotionCode.INSIGHT -> Violet500
50+
EmotionCode.OTHER -> Neutral500
51+
}
52+
3953
val EmotionCode.ratioBarColor: Color
4054
get() = when (this) {
4155
EmotionCode.WARMTH -> Yellow300

feature/detail/src/main/kotlin/com/ninecraft/booket/feature/detail/book/component/CollectedSeeds.kt

Lines changed: 56 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,36 @@ import androidx.compose.material3.HorizontalDivider
2222
import androidx.compose.material3.Icon
2323
import androidx.compose.material3.Text
2424
import androidx.compose.runtime.Composable
25+
import androidx.compose.runtime.remember
2526
import androidx.compose.ui.Alignment
2627
import androidx.compose.ui.Modifier
2728
import androidx.compose.ui.draw.clip
2829
import androidx.compose.ui.graphics.vector.ImageVector
2930
import androidx.compose.ui.res.painterResource
31+
import androidx.compose.ui.res.stringResource
3032
import androidx.compose.ui.res.vectorResource
3133
import androidx.compose.ui.unit.dp
3234
import com.ninecraft.booket.core.designsystem.ComponentPreview
3335
import com.ninecraft.booket.core.designsystem.graphicRes
36+
import com.ninecraft.booket.core.designsystem.primaryEmotionColor
3437
import com.ninecraft.booket.core.designsystem.ratioBarColor
3538
import com.ninecraft.booket.core.designsystem.theme.ReedTheme
36-
import com.ninecraft.booket.core.designsystem.theme.Yellow700
3739
import com.ninecraft.booket.core.model.EmotionCode
3840
import com.ninecraft.booket.core.model.EmotionModel
3941
import com.ninecraft.booket.core.model.PrimaryEmotionModel
42+
import com.ninecraft.booket.feature.detail.R
4043
import kotlinx.collections.immutable.ImmutableList
4144
import kotlinx.collections.immutable.persistentListOf
4245
import com.ninecraft.booket.core.designsystem.R as designR
4346

47+
private val EMOTION_DISPLAY_ORDER = listOf(
48+
EmotionCode.WARMTH,
49+
EmotionCode.JOY,
50+
EmotionCode.SADNESS,
51+
EmotionCode.INSIGHT,
52+
EmotionCode.OTHER,
53+
)
54+
4455
@Composable
4556
internal fun CollectedSeeds(
4657
seedsStats: ImmutableList<EmotionModel>,
@@ -85,17 +96,23 @@ internal fun CollectedSeeds(
8596

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

88-
Row(
89-
modifier = Modifier.fillMaxWidth(),
90-
horizontalArrangement = Arrangement.spacedBy(ReedTheme.spacing.spacing1),
91-
) {
92-
EmotionCode.entries.forEach { emotionCode ->
93-
val emotionModel = seedsStats.find { it.code == emotionCode }
94-
?: EmotionModel(emotionCode, 0)
95-
EmotionStatCard(
96-
emotion = emotionModel,
97-
modifier = Modifier.weight(1f),
98-
)
99+
val displayEmotions = remember(seedsStats) {
100+
EMOTION_DISPLAY_ORDER.mapNotNull { emotionCode ->
101+
seedsStats.find { it.code == emotionCode && it.count > 0 }
102+
}
103+
}
104+
105+
if (displayEmotions.isNotEmpty()) {
106+
Row(
107+
modifier = Modifier.fillMaxWidth(),
108+
horizontalArrangement = Arrangement.spacedBy(ReedTheme.spacing.spacing1),
109+
) {
110+
displayEmotions.forEach { emotionModel ->
111+
EmotionStatCard(
112+
emotion = emotionModel,
113+
modifier = Modifier.weight(1f),
114+
)
115+
}
99116
}
100117
}
101118
}
@@ -132,15 +149,28 @@ private fun CollectedSeedsHeader(
132149
Spacer(modifier = Modifier.width(ReedTheme.spacing.spacing2))
133150
}
134151

135-
Row {
152+
Row(
153+
verticalAlignment = Alignment.CenterVertically,
154+
) {
155+
val emotionDisplayName = if (primaryEmotion.code == EmotionCode.OTHER) {
156+
stringResource(R.string.collected_seed_other_emotion_name)
157+
} else {
158+
primaryEmotion.code.displayName
159+
}
136160
Text(
137-
text = "'${primaryEmotion.code.displayName}'",
138-
color = Yellow700,
161+
text = "'$emotionDisplayName'",
162+
color = primaryEmotion.code.primaryEmotionColor,
139163
style = ReedTheme.typography.label1SemiBold,
140164
)
141165
Spacer(modifier = Modifier.width(ReedTheme.spacing.spacing1))
142166
Text(
143-
text = "감정을 많이 느꼈어요",
167+
text = stringResource(
168+
if (primaryEmotion.code == EmotionCode.OTHER) {
169+
R.string.collected_seed_other_emotion_description
170+
} else {
171+
R.string.collected_seed_emotion_description
172+
},
173+
),
144174
color = ReedTheme.colors.contentSecondary,
145175
style = ReedTheme.typography.label1Medium,
146176
)
@@ -163,7 +193,9 @@ private fun EmotionRatioBar(
163193
seedsStats: ImmutableList<EmotionModel>,
164194
modifier: Modifier = Modifier,
165195
) {
166-
val totalCount = seedsStats.sumOf { it.count }.coerceAtLeast(1)
196+
val totalCount = remember(seedsStats) {
197+
seedsStats.sumOf { it.count }.coerceAtLeast(1)
198+
}
167199

168200
Row(
169201
modifier = modifier
@@ -231,13 +263,13 @@ private fun CollectedSeedsCollapsedPreview() {
231263
ReedTheme {
232264
CollectedSeeds(
233265
seedsStats = persistentListOf(
234-
EmotionModel(EmotionCode.WARMTH, 4),
266+
EmotionModel(EmotionCode.WARMTH, 2),
235267
EmotionModel(EmotionCode.JOY, 2),
236-
EmotionModel(EmotionCode.SADNESS, 2),
268+
EmotionModel(EmotionCode.SADNESS, 4),
237269
EmotionModel(EmotionCode.INSIGHT, 2),
238270
EmotionModel(EmotionCode.OTHER, 2),
239271
),
240-
representativeEmotion = PrimaryEmotionModel(EmotionCode.WARMTH, "기쁨"),
272+
representativeEmotion = PrimaryEmotionModel(EmotionCode.SADNESS, "슬픔"),
241273
isStatsExpanded = false,
242274
onToggleClick = {},
243275
)
@@ -250,13 +282,13 @@ private fun CollectedSeedsExpandedPreview() {
250282
ReedTheme {
251283
CollectedSeeds(
252284
seedsStats = persistentListOf(
253-
EmotionModel(EmotionCode.WARMTH, 4),
285+
EmotionModel(EmotionCode.WARMTH, 2),
254286
EmotionModel(EmotionCode.JOY, 2),
255287
EmotionModel(EmotionCode.SADNESS, 2),
256288
EmotionModel(EmotionCode.INSIGHT, 2),
257-
EmotionModel(EmotionCode.OTHER, 2),
289+
EmotionModel(EmotionCode.OTHER, 4),
258290
),
259-
representativeEmotion = PrimaryEmotionModel(EmotionCode.WARMTH, "기쁨"),
291+
representativeEmotion = PrimaryEmotionModel(EmotionCode.OTHER, "기타"),
260292
isStatsExpanded = true,
261293
onToggleClick = {},
262294
)
@@ -275,7 +307,7 @@ private fun CollectedSeedsExpandedDuplicatedPreview() {
275307
EmotionModel(EmotionCode.INSIGHT, 2),
276308
EmotionModel(EmotionCode.OTHER, 2),
277309
),
278-
representativeEmotion = PrimaryEmotionModel(EmotionCode.WARMTH, "기쁨"),
310+
representativeEmotion = PrimaryEmotionModel(EmotionCode.WARMTH, "따뜻함"),
279311
isStatsExpanded = true,
280312
onToggleClick = {},
281313
)

feature/detail/src/main/res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<string name="record_sort_title">정렬</string>
99
<string name="record_collection">내 기록 모음</string>
1010
<string name="collected_seed_title">내가 모은 씨앗</string>
11+
<string name="collected_seed_emotion_description">감정을 많이 느꼈어요</string>
12+
<string name="collected_seed_other_emotion_name">여러</string>
13+
<string name="collected_seed_other_emotion_description">감정을 느꼈어요</string>
1114
<string name="records_collection_empty">첫 기록을 남겨 보세요!\n나만의 아카이브를 만들 수 있어요.</string>
1215
<string name="register_book_record">독서 기록 추가</string>
1316
<string name="record_detail_share">공유하기</string>

0 commit comments

Comments
 (0)