From c7166df3e016e843e321f0fbcfba5c20c52f2013 Mon Sep 17 00:00:00 2001 From: arinming Date: Fri, 19 Jul 2024 19:18:56 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[FEAT]=20=EA=B2=80=EC=83=89=20=EA=B2=B0?= =?UTF-8?q?=EA=B3=BC=20=EC=8A=A4=ED=81=AC=EB=9E=A9=20=EC=B6=94=EA=B0=80,?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../terning/feature/home/home/HomeRoute.kt | 44 ++++++- .../feature/home/home/HomeViewModel.kt | 2 + .../component/HomeRecommendInternDialog.kt | 30 ----- .../searchprocess/SearchProcessRoute.kt | 107 ++++++++++++++---- .../searchprocess/SearchProcessViewModel.kt | 2 + 5 files changed, 132 insertions(+), 53 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/home/home/HomeRoute.kt b/feature/src/main/java/com/terning/feature/home/home/HomeRoute.kt index bc437e7a4..3b12f44bb 100644 --- a/feature/src/main/java/com/terning/feature/home/home/HomeRoute.kt +++ b/feature/src/main/java/com/terning/feature/home/home/HomeRoute.kt @@ -40,6 +40,16 @@ import com.terning.core.designsystem.component.dialog.TerningBasicDialog import com.terning.core.designsystem.component.item.InternItemWithShadow import com.terning.core.designsystem.component.topappbar.LogoTopAppBar import com.terning.core.designsystem.theme.Black +import com.terning.core.designsystem.theme.CalBlue1 +import com.terning.core.designsystem.theme.CalBlue2 +import com.terning.core.designsystem.theme.CalGreen1 +import com.terning.core.designsystem.theme.CalGreen2 +import com.terning.core.designsystem.theme.CalOrange1 +import com.terning.core.designsystem.theme.CalOrange2 +import com.terning.core.designsystem.theme.CalPink +import com.terning.core.designsystem.theme.CalPurple +import com.terning.core.designsystem.theme.CalRed +import com.terning.core.designsystem.theme.CalYellow import com.terning.core.designsystem.theme.Grey150 import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White @@ -285,7 +295,7 @@ fun HomeScreen( viewModel.deleteScrap( recommendInternList[scrapId].scrapId ?: -1, ) - if(homeDialogState.isScrappedState) { + if (homeDialogState.isScrappedState) { viewModel.getRecommendInternsData( currentSortBy.value, homeFilteringInfo.startYear ?: viewModel.currentYear, @@ -296,6 +306,22 @@ fun HomeScreen( } ) } else { + val colorList = listOf( + CalRed, + CalOrange1, + CalOrange2, + CalYellow, + CalGreen1, + CalGreen2, + CalBlue1, + CalBlue2, + CalPurple, + CalPink, + ) + + val selectedColorIndex = + colorList.indexOf(homeDialogState.selectedColor).takeIf { it >= 0 } ?: 0 + with(recommendInternList[scrapId]) { HomeRecommendInternDialog( internInfoList = listOf( @@ -304,8 +330,22 @@ fun HomeScreen( stringResource(id = R.string.intern_info_start_date) to startYearMonth, ), clickAction = { + if (homeDialogState.isPaletteOpen) { + viewModel.updatePaletteOpen(false) + viewModel.updateColorChange(false) + viewModel.updateScrapDialogVisible(false) + } else { + if (homeDialogState.isColorChange) { + viewModel.updateColorChange(false) + } + viewModel.updateScrapDialogVisible(false) + } + viewModel.postScrap( + recommendInternList[scrapId].internshipAnnouncementId, + selectedColorIndex, + ) viewModel.updateScrapDialogVisible(false) - if(homeDialogState.isScrappedState) { + if (homeDialogState.isScrappedState) { viewModel.getRecommendInternsData( currentSortBy.value, homeFilteringInfo.startYear ?: viewModel.currentYear, diff --git a/feature/src/main/java/com/terning/feature/home/home/HomeViewModel.kt b/feature/src/main/java/com/terning/feature/home/home/HomeViewModel.kt index f0764e7f0..de1d820b0 100644 --- a/feature/src/main/java/com/terning/feature/home/home/HomeViewModel.kt +++ b/feature/src/main/java/com/terning/feature/home/home/HomeViewModel.kt @@ -137,6 +137,7 @@ class HomeViewModel @Inject constructor( updateScrapDialogVisible(visible = false) updateScrapped(scrapped = true) getHomeTodayInternList() + _homeSideEffect.emit(HomeSideEffect.ShowToast(R.string.intern_scrap_add_toast_message)) }.onFailure { _homeSideEffect.emit(HomeSideEffect.ShowToast(R.string.server_failure)) } @@ -151,6 +152,7 @@ class HomeViewModel @Inject constructor( updateScrapDialogVisible(visible = false) updateScrapped(scrapped = true) getHomeTodayInternList() + _homeSideEffect.emit(HomeSideEffect.ShowToast(R.string.intern_scrap_delete_toast_message)) }.onFailure { _homeSideEffect.emit(HomeSideEffect.ShowToast(R.string.server_failure)) } diff --git a/feature/src/main/java/com/terning/feature/home/home/component/HomeRecommendInternDialog.kt b/feature/src/main/java/com/terning/feature/home/home/component/HomeRecommendInternDialog.kt index 45e08b4ba..d4cdbd71f 100644 --- a/feature/src/main/java/com/terning/feature/home/home/component/HomeRecommendInternDialog.kt +++ b/feature/src/main/java/com/terning/feature/home/home/component/HomeRecommendInternDialog.kt @@ -66,19 +66,6 @@ fun HomeRecommendInternDialog( ) { val state by viewModel.homeDialogState.collectAsStateWithLifecycle() - val colorList = listOf( - CalRed, - CalOrange1, - CalOrange2, - CalYellow, - CalGreen1, - CalGreen2, - CalBlue1, - CalBlue2, - CalPurple, - CalPink, - ) - Box( modifier = Modifier .fillMaxSize() @@ -225,29 +212,12 @@ fun HomeRecommendInternDialog( modifier = Modifier.fillMaxWidth(), contentAlignment = Alignment.BottomCenter ) { - val selectedColorIndex = - colorList.indexOf(state.selectedColor).takeIf { it >= 0 } ?: 0 - RoundButton( style = TerningTheme.typography.button3, paddingVertical = 12.dp, cornerRadius = 8.dp, text = R.string.dialog_scrap_button, onButtonClick = { - if (state.isPaletteOpen) { - viewModel.updatePaletteOpen(false) - viewModel.updateColorChange(false) - viewModel.updateScrapDialogVisible(false) - } else { - if (state.isColorChange) { - viewModel.updateColorChange(false) - } - viewModel.updateScrapDialogVisible(false) - } - viewModel.postScrap( - homeRecommendInternModel.internshipAnnouncementId, - selectedColorIndex, - ) clickAction() }, modifier = Modifier.padding(bottom = 8.dp) 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 b146271e9..5043c66bc 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 @@ -26,6 +26,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.layout.ContentScale +import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource @@ -43,14 +44,26 @@ import com.terning.core.designsystem.component.item.InternItemWithShadow import com.terning.core.designsystem.component.textfield.SearchTextField import com.terning.core.designsystem.component.topappbar.BackButtonTopAppBar import com.terning.core.designsystem.theme.Black +import com.terning.core.designsystem.theme.CalBlue1 +import com.terning.core.designsystem.theme.CalBlue2 +import com.terning.core.designsystem.theme.CalGreen1 +import com.terning.core.designsystem.theme.CalGreen2 +import com.terning.core.designsystem.theme.CalOrange1 +import com.terning.core.designsystem.theme.CalOrange2 +import com.terning.core.designsystem.theme.CalPink +import com.terning.core.designsystem.theme.CalPurple +import com.terning.core.designsystem.theme.CalRed +import com.terning.core.designsystem.theme.CalYellow import com.terning.core.designsystem.theme.Grey400 import com.terning.core.designsystem.theme.TerningMain import com.terning.core.designsystem.theme.TerningPointTheme import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.extension.addFocusCleaner import com.terning.core.extension.noRippleClickable +import com.terning.core.extension.toast +import com.terning.domain.entity.response.HomeRecommendInternModel import com.terning.feature.R -import com.terning.feature.intern.component.ScrapDialogContent +import com.terning.feature.home.home.component.HomeRecommendInternDialog import com.terning.feature.intern.navigation.navigateIntern private const val MAX_LINES = 1 @@ -60,6 +73,7 @@ fun SearchProcessRoute( navController: NavHostController, viewModel: SearchProcessViewModel = hiltViewModel(), ) { + val context = LocalContext.current val lifecycleOwner = LocalLifecycleOwner.current val currentSortBy: MutableState = remember { @@ -70,17 +84,11 @@ fun SearchProcessRoute( viewModel.sideEffect.flowWithLifecycle(lifecycle = lifecycleOwner.lifecycle) .collect { sideEffect -> when (sideEffect) { - is SearchProcessSideEffect.Toast -> { - sideEffect.message - } + is SearchProcessSideEffect.Toast -> context.toast(sideEffect.message) is SearchProcessSideEffect.ScrapUpdate -> { sideEffect.keyword } - - else -> { - - } } } } @@ -280,27 +288,84 @@ fun SearchProcessScreen( onClickScrapCancel = { viewModel.updateScrapDialogVisible(false) viewModel.deleteScrap( - selectedIntern.scrapId ?: -1, + internSearchResultData[selectedIndex].scrapId ?: -1, ) if (dialogState.isScrappedState) { + viewModel.getSearchList( + keyword = state.text, + sortBy = SORT_BY, + page = 0, + size = 10 + ) viewModel.updateScrapped(false) } + viewModel.updateSelectColor(CalRed) } ) } else { - val internInfoList = listOf( - stringResource(id = R.string.intern_info_d_day) to selectedIntern.deadline, - stringResource(id = R.string.intern_info_working) to selectedIntern.workingPeriod, - stringResource(id = R.string.intern_info_start_date) to selectedIntern.startYearMonth, - ) - ScrapDialogContent( - internInfoList = internInfoList, - dDay = selectedIntern.dDay, - title = selectedIntern.title, - companyImage = selectedIntern.companyImage, - announcementId = selectedIntern.internshipAnnouncementId, - type = 1 + val colorList = listOf( + CalRed, + CalOrange1, + CalOrange2, + CalYellow, + CalGreen1, + CalGreen2, + CalBlue1, + CalBlue2, + CalPurple, + CalPink, ) + + val selectedColorIndex = + colorList.indexOf(dialogState.selectedColor).takeIf { it >= 0 } ?: 0 + + with(selectedIntern) { + HomeRecommendInternDialog( + internInfoList = listOf( + stringResource(id = R.string.intern_info_d_day) to deadline, + stringResource(id = R.string.intern_info_working) to workingPeriod, + stringResource(id = R.string.intern_info_start_date) to startYearMonth, + ), + clickAction = { + if (dialogState.isPaletteOpen) { + viewModel.updatePaletteOpen(false) + viewModel.postScrap( + internshipAnnouncementId = internshipAnnouncementId, + selectedColorIndex, + ) + viewModel.updateColorChange(false) + viewModel.updateScrapDialogVisible(false) + } else { + if (dialogState.isColorChange) { + viewModel.postScrap( + internshipAnnouncementId, + selectedColorIndex + ) + viewModel.updateColorChange(false) + } else { + viewModel.postScrap(internshipAnnouncementId, 0) + + } + viewModel.updateScrapDialogVisible(false) + } + viewModel.postScrap( + internshipAnnouncementId = internshipAnnouncementId, + selectedColorIndex, + ) + }, + homeRecommendInternModel = HomeRecommendInternModel( + scrapId = scrapId, + internshipAnnouncementId = internshipAnnouncementId, + companyImage = companyImage, + title = title, + deadline = deadline, + workingPeriod = workingPeriod, + startYearMonth = startYearMonth, + isScrapped = scrapId != null, + dDay = dDay + ), + ) + } } } } 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 bd885bcef..9379909b3 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 @@ -81,6 +81,7 @@ class SearchProcessViewModel @Inject constructor( page = 0, size = 10 ) + _sideEffect.emit(SearchProcessSideEffect.Toast(R.string.intern_scrap_add_toast_message)) }.onFailure { _sideEffect.emit(SearchProcessSideEffect.Toast(R.string.server_failure)) } @@ -99,6 +100,7 @@ class SearchProcessViewModel @Inject constructor( page = 0, size = 10 ) + _sideEffect.emit(SearchProcessSideEffect.Toast(R.string.intern_scrap_delete_toast_message)) }.onFailure { _sideEffect.emit(SearchProcessSideEffect.Toast(R.string.server_failure)) } From 06d7d6505b20f63df50134346898d646624cd701 Mon Sep 17 00:00:00 2001 From: arinming Date: Fri, 19 Jul 2024 21:10:57 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[FEAT]=20=EA=B2=80=EC=83=89=20=EA=B2=B0?= =?UTF-8?q?=EA=B3=BC=20=EC=83=88=EB=A1=9C=EA=B3=A0=EC=B9=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../search/searchprocess/SearchProcessRoute.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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 5043c66bc..d8dab4e8a 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 @@ -120,6 +120,15 @@ fun SearchProcessScreen( focusRequester.requestFocus() } + LaunchedEffect(true) { + viewModel.getSearchList( + keyword = state.text, + sortBy = SORT_BY, + page = 0, + size = 10 + ) + } + Scaffold( modifier = modifier, topBar = { @@ -348,10 +357,6 @@ fun SearchProcessScreen( } viewModel.updateScrapDialogVisible(false) } - viewModel.postScrap( - internshipAnnouncementId = internshipAnnouncementId, - selectedColorIndex, - ) }, homeRecommendInternModel = HomeRecommendInternModel( scrapId = scrapId, From 07797826c17555cc9e75c2bfb4a8e8454f695e96 Mon Sep 17 00:00:00 2001 From: arinming Date: Fri, 19 Jul 2024 21:12:30 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[UI]=20=EA=B3=B5=EA=B3=A0=20=EC=9A=94?= =?UTF-8?q?=EC=95=BD=20UI=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/terning/feature/intern/InternRoute.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 75f1c127d..2249e3e68 100644 --- a/feature/src/main/java/com/terning/feature/intern/InternRoute.kt +++ b/feature/src/main/java/com/terning/feature/intern/InternRoute.kt @@ -270,7 +270,7 @@ fun InternScreen( ) { Row( modifier = modifier - .weight(1f), + .weight(2f), verticalAlignment = Alignment.Top, ) { Icon( @@ -286,7 +286,7 @@ fun InternScreen( Column( modifier = modifier - .weight(4f) + .weight(5f) .padding(start = 8.dp), verticalArrangement = Arrangement.spacedBy(4.dp, Alignment.Top), ) { @@ -317,7 +317,7 @@ fun InternScreen( ) { Row( modifier = modifier - .weight(1f), + .weight(2f), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.Start ) { @@ -334,7 +334,7 @@ fun InternScreen( Column( modifier = modifier - .weight(4f) + .weight(5f) .padding(start = 8.dp), verticalArrangement = Arrangement.spacedBy(4.dp, Alignment.Top), ) {