Skip to content

Commit a8b5f54

Browse files
committed
[BOOK-417] refactor: EmotionTag를 core:model의 Emotion으 대체
1 parent cd7107c commit a8b5f54

File tree

15 files changed

+56
-54
lines changed

15 files changed

+56
-54
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,11 @@ val Emotion.textColor: Color
2626
Emotion.SAD -> SadnessTextColor
2727
Emotion.INSIGHT -> InsightTextColor
2828
}
29+
30+
val Emotion.graphicRes: Int
31+
get() = when (this) {
32+
Emotion.WARM -> R.drawable.img_emotion_warmth
33+
Emotion.JOY -> R.drawable.img_emotion_joy
34+
Emotion.SAD -> R.drawable.img_emotion_sadness
35+
Emotion.INSIGHT -> R.drawable.img_emotion_insight
36+
}

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

Lines changed: 0 additions & 8 deletions
This file was deleted.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ class BookDetailPresenter @AssistedInject constructor(
306306
RecordCardScreen(
307307
quote = selectedRecordInfo.quote,
308308
bookTitle = selectedRecordInfo.bookTitle,
309-
emotionTag = selectedRecordInfo.emotionTags[0],
309+
emotion = selectedRecordInfo.emotionTags[0],
310310
),
311311
)
312312
}

feature/detail/src/main/kotlin/com/ninecraft/booket/feature/detail/card/RecordCardPresenter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class RecordCardPresenter @AssistedInject constructor(
7474
isLoading = isLoading,
7575
quote = screen.quote,
7676
bookTitle = screen.bookTitle,
77-
emotionTag = screen.emotionTag,
77+
emotion = screen.emotion,
7878
isCapturing = isCapturing,
7979
isSharing = isSharing,
8080
sideEffect = sideEffect,

feature/detail/src/main/kotlin/com/ninecraft/booket/feature/detail/card/RecordCardUi.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ internal fun RecordCardUi(
8383
RecordCard(
8484
quote = state.quote,
8585
bookTitle = state.bookTitle,
86-
emotionTag = state.emotionTag,
86+
emotion = state.emotion,
8787
modifier = Modifier
8888
.padding(top = ReedTheme.spacing.spacing5)
8989
.clip(RoundedCornerShape(ReedTheme.radius.md))

feature/detail/src/main/kotlin/com/ninecraft/booket/feature/detail/card/RecordCardUiState.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ data class RecordCardUiState(
1111
val quote: String = "",
1212
val bookTitle: String = "",
1313
val author: String = "",
14-
val emotionTag: String = "",
14+
val emotion: String = "",
1515
val isCapturing: Boolean = false,
1616
val isSharing: Boolean = false,
1717
val sideEffect: RecordCardSideEffect? = null,

feature/detail/src/main/kotlin/com/ninecraft/booket/feature/detail/card/component/RecordCard.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ import androidx.compose.ui.res.painterResource
1919
import androidx.compose.ui.text.style.TextOverflow
2020
import androidx.compose.ui.unit.sp
2121
import com.ninecraft.booket.core.designsystem.ComponentPreview
22-
import com.ninecraft.booket.core.designsystem.EmotionTag
2322
import com.ninecraft.booket.core.designsystem.theme.ReedTheme
23+
import com.ninecraft.booket.core.model.Emotion
2424
import com.ninecraft.booket.feature.detail.R
2525

2626
@Composable
2727
internal fun RecordCard(
2828
quote: String,
2929
bookTitle: String,
30-
emotionTag: String,
30+
emotion: String,
3131
modifier: Modifier = Modifier,
3232
) {
3333
Box(modifier = modifier.fillMaxWidth()) {
3434
Image(
35-
painter = painterResource(getEmotionCardImage(emotionTag)),
35+
painter = painterResource(getEmotionCardImage(emotion)),
3636
contentDescription = "Record Card Image",
3737
modifier = Modifier.fillMaxSize(),
3838
contentScale = ContentScale.Crop,
@@ -74,12 +74,12 @@ internal fun RecordCard(
7474
}
7575
}
7676

77-
private fun getEmotionCardImage(emotionTag: String): Int {
78-
return when (emotionTag) {
79-
EmotionTag.WARMTH.label -> R.drawable.img_record_card_warm
80-
EmotionTag.JOY.label -> R.drawable.img_record_card_joy
81-
EmotionTag.SADNESS.label -> R.drawable.img_record_card_sad
82-
EmotionTag.INSIGHT.label -> R.drawable.img_record_card_insight
77+
private fun getEmotionCardImage(emotion: String): Int {
78+
return when (emotion) {
79+
Emotion.WARM.displayName -> R.drawable.img_record_card_warm
80+
Emotion.JOY.displayName -> R.drawable.img_record_card_joy
81+
Emotion.SAD.displayName -> R.drawable.img_record_card_sad
82+
Emotion.INSIGHT.displayName -> R.drawable.img_record_card_insight
8383
else -> R.drawable.img_record_card_warm
8484
}
8585
}
@@ -91,7 +91,7 @@ private fun RecordCardPreview() {
9191
RecordCard(
9292
quote = "이 세상에 집이라 이름 붙일 수 없는 것이 있다면 그건 바로 여기, 내가 앉아 있는 이곳일 것이다.",
9393
bookTitle = "샤이닝",
94-
emotionTag = EmotionTag.WARMTH.label,
94+
emotion = Emotion.WARM.displayName,
9595
)
9696
}
9797
}

feature/detail/src/main/kotlin/com/ninecraft/booket/feature/detail/record/RecordDetailPresenter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class RecordDetailPresenter @AssistedInject constructor(
127127
RecordCardScreen(
128128
quote = recordDetailInfo.quote,
129129
bookTitle = recordDetailInfo.bookTitle,
130-
emotionTag = recordDetailInfo.emotionTags[0],
130+
emotion = recordDetailInfo.emotionTags[0],
131131
),
132132
)
133133
}

feature/edit/src/main/kotlin/com/ninecraft/booket/feature/edit/emotion/EmotionEditPresenter.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import androidx.compose.runtime.getValue
66
import androidx.compose.runtime.mutableStateOf
77
import androidx.compose.runtime.remember
88
import androidx.compose.runtime.setValue
9-
import com.ninecraft.booket.core.designsystem.EmotionTag
9+
import com.ninecraft.booket.core.model.Emotion
1010
import com.ninecraft.booket.feature.screens.EmotionEditScreen
1111
import com.slack.circuit.codegen.annotations.CircuitInject
1212
import com.slack.circuit.retained.rememberRetained
@@ -25,7 +25,7 @@ class EmotionEditPresenter @AssistedInject constructor(
2525
@Composable
2626
override fun present(): EmotionEditUiState {
2727
var selectedEmotion by rememberRetained { mutableStateOf(screen.emotion) }
28-
val emotionTags by rememberRetained { mutableStateOf(EmotionTag.entries.toPersistentList()) }
28+
val emotions by rememberRetained { mutableStateOf(Emotion.entries.toPersistentList()) }
2929
val isEditButtonEnabled by remember {
3030
derivedStateOf {
3131
selectedEmotion != screen.emotion
@@ -50,7 +50,7 @@ class EmotionEditPresenter @AssistedInject constructor(
5050

5151
return EmotionEditUiState(
5252
selectedEmotion = selectedEmotion,
53-
emotionTags = emotionTags,
53+
emotions = emotions,
5454
isEditButtonEnabled = isEditButtonEnabled,
5555
eventSink = ::handleEvent,
5656
)

feature/edit/src/main/kotlin/com/ninecraft/booket/feature/edit/emotion/EmotionEditUi.kt

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ import androidx.compose.ui.res.stringResource
2626
import androidx.compose.ui.unit.dp
2727
import com.ninecraft.booket.core.common.extensions.clickableSingle
2828
import com.ninecraft.booket.core.designsystem.ComponentPreview
29-
import com.ninecraft.booket.core.designsystem.EmotionTag
3029
import com.ninecraft.booket.core.designsystem.component.button.ReedButton
3130
import com.ninecraft.booket.core.designsystem.component.button.ReedButtonColorStyle
3231
import com.ninecraft.booket.core.designsystem.component.button.largeButtonStyle
32+
import com.ninecraft.booket.core.designsystem.graphicRes
3333
import com.ninecraft.booket.core.designsystem.theme.ReedTheme
3434
import com.ninecraft.booket.core.designsystem.theme.White
35+
import com.ninecraft.booket.core.model.Emotion
3536
import com.ninecraft.booket.core.ui.ReedScaffold
3637
import com.ninecraft.booket.core.ui.component.ReedBackTopAppBar
3738
import com.ninecraft.booket.feature.edit.R
@@ -100,13 +101,13 @@ private fun EmotionEditContent(
100101
verticalArrangement = Arrangement.spacedBy(ReedTheme.spacing.spacing3),
101102
horizontalArrangement = Arrangement.spacedBy(ReedTheme.spacing.spacing3),
102103
content = {
103-
items(state.emotionTags) { tag ->
104+
items(state.emotions) { tag ->
104105
EmotionItem(
105-
emotionTag = tag,
106+
emotion = tag,
106107
onClick = {
107-
state.eventSink(EmotionEditUiEvent.OnSelectEmotion(tag.label))
108+
state.eventSink(EmotionEditUiEvent.OnSelectEmotion(tag.displayName))
108109
},
109-
isSelected = state.selectedEmotion == tag.label,
110+
isSelected = state.selectedEmotion == tag.displayName,
110111
modifier = Modifier.fillMaxWidth(),
111112
)
112113
}
@@ -129,7 +130,7 @@ private fun EmotionEditContent(
129130

130131
@Composable
131132
private fun EmotionItem(
132-
emotionTag: EmotionTag,
133+
emotion: Emotion,
133134
onClick: () -> Unit,
134135
isSelected: Boolean,
135136
modifier: Modifier = Modifier,
@@ -156,7 +157,7 @@ private fun EmotionItem(
156157
contentAlignment = Alignment.Center,
157158
) {
158159
Image(
159-
painter = painterResource(emotionTag.graphic),
160+
painter = painterResource(emotion.graphicRes),
160161
contentDescription = "Emotion Image",
161162
modifier = Modifier.fillMaxSize(),
162163
contentScale = ContentScale.Crop,
@@ -168,11 +169,11 @@ private fun EmotionItem(
168169
@Composable
169170
private fun EmotionEditUiPreview() {
170171
ReedTheme {
171-
val emotionTags = EmotionTag.entries.toPersistentList()
172+
val emotions = Emotion.entries.toPersistentList()
172173

173174
EmotionEditUi(
174175
state = EmotionEditUiState(
175-
emotionTags = emotionTags,
176+
emotions = emotions,
176177
eventSink = {},
177178
),
178179
)

0 commit comments

Comments
 (0)