From acaac498adf3ae7be14a78c9002ce5c431422040 Mon Sep 17 00:00:00 2001 From: yunsehwan Date: Thu, 29 Aug 2024 20:15:50 +0900 Subject: [PATCH 1/7] =?UTF-8?q?[FIX]=20#64-=EB=A7=81=ED=81=AC=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20BottomSheet=EC=97=90=EC=84=9C=20=EC=95=8C=EB=A6=BC?= =?UTF-8?q?=20=EC=95=84=EC=9D=B4=EC=BD=98=EC=9D=B4=20=ED=95=AD=EC=83=81=20?= =?UTF-8?q?=ED=99=9C=EC=84=B1=ED=99=94=EB=90=98=EC=96=B4=EC=9E=88=EB=8A=94?= =?UTF-8?q?=20=EB=AC=B8=EC=A0=9C=EC=99=80=20=ED=8F=AC=ED=82=B7=EB=AA=85?= =?UTF-8?q?=EC=9D=B4=20=ED=95=AD=EC=83=81=20"=ED=85=8D=EC=8A=A4=ED=8A=B8"?= =?UTF-8?q?=EB=A1=9C=20=ED=91=9C=EC=8B=9C=EB=90=98=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LinkDetailBottomSheet.kt | 33 ++++++++++--------- .../template/linkdetailbottomsheet/Preview.kt | 2 +- .../pokit/home/pokit/UnclassifiedScreen.kt | 4 +-- .../pokit/home/remind/RemindScreen.kt | 2 +- .../pokit/home/remind/RemindViewModel.kt | 3 +- .../pokitdetail/PokitDetailScreen.kt | 4 +-- .../com/strayalpaca/pokitdetail/model/Link.kt | 17 +++------- .../java/pokitmons/pokit/search/Preview.kt | 6 ---- .../pokitmons/pokit/search/SearchScreen.kt | 2 +- .../searchitemlist/SearchItemList.kt | 2 +- .../java/pokitmons/pokit/search/model/Link.kt | 11 +++---- 11 files changed, 37 insertions(+), 49 deletions(-) diff --git a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/linkdetailbottomsheet/LinkDetailBottomSheet.kt b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/linkdetailbottomsheet/LinkDetailBottomSheet.kt index 6d49d07a..4b11f0bc 100644 --- a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/linkdetailbottomsheet/LinkDetailBottomSheet.kt +++ b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/linkdetailbottomsheet/LinkDetailBottomSheet.kt @@ -41,10 +41,11 @@ fun LinkDetailBottomSheet( thumbnailPainter: Painter, bookmark: Boolean, openWebBrowserByClick: Boolean, - linkType: String, + pokitName: String, dateString: String, onHideBottomSheet: () -> Unit, show: Boolean = false, + useRemind: Boolean = false, onClickBookmark: (() -> Unit)? = null, onClickRemoveLink: (() -> Unit)? = null, onClickModifyLink: (() -> Unit)? = null, @@ -63,23 +64,25 @@ fun LinkDetailBottomSheet( modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically ) { - Image( - painter = painterResource(id = R.drawable.icon_24_bell), - contentDescription = null, - modifier = Modifier - .size(20.dp) - .background( - color = PokitTheme.colors.brand, - shape = CircleShape - ) - .padding(2.dp), - colorFilter = ColorFilter.tint(PokitTheme.colors.inverseWh) - ) + if (useRemind) { + Image( + painter = painterResource(id = R.drawable.icon_24_bell), + contentDescription = null, + modifier = Modifier + .size(20.dp) + .background( + color = PokitTheme.colors.brand, + shape = CircleShape + ) + .padding(2.dp), + colorFilter = ColorFilter.tint(PokitTheme.colors.inverseWh) + ) - Spacer(modifier = Modifier.width(4.dp)) + Spacer(modifier = Modifier.width(4.dp)) + } Text( - text = linkType, + text = pokitName, modifier = Modifier .border( width = 1.dp, diff --git a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/linkdetailbottomsheet/Preview.kt b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/linkdetailbottomsheet/Preview.kt index 74f99887..3d162637 100644 --- a/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/linkdetailbottomsheet/Preview.kt +++ b/core/ui/src/main/java/pokitmons/pokit/core/ui/components/template/linkdetailbottomsheet/Preview.kt @@ -22,7 +22,7 @@ private fun LinkDetailBottomSheetPreview() { bookmark = true, openWebBrowserByClick = false, show = true, - linkType = "TEXT", + pokitName = "TEXT", dateString = "2024.08.27", onHideBottomSheet = { }, onClickBookmark = { }, diff --git a/feature/home/src/main/java/pokitmons/pokit/home/pokit/UnclassifiedScreen.kt b/feature/home/src/main/java/pokitmons/pokit/home/pokit/UnclassifiedScreen.kt index 1dcea235..dd9b32a1 100644 --- a/feature/home/src/main/java/pokitmons/pokit/home/pokit/UnclassifiedScreen.kt +++ b/feature/home/src/main/java/pokitmons/pokit/home/pokit/UnclassifiedScreen.kt @@ -41,7 +41,7 @@ fun UnclassifiedScreen( thumbnailPainter = rememberAsyncImagePainter(model = link.imageUrl), bookmark = link.bookmark, openWebBrowserByClick = true, - linkType = stringResource(link.linkType.textResourceId), + pokitName = link.pokitName, dateString = link.dateString, onHideBottomSheet = viewModel::hideDetailLinkBottomSheet, show = true, @@ -93,7 +93,7 @@ fun UnclassifiedScreen( key = { it.id } ) { unCategoryDetail -> LinkCard( - item = unCategoryDetail.linkType, + item = unCategoryDetail.pokitName, title = unCategoryDetail.title, sub = unCategoryDetail.createdAt, painter = rememberAsyncImagePainter(model = unCategoryDetail.imageUrl), diff --git a/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindScreen.kt b/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindScreen.kt index 81390306..97b4f70c 100644 --- a/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindScreen.kt +++ b/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindScreen.kt @@ -105,7 +105,7 @@ fun RemindScreen( thumbnailPainter = rememberAsyncImagePainter(model = link.imageUrl), bookmark = link.bookmark, openWebBrowserByClick = true, - linkType = stringResource(link.linkType.textResourceId), + pokitName = link.pokitName, dateString = link.dateString, onHideBottomSheet = viewModel::hideDetailLinkBottomSheet, show = true, diff --git a/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindViewModel.kt b/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindViewModel.kt index 0944b352..b91f1708 100644 --- a/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindViewModel.kt +++ b/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindViewModel.kt @@ -248,7 +248,8 @@ class RemindViewModel @Inject constructor( domainUrl = responseLink.domain, imageUrl = _currentShowingLink.value?.imageUrl, memo = responseLink.memo, - bookmark = responseLink.favorites + bookmark = responseLink.favorites, + pokitName = responseLink.categoryName ) } } diff --git a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt index c909d635..59170b7d 100644 --- a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt +++ b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt @@ -196,7 +196,7 @@ fun PokitDetailScreen( sub = "${link.dateString} · ${link.domainUrl}", painter = rememberAsyncImagePainter(link.imageUrl), notRead = link.isRead, - badgeText = stringResource(id = link.linkType.textResourceId), + badgeText = link.pokitName, onClickKebab = showLinkModifyBottomSheet, onClickItem = onClickLink, modifier = Modifier.padding(20.dp) @@ -220,7 +220,7 @@ fun PokitDetailScreen( thumbnailPainter = rememberAsyncImagePainter(state.currentLink.imageUrl), bookmark = state.currentLink.bookmark, openWebBrowserByClick = true, - linkType = stringResource(state.currentLink.linkType.textResourceId), + pokitName = state.currentLink.pokitName, dateString = state.currentLink.dateString, onHideBottomSheet = hideLinkDetailBottomSheet, show = state.linkDetailBottomSheetVisible diff --git a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/model/Link.kt b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/model/Link.kt index d29f99ae..dae9b11c 100644 --- a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/model/Link.kt +++ b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/model/Link.kt @@ -1,6 +1,5 @@ package com.strayalpaca.pokitdetail.model -import com.strayalpaca.pokitdetail.R import pokitmons.pokit.domain.model.link.Link as DomainLink data class Link( @@ -9,7 +8,8 @@ data class Link( val dateString: String = "", val domainUrl: String = "", val isRead: Boolean = false, - val linkType: LinkType = LinkType.TEXT, + val pokitName: String = "", + val pokitId: String = "", val url: String = "", val memo: String = "", val bookmark: Boolean = false, @@ -27,16 +27,14 @@ data class Link( url = domainLink.data, memo = domainLink.memo, imageUrl = domainLink.thumbnail, - createdAt = domainLink.createdAt + createdAt = domainLink.createdAt, + pokitName = domainLink.categoryName, + pokitId = domainLink.categoryId.toString() ) } } } -enum class LinkType(val textResourceId: Int) { - TEXT(R.string.badge_text), -} - internal val sampleLinkList = listOf( Link( id = "1", @@ -45,7 +43,6 @@ internal val sampleLinkList = listOf( dateString = "2024.04.12", domainUrl = "youtu.be", isRead = true, - linkType = LinkType.TEXT, url = "", memo = "", bookmark = true @@ -57,7 +54,6 @@ internal val sampleLinkList = listOf( dateString = "2024.05.12", domainUrl = "youtu.be", isRead = false, - linkType = LinkType.TEXT, url = "", memo = "", bookmark = true @@ -69,7 +65,6 @@ internal val sampleLinkList = listOf( dateString = "2024.04.12", domainUrl = "pokitmons.pokit", isRead = true, - linkType = LinkType.TEXT, url = "", memo = "", bookmark = true @@ -81,7 +76,6 @@ internal val sampleLinkList = listOf( dateString = "2024.06.12", domainUrl = "youtu.be", isRead = true, - linkType = LinkType.TEXT, url = "", memo = "", bookmark = true @@ -93,7 +87,6 @@ internal val sampleLinkList = listOf( dateString = "2024.07.14", domainUrl = "youtu.be", isRead = false, - linkType = LinkType.TEXT, url = "", memo = "", bookmark = true diff --git a/feature/search/src/main/java/pokitmons/pokit/search/Preview.kt b/feature/search/src/main/java/pokitmons/pokit/search/Preview.kt index 17d4325f..4901d6f2 100644 --- a/feature/search/src/main/java/pokitmons/pokit/search/Preview.kt +++ b/feature/search/src/main/java/pokitmons/pokit/search/Preview.kt @@ -7,7 +7,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import pokitmons.pokit.core.ui.theme.PokitTheme import pokitmons.pokit.search.model.Link -import pokitmons.pokit.search.model.LinkType import pokitmons.pokit.search.model.SearchScreenState import pokitmons.pokit.search.model.SearchScreenStep @@ -34,7 +33,6 @@ internal val sampleLinks = listOf( dateString = "2024.04.12", domainUrl = "youtu.be", isRead = true, - linkType = LinkType.TEXT, url = "", memo = "", bookmark = true @@ -46,7 +44,6 @@ internal val sampleLinks = listOf( dateString = "2024.05.12", domainUrl = "youtu.be", isRead = false, - linkType = LinkType.TEXT, url = "", memo = "", bookmark = true @@ -58,7 +55,6 @@ internal val sampleLinks = listOf( dateString = "2024.04.12", domainUrl = "pokitmons.pokit", isRead = true, - linkType = LinkType.TEXT, url = "", memo = "", bookmark = true @@ -70,7 +66,6 @@ internal val sampleLinks = listOf( dateString = "2024.06.12", domainUrl = "youtu.be", isRead = true, - linkType = LinkType.TEXT, url = "", memo = "", bookmark = true @@ -82,7 +77,6 @@ internal val sampleLinks = listOf( dateString = "2024.07.14", domainUrl = "youtu.be", isRead = false, - linkType = LinkType.TEXT, url = "", memo = "", bookmark = true diff --git a/feature/search/src/main/java/pokitmons/pokit/search/SearchScreen.kt b/feature/search/src/main/java/pokitmons/pokit/search/SearchScreen.kt index 3aa7cea7..58cedcd1 100644 --- a/feature/search/src/main/java/pokitmons/pokit/search/SearchScreen.kt +++ b/feature/search/src/main/java/pokitmons/pokit/search/SearchScreen.kt @@ -56,7 +56,7 @@ fun SearchScreenContainer( thumbnailPainter = rememberAsyncImagePainter(link.imageUrl), bookmark = link.bookmark, openWebBrowserByClick = true, - linkType = stringResource(id = link.linkType.textResourceId), + pokitName = link.pokitName, dateString = link.dateString, onHideBottomSheet = viewModel::hideLinkDetailBottomSheet, show = state.showLinkDetailBottomSheet, diff --git a/feature/search/src/main/java/pokitmons/pokit/search/components/searchitemlist/SearchItemList.kt b/feature/search/src/main/java/pokitmons/pokit/search/components/searchitemlist/SearchItemList.kt index d9a7ea9c..75ec7004 100644 --- a/feature/search/src/main/java/pokitmons/pokit/search/components/searchitemlist/SearchItemList.kt +++ b/feature/search/src/main/java/pokitmons/pokit/search/components/searchitemlist/SearchItemList.kt @@ -92,7 +92,7 @@ internal fun SearchItemList( sub = "${link.dateString} · ${link.domainUrl}", painter = rememberAsyncImagePainter(link.imageUrl), notRead = !link.isRead, - badgeText = stringResource(id = link.linkType.textResourceId), + badgeText = link.pokitName, onClickKebab = onClickLinkKebab, onClickItem = onClickLink, modifier = Modifier.padding(20.dp) diff --git a/feature/search/src/main/java/pokitmons/pokit/search/model/Link.kt b/feature/search/src/main/java/pokitmons/pokit/search/model/Link.kt index 3379f8aa..cb03f5e9 100644 --- a/feature/search/src/main/java/pokitmons/pokit/search/model/Link.kt +++ b/feature/search/src/main/java/pokitmons/pokit/search/model/Link.kt @@ -1,6 +1,5 @@ package pokitmons.pokit.search.model -import pokitmons.pokit.search.R import pokitmons.pokit.domain.model.link.Link as DomainLink data class Link( @@ -9,7 +8,8 @@ data class Link( val dateString: String = "", val domainUrl: String = "", val isRead: Boolean = false, - val linkType: LinkType = LinkType.TEXT, + val pokitName: String = "", + val pokitId: String = "", val url: String = "", val memo: String = "", val bookmark: Boolean = false, @@ -27,12 +27,9 @@ data class Link( memo = domainLink.memo, imageUrl = domainLink.thumbnail, bookmark = domainLink.favorites, - linkType = LinkType.TEXT + pokitName = domainLink.categoryName, + pokitId = domainLink.categoryId.toString() ) } } } - -enum class LinkType(val textResourceId: Int) { - TEXT(R.string.text), -} From aa2ea4ba334014e496d2e85300615fccd0c16e9a Mon Sep 17 00:00:00 2001 From: yunsehwan Date: Thu, 29 Aug 2024 20:57:36 +0900 Subject: [PATCH 2/7] =?UTF-8?q?[FIX]=20#64-=EB=A7=81=ED=81=AC=20=EC=A6=90?= =?UTF-8?q?=EA=B2=A8=EC=B0=BE=EA=B8=B0=20=EC=B7=A8=EC=86=8C=EA=B0=80=20?= =?UTF-8?q?=EC=A0=95=EC=83=81=EC=A0=81=EC=9C=BC=EB=A1=9C=20=EC=9E=91?= =?UTF-8?q?=EB=8F=99=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8D=98=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/src/main/java/pokitmons/pokit/data/api/LinkApi.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/src/main/java/pokitmons/pokit/data/api/LinkApi.kt b/data/src/main/java/pokitmons/pokit/data/api/LinkApi.kt index 090a48dc..005032c5 100644 --- a/data/src/main/java/pokitmons/pokit/data/api/LinkApi.kt +++ b/data/src/main/java/pokitmons/pokit/data/api/LinkApi.kt @@ -64,7 +64,7 @@ interface LinkApi { ): ModifyLinkResponse @PUT("content/{contentId}/bookmark") - suspend fun cancelBookmark(@Path("contentId") contentId: Int) + suspend fun cancelBookmark(@Path("contentId") contentId: Int): Response @POST("content/{contentId}/bookmark") suspend fun applyBookmark(@Path("contentId") contentId: Int): ApplyBookmarkResponse From 9fd23d2eb2f0377bf5406ecceb54f4e30ed1d736 Mon Sep 17 00:00:00 2001 From: yunsehwan Date: Thu, 29 Aug 2024 20:59:08 +0900 Subject: [PATCH 3/7] =?UTF-8?q?[FIX]=20#64-=EB=A7=81=ED=81=AC=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20bottomSheet=EC=97=90=20=EC=A6=90=EA=B2=A8=EC=B0=BE?= =?UTF-8?q?=EA=B8=B0=20=ED=81=B4=EB=A6=AD=EC=9D=B4=20=EC=9E=91=EB=8F=99?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8D=98=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95,=20=EC=B6=94=EA=B0=80/=EC=88=98=EC=A0=95/?= =?UTF-8?q?=EA=B3=B5=EC=9C=A0=20bottomSheet=EC=97=90=EC=84=9C=20=EA=B3=B5?= =?UTF-8?q?=EC=9C=A0=20=EB=B2=84=ED=8A=BC=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pokitmons/pokit/home/pokit/PokitScreen.kt | 1 - .../pokit/home/pokit/PokitViewModel.kt | 20 ++++++++++++++++ .../pokit/home/pokit/UnclassifiedScreen.kt | 3 +-- .../pokit/home/remind/RemindScreen.kt | 1 - .../pokitdetail/PokitDetailScreen.kt | 9 +++---- .../pokitdetail/PokitDetailViewModel.kt | 24 +++++++++++++++++++ .../pokitmons/pokit/search/SearchScreen.kt | 4 ---- 7 files changed, 50 insertions(+), 12 deletions(-) diff --git a/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitScreen.kt b/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitScreen.kt index e808aad0..5af92453 100644 --- a/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitScreen.kt +++ b/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitScreen.kt @@ -54,7 +54,6 @@ fun PokitScreen( when (pokitOptionBottomSheetType) { BottomSheetType.MODIFY -> { ModifyBottomSheetContent( - onClickShare = {}, onClickModify = remember { { viewModel.hidePokitDetailRemoveBottomSheet() diff --git a/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitViewModel.kt b/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitViewModel.kt index 06db6857..f9b37898 100644 --- a/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitViewModel.kt +++ b/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitViewModel.kt @@ -25,6 +25,7 @@ import pokitmons.pokit.domain.model.pokit.MAX_POKIT_COUNT import pokitmons.pokit.domain.model.pokit.PokitsSort import pokitmons.pokit.domain.usecase.link.DeleteLinkUseCase import pokitmons.pokit.domain.usecase.link.GetLinksUseCase +import pokitmons.pokit.domain.usecase.link.SetBookmarkUseCase import pokitmons.pokit.domain.usecase.pokit.DeletePokitUseCase import pokitmons.pokit.domain.usecase.pokit.GetPokitCountUseCase import pokitmons.pokit.domain.usecase.pokit.GetPokitsUseCase @@ -41,6 +42,7 @@ class PokitViewModel @Inject constructor( private val deletePokitUseCase: DeletePokitUseCase, private val getPokitCountUseCase: GetPokitCountUseCase, private val deleteLinkUseCase: DeleteLinkUseCase, + private val setBookmarkUseCase: SetBookmarkUseCase ) : ViewModel() { private val _sideEffect = MutableEventFlow() @@ -321,6 +323,24 @@ class PokitViewModel @Inject constructor( fun hideDetailLinkBottomSheet() { _currentDetailShowLink.update { null } } + + fun toggleBookmark() { + val currentLink = _currentDetailShowLink.value ?: return + val currentLinkId = currentLink.id.toIntOrNull() ?: return + val applyBookmarked = !currentLink.bookmark + + viewModelScope.launch { + val response = setBookmarkUseCase.setBookMarked(currentLinkId, applyBookmarked) + if (response is PokitResult.Success) { + val bookmarkChangedLink = currentLink.copy(bookmark = applyBookmarked) + linkPaging.modifyItem(bookmarkChangedLink) + + if (currentLink.id == _currentDetailShowLink.value?.id) { + _currentDetailShowLink.update { bookmarkChangedLink } + } + } + } + } } sealed class Category { diff --git a/feature/home/src/main/java/pokitmons/pokit/home/pokit/UnclassifiedScreen.kt b/feature/home/src/main/java/pokitmons/pokit/home/pokit/UnclassifiedScreen.kt index dd9b32a1..6a780f86 100644 --- a/feature/home/src/main/java/pokitmons/pokit/home/pokit/UnclassifiedScreen.kt +++ b/feature/home/src/main/java/pokitmons/pokit/home/pokit/UnclassifiedScreen.kt @@ -45,7 +45,7 @@ fun UnclassifiedScreen( dateString = link.dateString, onHideBottomSheet = viewModel::hideDetailLinkBottomSheet, show = true, - onClickBookmark = {} + onClickBookmark = viewModel::toggleBookmark ) } @@ -56,7 +56,6 @@ fun UnclassifiedScreen( when (pokitOptionBottomSheetType) { BottomSheetType.MODIFY -> { ModifyBottomSheetContent( - onClickShare = {}, onClickModify = remember { { viewModel.hideLinkOptionBottomSheet() diff --git a/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindScreen.kt b/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindScreen.kt index 97b4f70c..a149b99c 100644 --- a/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindScreen.kt +++ b/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindScreen.kt @@ -70,7 +70,6 @@ fun RemindScreen( when (pokitOptionBottomSheetType) { BottomSheetType.MODIFY -> { ModifyBottomSheetContent( - onClickShare = {}, onClickModify = remember { { viewModel.hideLinkOptionBottomSheet() diff --git a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt index 59170b7d..752cfc9f 100644 --- a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt +++ b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt @@ -87,7 +87,8 @@ fun PokitDetailScreenContainer( onClickLinkRemove = viewModel::deleteLink, loadNextPokits = viewModel::loadNextPokits, refreshPokits = viewModel::refreshPokits, - loadNextLinks = viewModel::loadNextLinks + loadNextLinks = viewModel::loadNextLinks, + onClickBookmark = viewModel::toggleBookmark ) } @@ -120,6 +121,7 @@ fun PokitDetailScreen( loadNextPokits: () -> Unit = {}, refreshPokits: () -> Unit = {}, loadNextLinks: () -> Unit = {}, + onClickBookmark: () -> Unit = {}, ) { Column( modifier = Modifier.fillMaxSize() @@ -223,7 +225,8 @@ fun PokitDetailScreen( pokitName = state.currentLink.pokitName, dateString = state.currentLink.dateString, onHideBottomSheet = hideLinkDetailBottomSheet, - show = state.linkDetailBottomSheetVisible + show = state.linkDetailBottomSheetVisible, + onClickBookmark = onClickBookmark ) } @@ -281,7 +284,6 @@ fun PokitDetailScreen( when (state.linkBottomSheetType) { BottomSheetType.MODIFY -> { ModifyBottomSheetContent( - onClickShare = {}, onClickModify = remember { { state.currentLink?.let { link -> @@ -317,7 +319,6 @@ fun PokitDetailScreen( when (state.pokitBottomSheetType) { BottomSheetType.MODIFY -> { ModifyBottomSheetContent( - onClickShare = {}, onClickModify = remember { { hidePokitModifyBottomSheet() diff --git a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailViewModel.kt b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailViewModel.kt index 7f7edbd0..c795cfb8 100644 --- a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailViewModel.kt +++ b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailViewModel.kt @@ -26,6 +26,7 @@ import pokitmons.pokit.domain.commom.PokitResult import pokitmons.pokit.domain.model.link.LinksSort import pokitmons.pokit.domain.usecase.link.DeleteLinkUseCase import pokitmons.pokit.domain.usecase.link.GetLinksUseCase +import pokitmons.pokit.domain.usecase.link.SetBookmarkUseCase import pokitmons.pokit.domain.usecase.pokit.DeletePokitUseCase import pokitmons.pokit.domain.usecase.pokit.GetPokitUseCase import pokitmons.pokit.domain.usecase.pokit.GetPokitsUseCase @@ -39,6 +40,7 @@ class PokitDetailViewModel @Inject constructor( private val getPokitUseCase: GetPokitUseCase, private val deletePokitUseCase: DeletePokitUseCase, private val deleteLinkUseCase: DeleteLinkUseCase, + private val setBookmarkUseCase: SetBookmarkUseCase, savedStateHandle: SavedStateHandle, ) : ViewModel() { private val pokitPaging = PokitPaging( @@ -250,4 +252,26 @@ class PokitDetailViewModel @Inject constructor( } } } + + fun toggleBookmark() { + val currentLink = state.value.currentLink ?: return + val currentLinkId = currentLink.id.toIntOrNull() ?: return + val applyBookmarked = !currentLink.bookmark + + viewModelScope.launch { + val response = setBookmarkUseCase.setBookMarked(currentLinkId, applyBookmarked) + if (response is PokitResult.Success) { + val bookmarkChangedLink = currentLink.copy(bookmark = applyBookmarked) + linkPaging.modifyItem(bookmarkChangedLink) + + if (currentLink.id == state.value.currentLink?.id) { + _state.update { state -> + state.copy( + currentLink = bookmarkChangedLink + ) + } + } + } + } + } } diff --git a/feature/search/src/main/java/pokitmons/pokit/search/SearchScreen.kt b/feature/search/src/main/java/pokitmons/pokit/search/SearchScreen.kt index 58cedcd1..8063935c 100644 --- a/feature/search/src/main/java/pokitmons/pokit/search/SearchScreen.kt +++ b/feature/search/src/main/java/pokitmons/pokit/search/SearchScreen.kt @@ -103,10 +103,6 @@ fun SearchScreenContainer( viewModel.showLinkRemoveBottomSheet(link) } } - }, - onClickShare = remember { - { - } } ) } From cbae1bb45975762d8bcc6d83daf27e2545b911a6 Mon Sep 17 00:00:00 2001 From: yunsehwan Date: Fri, 30 Aug 2024 19:51:01 +0900 Subject: [PATCH 4/7] [CHORE] #64-ktlint --- .../src/main/java/pokitmons/pokit/home/pokit/PokitViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitViewModel.kt b/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitViewModel.kt index f9b37898..98b4de07 100644 --- a/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitViewModel.kt +++ b/feature/home/src/main/java/pokitmons/pokit/home/pokit/PokitViewModel.kt @@ -42,7 +42,7 @@ class PokitViewModel @Inject constructor( private val deletePokitUseCase: DeletePokitUseCase, private val getPokitCountUseCase: GetPokitCountUseCase, private val deleteLinkUseCase: DeleteLinkUseCase, - private val setBookmarkUseCase: SetBookmarkUseCase + private val setBookmarkUseCase: SetBookmarkUseCase, ) : ViewModel() { private val _sideEffect = MutableEventFlow() From 66bb860b562b3ea1decb1fd89e0c329fcf9002eb Mon Sep 17 00:00:00 2001 From: yunsehwan Date: Fri, 30 Aug 2024 20:40:34 +0900 Subject: [PATCH 5/7] =?UTF-8?q?[FIX]=20#64-=ED=8F=AC=ED=82=B7=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20=ED=99=94=EB=A9=B4=EC=97=90=EC=84=9C=20=EC=9D=BD?= =?UTF-8?q?=EC=9D=8C=20=EC=95=88=EC=9D=BD=EC=9D=8C=20=EC=97=AC=EB=B6=80?= =?UTF-8?q?=EA=B0=80=20=EB=B0=98=EB=8C=80=EB=A1=9C=20=ED=91=9C=EC=8B=9C?= =?UTF-8?q?=EB=90=98=EB=8D=98=20=EB=AC=B8=EC=A0=9C=20=EC=88=98=EC=A0=95,?= =?UTF-8?q?=20=EB=B6=81=EB=A7=88=ED=81=AC=20=EB=B3=80=EA=B2=BD=EC=9D=B4=20?= =?UTF-8?q?=EC=A0=95=EC=83=81=EC=A0=81=EC=9C=BC=EB=A1=9C=20=EB=8F=99?= =?UTF-8?q?=EC=9E=91=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8D=98=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pokitdetail/PokitDetailScreen.kt | 5 ++-- .../pokitdetail/PokitDetailViewModel.kt | 23 +++++++++++++++++-- .../com/strayalpaca/pokitdetail/model/Link.kt | 3 ++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt index 752cfc9f..eef10b24 100644 --- a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt +++ b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailScreen.kt @@ -197,7 +197,7 @@ fun PokitDetailScreen( title = link.title, sub = "${link.dateString} · ${link.domainUrl}", painter = rememberAsyncImagePainter(link.imageUrl), - notRead = link.isRead, + notRead = !link.isRead, badgeText = link.pokitName, onClickKebab = showLinkModifyBottomSheet, onClickItem = onClickLink, @@ -264,7 +264,8 @@ fun PokitDetailScreen( state = lazyColumnListState ) { items( - items = pokitList + items = pokitList, + key = { it.id } ) { pokit -> PokitList( item = pokit, diff --git a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailViewModel.kt b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailViewModel.kt index c795cfb8..4356fb09 100644 --- a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailViewModel.kt +++ b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/PokitDetailViewModel.kt @@ -25,6 +25,7 @@ import pokitmons.pokit.core.feature.navigation.args.PokitUpdateEvent import pokitmons.pokit.domain.commom.PokitResult import pokitmons.pokit.domain.model.link.LinksSort import pokitmons.pokit.domain.usecase.link.DeleteLinkUseCase +import pokitmons.pokit.domain.usecase.link.GetLinkUseCase import pokitmons.pokit.domain.usecase.link.GetLinksUseCase import pokitmons.pokit.domain.usecase.link.SetBookmarkUseCase import pokitmons.pokit.domain.usecase.pokit.DeletePokitUseCase @@ -41,6 +42,7 @@ class PokitDetailViewModel @Inject constructor( private val deletePokitUseCase: DeletePokitUseCase, private val deleteLinkUseCase: DeleteLinkUseCase, private val setBookmarkUseCase: SetBookmarkUseCase, + private val getLinkUseCase: GetLinkUseCase, savedStateHandle: SavedStateHandle, ) : ViewModel() { private val pokitPaging = PokitPaging( @@ -189,7 +191,22 @@ class PokitDetailViewModel @Inject constructor( } fun showLinkDetailBottomSheet(link: Link) { - _state.update { it.copy(currentLink = link, linkDetailBottomSheetVisible = true) } + _state.update { + it.copy(currentLink = link, linkDetailBottomSheetVisible = true) + } + + viewModelScope.launch { + val response = getLinkUseCase.getLink(link.id.toInt()) + if (response is PokitResult.Success && state.value.currentLink?.id == link.id && state.value.linkDetailBottomSheetVisible) { + _state.update { it.copy(currentLink = Link.fromDomainLink(response.result).copy(imageUrl = link.imageUrl, isRead = true)) } + } + + val isReadChangedLink = linkPaging.pagingData.value + .find { it.id == link.id } + ?.copy(isRead = true) ?: return@launch + + linkPaging.modifyItem(isReadChangedLink) + } } fun hideLinkDetailBottomSheet() { @@ -261,7 +278,9 @@ class PokitDetailViewModel @Inject constructor( viewModelScope.launch { val response = setBookmarkUseCase.setBookMarked(currentLinkId, applyBookmarked) if (response is PokitResult.Success) { - val bookmarkChangedLink = currentLink.copy(bookmark = applyBookmarked) + val bookmarkChangedLink = linkPaging.pagingData.value + .find { it.id == currentLink.id } + ?.copy(bookmark = applyBookmarked) ?: return@launch linkPaging.modifyItem(bookmarkChangedLink) if (currentLink.id == state.value.currentLink?.id) { diff --git a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/model/Link.kt b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/model/Link.kt index dae9b11c..3980ea3f 100644 --- a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/model/Link.kt +++ b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/model/Link.kt @@ -29,7 +29,8 @@ data class Link( imageUrl = domainLink.thumbnail, createdAt = domainLink.createdAt, pokitName = domainLink.categoryName, - pokitId = domainLink.categoryId.toString() + pokitId = domainLink.categoryId.toString(), + bookmark = domainLink.favorites, ) } } From b14c0d3423299c23d71c7bc0b7eda99126c39f91 Mon Sep 17 00:00:00 2001 From: yunsehwan Date: Fri, 30 Aug 2024 20:42:00 +0900 Subject: [PATCH 6/7] =?UTF-8?q?[FIX]=20#64-(=EC=9E=84=EC=8B=9C=EC=88=98?= =?UTF-8?q?=EC=A0=95)=20=EC=A6=90=EA=B2=A8=EC=B0=BE=EA=B8=B0=20=EB=A7=81?= =?UTF-8?q?=ED=81=AC=EC=97=90=EC=84=9C=20=EC=B9=B4=ED=85=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=20=EC=9D=B4=EB=A6=84=20=ED=91=9C=EC=8B=9C=20=EB=B6=80?= =?UTF-8?q?=EB=B6=84=EC=97=90=20=EB=A7=81=ED=81=AC=20Url=EC=9D=B4=20?= =?UTF-8?q?=ED=91=9C=EC=8B=9C=EB=90=98=EB=8A=94=20=ED=98=84=EC=83=81=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=ED=95=98=EA=B8=B0=20=EC=9C=84=ED=95=B4=20?= =?UTF-8?q?=EC=9E=84=EC=9D=98=EB=A1=9C=20=ED=95=B4=EB=8B=B9=20UI=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0.=20=EC=B6=94=ED=9B=84=20Remind=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=ED=98=95=EC=8B=9D=EC=97=90=20=ED=8F=AC?= =?UTF-8?q?=ED=82=B7=EB=AA=85=EC=9D=B4=20=ED=8F=AC=ED=95=A8=EB=90=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95=ED=95=A0=20=EB=95=8C=20?= =?UTF-8?q?=EB=8B=A4=EC=8B=9C=20=EB=B0=98=EC=98=81=20=ED=95=84=EC=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/pokitmons/pokit/home/remind/RemindScreen.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindScreen.kt b/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindScreen.kt index a149b99c..6b900077 100644 --- a/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindScreen.kt +++ b/feature/home/src/main/java/pokitmons/pokit/home/remind/RemindScreen.kt @@ -242,7 +242,7 @@ fun RemindScreen( sub = "${favoriteContent.createdAt} • ${favoriteContent.domain}", painter = rememberAsyncImagePainter(favoriteContent.thumbNail), notRead = favoriteContent.isRead, - badgeText = favoriteContent.data, + badgeText = null, onClickKebab = { viewModel.showLinkOptionBottomSheet(remindResult = favoriteContent) }, From c0e3aed5c355920a6fc8b30b778d2ffe9b65d988 Mon Sep 17 00:00:00 2001 From: yunsehwan Date: Fri, 30 Aug 2024 20:42:35 +0900 Subject: [PATCH 7/7] =?UTF-8?q?[CHORE]=20#64-ktlint=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/strayalpaca/pokitdetail/model/Link.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/model/Link.kt b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/model/Link.kt index 3980ea3f..735e18a1 100644 --- a/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/model/Link.kt +++ b/feature/pokitdetail/src/main/java/com/strayalpaca/pokitdetail/model/Link.kt @@ -30,7 +30,7 @@ data class Link( createdAt = domainLink.createdAt, pokitName = domainLink.categoryName, pokitId = domainLink.categoryId.toString(), - bookmark = domainLink.favorites, + bookmark = domainLink.favorites ) } }