From daa9dbe954d15ff1210c16e4a7a0c4bcbf4cd2db Mon Sep 17 00:00:00 2001 From: arinming Date: Mon, 16 Sep 2024 03:52:19 +0900 Subject: [PATCH] =?UTF-8?q?[FIX/#250]=20=EC=8A=A4=ED=81=AC=EB=9E=A9=20?= =?UTF-8?q?=EB=8B=A4=EC=9D=B4=EC=96=BC=EB=A1=9C=EA=B7=B8=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../calendar/list/CalendarListScreen.kt | 2 +- .../calendar/week/CalendarWeekScreen.kt | 2 +- .../feature/dialog/detail/ScrapDialog.kt | 16 +++---- .../com/terning/feature/intern/InternRoute.kt | 2 +- .../searchprocess/SearchProcessRoute.kt | 44 +++++++++---------- .../searchprocess/SearchProcessViewModel.kt | 10 +++++ 6 files changed, 43 insertions(+), 33 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/calendar/list/CalendarListScreen.kt b/feature/src/main/java/com/terning/feature/calendar/list/CalendarListScreen.kt index 6e145abbc..59189d662 100644 --- a/feature/src/main/java/com/terning/feature/calendar/list/CalendarListScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/list/CalendarListScreen.kt @@ -125,7 +125,7 @@ private fun CalendarListScreen( uiState: CalendarListUiState, navigateToAnnouncement: (Long) -> Unit, onDismissCancelDialog: (Boolean) -> Unit, - onDismissInternDialog: () -> Unit, + onDismissInternDialog: (Boolean) -> Unit, onClickChangeColor: () -> Unit, onClickInternship: (CalendarScrapDetail) -> Unit, onClickScrapButton: (Long) -> Unit, diff --git a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt index ca882549f..bfc8bf56b 100644 --- a/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt +++ b/feature/src/main/java/com/terning/feature/calendar/week/CalendarWeekScreen.kt @@ -121,7 +121,7 @@ private fun CalendarWeekScreen( selectedDate: LocalDate, updateSelectedDate: (LocalDate) -> Unit, onDismissCancelDialog: (Boolean) -> Unit, - onDismissInternDialog: () -> Unit, + onDismissInternDialog: (Boolean) -> Unit, onClickChangeColor: () -> Unit, onClickInternship: (CalendarScrapDetail) -> Unit, onClickScrapButton: (Long) -> Unit, diff --git a/feature/src/main/java/com/terning/feature/dialog/detail/ScrapDialog.kt b/feature/src/main/java/com/terning/feature/dialog/detail/ScrapDialog.kt index 0928b1cc8..fbca9cf37 100644 --- a/feature/src/main/java/com/terning/feature/dialog/detail/ScrapDialog.kt +++ b/feature/src/main/java/com/terning/feature/dialog/detail/ScrapDialog.kt @@ -64,11 +64,11 @@ fun ScrapDialog( internshipAnnouncementId: Long, companyImage: String, isScrapped: Boolean, - onDismissRequest: () -> Unit = {}, + onDismissRequest: (Boolean) -> Unit = {}, onScrapAnnouncement: () -> Unit = {}, onClickChangeColor: () -> Unit = {}, onClickNavigateButton: (Long) -> Unit = {}, - viewModel: ScrapDialogViewModel = hiltViewModel() + viewModel: ScrapDialogViewModel = hiltViewModel(), ) { val context = LocalContext.current val lifecycleOwner = LocalLifecycleOwner.current @@ -83,12 +83,12 @@ fun ScrapDialog( is ScrapDialogSideEffect.DismissDialog -> { viewModel.initUiState() - onDismissRequest() + onDismissRequest(false) } is ScrapDialogSideEffect.PatchedScrap -> { onClickChangeColor() - onDismissRequest() + onDismissRequest(false) } is ScrapDialogSideEffect.NavigateToDetail -> onClickNavigateButton( @@ -97,7 +97,7 @@ fun ScrapDialog( is ScrapDialogSideEffect.ScrappedAnnouncement -> { onScrapAnnouncement() - onDismissRequest() + onDismissRequest(true) } } } @@ -150,7 +150,7 @@ private fun ScrapDialogScreen( onClickColorButton: (ColorType) -> Unit, onClickNavigateButton: () -> Unit, onClickColorChangeButton: () -> Unit, - onClickScrapButton: () -> Unit + onClickScrapButton: () -> Unit, ) { Box( modifier = Modifier @@ -277,7 +277,7 @@ private fun ScrapDialogScreen( @Composable private fun NewScrapButton( onClickScrapButton: () -> Unit, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, ) { RoundButton( style = TerningTheme.typography.button3, @@ -294,7 +294,7 @@ private fun DetailScrapButton( isColorChanged: Boolean, onClickNavigateButton: () -> Unit, onClickColorChangeButton: () -> Unit, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, ) { Row( modifier = modifier diff --git a/feature/src/main/java/com/terning/feature/intern/InternRoute.kt b/feature/src/main/java/com/terning/feature/intern/InternRoute.kt index ef02c79ed..30e877e99 100644 --- a/feature/src/main/java/com/terning/feature/intern/InternRoute.kt +++ b/feature/src/main/java/com/terning/feature/intern/InternRoute.kt @@ -104,7 +104,7 @@ fun InternScreen( internUiState: InternUiState, internInfo: InternInfo, onDismissCancelDialog: (Boolean) -> Unit, - onDismissScrapDialog: () -> Unit, + onDismissScrapDialog: (Boolean) -> Unit, onClickCancelButton: (InternInfo) -> Unit, onClickScrapButton: (InternInfo) -> Unit, ) { diff --git a/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessRoute.kt b/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessRoute.kt index b27fa9f58..ac7e3659d 100644 --- a/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessRoute.kt +++ b/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessRoute.kt @@ -69,7 +69,7 @@ fun SearchProcessRoute( viewModel.getSearchList( keyword = state.text, page = 0, - size = 100 + size = 0 ) } @@ -109,23 +109,19 @@ fun SearchProcessRoute( onSortButtonClick = { viewModel.updateSheetVisible(true) }, - onDismissCancelDialog = { - viewModel.getSearchList( - keyword = state.keyword, - sortBy = state.sortBy.ordinal, - page = state.page, - size = state.size - ) + onDismissScrapDialog = { isScrapped, searchResult -> viewModel.updateScrapDialogVisible(false) - }, - onDismissScrapDialog = { - viewModel.getSearchList( - keyword = state.keyword, - sortBy = state.sortBy.ordinal, - page = state.page, - size = state.size + viewModel.updateSearchResultScrapStatus( + searchResult.internshipAnnouncementId, + isScrapped ) + }, + onDismissCancelDialog = { isScrapped, searchResult -> viewModel.updateScrapDialogVisible(false) + viewModel.updateSearchResultScrapStatus( + searchResult.internshipAnnouncementId, + !isScrapped + ) }, onDismissSheet = { viewModel.updateSheetVisible(false) @@ -160,8 +156,8 @@ fun SearchProcessScreen( updateText: (String) -> Unit = {}, onSearchAction: () -> Unit = {}, onSortButtonClick: () -> Unit = {}, - onDismissCancelDialog: (Boolean) -> Unit, - onDismissScrapDialog: () -> Unit, + onDismissCancelDialog: (Boolean, SearchResult) -> Unit, + onDismissScrapDialog: (Boolean, SearchResult) -> Unit, onDismissSheet: () -> Unit = {}, onScrapButtonClicked: (SearchResult) -> Unit, onSortChange: (Int) -> Unit = {}, @@ -223,8 +219,6 @@ fun SearchProcessScreen( horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center ) { - - Row( horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically, @@ -270,7 +264,9 @@ fun SearchProcessScreen( intern = internSearchResultData[index], navigateToIntern = navigateToIntern, onScrapButtonClicked = { - onScrapButtonClicked(internSearchResultData[index]) + with(internSearchResultData[index]) { + onScrapButtonClicked(this) + } } ) } @@ -338,7 +334,9 @@ fun SearchProcessScreen( if (searchResult.isScrapped) { ScrapCancelDialog( internshipAnnouncementId = searchResult.internshipAnnouncementId, - onDismissRequest = onDismissCancelDialog + onDismissRequest = { isScrapped -> + onDismissCancelDialog(isScrapped, searchResult) + } ) } else { ScrapDialog( @@ -350,7 +348,9 @@ fun SearchProcessScreen( internshipAnnouncementId = searchResult.internshipAnnouncementId, companyImage = searchResult.companyImage, isScrapped = false, - onDismissRequest = onDismissScrapDialog, + onDismissRequest = { isScrapped -> + onDismissScrapDialog(isScrapped, searchResult) + } ) } } diff --git a/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessViewModel.kt b/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessViewModel.kt index e912c4de8..c2aeb5d59 100644 --- a/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessViewModel.kt +++ b/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessViewModel.kt @@ -111,4 +111,14 @@ class SearchProcessViewModel @Inject constructor( size = 100 ) } + + fun updateSearchResultScrapStatus(internshipId: Long, isScrapped: Boolean) { + _internSearchResultData.value = _internSearchResultData.value.map { searchResult -> + if (searchResult.internshipAnnouncementId == internshipId) { + searchResult.copy(isScrapped = isScrapped) + } else { + searchResult + } + } + } }