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

This file was deleted.

1 change: 1 addition & 0 deletions core/designsystem/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ android {
dependencies {
implementations(
projects.core.common,
projects.core.model,

libs.androidx.splash,

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.ninecraft.booket.core.designsystem

import androidx.compose.ui.graphics.Color
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.SadnessBgColor
import com.ninecraft.booket.core.designsystem.theme.SadnessTextColor
import com.ninecraft.booket.core.designsystem.theme.WarmthBgColor
import com.ninecraft.booket.core.designsystem.theme.WarmthTextColor
import com.ninecraft.booket.core.model.Emotion

val Emotion.bgColor: Color
get() = when (this) {
Emotion.WARM -> WarmthBgColor
Emotion.JOY -> JoyBgColor
Emotion.SAD -> SadnessBgColor
Emotion.INSIGHT -> InsightBgColor
}

val Emotion.textColor: Color
get() = when (this) {
Emotion.WARM -> WarmthTextColor
Emotion.JOY -> JoyTextColor
Emotion.SAD -> SadnessTextColor
Emotion.INSIGHT -> InsightTextColor
}

val Emotion.graphicRes: Int
get() = when (this) {
Emotion.WARM -> R.drawable.img_emotion_warmth
Emotion.JOY -> R.drawable.img_emotion_joy
Emotion.SAD -> R.drawable.img_emotion_sadness
Emotion.INSIGHT -> R.drawable.img_emotion_insight
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ class BookDetailPresenter @AssistedInject constructor(
RecordCardScreen(
quote = selectedRecordInfo.quote,
bookTitle = selectedRecordInfo.bookTitle,
emotionTag = selectedRecordInfo.emotionTags[0],
emotion = selectedRecordInfo.emotionTags[0],
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import com.ninecraft.booket.core.common.extensions.toBackgroundColor
import com.ninecraft.booket.core.common.extensions.toTextColor
import com.ninecraft.booket.core.designsystem.ComponentPreview
import com.ninecraft.booket.core.designsystem.bgColor
import com.ninecraft.booket.core.designsystem.textColor
import com.ninecraft.booket.core.designsystem.theme.ReedTheme
import com.ninecraft.booket.core.model.Emotion
import com.ninecraft.booket.core.model.EmotionModel
Expand All @@ -42,7 +42,7 @@ internal fun SeedItem(
Box(
modifier = Modifier
.clip(RoundedCornerShape(ReedTheme.radius.full))
.background(emotion.name.toBackgroundColor())
.background(emotion.name.bgColor)
.padding(
horizontal = ReedTheme.spacing.spacing2,
vertical = ReedTheme.spacing.spacing1,
Expand All @@ -51,7 +51,7 @@ internal fun SeedItem(
) {
Text(
text = emotion.name.displayName,
color = emotion.name.toTextColor(),
color = emotion.name.textColor,
style = ReedTheme.typography.label2SemiBold,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class RecordCardPresenter @AssistedInject constructor(
isLoading = isLoading,
quote = screen.quote,
bookTitle = screen.bookTitle,
emotionTag = screen.emotionTag,
emotion = screen.emotion,
isCapturing = isCapturing,
isSharing = isSharing,
sideEffect = sideEffect,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ internal fun RecordCardUi(
RecordCard(
quote = state.quote,
bookTitle = state.bookTitle,
emotionTag = state.emotionTag,
emotion = state.emotion,
modifier = Modifier
.padding(top = ReedTheme.spacing.spacing5)
.clip(RoundedCornerShape(ReedTheme.radius.md))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ data class RecordCardUiState(
val quote: String = "",
val bookTitle: String = "",
val author: String = "",
val emotionTag: String = "",
val emotion: String = "",
val isCapturing: Boolean = false,
val isSharing: Boolean = false,
val sideEffect: RecordCardSideEffect? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.sp
import com.ninecraft.booket.core.designsystem.ComponentPreview
import com.ninecraft.booket.core.designsystem.EmotionTag
import com.ninecraft.booket.core.designsystem.theme.ReedTheme
import com.ninecraft.booket.core.model.Emotion
import com.ninecraft.booket.feature.detail.R

@Composable
internal fun RecordCard(
quote: String,
bookTitle: String,
emotionTag: String,
emotion: String,
modifier: Modifier = Modifier,
) {
Box(modifier = modifier.fillMaxWidth()) {
Image(
painter = painterResource(getEmotionCardImage(emotionTag)),
painter = painterResource(getEmotionCardImage(emotion)),
contentDescription = "Record Card Image",
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop,
Expand Down Expand Up @@ -74,12 +74,12 @@ internal fun RecordCard(
}
}

private fun getEmotionCardImage(emotionTag: String): Int {
return when (emotionTag) {
EmotionTag.WARMTH.label -> R.drawable.img_record_card_warm
EmotionTag.JOY.label -> R.drawable.img_record_card_joy
EmotionTag.SADNESS.label -> R.drawable.img_record_card_sad
EmotionTag.INSIGHT.label -> R.drawable.img_record_card_insight
private fun getEmotionCardImage(emotion: String): Int {
return when (emotion) {
Emotion.WARM.displayName -> R.drawable.img_record_card_warm
Emotion.JOY.displayName -> R.drawable.img_record_card_joy
Emotion.SAD.displayName -> R.drawable.img_record_card_sad
Emotion.INSIGHT.displayName -> R.drawable.img_record_card_insight
else -> R.drawable.img_record_card_warm
}
}
Expand All @@ -91,7 +91,7 @@ private fun RecordCardPreview() {
RecordCard(
quote = "이 세상에 집이라 이름 붙일 수 없는 것이 있다면 그건 바로 여기, 내가 앉아 있는 이곳일 것이다.",
bookTitle = "샤이닝",
emotionTag = EmotionTag.WARMTH.label,
emotion = Emotion.WARM.displayName,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class RecordDetailPresenter @AssistedInject constructor(
RecordCardScreen(
quote = recordDetailInfo.quote,
bookTitle = recordDetailInfo.bookTitle,
emotionTag = recordDetailInfo.emotionTags[0],
emotion = recordDetailInfo.emotionTags[0],
),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import com.ninecraft.booket.core.designsystem.EmotionTag
import com.ninecraft.booket.core.model.Emotion
import com.ninecraft.booket.feature.screens.EmotionEditScreen
import com.slack.circuit.codegen.annotations.CircuitInject
import com.slack.circuit.retained.rememberRetained
Expand All @@ -25,7 +25,7 @@ class EmotionEditPresenter @AssistedInject constructor(
@Composable
override fun present(): EmotionEditUiState {
var selectedEmotion by rememberRetained { mutableStateOf(screen.emotion) }
val emotionTags by rememberRetained { mutableStateOf(EmotionTag.entries.toPersistentList()) }
val emotions by rememberRetained { mutableStateOf(Emotion.entries.toPersistentList()) }
val isEditButtonEnabled by remember {
derivedStateOf {
selectedEmotion != screen.emotion
Expand All @@ -50,7 +50,7 @@ class EmotionEditPresenter @AssistedInject constructor(

return EmotionEditUiState(
selectedEmotion = selectedEmotion,
emotionTags = emotionTags,
emotions = emotions,
isEditButtonEnabled = isEditButtonEnabled,
eventSink = ::handleEvent,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import com.ninecraft.booket.core.common.extensions.clickableSingle
import com.ninecraft.booket.core.designsystem.ComponentPreview
import com.ninecraft.booket.core.designsystem.EmotionTag
import com.ninecraft.booket.core.designsystem.component.button.ReedButton
import com.ninecraft.booket.core.designsystem.component.button.ReedButtonColorStyle
import com.ninecraft.booket.core.designsystem.component.button.largeButtonStyle
import com.ninecraft.booket.core.designsystem.graphicRes
import com.ninecraft.booket.core.designsystem.theme.ReedTheme
import com.ninecraft.booket.core.designsystem.theme.White
import com.ninecraft.booket.core.model.Emotion
import com.ninecraft.booket.core.ui.ReedScaffold
import com.ninecraft.booket.core.ui.component.ReedBackTopAppBar
import com.ninecraft.booket.feature.edit.R
Expand Down Expand Up @@ -100,13 +101,13 @@ private fun EmotionEditContent(
verticalArrangement = Arrangement.spacedBy(ReedTheme.spacing.spacing3),
horizontalArrangement = Arrangement.spacedBy(ReedTheme.spacing.spacing3),
content = {
items(state.emotionTags) { tag ->
items(state.emotions) { tag ->
EmotionItem(
emotionTag = tag,
emotion = tag,
onClick = {
state.eventSink(EmotionEditUiEvent.OnSelectEmotion(tag.label))
state.eventSink(EmotionEditUiEvent.OnSelectEmotion(tag.displayName))
},
isSelected = state.selectedEmotion == tag.label,
isSelected = state.selectedEmotion == tag.displayName,
modifier = Modifier.fillMaxWidth(),
)
}
Expand All @@ -129,7 +130,7 @@ private fun EmotionEditContent(

@Composable
private fun EmotionItem(
emotionTag: EmotionTag,
emotion: Emotion,
onClick: () -> Unit,
isSelected: Boolean,
modifier: Modifier = Modifier,
Expand All @@ -156,7 +157,7 @@ private fun EmotionItem(
contentAlignment = Alignment.Center,
) {
Image(
painter = painterResource(emotionTag.graphic),
painter = painterResource(emotion.graphicRes),
contentDescription = "Emotion Image",
modifier = Modifier.fillMaxSize(),
contentScale = ContentScale.Crop,
Expand All @@ -168,11 +169,11 @@ private fun EmotionItem(
@Composable
private fun EmotionEditUiPreview() {
ReedTheme {
val emotionTags = EmotionTag.entries.toPersistentList()
val emotions = Emotion.entries.toPersistentList()

EmotionEditUi(
state = EmotionEditUiState(
emotionTags = emotionTags,
emotions = emotions,
eventSink = {},
),
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.ninecraft.booket.feature.edit.emotion

import com.ninecraft.booket.core.designsystem.EmotionTag
import com.ninecraft.booket.core.model.Emotion
import com.slack.circuit.runtime.CircuitUiEvent
import com.slack.circuit.runtime.CircuitUiState
import kotlinx.collections.immutable.ImmutableList
Expand All @@ -9,7 +9,7 @@ import kotlinx.collections.immutable.persistentListOf
data class EmotionEditUiState(
val selectedEmotion: String = "",
val isEditButtonEnabled: Boolean = false,
val emotionTags: ImmutableList<EmotionTag> = persistentListOf(),
val emotions: ImmutableList<Emotion> = persistentListOf(),
val eventSink: (EmotionEditUiEvent) -> Unit,
) : CircuitUiState

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import androidx.compose.ui.text.TextRange
import com.ninecraft.booket.core.common.analytics.AnalyticsHelper
import com.ninecraft.booket.core.common.utils.handleException
import com.ninecraft.booket.core.data.api.repository.RecordRepository
import com.ninecraft.booket.core.designsystem.EmotionTag
import com.ninecraft.booket.core.designsystem.RecordStep
import com.ninecraft.booket.core.model.Emotion
import com.ninecraft.booket.feature.screens.LoginScreen
import com.ninecraft.booket.feature.screens.OcrScreen
import com.ninecraft.booket.feature.screens.RecordDetailScreen
Expand Down Expand Up @@ -73,8 +73,8 @@ class RecordRegisterPresenter @AssistedInject constructor(
).toPersistentList(),
)
}
val emotionTags by rememberRetained { mutableStateOf(EmotionTag.entries.toPersistentList()) }
var selectedEmotion by rememberRetained { mutableStateOf<EmotionTag?>(null) }
val emotions by rememberRetained { mutableStateOf(Emotion.entries.toPersistentList()) }
var selectedEmotion by rememberRetained { mutableStateOf<Emotion?>(null) }
var selectedImpressionGuide by rememberRetained { mutableStateOf("") }
var beforeSelectedImpressionGuide by rememberRetained { mutableStateOf(selectedImpressionGuide) }
val impressionState = rememberTextFieldState()
Expand Down Expand Up @@ -254,7 +254,7 @@ class RecordRegisterPresenter @AssistedInject constructor(
userBookId = screen.userBookId,
pageNumber = recordPageState.text.toString().toIntOrNull() ?: 0,
quote = recordSentenceState.text.toString(),
emotionTags = selectedEmotion?.let { listOf(it.label) } ?: emptyList(),
emotionTags = selectedEmotion?.let { listOf(it.displayName) } ?: emptyList(),
impression = impressionState.text.toString(),
)
}
Expand Down Expand Up @@ -292,7 +292,7 @@ class RecordRegisterPresenter @AssistedInject constructor(
recordPageState = recordPageState,
recordSentenceState = recordSentenceState,
isPageError = isPageError,
emotionTags = emotionTags,
emotions = emotions,
selectedEmotion = selectedEmotion,
impressionState = impressionState,
impressionGuideList = impressionGuideList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.ninecraft.booket.feature.record.register

import androidx.compose.foundation.text.input.TextFieldState
import androidx.compose.runtime.Immutable
import com.ninecraft.booket.core.designsystem.EmotionTag
import com.ninecraft.booket.core.designsystem.RecordStep
import com.ninecraft.booket.core.model.Emotion
import com.slack.circuit.runtime.CircuitUiEvent
import com.slack.circuit.runtime.CircuitUiState
import kotlinx.collections.immutable.ImmutableList
Expand All @@ -16,8 +16,8 @@ data class RecordRegisterUiState(
val recordPageState: TextFieldState = TextFieldState(),
val recordSentenceState: TextFieldState = TextFieldState(),
val isPageError: Boolean = false,
val emotionTags: ImmutableList<EmotionTag> = persistentListOf(),
val selectedEmotion: EmotionTag? = null,
val emotions: ImmutableList<Emotion> = persistentListOf(),
val selectedEmotion: Emotion? = null,
val impressionState: TextFieldState = TextFieldState(),
val impressionGuideList: ImmutableList<String> = persistentListOf(),
val selectedImpressionGuide: String = "",
Expand Down Expand Up @@ -46,7 +46,7 @@ sealed interface RecordRegisterUiEvent : CircuitUiEvent {
data object OnClearClick : RecordRegisterUiEvent
data object OnNextButtonClick : RecordRegisterUiEvent
data object OnSentenceScanButtonClick : RecordRegisterUiEvent
data class OnSelectEmotion(val emotion: EmotionTag) : RecordRegisterUiEvent
data class OnSelectEmotion(val emotion: Emotion) : RecordRegisterUiEvent
data object OnImpressionGuideButtonClick : RecordRegisterUiEvent
data object OnImpressionGuideBottomSheetDismiss : RecordRegisterUiEvent
data class OnSelectImpressionGuide(val index: Int) : RecordRegisterUiEvent
Expand Down
Loading
Loading