From 4e7b3dc57f27e87e39d00ea9b1ca95e76eeced7d Mon Sep 17 00:00:00 2001 From: arinming Date: Mon, 15 Jul 2024 18:43:35 +0900 Subject: [PATCH 1/6] =?UTF-8?q?[FEAT/#80]=20viewModel=20=EC=83=81=ED=83=9C?= =?UTF-8?q?=EC=97=90=20existSearchResults=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../textfield/TerningBasicTextField.kt | 1 - .../com/terning/feature/main/MainNavigator.kt | 2 +- .../searchprocess/SearchProcessRoute.kt | 100 ++++++++++++------ .../searchprocess/SearchProcessViewModel.kt | 1 + .../models/SearchProcessState.kt | 1 + 5 files changed, 68 insertions(+), 37 deletions(-) diff --git a/core/src/main/java/com/terning/core/designsystem/component/textfield/TerningBasicTextField.kt b/core/src/main/java/com/terning/core/designsystem/component/textfield/TerningBasicTextField.kt index e73c1a3d5..5fcea5394 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/textfield/TerningBasicTextField.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/textfield/TerningBasicTextField.kt @@ -136,7 +136,6 @@ fun TerningBasicTextField( Row( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp), - modifier = Modifier.padding(vertical = 8.dp) ) { helperIcon?.let { Icon( diff --git a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt index f74336ff4..361fb6103 100644 --- a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt +++ b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt @@ -24,7 +24,7 @@ class MainNavigator( @Composable get() = navController .currentBackStackEntryAsState().value?.destination - val startDestination = SignIn + val startDestination = Search val currentTab: MainTab? @Composable get() = MainTab.find { tab -> 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 4bcedab18..3667ed39a 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 @@ -4,6 +4,7 @@ import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding @@ -12,8 +13,12 @@ import androidx.compose.material3.Scaffold import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.MutableState import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableIntStateOf +import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.focus.FocusRequester @@ -28,6 +33,7 @@ import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.navigation.NavHostController import androidx.navigation.compose.rememberNavController +import com.terning.core.designsystem.component.button.SortingButton import com.terning.core.designsystem.component.textfield.SearchTextField import com.terning.core.designsystem.component.topappbar.BackButtonTopAppBar import com.terning.core.designsystem.theme.Grey400 @@ -43,18 +49,24 @@ private const val MAX_LINES = 1 fun SearchProcessRoute( navController: NavHostController, ) { + val currentSortBy: MutableState = remember { + mutableIntStateOf(0) + } SearchProcessScreen( navController = navController, + currentSortBy = currentSortBy ) } @Composable fun SearchProcessScreen( + currentSortBy: MutableState, modifier: Modifier = Modifier, navController: NavHostController, viewModel: SearchProcessViewModel = hiltViewModel(), ) { val state by viewModel.state.collectAsStateWithLifecycle() + var sheetState by remember { mutableStateOf(false) } val focusRequester = remember { FocusRequester() } val focusManager = LocalFocusManager.current @@ -115,51 +127,66 @@ fun SearchProcessScreen( if (state.showSearchResults) { Column( modifier = Modifier - .fillMaxWidth() - .padding(top = 87.dp), + .fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center ) { - Image( - painter = painterResource( - id = R.drawable.ic_nosearch - ), - contentDescription = stringResource( - id = R.string.search_process_no_result_icon + if (state.existSearchResults) { + Row( + modifier = Modifier + .fillMaxWidth(), + horizontalArrangement = Arrangement.End, + ) { + SortingButton( + sortBy = currentSortBy.value, + onCLick = { sheetState = true }, + ) + } + } else { + Spacer( + modifier = Modifier.padding(top = 87.dp) ) - ) - Row( - modifier = Modifier - .padding( - top = 16.dp, - bottom = 6.dp + Image( + painter = painterResource( + id = R.drawable.ic_nosearch + ), + contentDescription = stringResource( + id = R.string.search_process_no_result_icon ) - .fillMaxWidth(), - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.Center - ) { - Text( - text = state.query, - style = TerningTheme.typography.body1, - color = TerningMain, - maxLines = MAX_LINES, - overflow = TextOverflow.Ellipsis, - modifier = Modifier.weight(1f, false) ) + Row( + modifier = Modifier + .padding( + top = 16.dp, + bottom = 6.dp + ) + .fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.Center + ) { + Text( + text = state.query, + style = TerningTheme.typography.body1, + color = TerningMain, + maxLines = MAX_LINES, + overflow = TextOverflow.Ellipsis, + modifier = Modifier.weight(1f, false) + ) + Text( + text = stringResource(id = R.string.search_process_no_result_text_sub), + style = TerningTheme.typography.body1, + color = Grey400, + modifier = Modifier.wrapContentWidth() + ) + } Text( - text = stringResource(id = R.string.search_process_no_result_text_sub), + text = stringResource( + id = R.string.search_process_no_result_text_main + ), style = TerningTheme.typography.body1, color = Grey400, - modifier = Modifier.wrapContentWidth() ) } - Text( - text = stringResource( - id = R.string.search_process_no_result_text_main - ), - style = TerningTheme.typography.body1, - color = Grey400, - ) } } } @@ -171,7 +198,10 @@ fun SearchProcessScreen( fun SearchProcessScreenPreview() { TerningPointTheme { SearchProcessScreen( - navController = rememberNavController() + navController = rememberNavController(), + currentSortBy = remember { + mutableIntStateOf(0) + } ) } } 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 a88196b52..32b263f2c 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 @@ -24,5 +24,6 @@ class SearchProcessViewModel @Inject constructor() : ViewModel() { fun updateShowSearchResults(show: Boolean) { _state.value = _state.value.copy(showSearchResults = show) + _state.value = _state.value.copy(existSearchResults = true) } } diff --git a/feature/src/main/java/com/terning/feature/search/searchprocess/models/SearchProcessState.kt b/feature/src/main/java/com/terning/feature/search/searchprocess/models/SearchProcessState.kt index 2f55b7287..1caf08b48 100644 --- a/feature/src/main/java/com/terning/feature/search/searchprocess/models/SearchProcessState.kt +++ b/feature/src/main/java/com/terning/feature/search/searchprocess/models/SearchProcessState.kt @@ -5,4 +5,5 @@ data class SearchProcessState( val text: String = "", val query: String = "", val showSearchResults: Boolean = false, + val existSearchResults: Boolean = false, ) \ No newline at end of file From a83db39a1c834b2a52869b6854a43c1ddb7e478a Mon Sep 17 00:00:00 2001 From: arinming Date: Mon, 15 Jul 2024 19:01:11 +0900 Subject: [PATCH 2/6] =?UTF-8?q?[FEAT/#80]=20InternItemWithShadow=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/item/InternItemWithShadow.kt | 42 +++++++++ .../terning/feature/home/home/HomeRoute.kt | 43 +++------ .../searchprocess/SearchProcessRoute.kt | 88 ++++++++++++++++++- 3 files changed, 141 insertions(+), 32 deletions(-) create mode 100644 core/src/main/java/com/terning/core/designsystem/component/item/InternItemWithShadow.kt diff --git a/core/src/main/java/com/terning/core/designsystem/component/item/InternItemWithShadow.kt b/core/src/main/java/com/terning/core/designsystem/component/item/InternItemWithShadow.kt new file mode 100644 index 000000000..abe0553e3 --- /dev/null +++ b/core/src/main/java/com/terning/core/designsystem/component/item/InternItemWithShadow.kt @@ -0,0 +1,42 @@ +package com.terning.core.designsystem.component.item + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp +import com.terning.core.designsystem.theme.Grey200 +import com.terning.core.designsystem.theme.White +import com.terning.core.extension.customShadow + +@Composable +fun InternItemWithShadow( + imageUrl: String, + title: String, + dateDeadline: String, + workingPeriod: String, + isScraped: Boolean, +) { + Box( + modifier = Modifier + .customShadow( + color = Grey200, + shadowRadius = 10.dp, + shadowWidth = 2.dp + ) + .background( + color = White, + shape = RoundedCornerShape(10.dp) + ) + ) { + InternItem( + imageUrl = imageUrl, + title = title, + dateDeadline = dateDeadline, + workingPeriod = workingPeriod, + isScraped = isScraped + ) + } +} \ No newline at end of file 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 4c03dd063..125357311 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 @@ -12,7 +12,6 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn -import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Scaffold import androidx.compose.material3.Text @@ -30,21 +29,18 @@ import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import com.terning.core.designsystem.component.bottomsheet.SortingBottomSheet import com.terning.core.designsystem.component.button.SortingButton -import com.terning.core.designsystem.component.item.InternItem +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.Grey150 -import com.terning.core.designsystem.theme.Grey200 import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.designsystem.theme.White -import com.terning.core.extension.customShadow import com.terning.feature.R import com.terning.feature.home.home.component.HomeFilteringEmptyIntern import com.terning.feature.home.home.component.HomeFilteringScreen import com.terning.feature.home.home.component.HomeRecommendEmptyIntern import com.terning.feature.home.home.component.HomeTodayEmptyIntern import com.terning.feature.home.home.component.HomeTodayIntern -import com.terning.feature.home.home.model.RecommendInternData import com.terning.feature.home.home.model.UserNameState import com.terning.feature.home.home.model.UserScrapState @@ -140,7 +136,17 @@ fun HomeScreen( if (userNameState.internFilter != null && recommendInternData.isNotEmpty()) { items(recommendInternData.size) { index -> - ShowRecommendIntern(recommendInternData[index]) + Box( + modifier = Modifier.padding(horizontal = 24.dp) + ) { + InternItemWithShadow( + imageUrl = recommendInternData[index].imgUrl, + title = recommendInternData[index].title, + dateDeadline = recommendInternData[index].dDay.toString(), + workingPeriod = recommendInternData[index].workingPeriod.toString(), + isScraped = recommendInternData[index].isScrapped, + ) + } } } } @@ -227,29 +233,4 @@ private fun ShowInternFilter(userNameState: UserNameState) { ) } } -} - -@Composable -private fun ShowRecommendIntern(recommendInternData: RecommendInternData) { - Box( - modifier = Modifier - .padding(horizontal = 24.dp) - .customShadow( - color = Grey200, - shadowRadius = 10.dp, - shadowWidth = 2.dp - ) - .background( - color = White, - shape = RoundedCornerShape(10.dp) - ) - ) { - InternItem( - imageUrl = recommendInternData.imgUrl, - title = recommendInternData.title, - dateDeadline = recommendInternData.dDay.toString(), - workingPeriod = recommendInternData.workingPeriod.toString(), - isScraped = recommendInternData.isScrapped, - ) - } } \ No newline at end of file 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 3667ed39a..8e60a6901 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 @@ -3,12 +3,14 @@ package com.terning.feature.search.searchprocess import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.wrapContentWidth +import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material3.Scaffold import androidx.compose.material3.Text import androidx.compose.runtime.Composable @@ -34,6 +36,7 @@ import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.navigation.NavHostController import androidx.navigation.compose.rememberNavController import com.terning.core.designsystem.component.button.SortingButton +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.Grey400 @@ -42,6 +45,7 @@ import com.terning.core.designsystem.theme.TerningPointTheme import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.extension.addFocusCleaner import com.terning.feature.R +import com.terning.feature.home.home.model.RecommendInternData private const val MAX_LINES = 1 @@ -67,7 +71,71 @@ fun SearchProcessScreen( ) { val state by viewModel.state.collectAsStateWithLifecycle() var sheetState by remember { mutableStateOf(false) } - + val recommendState: List = listOf( + RecommendInternData( + imgUrl = "https://reqres.in/img/faces/7-image.jpg", + title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", + dDay = 22, + workingPeriod = 2, + isScrapped = true, + ), + RecommendInternData( + imgUrl = "https://reqres.in/img/faces/7-image.jpg", + title = "ㅇㄻㅇㅁㄻㄹㅇㅁㅇㄹ", + dDay = 9, + workingPeriod = 6, + isScrapped = false, + ), + RecommendInternData( + imgUrl = "https://reqres.in/img/faces/7-image.jpg", + title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", + dDay = 2, + workingPeriod = 4, + isScrapped = true, + ), + RecommendInternData( + imgUrl = "https://reqres.in/img/faces/7-image.jpg", + title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", + dDay = 22, + workingPeriod = 2, + isScrapped = true, + ), + RecommendInternData( + imgUrl = "https://reqres.in/img/faces/7-image.jpg", + title = "ㅇㄻㅇㅁㄻㄹㅇㅁㅇㄹ", + dDay = 9, + workingPeriod = 6, + isScrapped = false, + ), + RecommendInternData( + imgUrl = "https://reqres.in/img/faces/7-image.jpg", + title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", + dDay = 2, + workingPeriod = 4, + isScrapped = true, + ), + RecommendInternData( + imgUrl = "https://reqres.in/img/faces/7-image.jpg", + title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", + dDay = 22, + workingPeriod = 2, + isScrapped = true, + ), + RecommendInternData( + imgUrl = "https://reqres.in/img/faces/7-image.jpg", + title = "ㅇㄻㅇㅁㄻㄹㅇㅁㅇㄹ", + dDay = 9, + workingPeriod = 6, + isScrapped = false, + ), + RecommendInternData( + imgUrl = "https://reqres.in/img/faces/7-image.jpg", + title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", + dDay = 2, + workingPeriod = 4, + isScrapped = true, + ), + ) val focusRequester = remember { FocusRequester() } val focusManager = LocalFocusManager.current @@ -142,6 +210,24 @@ fun SearchProcessScreen( onCLick = { sheetState = true }, ) } + LazyColumn( + contentPadding = PaddingValues( + top = 12.dp, + bottom = 20.dp, + ), + verticalArrangement = Arrangement.spacedBy(12.dp) + ) { + items(recommendState.size) { index -> + InternItemWithShadow( + imageUrl = recommendState[index].imgUrl, + title = recommendState[index].title, + dateDeadline = recommendState[index].dDay.toString(), + workingPeriod = recommendState[index].workingPeriod.toString(), + isScraped = recommendState[index].isScrapped + ) + } + } + } else { Spacer( modifier = Modifier.padding(top = 87.dp) From cf7c1d35c9aabdd45fe0a1a7cf6f8471e7eaa206 Mon Sep 17 00:00:00 2001 From: arinming Date: Mon, 15 Jul 2024 19:04:21 +0900 Subject: [PATCH 3/6] =?UTF-8?q?[DELETE/#80]=20ic=5Fnosearch=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EB=B0=8F=20ic=5Fempty=5Flogo=EB=A1=9C=20=EB=8C=80?= =?UTF-8?q?=EC=B2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/item/InternItemWithShadow.kt | 3 +-- .../feature/intern/component/InternCompanyInfo.kt | 2 +- .../feature/search/searchprocess/SearchProcessRoute.kt | 2 +- feature/src/main/res/drawable/ic_nosearch.xml | 10 ---------- 4 files changed, 3 insertions(+), 14 deletions(-) delete mode 100644 feature/src/main/res/drawable/ic_nosearch.xml diff --git a/core/src/main/java/com/terning/core/designsystem/component/item/InternItemWithShadow.kt b/core/src/main/java/com/terning/core/designsystem/component/item/InternItemWithShadow.kt index abe0553e3..f16382734 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/item/InternItemWithShadow.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/item/InternItemWithShadow.kt @@ -2,7 +2,6 @@ package com.terning.core.designsystem.component.item import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier @@ -24,7 +23,7 @@ fun InternItemWithShadow( .customShadow( color = Grey200, shadowRadius = 10.dp, - shadowWidth = 2.dp + shadowWidth = 2.dp, ) .background( color = White, diff --git a/feature/src/main/java/com/terning/feature/intern/component/InternCompanyInfo.kt b/feature/src/main/java/com/terning/feature/intern/component/InternCompanyInfo.kt index ed50ea608..4c5974242 100644 --- a/feature/src/main/java/com/terning/feature/intern/component/InternCompanyInfo.kt +++ b/feature/src/main/java/com/terning/feature/intern/component/InternCompanyInfo.kt @@ -54,7 +54,7 @@ fun InternCompanyInfo(modifier: Modifier) { ) { Image( painter = painterResource( - id = R.drawable.ic_nosearch + id = R.drawable.ic_empty_logo ), modifier = modifier.fillMaxWidth(), contentDescription = null, 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 8e60a6901..ab48462f0 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 @@ -234,7 +234,7 @@ fun SearchProcessScreen( ) Image( painter = painterResource( - id = R.drawable.ic_nosearch + id = R.drawable.ic_empty_logo ), contentDescription = stringResource( id = R.string.search_process_no_result_icon diff --git a/feature/src/main/res/drawable/ic_nosearch.xml b/feature/src/main/res/drawable/ic_nosearch.xml deleted file mode 100644 index c63bd8fb7..000000000 --- a/feature/src/main/res/drawable/ic_nosearch.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - From 96069ffd09e3ed4df46530b4e6a7be0dc65675b7 Mon Sep 17 00:00:00 2001 From: arinming Date: Mon, 15 Jul 2024 19:17:32 +0900 Subject: [PATCH 4/6] =?UTF-8?q?[FEAT/#80]=20=EA=B2=80=EC=83=89=20=EA=B2=B0?= =?UTF-8?q?=EA=B3=BC=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EB=B7=B0=20=EB=9D=84?= =?UTF-8?q?=EC=9A=B0=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/home/home/HomeViewModel.kt | 26 +++--- .../{RecommendInternData.kt => InternData.kt} | 2 +- .../searchprocess/SearchProcessRoute.kt | 93 +++++-------------- .../searchprocess/SearchProcessViewModel.kt | 88 ++++++++++++++++++ .../models/SearchProcessState.kt | 3 + 5 files changed, 126 insertions(+), 86 deletions(-) rename feature/src/main/java/com/terning/feature/home/home/model/{RecommendInternData.kt => InternData.kt} (84%) 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 68fd0d2f1..8ed636ae3 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 @@ -11,7 +11,7 @@ import com.terning.core.designsystem.theme.CalOrange1 import com.terning.core.designsystem.theme.CalPink import com.terning.core.designsystem.theme.CalYellow import com.terning.feature.home.home.model.InternFilterData -import com.terning.feature.home.home.model.RecommendInternData +import com.terning.feature.home.home.model.InternData import com.terning.feature.home.home.model.ScrapData import com.terning.feature.home.home.model.UserNameState import com.terning.feature.home.home.model.UserScrapState @@ -45,7 +45,7 @@ class HomeViewModel @Inject constructor( ) val scrapData get() = _scrapState.asStateFlow() - private val _recommendInternState = MutableStateFlow>( + private val _recommendInternState = MutableStateFlow>( // getRecommendData() listOf() ) @@ -103,71 +103,71 @@ private fun getScrapData(): List = listOf( ), ) -private fun getRecommendData(): List = listOf( - RecommendInternData( +private fun getRecommendData(): List = listOf( + InternData( imgUrl = "https://reqres.in/img/faces/7-image.jpg", title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", dDay = 22, workingPeriod = 2, isScrapped = true, ), - RecommendInternData( + InternData( imgUrl = "https://reqres.in/img/faces/7-image.jpg", title = "ㅇㄻㅇㅁㄻㄹㅇㅁㅇㄹ", dDay = 9, workingPeriod = 6, isScrapped = false, ), - RecommendInternData( + InternData( imgUrl = "https://reqres.in/img/faces/7-image.jpg", title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", dDay = 2, workingPeriod = 4, isScrapped = true, ), - RecommendInternData( + InternData( imgUrl = "https://reqres.in/img/faces/7-image.jpg", title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", dDay = 2, workingPeriod = 4, isScrapped = false, ), - RecommendInternData( + InternData( imgUrl = "https://reqres.in/img/faces/7-image.jpg", title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", dDay = 2, workingPeriod = 4, isScrapped = true, ), - RecommendInternData( + InternData( imgUrl = "https://reqres.in/img/faces/7-image.jpg", title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", dDay = 2, workingPeriod = 4, isScrapped = true, ), - RecommendInternData( + InternData( imgUrl = "https://reqres.in/img/faces/7-image.jpg", title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", dDay = 2, workingPeriod = 4, isScrapped = false, ), - RecommendInternData( + InternData( imgUrl = "https://reqres.in/img/faces/7-image.jpg", title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", dDay = 2, workingPeriod = 4, isScrapped = true, ), - RecommendInternData( + InternData( imgUrl = "https://reqres.in/img/faces/7-image.jpg", title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", dDay = 2, workingPeriod = 4, isScrapped = false, ), - RecommendInternData( + InternData( imgUrl = "https://reqres.in/img/faces/7-image.jpg", title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", dDay = 2, diff --git a/feature/src/main/java/com/terning/feature/home/home/model/RecommendInternData.kt b/feature/src/main/java/com/terning/feature/home/home/model/InternData.kt similarity index 84% rename from feature/src/main/java/com/terning/feature/home/home/model/RecommendInternData.kt rename to feature/src/main/java/com/terning/feature/home/home/model/InternData.kt index 5b84c180a..4beafb192 100644 --- a/feature/src/main/java/com/terning/feature/home/home/model/RecommendInternData.kt +++ b/feature/src/main/java/com/terning/feature/home/home/model/InternData.kt @@ -1,6 +1,6 @@ package com.terning.feature.home.home.model -data class RecommendInternData( +data class InternData( val imgUrl: String, val title: String, val dDay: Int, 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 ab48462f0..4f0c46e4c 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 @@ -35,6 +35,7 @@ import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.navigation.NavHostController import androidx.navigation.compose.rememberNavController +import com.terning.core.designsystem.component.bottomsheet.SortingBottomSheet import com.terning.core.designsystem.component.button.SortingButton import com.terning.core.designsystem.component.item.InternItemWithShadow import com.terning.core.designsystem.component.textfield.SearchTextField @@ -45,7 +46,6 @@ import com.terning.core.designsystem.theme.TerningPointTheme import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.extension.addFocusCleaner import com.terning.feature.R -import com.terning.feature.home.home.model.RecommendInternData private const val MAX_LINES = 1 @@ -71,71 +71,19 @@ fun SearchProcessScreen( ) { val state by viewModel.state.collectAsStateWithLifecycle() var sheetState by remember { mutableStateOf(false) } - val recommendState: List = listOf( - RecommendInternData( - imgUrl = "https://reqres.in/img/faces/7-image.jpg", - title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", - dDay = 22, - workingPeriod = 2, - isScrapped = true, - ), - RecommendInternData( - imgUrl = "https://reqres.in/img/faces/7-image.jpg", - title = "ㅇㄻㅇㅁㄻㄹㅇㅁㅇㄹ", - dDay = 9, - workingPeriod = 6, - isScrapped = false, - ), - RecommendInternData( - imgUrl = "https://reqres.in/img/faces/7-image.jpg", - title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", - dDay = 2, - workingPeriod = 4, - isScrapped = true, - ), - RecommendInternData( - imgUrl = "https://reqres.in/img/faces/7-image.jpg", - title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", - dDay = 22, - workingPeriod = 2, - isScrapped = true, - ), - RecommendInternData( - imgUrl = "https://reqres.in/img/faces/7-image.jpg", - title = "ㅇㄻㅇㅁㄻㄹㅇㅁㅇㄹ", - dDay = 9, - workingPeriod = 6, - isScrapped = false, - ), - RecommendInternData( - imgUrl = "https://reqres.in/img/faces/7-image.jpg", - title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", - dDay = 2, - workingPeriod = 4, - isScrapped = true, - ), - RecommendInternData( - imgUrl = "https://reqres.in/img/faces/7-image.jpg", - title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", - dDay = 22, - workingPeriod = 2, - isScrapped = true, - ), - RecommendInternData( - imgUrl = "https://reqres.in/img/faces/7-image.jpg", - title = "ㅇㄻㅇㅁㄻㄹㅇㅁㅇㄹ", - dDay = 9, - workingPeriod = 6, - isScrapped = false, - ), - RecommendInternData( - imgUrl = "https://reqres.in/img/faces/7-image.jpg", - title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", - dDay = 2, - workingPeriod = 4, - isScrapped = true, - ), - ) + val internSearchResultData by viewModel.internSearchResultData.collectAsStateWithLifecycle() + + + if (sheetState) { + SortingBottomSheet( + onDismiss = { + sheetState = false + }, + currentSortBy = currentSortBy.value, + newSortBy = currentSortBy + ) + } + val focusRequester = remember { FocusRequester() } val focusManager = LocalFocusManager.current @@ -189,6 +137,7 @@ fun SearchProcessScreen( onDoneAction = { viewModel.updateQuery(state.text) viewModel.updateShowSearchResults(true) + viewModel.updateExistSearchResults(state.text) } ) @@ -217,13 +166,13 @@ fun SearchProcessScreen( ), verticalArrangement = Arrangement.spacedBy(12.dp) ) { - items(recommendState.size) { index -> + items(internSearchResultData.size) { index -> InternItemWithShadow( - imageUrl = recommendState[index].imgUrl, - title = recommendState[index].title, - dateDeadline = recommendState[index].dDay.toString(), - workingPeriod = recommendState[index].workingPeriod.toString(), - isScraped = recommendState[index].isScrapped + imageUrl = internSearchResultData[index].imgUrl, + title = internSearchResultData[index].title, + dateDeadline = internSearchResultData[index].dDay.toString(), + workingPeriod = internSearchResultData[index].workingPeriod.toString(), + isScraped = internSearchResultData[index].isScrapped ) } } 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 32b263f2c..103bb6f84 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 @@ -1,10 +1,12 @@ package com.terning.feature.search.searchprocess import androidx.lifecycle.ViewModel +import com.terning.feature.home.home.model.InternData import com.terning.feature.search.searchprocess.models.SearchProcessState import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asStateFlow import javax.inject.Inject @HiltViewModel @@ -14,6 +16,11 @@ class SearchProcessViewModel @Inject constructor() : ViewModel() { val state: StateFlow get() = _state + private val _internSearchResultState = MutableStateFlow( + getRecommendData() + ) + val internSearchResultData get() = _internSearchResultState.asStateFlow() + fun updateText(newText: String) { _state.value = _state.value.copy(text = newText) } @@ -26,4 +33,85 @@ class SearchProcessViewModel @Inject constructor() : ViewModel() { _state.value = _state.value.copy(showSearchResults = show) _state.value = _state.value.copy(existSearchResults = true) } + + + fun updateExistSearchResults(query: String) { + val exist = + _internSearchResultState.value.any { it.title.contains(query, ignoreCase = true) } + _state.value = _state.value.copy(existSearchResults = exist) + } } + + +private fun getRecommendData(): List = listOf( + InternData( + imgUrl = "https://reqres.in/img/faces/7-image.jpg", + title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", + dDay = 22, + workingPeriod = 2, + isScrapped = true, + ), + InternData( + imgUrl = "https://reqres.in/img/faces/7-image.jpg", + title = "ㅇㄻㅇㅁㄻㄹㅇㅁㅇㄹ", + dDay = 9, + workingPeriod = 6, + isScrapped = false, + ), + InternData( + imgUrl = "https://reqres.in/img/faces/7-image.jpg", + title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", + dDay = 2, + workingPeriod = 4, + isScrapped = true, + ), + InternData( + imgUrl = "https://reqres.in/img/faces/7-image.jpg", + title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", + dDay = 2, + workingPeriod = 4, + isScrapped = false, + ), + InternData( + imgUrl = "https://reqres.in/img/faces/7-image.jpg", + title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", + dDay = 2, + workingPeriod = 4, + isScrapped = true, + ), + InternData( + imgUrl = "https://reqres.in/img/faces/7-image.jpg", + title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", + dDay = 2, + workingPeriod = 4, + isScrapped = true, + ), + InternData( + imgUrl = "https://reqres.in/img/faces/7-image.jpg", + title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", + dDay = 2, + workingPeriod = 4, + isScrapped = false, + ), + InternData( + imgUrl = "https://reqres.in/img/faces/7-image.jpg", + title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", + dDay = 2, + workingPeriod = 4, + isScrapped = true, + ), + InternData( + imgUrl = "https://reqres.in/img/faces/7-image.jpg", + title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", + dDay = 2, + workingPeriod = 4, + isScrapped = false, + ), + InternData( + imgUrl = "https://reqres.in/img/faces/7-image.jpg", + title = "[유한킴벌리] 그린캠프 w.대학생 숲 활동가", + dDay = 2, + workingPeriod = 4, + isScrapped = true, + ), +) \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/search/searchprocess/models/SearchProcessState.kt b/feature/src/main/java/com/terning/feature/search/searchprocess/models/SearchProcessState.kt index 1caf08b48..f00b0f1ca 100644 --- a/feature/src/main/java/com/terning/feature/search/searchprocess/models/SearchProcessState.kt +++ b/feature/src/main/java/com/terning/feature/search/searchprocess/models/SearchProcessState.kt @@ -1,9 +1,12 @@ package com.terning.feature.search.searchprocess.models +import com.terning.feature.home.home.model.InternData + data class SearchProcessState( val text: String = "", val query: String = "", val showSearchResults: Boolean = false, val existSearchResults: Boolean = false, + val searchResults: List = emptyList(), ) \ No newline at end of file From 89fd781cc5be629e189e3266ee59e0f4f2ea6299 Mon Sep 17 00:00:00 2001 From: arinming Date: Mon, 15 Jul 2024 19:22:08 +0900 Subject: [PATCH 5/6] =?UTF-8?q?[FEAT/#80]=20=EA=B2=BD=EB=A1=9C=20=EC=B4=88?= =?UTF-8?q?=EA=B8=B0=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature/src/main/java/com/terning/feature/main/MainNavigator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt index 361fb6103..f74336ff4 100644 --- a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt +++ b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt @@ -24,7 +24,7 @@ class MainNavigator( @Composable get() = navController .currentBackStackEntryAsState().value?.destination - val startDestination = Search + val startDestination = SignIn val currentTab: MainTab? @Composable get() = MainTab.find { tab -> From 12a396e891289d6e80f9b582c5d79fc48a596d58 Mon Sep 17 00:00:00 2001 From: arinming Date: Tue, 16 Jul 2024 00:25:56 +0900 Subject: [PATCH 6/6] =?UTF-8?q?[REFACTOR/#80]=20=EC=A4=84=EB=B0=94?= =?UTF-8?q?=EA=BF=88=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/terning/feature/home/home/HomeViewModel.kt | 6 +++--- .../src/main/java/com/terning/feature/main/MainNavigator.kt | 2 +- .../java/com/terning/feature/search/search/SearchRoute.kt | 1 - .../feature/search/searchprocess/SearchProcessRoute.kt | 2 -- .../feature/search/searchprocess/SearchProcessViewModel.kt | 1 - 5 files changed, 4 insertions(+), 8 deletions(-) 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 7a1a88d0e..94e29b4f7 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 @@ -24,7 +24,7 @@ import javax.inject.Inject class HomeViewModel @Inject constructor( ) : ViewModel() { - private val _userName by mutableStateOf( + private val _userName by mutableStateOf( UserNameState( userName = "남지우자랑스러운티엘이되", internFilter = InternFilterData( @@ -37,7 +37,7 @@ class HomeViewModel @Inject constructor( ) val userName get() = _userName - private val _scrapState = MutableStateFlow( + private val _scrapState = MutableStateFlow( UserScrapState( isScrapExist = true, scrapData = getScrapData() @@ -45,7 +45,7 @@ class HomeViewModel @Inject constructor( ) val scrapData get() = _scrapState.asStateFlow() - private val _recommendInternState = MutableStateFlow>( + private val _recommendInternState = MutableStateFlow( getRecommendData() ) val recommendInternData get() = _recommendInternState.asStateFlow() diff --git a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt index f74336ff4..361fb6103 100644 --- a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt +++ b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt @@ -24,7 +24,7 @@ class MainNavigator( @Composable get() = navController .currentBackStackEntryAsState().value?.destination - val startDestination = SignIn + val startDestination = Search val currentTab: MainTab? @Composable get() = MainTab.find { tab -> diff --git a/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt b/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt index 67e792d95..17becd309 100644 --- a/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt +++ b/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt @@ -100,5 +100,4 @@ fun SearchScreen( SearchInternList(type = InternListType.SCRAP) } } - } 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 4f0c46e4c..26d84657b 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 @@ -73,7 +73,6 @@ fun SearchProcessScreen( var sheetState by remember { mutableStateOf(false) } val internSearchResultData by viewModel.internSearchResultData.collectAsStateWithLifecycle() - if (sheetState) { SortingBottomSheet( onDismiss = { @@ -176,7 +175,6 @@ fun SearchProcessScreen( ) } } - } else { Spacer( modifier = Modifier.padding(top = 87.dp) 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 103bb6f84..589f3106a 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 @@ -42,7 +42,6 @@ class SearchProcessViewModel @Inject constructor() : ViewModel() { } } - private fun getRecommendData(): List = listOf( InternData( imgUrl = "https://reqres.in/img/faces/7-image.jpg",