-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 도서 상세 화면 Ui 구현 #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7a149ea
14dc829
629cf91
1f3afae
61974f9
18d7186
0d74a87
1cbdcc5
db2d497
8744a54
0587dc0
c02e98b
bc78d8c
1b2236b
070b7a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,8 @@ dependencies { | |
| projects.core.model, | ||
| projects.core.network, | ||
|
|
||
| libs.kotlinx.collections.immutable, | ||
|
|
||
| libs.logger, | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.ninecraft.booket.core.common.constants | ||
|
|
||
| import com.ninecraft.booket.core.common.R | ||
|
|
||
| enum class BookStatus(val value: String) { | ||
| BEFORE_READING("BEFORE_READING"), | ||
| READING("READING"), | ||
| COMPLETED("COMPLETED"), | ||
| ; | ||
|
|
||
| fun getDisplayNameRes(): Int { | ||
| return when (this) { | ||
| BEFORE_READING -> R.string.book_status_before | ||
| READING -> R.string.book_status_reading | ||
| COMPLETED -> R.string.book_status_completed | ||
| } | ||
| } | ||
|
|
||
| companion object Companion { | ||
| fun fromValue(value: String): BookStatus? { | ||
| return entries.find { it.value == value } | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package com.ninecraft.booket.core.common.extensions | ||
|
|
||
| import androidx.compose.ui.graphics.Color | ||
| import com.ninecraft.booket.core.model.Emotion | ||
|
|
||
| fun Emotion.toTextColor(): Color { | ||
| return when (this) { | ||
| Emotion.WARM -> Color(0xFFE3931B) | ||
| Emotion.JOY -> Color(0xFFEE6B33) | ||
| Emotion.TENSION -> Color(0xFF9A55E4) | ||
| Emotion.SADNESS -> Color(0xFF2872E9) | ||
| } | ||
| } | ||
|
|
||
| fun Emotion.toBackgroundColor(): Color { | ||
| return when (this) { | ||
| Emotion.WARM -> Color(0xFFFFF5D3) | ||
| Emotion.JOY -> Color(0xFFFFEBE3) | ||
| Emotion.TENSION -> Color(0xFFF3E8FF) | ||
| Emotion.SADNESS -> Color(0xFFE1ECFF) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package com.ninecraft.booket.core.common.util | ||
|
|
||
| import com.ninecraft.booket.core.model.EmotionModel | ||
|
|
||
| data class EmotionAnalysisResult( | ||
| val topEmotions: List<EmotionModel>, | ||
| val displayType: EmotionDisplayType, | ||
| ) | ||
|
|
||
| enum class EmotionDisplayType { | ||
| SINGLE, // 1개 감정이 1위 | ||
| DUAL, // 2개 감정이 공동 1위 | ||
| BALANCED, // 3개 이상 감정이 공동 1위 | ||
| } | ||
|
|
||
| fun analyzeEmotions(emotions: List<EmotionModel>): EmotionAnalysisResult { | ||
| if (emotions.isEmpty()) { | ||
| return EmotionAnalysisResult(emptyList(), EmotionDisplayType.BALANCED) | ||
| } | ||
|
|
||
| val maxCount = emotions.maxOf { it.count } | ||
| val topEmotions = emotions.filter { it.count == maxCount } | ||
|
|
||
| val displayType = when (topEmotions.size) { | ||
| 1 -> EmotionDisplayType.SINGLE | ||
| 2 -> EmotionDisplayType.DUAL | ||
| else -> EmotionDisplayType.BALANCED | ||
| } | ||
|
|
||
| return EmotionAnalysisResult(topEmotions, displayType) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <resources> | ||
| <string name="book_status_before">읽기 전</string> | ||
| <string name="book_status_reading">읽는 중</string> | ||
| <string name="book_status_completed">독서 완료</string> | ||
| <string name="record_sort_page_ascending">페이지순</string> | ||
| <string name="record_sort_recent_register">최신 등록순</string> | ||
| </resources> |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,18 @@ | ||||||||||||||||||||||||||||||||||
| package com.ninecraft.booket.core.model | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| import androidx.compose.runtime.Stable | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| @Stable | ||||||||||||||||||||||||||||||||||
| data class EmotionModel( | ||||||||||||||||||||||||||||||||||
| val type: Emotion, | ||||||||||||||||||||||||||||||||||
| val count: Int, | ||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| enum class Emotion( | ||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아아.. 만드셨군요... 편히 쓰라고 core:designsystem에 저도 만들어놨는데 ^_ㅠ enum class EmotionTag(val label: String, val bgColor: Color, val textColor: Color, val graphic: Int) {
WARMTH("따뜻함", WarmthBgColor, WarmthTextColor, 0),
JOY("즐거움", JoyBgColor, JoyTextColor, 0),
TENSION("긴장감", TensionBgColor, TensionTextColor, 0),
SADNESS("슬픔", SadnessBgColor, SadnessTextColor, 0),
} |
||||||||||||||||||||||||||||||||||
| val displayName: String, | ||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||
| WARM("따뜻함"), | ||||||||||||||||||||||||||||||||||
| JOY("즐거움"), | ||||||||||||||||||||||||||||||||||
| TENSION("긴장감"), | ||||||||||||||||||||||||||||||||||
| SADNESS("슬픔"), | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+11
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 모델 계층에 하드코딩된 한글 문자열 → 리소스화 필요
-enum class Emotion(
- val displayName: String,
-) {
- WARM("따뜻함"),
- JOY("즐거움"),
- TENSION("긴장감"),
- SADNESS("슬픔"),
-}
+enum class Emotion(@StringRes val labelResId: Int) {
+ WARM(R.string.emotion_warm),
+ JOY(R.string.emotion_joy),
+ TENSION(R.string.emotion_tension),
+ SADNESS(R.string.emotion_sadness),
+}리소스 파일( 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. core:model 은 kotlin 모듈이라 R 참조 불가능, 그리고 일단은 다국어 지원 예정은 없어 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @easyhooon 말씀하신대로 맞습니다! ✏️ Learnings added
🧠 Learnings used |
||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,8 @@ ksp { | |
|
|
||
| dependencies { | ||
| implementations( | ||
| libs.kotlinx.collections.immutable, | ||
|
|
||
| libs.logger, | ||
| ) | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
감정 분석 클라에서 하는거였나요...????????
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API 가 어떻게 나올지 몰라서 일단 구현했는데, API 연동 이후 필요없으면 제거하면 될것 같아여
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아깝네요...
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굳이 지울 필요 없이, 각 상황에 대한 프리뷰를 구성하는데 사용할 수 있을 듯 합니다.
적용완료 bc78d8c