-
Notifications
You must be signed in to change notification settings - Fork 0
Chore/#126 link #143
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
base: develop
Are you sure you want to change the base?
Chore/#126 link #143
Changes from 25 commits
1a97d79
bb8fbf3
cae9a16
ef003df
cda40a1
1917332
b160d51
0c1d6cc
522b105
cd65a08
516e0eb
ed304fb
4b6f8d4
eac6b65
9a82420
c36b349
b34cf5a
03b924b
3a38cf7
82d3384
d01469e
d33e92f
ddde533
7ccb07d
6aa03ba
c57bb3d
e9faa7c
6f5513f
7f70dea
71f5c0d
f2fe87f
ceaa443
92cf18d
155ec68
523e337
b8f42c3
c7bb7b6
9f7a772
97dc501
ae715ef
58a76d0
f83aa5e
4177d52
1f14c4f
14c80b2
6956155
a3e4141
72b7beb
3656030
488e453
badd798
15a9dcd
3422028
45b03a5
71c41df
f3e834b
6bc7736
02cc312
0c9138c
33e3734
d86b3ac
4cf3e1b
742bb1e
26cc654
1422b6a
0b32e8c
dd8fb76
f3d00c4
ac2984f
eb9a021
406cb78
0b5645c
8962f7e
7878663
63218e4
e9c8c57
bf47a4d
e953b32
4bf61d9
3d1dc87
b2f49ed
11811bb
91512d1
5ade90b
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 |
|---|---|---|
|
|
@@ -49,7 +49,8 @@ import com.linku.file.FileViewModel | |
| import com.linku.file.viewmodel.folder.state.FolderStateViewModel | ||
| import com.linku.home.HomeApp | ||
| import com.linku.home.HomeViewModel | ||
| import com.linku.home.screen.SaveLinkResultScreen | ||
| import com.linku.home.component.LinkCategoryOption | ||
| import com.linku.home.screen.LinkDetailScreen | ||
| import com.linku.home.screen.SaveLinkScreen | ||
| import com.linku.linku_android.curation.curationGraph | ||
| import com.linku.login.navigation.LoginApp | ||
|
|
@@ -359,7 +360,7 @@ fun MainApp( | |
| HomeApp( | ||
| viewModel = homeViewModel, | ||
| nickname = nickname.orEmpty().ifBlank { "๋งํ" }, | ||
| onNavigateToMyPage = { // TODO: ์ถํ ์๋ฆผ ์ค์ ํ์ด์ง๋ก ์ด๋ | ||
| onNavigateToMyPage = { | ||
| navigator.navigate(NavigationRoute.MyPage.route) { | ||
| popUpTo(navigator.graph.findStartDestination().id) { | ||
| saveState = true | ||
|
|
@@ -369,6 +370,13 @@ fun MainApp( | |
| restoreState = true | ||
| } | ||
| }, | ||
| onNavigateToSaveLink = { url -> | ||
| homeViewModel.setUrl(url) | ||
| navigator.navigate("savelink") | ||
| }, | ||
| onNavigateToLinkDetail = { linkuId -> | ||
| navigator.navigate("savelinkresult/$linkuId") | ||
| }, | ||
| onShowNavBar = { showNavBar = it } | ||
| ) | ||
| } | ||
|
|
@@ -453,10 +461,12 @@ fun MainApp( | |
| SaveLinkScreen( | ||
| image = vm.image, | ||
| url = vm.url, | ||
| title = vm.title, | ||
| memo = vm.memo, | ||
| selectedEmotionId = vm.selectedEmotionId, | ||
| onPickImage = { imagePicker.launch("image/*") }, | ||
| onUrlChange = vm::setUrl, | ||
| onTitleChange = vm::setTitle, | ||
| onMemoChange = vm::setMemo, | ||
| onEmotionSelect = vm::selectEmotion, | ||
| onSaveClick = { | ||
|
|
@@ -496,48 +506,130 @@ fun MainApp( | |
| vm.loadCategoryColors() | ||
| } | ||
|
|
||
| fun emotionNameOf(id: Long?): String { | ||
| return when (id) { | ||
| 1L -> "์ฆ๊ฑฐ์" | ||
| 2L -> "ํ์จ" | ||
| 3L -> "์ค๋ " | ||
| 4L -> "์ฌํ" | ||
| 5L -> "์ง์ฆ" | ||
| 6L -> "๋ถ๋ ธ" | ||
| else -> "๊ฐ์ " | ||
| } | ||
| } | ||
|
|
||
| // TODO: ์นดํ ๊ณ ๋ฆฌ API ์ฐ๋ ํ categoryId ๊ธฐ์ค ์ค์ ์นดํ ๊ณ ๋ฆฌ๋ช /์์ ๋งคํ์ผ๋ก ๊ต์ฒด | ||
| fun categoryNameOf(id: Long?): String { | ||
| return when (id) { | ||
| 1L -> "์ดํ" | ||
| 2L -> "๋ด์ค" | ||
| 3L -> "๊ณต๋ถ๋ฒ" | ||
| 4L -> "ITยท๊ฐ๋ฐ" | ||
| 5L -> "์๊ธฐ๊ณ๋ฐ" | ||
| 6L -> "์ทจ์ ยท์ด์ง" | ||
| 7L -> "๋น์ฆ๋์ค ์ธ์ฌ์ดํธ" | ||
| 8L -> "์์ฐ์ฑยทํด" | ||
| 9L -> "๋ผ์ดํ์คํ์ผ" | ||
| 10L -> "์ฌ๋ฆฌยท์๊ธฐ์ดํด" | ||
| 11L -> "์์ธ์ดยท์นผ๋ผ" | ||
| 12L -> "ํธ๋ ๋" | ||
| 13L -> "๋์์ธยท์์ " | ||
| 14L -> "์์ยท๋ฎค์ง" | ||
| 15L -> "๋ง์งยท์ฌํ" | ||
| 16L -> "๊ธฐํ" | ||
| else -> "์นดํ ๊ณ ๋ฆฌ" | ||
| } | ||
| } | ||
|
|
||
| fun categoryIdOf(name: String): Long? { | ||
| return when (name) { | ||
| "์ดํ" -> 1L | ||
| "๋ด์ค" -> 2L | ||
| "๊ณต๋ถ๋ฒ" -> 3L | ||
| "ITยท๊ฐ๋ฐ" -> 4L | ||
| "์๊ธฐ๊ณ๋ฐ" -> 5L | ||
| "์ทจ์ ยท์ด์ง" -> 6L | ||
| "๋น์ฆ๋์ค ์ธ์ฌ์ดํธ" -> 7L | ||
| "์์ฐ์ฑยทํด" -> 8L | ||
| "๋ผ์ดํ์คํ์ผ" -> 9L | ||
| "์ฌ๋ฆฌยท์๊ธฐ์ดํด" -> 10L | ||
| "์์ธ์ดยท์นผ๋ผ" -> 11L | ||
| "ํธ๋ ๋" -> 12L | ||
| "๋์์ธยท์์ " -> 13L | ||
| "์์ยท๋ฎค์ง" -> 14L | ||
| "๋ง์งยท์ฌํ" -> 15L | ||
| "๊ธฐํ" -> 16L | ||
| else -> null | ||
| } | ||
| } | ||
|
|
||
| fun keywordToTags(keyword: String?): List<String> { | ||
| return keyword | ||
| .orEmpty() | ||
| .split(",", " ", "#") | ||
| .map { it.trim() } | ||
| .filter { it.isNotBlank() } | ||
| .take(4) | ||
| } | ||
|
|
||
| // ์งํ๋ฅ /์์ ๋งต ์์ง | ||
| val aiProgress = vm.aiProgress.collectAsState().value | ||
| val categoryColorMap = vm.categoryColorMap.collectAsState().value | ||
|
|
||
| val categoryOptions = categoryColorMap.mapNotNull { (name, style) -> | ||
| val id = categoryIdOf(name) ?: return@mapNotNull null | ||
|
Collaborator
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. [P1] ์ฌ๊ธฐ์ ์๋ฒ์์ ๋ด๋ ค์ค string ๋ฐ์ดํฐ๋ฅผ ๋ค์ LongId๋ก ์ญ๋งคํํ๋๊ฑฐ ๋ง๋์? ์ ์๋๋ฉด categoryColorMap์ String ํค๊ฐ ์๋๋ผ CategoryType ํค๋ก ๋ฐ๊พธ๋ ๋ฐฉํฅ์ ์ด๋ค๊ฐ์? private val _categoryColorMap = MutableStateFlow<Map<CategoryType, CategoryColorStyle>>(emptyMap())์ด๋ ๊ฒ ํ๋ทฐ๋ชจ๋ธ์์ ์์ String name์ ํ ๋ฒ ๋ณํํ๋ฉด.... ๋ญ ์ญ ๋งคํํ ํ์๋ ์์ง ์์๊น ์ถ์๋ฐ ๊ทธ๋ฌ๋ฉด ์ฌ๊ธฐ์๋ val categoryOptions = categoryColorMap.map { (type, style) ->
LinkCategoryOption(
id = type.id,
name = type.tagName,
color = style.color4
)
}์ด๋ ๊ฒ ํ๋ฉด ๋ ๊ฒ ๊ฐ๊ธฐ๋ ํ๊ณ ..? ์ ์๋๋ฉด ์์ LinkCategoryOption์ด Long id๋ฅผ ๋ฐ๋ก ๋ค ํ์ ์์ด CategoryType์ ์ง์ ๋๋ ๋ฐฉ์๋ ์์ ๊ฒ ๊ฐ์๋ฐ ์งํ์ด๊ฐ ๊ฐ๋ฐํ ํํธ์ด๋ ํ ๋ฒ ๋ณด๊ณ ํ๋จํด์ฃผ์ธ์:) |
||
|
|
||
| LinkCategoryOption( | ||
| id = id, | ||
| name = name, | ||
| color = style.color4 | ||
| ) | ||
| } | ||
|
Comment on lines
+519
to
+582
Collaborator
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. ์ด๋ฆ๋ง์ผ๋ก๋ ์ ๋ํฌํ ๋ฐ์ดํฐ๋ค์ Long ํ์ id๊ฐ ๋ค์ด๊ฐ๋ ๊ฑด ๋ถ์๋ถ์ํ๋ค์..
Collaborator
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. ์ด๋์ผ๋ก ๋ฐ๊ฟ๋ณผ๊ฒ์ |
||
|
|
||
| // ์ธ๋ถ ๋ธ๋ผ์ฐ์ ์ด๊ธฐ | ||
| fun openUrl(url: String) { | ||
| runCatching { | ||
| val fixed = if (url.startsWith("http")) url else "https://$url" | ||
| val fixed = if ( | ||
| url.startsWith("http://") || url.startsWith("https://") | ||
| ) { | ||
| url | ||
| } else { | ||
| "https://$url" | ||
| } | ||
|
|
||
| val intent = Intent( | ||
| Intent.ACTION_VIEW, | ||
| fixed.toUri() | ||
| ) | ||
|
|
||
| context.startActivity(intent) | ||
| }.onFailure { | ||
| Toast.makeText(context, "๋งํฌ๋ฅผ ์ด ์ ์์ด์.", Toast.LENGTH_SHORT).show() | ||
| } | ||
| } | ||
|
|
||
| SaveLinkResultScreen( | ||
| link = vm.linkDetail, | ||
| aiArticle = vm.aiArticleDetail, | ||
| isLoading = vm.isLoadingLinkDetail || vm.isLoadingAiArticle, | ||
| isAiLoading = vm.isLoadingAiArticle, | ||
| onBack = { navigator.popBackStack() }, | ||
| onOpenLink = { url -> openUrl(url) }, | ||
| categoryColorMap = categoryColorMap, | ||
| onSubmitEdit = { title, memo, categoryId, emotionId -> | ||
| vm.updateLink( | ||
| title = title, | ||
| memo = memo, | ||
| categoryId = categoryId, | ||
| emotionId = emotionId, | ||
| onSucceed = { Toast.makeText(context, "์์ ์๋ฃ", Toast.LENGTH_SHORT).show() }, | ||
| onFailed = { e -> | ||
| Log.e("SaveLinkResult", "์์ ์คํจ", e) | ||
| Toast.makeText(context, e.message ?: "์์ ์ ์คํจํ์ต๋๋ค.", Toast.LENGTH_SHORT).show() | ||
| } | ||
| ) | ||
| }, | ||
| onRequestAiSummary = { vm.loadAiArticle(linkuId) }, | ||
| aiProgress = aiProgress, | ||
| onCancelAi = { vm.cancelAiArticleJob() } | ||
| val linkDetail = vm.linkDetail | ||
| val aiArticle = vm.aiArticleDetail | ||
|
|
||
| val displayKeyword = aiArticle?.keyword?.trim().orEmpty() | ||
| .ifEmpty { linkDetail?.keyword.orEmpty() } | ||
|
|
||
| val displaySummary = aiArticle?.summary?.trim().orEmpty() | ||
| .ifEmpty { linkDetail?.summary.orEmpty() } | ||
|
|
||
| LinkDetailScreen( | ||
| linkTitle = linkDetail?.title.orEmpty(), | ||
| category = categoryNameOf(linkDetail?.categoryId), | ||
| emotion = emotionNameOf(linkDetail?.emotionId), | ||
| situation = "ํตํ ์ค", // TODO: ์์ธ API์ situationId ์๊ธฐ๋ฉด ์ค์ ๊ฐ์ผ๋ก ๋ณ๊ฒฝ | ||
| linkUrl = linkDetail?.linku.orEmpty(), | ||
| memo = linkDetail?.memo.orEmpty(), | ||
| tags = keywordToTags(displayKeyword), | ||
| aiSummary = displaySummary, | ||
| categoryOptions = categoryOptions, | ||
| onBack = { | ||
| navigator.popBackStack() | ||
| } | ||
| ) | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,59 @@ | ||
| package com.linku.core.model | ||
|
|
||
| import androidx.annotation.DrawableRes | ||
| import com.linku.design.R | ||
|
Hongji03 marked this conversation as resolved.
Outdated
|
||
|
|
||
| enum class EmotionType( | ||
| val id: Long, | ||
|
Collaborator
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. ์๊ธฐ๋ |
||
| val tagName: String | ||
| val tagName: String, | ||
| @DrawableRes val imgRes: Int | ||
|
Hongji03 marked this conversation as resolved.
Outdated
|
||
| ) { | ||
| JOY(1, "์ฆ๊ฑฐ์"), | ||
| PEACE(2, "ํ์จ"), | ||
| EXCITEMENT(3, "์ค๋ "), | ||
| SADNESS(4, "์ฌํ"), | ||
| ANNOYANCE(5, "์ง์ฆ"), | ||
| ANGER(6, "๋ถ๋ ธ"); | ||
| JOY( | ||
| id = 1L, | ||
| tagName = "์ฆ๊ฑฐ์", | ||
| imgRes = R.drawable.ic_joy | ||
| ), | ||
| CALM( | ||
| id = 2L, | ||
| tagName = "ํ์จ", | ||
| imgRes = R.drawable.ic_calm | ||
| ), | ||
| EXCITE( | ||
| id = 3L, | ||
| tagName = "์ค๋ ", | ||
| imgRes = R.drawable.ic_excite | ||
| ), | ||
| SAD( | ||
| id = 4L, | ||
| tagName = "์ฌํ", | ||
| imgRes = R.drawable.ic_sad | ||
| ), | ||
| IRRITATION( | ||
| id = 5L, | ||
| tagName = "์ง์ฆ", | ||
| imgRes = R.drawable.ic_irritation | ||
| ), | ||
| ANGER( | ||
| id = 6L, | ||
| tagName = "๋ถ๋ ธ", | ||
| imgRes = R.drawable.ic_anger | ||
| ); | ||
|
|
||
| companion object { | ||
| fun fromId(id: Long): EmotionType? = values().find { it.id == id } | ||
| fun fromId(id: Long?): EmotionType? { | ||
| return entries.firstOrNull { it.id == id } | ||
| } | ||
|
|
||
| fun fromTagName(tagName: String?): EmotionType? { | ||
| return entries.firstOrNull { it.tagName == tagName } | ||
| } | ||
|
|
||
| fun tagNameOf(id: Long?): String? { | ||
| return fromId(id)?.tagName | ||
| } | ||
|
|
||
| fun idOf(tagName: String?): Long? { | ||
| return fromTagName(tagName)?.id | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| package com.linku.core.model | ||
|
|
||
| data class Situation( | ||
| val id: Long, | ||
|
Hongji03 marked this conversation as resolved.
|
||
| val tagName: String | ||
| ) | ||
|
|
||
| object SituationOptions { | ||
| val linkDetailSituations: List<Situation> = listOf( | ||
| Situation(1L, "ํตํ ์ค"), | ||
| Situation(2L, "๊ณต๋ถ ์ค"), | ||
| Situation(3L, "ํด์ ์ค"), | ||
| Situation(4L, "์ด๋ ์ค"), | ||
| Situation(5L, "์์ฌ ์ค"), | ||
| Situation(6L, "์๊ธฐ ์ ") | ||
| ) | ||
|
|
||
| fun situationsFor(jobId: Long): List<Situation> = when (jobId) { | ||
| 1L -> listOf( | ||
| Situation(1L, "ํตํ ์ค"), | ||
| Situation(2L, "๊ณต๋ถ ์ค"), | ||
| Situation(3L, "์์ฌ ์ค"), | ||
| Situation(4L, "์ํ ์ค๋น"), | ||
| Situation(5L, "์น๊ตฌ๋"), | ||
| Situation(6L, "์ผํ ์ค"), | ||
| Situation(7L, "ํด์ ์ค"), | ||
| Situation(8L, "์๊ธฐ ์ ") | ||
| ) | ||
|
|
||
| 2L -> listOf( | ||
| Situation(9L, "๊ณผ์ ์ค"), | ||
| Situation(10L, "ํตํ ์ค"), | ||
| Situation(11L, "์ผํ ์ค"), | ||
| Situation(12L, "์๋ฐ ์ค"), | ||
| Situation(13L, "ํธ๋ ๋ ํ์ธ"), | ||
| Situation(14L, "๋ฐ์ดํธ ์ค"), | ||
| Situation(15L, "ํด์ ์ค"), | ||
| Situation(16L, "์๊ธฐ ์ ") | ||
| ) | ||
|
|
||
| 3L -> listOf( | ||
| Situation(17L, "์ถํด๊ทผ"), | ||
| Situation(18L, "ํธ๋ ๋ ํ์ธ"), | ||
| Situation(19L, "์ ๋ฌด ์ค"), | ||
| Situation(20L, "์ปค๋ฆฌ์ด ๊ณ ๋ฏผ"), | ||
| Situation(21L, "์ผํ ์ค"), | ||
| Situation(22L, "๋ฐ์ดํธ ์ค"), | ||
| Situation(23L, "ํด์ ์ค"), | ||
| Situation(24L, "์๊ธฐ ์ ") | ||
| ) | ||
|
|
||
| 4L -> listOf( | ||
| Situation(25L, "์ถํด๊ทผ"), | ||
| Situation(26L, "์ ๋ฌด ์ค๋น ์ค"), | ||
| Situation(27L, "๋ฐ์ดํธ ์ค"), | ||
| Situation(28L, "์์ฌ"), | ||
| Situation(29L, "์ผํ ์ค"), | ||
| Situation(30L, "ํธ๋ ๋ ํ์ธ"), | ||
| Situation(31L, "ํด์ ์ค"), | ||
| Situation(32L, "์๊ธฐ ์ ") | ||
| ) | ||
|
|
||
| 5L -> listOf( | ||
| Situation(33L, "์์ ์ค"), | ||
| Situation(34L, "์ผํ ์ค"), | ||
| Situation(35L, "ํธ๋ ๋ ํ์ธ"), | ||
| Situation(36L, "๋ฐ์ดํธ ์ค"), | ||
| Situation(37L, "์ด๋ ์ค"), | ||
| Situation(38L, "์์ฌ"), | ||
| Situation(39L, "ํด์ ์ค"), | ||
| Situation(40L, "์๊ธฐ ์ ") | ||
| ) | ||
|
|
||
| 6L -> listOf( | ||
| Situation(41L, "์์์ ์์ฑ"), | ||
| Situation(42L, "๋ฉด์ ์ค๋น"), | ||
| Situation(43L, "์๋ฆฌ ์ค"), | ||
| Situation(44L, "ํธ๋ ๋ ํ์ธ"), | ||
| Situation(45L, "์ผํ ์ค"), | ||
| Situation(46L, "์ด๋ ์ค"), | ||
| Situation(47L, "ํด์ ์ค"), | ||
| Situation(48L, "์๊ธฐ ์ ") | ||
| ) | ||
|
|
||
| else -> situationsFor(3L) | ||
| } | ||
|
|
||
| fun nameOf(id: Long?): String? { | ||
| if (id == null) return null | ||
|
|
||
| return (linkDetailSituations + (1L..6L).flatMap { situationsFor(it) }) | ||
|
Hongji03 marked this conversation as resolved.
Outdated
|
||
| .distinctBy { it.id } | ||
| .firstOrNull { it.id == id } | ||
| ?.tagName | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| fun idOf(tagName: String, jobId: Long? = null): Long? { | ||
| val options = if (jobId != null) { | ||
| situationsFor(jobId) | ||
| } else { | ||
| linkDetailSituations | ||
| } | ||
|
|
||
| return options.firstOrNull { it.tagName == tagName }?.id | ||
| } | ||
|
Hongji03 marked this conversation as resolved.
Outdated
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.