From eb4423827f35d03b7ce516699b0a94a1dda54f38 Mon Sep 17 00:00:00 2001 From: arinming Date: Wed, 10 Jul 2024 17:47:29 +0900 Subject: [PATCH 01/10] =?UTF-8?q?[FEAT/#31]=20SearchProcessRoute=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/textfield/SearchTextField.kt | 4 +-- .../textfield/TerningBasicTextField.kt | 4 +-- .../com/terning/feature/main/MainNavigator.kt | 4 +-- .../com/terning/feature/main/MainScreen.kt | 4 ++- .../com/terning/feature/search/SearchRoute.kt | 30 +++++++++++-------- .../search/navigation/SearchNavigation.kt | 9 ++++-- .../searchprocess/SearchProcessRoute.kt | 17 +++++++++++ .../navigation/SearchProcessNavigation.kt | 25 ++++++++++++++++ 8 files changed, 75 insertions(+), 22 deletions(-) create mode 100644 feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt create mode 100644 feature/src/main/java/com/terning/feature/searchprocess/navigation/SearchProcessNavigation.kt diff --git a/core/src/main/java/com/terning/core/designsystem/component/textfield/SearchTextField.kt b/core/src/main/java/com/terning/core/designsystem/component/textfield/SearchTextField.kt index db4f28f59..f8f063fcd 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/textfield/SearchTextField.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/textfield/SearchTextField.kt @@ -9,8 +9,8 @@ import com.terning.core.designsystem.theme.TerningTheme @Composable fun SearchTextField( - text: String, - onValueChange: (String) -> Unit, + text: String = "", + onValueChange: (String) -> Unit = {}, readOnly: Boolean = false, hint: String, leftIcon: Int, 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 358e42b5a..0d924ea93 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 @@ -35,8 +35,8 @@ import com.terning.core.designsystem.theme.White @Composable fun TerningBasicTextField( - value: String, - onValueChange: (String) -> Unit, + value: String = "", + onValueChange: (String) -> Unit = {}, readOnly: Boolean = false, textStyle: TextStyle, textColor: Color, 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 beb7b7920..e67b04927 100644 --- a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt +++ b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt @@ -12,7 +12,7 @@ import androidx.navigation.navOptions import com.terning.feature.calendar.navigation.navigateCalendar import com.terning.feature.home.navigation.navigateHome import com.terning.feature.mypage.navigation.navigateMyPage -import com.terning.feature.onboarding.signin.navigation.SignIn +import com.terning.feature.search.navigation.Search import com.terning.feature.search.navigation.navigateSearch class MainNavigator( @@ -22,7 +22,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/main/MainScreen.kt b/feature/src/main/java/com/terning/feature/main/MainScreen.kt index 4ec98081e..90b68584a 100644 --- a/feature/src/main/java/com/terning/feature/main/MainScreen.kt +++ b/feature/src/main/java/com/terning/feature/main/MainScreen.kt @@ -29,6 +29,7 @@ import com.terning.feature.mypage.navigation.myPageNavGraph import com.terning.feature.onboarding.signin.navigation.signInNavGraph import com.terning.feature.onboarding.signup.navigation.signUpNavGraph import com.terning.feature.search.navigation.searchNavGraph +import com.terning.feature.searchprocess.navigation.searchProcessNavGraph @Composable fun MainScreen( @@ -64,10 +65,11 @@ fun MainScreen( ) { homeNavGraph() calendarNavGraph() - searchNavGraph() + searchNavGraph(navHostController = navigator.navController) myPageNavGraph() signInNavGraph(navHostController = navigator.navController) signUpNavGraph() + searchProcessNavGraph() } } } diff --git a/feature/src/main/java/com/terning/feature/search/SearchRoute.kt b/feature/src/main/java/com/terning/feature/search/SearchRoute.kt index 35a2d51c3..8196c5ba5 100644 --- a/feature/src/main/java/com/terning/feature/search/SearchRoute.kt +++ b/feature/src/main/java/com/terning/feature/search/SearchRoute.kt @@ -1,5 +1,6 @@ package com.terning.feature.search +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Spacer @@ -8,13 +9,10 @@ import androidx.compose.foundation.layout.padding import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.Text import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp +import androidx.navigation.NavHostController import com.terning.core.designsystem.component.textfield.SearchTextField import com.terning.core.designsystem.theme.Black import com.terning.core.designsystem.theme.Grey100 @@ -22,15 +20,19 @@ import com.terning.core.designsystem.theme.TerningTheme import com.terning.feature.R import com.terning.feature.search.component.ImageSlider import com.terning.feature.search.component.SearchInternList +import com.terning.feature.searchprocess.navigation.navigateSearchProcess @Composable -fun SearchRoute() { - SearchScreen() +fun SearchRoute( + navController: NavHostController, +) { + SearchScreen(navController = navController) } @Composable -fun SearchScreen() { - var text by remember { mutableStateOf("") } +fun SearchScreen( + navController: NavHostController, +) { val images = listOf( R.drawable.ic_nav_search, R.drawable.ic_check, @@ -41,12 +43,14 @@ fun SearchScreen() { modifier = Modifier .fillMaxWidth() ) { - Box(modifier = Modifier.padding(16.dp)) { - SearchTextField( - text = text, - onValueChange = { newText -> - text = newText + Box( + modifier = Modifier + .padding(16.dp) + .clickable { + navController.navigateSearchProcess() }, + ) { + SearchTextField( readOnly = true, hint = stringResource(R.string.search_text_field_hint), leftIcon = R.drawable.ic_nav_search, diff --git a/feature/src/main/java/com/terning/feature/search/navigation/SearchNavigation.kt b/feature/src/main/java/com/terning/feature/search/navigation/SearchNavigation.kt index 26e2036b6..065ceef4b 100644 --- a/feature/src/main/java/com/terning/feature/search/navigation/SearchNavigation.kt +++ b/feature/src/main/java/com/terning/feature/search/navigation/SearchNavigation.kt @@ -2,6 +2,7 @@ package com.terning.feature.search.navigation import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder +import androidx.navigation.NavHostController import androidx.navigation.NavOptions import androidx.navigation.compose.composable import com.terning.core.navigation.MainTabRoute @@ -15,9 +16,13 @@ fun NavController.navigateSearch(navOptions: NavOptions? = null) { ) } -fun NavGraphBuilder.searchNavGraph() { +fun NavGraphBuilder.searchNavGraph( + navHostController: NavHostController, +) { composable { - SearchRoute() + SearchRoute( + navController = navHostController + ) } } diff --git a/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt b/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt new file mode 100644 index 000000000..821d39f1e --- /dev/null +++ b/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt @@ -0,0 +1,17 @@ +package com.terning.feature.searchprocess + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue + +@Composable +fun SearchProcessRoute() { + SearchProcessScreen() +} + +@Composable +fun SearchProcessScreen() { + var text by remember { mutableStateOf("") } +} \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/searchprocess/navigation/SearchProcessNavigation.kt b/feature/src/main/java/com/terning/feature/searchprocess/navigation/SearchProcessNavigation.kt new file mode 100644 index 000000000..091ee44ed --- /dev/null +++ b/feature/src/main/java/com/terning/feature/searchprocess/navigation/SearchProcessNavigation.kt @@ -0,0 +1,25 @@ +package com.terning.feature.searchprocess.navigation + +import androidx.navigation.NavController +import androidx.navigation.NavGraphBuilder +import androidx.navigation.NavOptions +import androidx.navigation.compose.composable +import com.terning.core.navigation.MainTabRoute +import com.terning.feature.searchprocess.SearchProcessRoute +import kotlinx.serialization.Serializable + +fun NavController.navigateSearchProcess(navOptions: NavOptions? = null) { + navigate( + route = SearchProcess, + navOptions = navOptions + ) +} + +fun NavGraphBuilder.searchProcessNavGraph() { + composable { + SearchProcessRoute() + } +} + +@Serializable +data object SearchProcess : MainTabRoute \ No newline at end of file From eef2bee5827ba4cdcd2c5d2027c2c6e7a4003068 Mon Sep 17 00:00:00 2001 From: arinming Date: Wed, 10 Jul 2024 19:15:45 +0900 Subject: [PATCH 02/10] =?UTF-8?q?[FEAT/#31]=20SearchProcessScreen=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/textfield/NameTextField.kt | 2 ++ .../component/textfield/SearchTextField.kt | 5 +++++ .../textfield/TerningBasicTextField.kt | 6 +++++- .../com/terning/feature/main/MainNavigator.kt | 2 +- .../com/terning/feature/search/SearchRoute.kt | 17 +++++++---------- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/com/terning/core/designsystem/component/textfield/NameTextField.kt b/core/src/main/java/com/terning/core/designsystem/component/textfield/NameTextField.kt index 88d60457d..f022fff93 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/textfield/NameTextField.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/textfield/NameTextField.kt @@ -1,6 +1,7 @@ package com.terning.core.designsystem.component.textfield import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.SolidColor import com.terning.core.designsystem.theme.Black @@ -22,6 +23,7 @@ fun NameTextField( TerningBasicTextField( value = text, onValueChange = onValueChange, + modifier = Modifier, textStyle = TerningTheme.typography.detail1, textColor = Black, drawLineColor = Grey500, diff --git a/core/src/main/java/com/terning/core/designsystem/component/textfield/SearchTextField.kt b/core/src/main/java/com/terning/core/designsystem/component/textfield/SearchTextField.kt index 05dd35414..88349f1b9 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/textfield/SearchTextField.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/textfield/SearchTextField.kt @@ -1,6 +1,7 @@ package com.terning.core.designsystem.component.textfield import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.SolidColor import com.terning.core.designsystem.theme.Grey300 import com.terning.core.designsystem.theme.Grey400 @@ -11,13 +12,16 @@ import com.terning.core.designsystem.theme.TerningTheme fun SearchTextField( text: String = "", onValueChange: (String) -> Unit = {}, + modifier: Modifier, hint: String, leftIcon: Int, + enabled: Boolean = true, readOnly: Boolean = false, ) { TerningBasicTextField( value = text, onValueChange = onValueChange, + modifier = modifier, textStyle = TerningTheme.typography.button3, textColor = Grey400, cursorBrush = SolidColor(Grey300), @@ -27,6 +31,7 @@ fun SearchTextField( hintColor = Grey300, leftIcon = leftIcon, leftIconColor = TerningMain, + enabled = enabled, readOnly = readOnly, ) } \ No newline at end of file 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 080b9f8c5..ce8b2063a 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 @@ -37,6 +37,7 @@ import com.terning.core.designsystem.theme.White fun TerningBasicTextField( value: String = "", onValueChange: (String) -> Unit = {}, + modifier: Modifier, textStyle: TextStyle, textColor: Color, hintColor: Color, @@ -51,6 +52,7 @@ fun TerningBasicTextField( helperMessage: String = "", helperIcon: Int? = null, helperColor: Color = TerningMain, + enabled: Boolean = true, readOnly: Boolean = false, ) { val keyboardController = LocalSoftwareKeyboardController.current @@ -70,7 +72,7 @@ fun TerningBasicTextField( } ), - modifier = Modifier + modifier = modifier .fillMaxWidth() .background(White) .drawWithContent { @@ -124,6 +126,8 @@ fun TerningBasicTextField( } } }, + + enabled = enabled, readOnly = readOnly, ) 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 68d33fb38..c82fa571f 100644 --- a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt +++ b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt @@ -23,7 +23,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/SearchRoute.kt b/feature/src/main/java/com/terning/feature/search/SearchRoute.kt index 4d5f65a77..cceb4a499 100644 --- a/feature/src/main/java/com/terning/feature/search/SearchRoute.kt +++ b/feature/src/main/java/com/terning/feature/search/SearchRoute.kt @@ -19,6 +19,7 @@ import com.terning.core.designsystem.theme.Grey100 import com.terning.core.designsystem.theme.TerningTheme import com.terning.feature.R import com.terning.feature.search.component.ImageSlider +import com.terning.feature.search.component.InternListType import com.terning.feature.search.component.SearchInternList import com.terning.feature.searchprocess.navigation.navigateSearchProcess @@ -45,17 +46,16 @@ fun SearchScreen( ) { Box( modifier = Modifier - .padding( - horizontal = 24.dp, - vertical = 16.dp - ) + .padding(horizontal = 24.dp, vertical = 16.dp) .clickable { navController.navigateSearchProcess() - }, + } ) { SearchTextField( hint = stringResource(R.string.search_text_field_hint), leftIcon = R.drawable.ic_nav_search, + modifier = Modifier.fillMaxWidth(), + enabled = false, readOnly = true, ) } @@ -68,10 +68,7 @@ fun SearchScreen( Text( text = stringResource(id = R.string.search_today_popular), - modifier = Modifier.padding( - horizontal = 24.dp, - vertical = 4.dp - ), + modifier = Modifier.padding(horizontal = 24.dp, vertical = 4.dp), style = TerningTheme.typography.title1, color = Black ) @@ -84,4 +81,4 @@ fun SearchScreen( ) SearchInternList(type = InternListType.SCRAP) } -} \ No newline at end of file +} From e9f0e90c0b42d92bb9fd9e1eb4c1294e937dfec7 Mon Sep 17 00:00:00 2001 From: arinming Date: Wed, 10 Jul 2024 21:36:14 +0900 Subject: [PATCH 03/10] =?UTF-8?q?[FEAT/#31]=20SearchProcessScreen=20UI=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../topappbar/TerningBasicTopAppBar.kt | 11 ++-- .../com/terning/feature/main/MainNavigator.kt | 1 - .../com/terning/feature/main/MainScreen.kt | 3 +- .../searchprocess/SearchProcessRoute.kt | 62 ++++++++++++++++++- 4 files changed, 69 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/com/terning/core/designsystem/component/topappbar/TerningBasicTopAppBar.kt b/core/src/main/java/com/terning/core/designsystem/component/topappbar/TerningBasicTopAppBar.kt index a5088099f..40bedc3d6 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/topappbar/TerningBasicTopAppBar.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/topappbar/TerningBasicTopAppBar.kt @@ -37,12 +37,14 @@ fun TerningBasicTopAppBar( }, navigationIcon = { if (showBackButton) { - IconButton(onClick = { - onBackButtonClick.invoke() - }) { + IconButton( + onClick = { + onBackButtonClick.invoke() + }) { Icon( painter = painterResource(id = R.drawable.ic_back), - contentDescription = stringResource(id = R.string.ic_back) + contentDescription = stringResource(id = R.string.ic_back), + modifier = Modifier.padding(start = 8.dp) ) } } else { @@ -55,6 +57,5 @@ fun TerningBasicTopAppBar( } }, colors = TopAppBarDefaults.topAppBarColors(White), - modifier = Modifier.padding(horizontal = 16.dp) ) } \ No newline at end of file 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 c82fa571f..e67b04927 100644 --- a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt +++ b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt @@ -12,7 +12,6 @@ import androidx.navigation.navOptions import com.terning.feature.calendar.navigation.navigateCalendar import com.terning.feature.home.navigation.navigateHome import com.terning.feature.mypage.navigation.navigateMyPage -import com.terning.feature.onboarding.signin.navigation.SignIn import com.terning.feature.search.navigation.Search import com.terning.feature.search.navigation.navigateSearch diff --git a/feature/src/main/java/com/terning/feature/main/MainScreen.kt b/feature/src/main/java/com/terning/feature/main/MainScreen.kt index 90b68584a..9ef09c7dd 100644 --- a/feature/src/main/java/com/terning/feature/main/MainScreen.kt +++ b/feature/src/main/java/com/terning/feature/main/MainScreen.kt @@ -22,6 +22,7 @@ import com.terning.core.designsystem.component.topappbar.TerningBasicTopAppBar import com.terning.core.designsystem.theme.Grey300 import com.terning.core.designsystem.theme.TerningMain import com.terning.core.designsystem.theme.White +import com.terning.core.navigation.MainTabRoute import com.terning.core.util.NoRippleInteractionSource import com.terning.feature.calendar.navigation.calendarNavGraph import com.terning.feature.home.navigation.homeNavGraph @@ -42,7 +43,7 @@ fun MainScreen( MainTab.CALENDAR -> TerningBasicTopAppBar() MainTab.SEARCH -> LogoTopAppBar() MainTab.MY_PAGE -> MyPageTopAppBar() - null -> TerningBasicTopAppBar() + else -> TerningBasicTopAppBar() } }, bottomBar = { diff --git a/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt b/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt index 821d39f1e..3ce3183d1 100644 --- a/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt +++ b/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt @@ -1,10 +1,25 @@ package com.terning.feature.searchprocess +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import com.terning.core.designsystem.component.textfield.SearchTextField +import com.terning.core.designsystem.component.topappbar.BackButtonTopAppBar +import com.terning.core.designsystem.theme.Grey500 +import com.terning.core.designsystem.theme.TerningPointTheme +import com.terning.core.designsystem.theme.TerningTheme +import com.terning.feature.R @Composable fun SearchProcessRoute() { @@ -12,6 +27,51 @@ fun SearchProcessRoute() { } @Composable -fun SearchProcessScreen() { +fun SearchProcessScreen( + modifier: Modifier = Modifier, +) { var text by remember { mutableStateOf("") } + + Scaffold( + modifier = modifier, + topBar = { + BackButtonTopAppBar(title = "검색") {} + } + ) { paddingValues -> + Column( + modifier = Modifier + .fillMaxWidth() + .padding( + top = paddingValues.calculateTopPadding(), + start = 24.dp, + end = 24.dp + ) + ) { + Text( + text = "어떤 공고를\n찾고 계시나요?", + style = TerningTheme.typography.heading2, + color = Grey500, + modifier = Modifier.padding( + vertical = 16.dp + ) + ) + SearchTextField( + text = text, + onValueChange = { newText -> + text = newText + }, + hint = stringResource(R.string.search_text_field_hint), + leftIcon = R.drawable.ic_nav_search, + modifier = modifier.padding(top = 8.dp) + ) + } + } +} + +@Preview(showBackground = true) +@Composable +fun SearchProcessScreenPreview() { + TerningPointTheme { + SearchProcessScreen() + } } \ No newline at end of file From 9b856f520af39a699ab6e864caf7d1cd620e12c3 Mon Sep 17 00:00:00 2001 From: arinming Date: Wed, 10 Jul 2024 23:10:17 +0900 Subject: [PATCH 04/10] =?UTF-8?q?[FEAT/#31]=20TopBar=20=EC=97=AC=EB=B0=B1?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../topappbar/BackButtonTopAppBar.kt | 6 +- .../component/topappbar/LogoTopAppBar.kt | 8 +- .../component/topappbar/MyPageTopAppBar.kt | 8 +- .../topappbar/TerningBasicTopAppBar.kt | 4 + .../com/terning/feature/home/HomeRoute.kt | 18 +++- .../com/terning/feature/main/MainScreen.kt | 23 ----- .../com/terning/feature/mypage/MyPageRoute.kt | 32 ++++--- .../com/terning/feature/search/SearchRoute.kt | 88 +++++++++++-------- .../searchprocess/SearchProcessRoute.kt | 33 +++++-- 9 files changed, 134 insertions(+), 86 deletions(-) diff --git a/core/src/main/java/com/terning/core/designsystem/component/topappbar/BackButtonTopAppBar.kt b/core/src/main/java/com/terning/core/designsystem/component/topappbar/BackButtonTopAppBar.kt index dec2124c9..960ebdc6e 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/topappbar/BackButtonTopAppBar.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/topappbar/BackButtonTopAppBar.kt @@ -1,14 +1,18 @@ package com.terning.core.designsystem.component.topappbar import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier @Composable fun BackButtonTopAppBar( - title: String, onBackButtonClick: (() -> Unit), + title: String, + modifier: Modifier, + onBackButtonClick: (() -> Unit), ) { TerningBasicTopAppBar( title = title, showBackButton = true, + modifier = modifier, onBackButtonClick = { onBackButtonClick.invoke() }, ) } \ No newline at end of file diff --git a/core/src/main/java/com/terning/core/designsystem/component/topappbar/LogoTopAppBar.kt b/core/src/main/java/com/terning/core/designsystem/component/topappbar/LogoTopAppBar.kt index f664c68c4..5bf8df8f7 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/topappbar/LogoTopAppBar.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/topappbar/LogoTopAppBar.kt @@ -2,12 +2,15 @@ package com.terning.core.designsystem.component.topappbar import androidx.compose.material3.Icon import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import com.terning.core.R @Composable -fun LogoTopAppBar() { +fun LogoTopAppBar( + modifier: Modifier = Modifier +) { TerningBasicTopAppBar( showBackButton = false, actions = listOf { @@ -15,6 +18,7 @@ fun LogoTopAppBar() { painter = painterResource(id = R.drawable.ic_logo), contentDescription = stringResource(id = R.string.ic_logo), ) - } + }, + modifier = modifier ) } diff --git a/core/src/main/java/com/terning/core/designsystem/component/topappbar/MyPageTopAppBar.kt b/core/src/main/java/com/terning/core/designsystem/component/topappbar/MyPageTopAppBar.kt index 37e28fbc8..50d279e68 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/topappbar/MyPageTopAppBar.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/topappbar/MyPageTopAppBar.kt @@ -6,6 +6,7 @@ import androidx.compose.material3.IconButton import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextAlign @@ -13,7 +14,9 @@ import com.terning.core.R import com.terning.core.designsystem.theme.TerningTheme @Composable -fun MyPageTopAppBar() { +fun MyPageTopAppBar( + modifier: Modifier, +) { TerningBasicTopAppBar( showBackButton = false, actions = listOf( @@ -36,6 +39,7 @@ fun MyPageTopAppBar() { } } } - ) + ), + modifier = modifier, ) } diff --git a/core/src/main/java/com/terning/core/designsystem/component/topappbar/TerningBasicTopAppBar.kt b/core/src/main/java/com/terning/core/designsystem/component/topappbar/TerningBasicTopAppBar.kt index 40bedc3d6..9fd5c8572 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/topappbar/TerningBasicTopAppBar.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/topappbar/TerningBasicTopAppBar.kt @@ -1,5 +1,6 @@ package com.terning.core.designsystem.component.topappbar +import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.padding import androidx.compose.material3.CenterAlignedTopAppBar import androidx.compose.material3.ExperimentalMaterial3Api @@ -21,6 +22,7 @@ import com.terning.core.designsystem.theme.White @Composable fun TerningBasicTopAppBar( title: String = "", + modifier: Modifier, showBackButton: Boolean = false, actions: List<@Composable () -> Unit> = emptyList(), onBackButtonClick: () -> Unit = {}, @@ -35,6 +37,7 @@ fun TerningBasicTopAppBar( ) }, + modifier = modifier, navigationIcon = { if (showBackButton) { IconButton( @@ -57,5 +60,6 @@ fun TerningBasicTopAppBar( } }, colors = TopAppBarDefaults.topAppBarColors(White), + windowInsets = WindowInsets(0, 0, 0, 0), ) } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/home/HomeRoute.kt b/feature/src/main/java/com/terning/feature/home/HomeRoute.kt index aa516b623..76310db84 100644 --- a/feature/src/main/java/com/terning/feature/home/HomeRoute.kt +++ b/feature/src/main/java/com/terning/feature/home/HomeRoute.kt @@ -2,9 +2,12 @@ package com.terning.feature.home import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Scaffold import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import com.terning.core.designsystem.component.topappbar.LogoTopAppBar @Composable fun HomeRoute() { @@ -13,7 +16,18 @@ fun HomeRoute() { @Composable fun HomeScreen() { - Column(modifier = Modifier.fillMaxSize()) { - Text(text = "홈 스크린") + Scaffold( + modifier = Modifier, + topBar = { + LogoTopAppBar() + } + ) { paddingValues -> + Column( + modifier = Modifier + .fillMaxSize() + .padding(paddingValues) + ) { + Text(text = "홈 스크린") + } } } \ No newline at end of file diff --git a/feature/src/main/java/com/terning/feature/main/MainScreen.kt b/feature/src/main/java/com/terning/feature/main/MainScreen.kt index 9ef09c7dd..59d3e4ac6 100644 --- a/feature/src/main/java/com/terning/feature/main/MainScreen.kt +++ b/feature/src/main/java/com/terning/feature/main/MainScreen.kt @@ -37,15 +37,6 @@ fun MainScreen( navigator: MainNavigator = rememberMainNavigator(), ) { Scaffold( - topBar = { - when (navigator.currentTab) { - MainTab.HOME -> LogoTopAppBar() - MainTab.CALENDAR -> TerningBasicTopAppBar() - MainTab.SEARCH -> LogoTopAppBar() - MainTab.MY_PAGE -> MyPageTopAppBar() - else -> TerningBasicTopAppBar() - } - }, bottomBar = { MainBottomBar( isVisible = navigator.showBottomBar(), @@ -76,20 +67,6 @@ fun MainScreen( } } - -@Composable -private fun MainTopBar( - isVisible: Boolean, - tabs: List, - currentTab: MainTab?, - onTabSelected: (MainTab) -> Unit, -) { - AnimatedVisibility( - visible = isVisible, - ) { - } -} - @Composable private fun MainBottomBar( isVisible: Boolean, diff --git a/feature/src/main/java/com/terning/feature/mypage/MyPageRoute.kt b/feature/src/main/java/com/terning/feature/mypage/MyPageRoute.kt index 90dcbcaf1..6c803afce 100644 --- a/feature/src/main/java/com/terning/feature/mypage/MyPageRoute.kt +++ b/feature/src/main/java/com/terning/feature/mypage/MyPageRoute.kt @@ -4,16 +4,17 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items +import androidx.compose.material3.Scaffold import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalLifecycleOwner -import androidx.compose.ui.unit.dp import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.flowWithLifecycle +import com.terning.core.designsystem.component.topappbar.MyPageTopAppBar import com.terning.core.extension.toast import com.terning.core.state.UiState import com.terning.domain.entity.response.MockResponseModel @@ -55,17 +56,24 @@ fun MyPageRoute( fun MyPageScreen( mockList: List, ) { - LazyColumn( - modifier = Modifier - .fillMaxSize() - .padding(20.dp) - ) { - items(mockList) { friend -> - MockItem( - name = friend.firstName, - profileImage = friend.avatar, - email = friend.email - ) + Scaffold( + modifier = Modifier, + topBar = { + MyPageTopAppBar(modifier = Modifier) + } + ) { paddingValues -> + LazyColumn( + modifier = Modifier + .fillMaxSize() + .padding(paddingValues) + ) { + items(mockList) { friend -> + MockItem( + name = friend.firstName, + profileImage = friend.avatar, + email = friend.email + ) + } } } } diff --git a/feature/src/main/java/com/terning/feature/search/SearchRoute.kt b/feature/src/main/java/com/terning/feature/search/SearchRoute.kt index cceb4a499..2702e3c3a 100644 --- a/feature/src/main/java/com/terning/feature/search/SearchRoute.kt +++ b/feature/src/main/java/com/terning/feature/search/SearchRoute.kt @@ -4,9 +4,11 @@ import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column 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.material3.HorizontalDivider +import androidx.compose.material3.Scaffold import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier @@ -14,6 +16,7 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.navigation.NavHostController import com.terning.core.designsystem.component.textfield.SearchTextField +import com.terning.core.designsystem.component.topappbar.LogoTopAppBar import com.terning.core.designsystem.theme.Black import com.terning.core.designsystem.theme.Grey100 import com.terning.core.designsystem.theme.TerningTheme @@ -27,11 +30,14 @@ import com.terning.feature.searchprocess.navigation.navigateSearchProcess fun SearchRoute( navController: NavHostController, ) { - SearchScreen(navController = navController) + SearchScreen( + navController = navController + ) } @Composable fun SearchScreen( + modifier: Modifier = Modifier, navController: NavHostController, ) { val images = listOf( @@ -40,45 +46,57 @@ fun SearchScreen( R.drawable.ic_nav_my_page, ) - Column( - modifier = Modifier - .fillMaxWidth() - ) { - Box( + Scaffold( + modifier = modifier, + topBar = { + LogoTopAppBar() + } + ) { paddingValues -> + Column( modifier = Modifier - .padding(horizontal = 24.dp, vertical = 16.dp) - .clickable { - navController.navigateSearchProcess() - } + .fillMaxSize() + .padding(paddingValues) ) { - SearchTextField( - hint = stringResource(R.string.search_text_field_hint), - leftIcon = R.drawable.ic_nav_search, - modifier = Modifier.fillMaxWidth(), - enabled = false, - readOnly = true, - ) - } + Box( + modifier = Modifier + .padding( + horizontal = 24.dp, + vertical = 16.dp + ) + .clickable { + navController.navigateSearchProcess() + } + ) { + SearchTextField( + hint = stringResource(R.string.search_text_field_hint), + leftIcon = R.drawable.ic_nav_search, + modifier = Modifier.fillMaxWidth(), + enabled = false, + readOnly = true, + ) + } - ImageSlider( - images = images - ) + ImageSlider( + images = images + ) - Spacer(modifier = Modifier.padding(8.dp)) + Spacer(modifier = Modifier.padding(8.dp)) - Text( - text = stringResource(id = R.string.search_today_popular), - modifier = Modifier.padding(horizontal = 24.dp, vertical = 4.dp), - style = TerningTheme.typography.title1, - color = Black - ) + Text( + text = stringResource(id = R.string.search_today_popular), + modifier = Modifier.padding(horizontal = 24.dp, vertical = 4.dp), + style = TerningTheme.typography.title1, + color = Black + ) - SearchInternList(type = InternListType.VIEW) - HorizontalDivider( - thickness = 4.dp, - modifier = Modifier.padding(vertical = 8.dp), - color = Grey100, - ) - SearchInternList(type = InternListType.SCRAP) + SearchInternList(type = InternListType.VIEW) + HorizontalDivider( + thickness = 4.dp, + modifier = Modifier.padding(vertical = 8.dp), + color = Grey100, + ) + SearchInternList(type = InternListType.SCRAP) + } } + } diff --git a/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt b/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt index 3ce3183d1..78e02dc8d 100644 --- a/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt +++ b/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt @@ -1,16 +1,20 @@ package com.terning.feature.searchprocess import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.material3.Scaffold import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier +import androidx.compose.ui.focus.FocusRequester +import androidx.compose.ui.focus.focusRequester +import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp @@ -19,6 +23,7 @@ import com.terning.core.designsystem.component.topappbar.BackButtonTopAppBar import com.terning.core.designsystem.theme.Grey500 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 @Composable @@ -32,20 +37,26 @@ fun SearchProcessScreen( ) { var text by remember { mutableStateOf("") } + val focusRequester = remember { FocusRequester() } + val focusManager = LocalFocusManager.current + + LaunchedEffect(Unit) { + focusRequester.requestFocus() + } + Scaffold( modifier = modifier, topBar = { - BackButtonTopAppBar(title = "검색") {} + BackButtonTopAppBar( + title = "검색", onBackButtonClick = { }, + modifier = Modifier + ) } ) { paddingValues -> Column( modifier = Modifier - .fillMaxWidth() - .padding( - top = paddingValues.calculateTopPadding(), - start = 24.dp, - end = 24.dp - ) + .fillMaxSize() + .padding(paddingValues) ) { Text( text = "어떤 공고를\n찾고 계시나요?", @@ -62,10 +73,14 @@ fun SearchProcessScreen( }, hint = stringResource(R.string.search_text_field_hint), leftIcon = R.drawable.ic_nav_search, - modifier = modifier.padding(top = 8.dp) + modifier = Modifier + .padding(top = 8.dp) + .focusRequester(focusRequester) + .addFocusCleaner(focusManager) ) } } + } @Preview(showBackground = true) From 35e44622e0ea470c3e7e7c2395d4e1f128fb056c Mon Sep 17 00:00:00 2001 From: arinming Date: Thu, 11 Jul 2024 01:28:26 +0900 Subject: [PATCH 05/10] =?UTF-8?q?[FEAT/#31]=20=EC=97=AC=EB=B0=B1=20?= =?UTF-8?q?=ED=84=B0=EC=B9=98=EC=8B=9C=20=ED=82=A4=EB=B3=B4=EB=93=9C=20?= =?UTF-8?q?=EC=88=A8=EA=B8=B0=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feature/searchprocess/SearchProcessRoute.kt | 10 ++++++---- feature/src/main/res/values/strings.xml | 4 ++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt b/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt index 78e02dc8d..220b5b096 100644 --- a/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt +++ b/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt @@ -48,7 +48,8 @@ fun SearchProcessScreen( modifier = modifier, topBar = { BackButtonTopAppBar( - title = "검색", onBackButtonClick = { }, + title = stringResource(id = R.string.search_process_top_bar_title), + onBackButtonClick = { }, modifier = Modifier ) } @@ -57,9 +58,11 @@ fun SearchProcessScreen( modifier = Modifier .fillMaxSize() .padding(paddingValues) + .padding(horizontal = 24.dp) + .addFocusCleaner(focusManager) ) { Text( - text = "어떤 공고를\n찾고 계시나요?", + text = stringResource(id = R.string.search_process_question_text), style = TerningTheme.typography.heading2, color = Grey500, modifier = Modifier.padding( @@ -80,7 +83,6 @@ fun SearchProcessScreen( ) } } - } @Preview(showBackground = true) @@ -89,4 +91,4 @@ fun SearchProcessScreenPreview() { TerningPointTheme { SearchProcessScreen() } -} \ No newline at end of file +} diff --git a/feature/src/main/res/values/strings.xml b/feature/src/main/res/values/strings.xml index 9594d9aa8..5ea0e5feb 100644 --- a/feature/src/main/res/values/strings.xml +++ b/feature/src/main/res/values/strings.xml @@ -33,6 +33,10 @@ 지금 조회수가 많은 공고들이에요 지금 스크랩 수가 많은 공고들이에요 + + 검색 + 어떤 공고를\n찾고 계시나요? + From db3154b8baaa6c66ff106662f2122ed80b5ec591 Mon Sep 17 00:00:00 2001 From: arinming Date: Thu, 11 Jul 2024 01:35:58 +0900 Subject: [PATCH 06/10] =?UTF-8?q?[FEAT/#31]=20BackButton=20Navigation=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/terning/feature/main/MainNavigator.kt | 4 +-- .../com/terning/feature/main/MainScreen.kt | 6 +--- .../searchprocess/SearchProcessRoute.kt | 30 +++++++++---------- .../navigation/SearchProcessNavigation.kt | 9 ++++-- 4 files changed, 24 insertions(+), 25 deletions(-) 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 e67b04927..beb7b7920 100644 --- a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt +++ b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt @@ -12,7 +12,7 @@ import androidx.navigation.navOptions import com.terning.feature.calendar.navigation.navigateCalendar import com.terning.feature.home.navigation.navigateHome import com.terning.feature.mypage.navigation.navigateMyPage -import com.terning.feature.search.navigation.Search +import com.terning.feature.onboarding.signin.navigation.SignIn import com.terning.feature.search.navigation.navigateSearch class MainNavigator( @@ -22,7 +22,7 @@ class MainNavigator( @Composable get() = navController .currentBackStackEntryAsState().value?.destination - val startDestination = Search + val startDestination = SignIn val currentTab: MainTab? @Composable get() = MainTab.find { tab -> diff --git a/feature/src/main/java/com/terning/feature/main/MainScreen.kt b/feature/src/main/java/com/terning/feature/main/MainScreen.kt index 59d3e4ac6..ded0535d4 100644 --- a/feature/src/main/java/com/terning/feature/main/MainScreen.kt +++ b/feature/src/main/java/com/terning/feature/main/MainScreen.kt @@ -16,13 +16,9 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import androidx.navigation.compose.NavHost -import com.terning.core.designsystem.component.topappbar.LogoTopAppBar -import com.terning.core.designsystem.component.topappbar.MyPageTopAppBar -import com.terning.core.designsystem.component.topappbar.TerningBasicTopAppBar import com.terning.core.designsystem.theme.Grey300 import com.terning.core.designsystem.theme.TerningMain import com.terning.core.designsystem.theme.White -import com.terning.core.navigation.MainTabRoute import com.terning.core.util.NoRippleInteractionSource import com.terning.feature.calendar.navigation.calendarNavGraph import com.terning.feature.home.navigation.homeNavGraph @@ -61,7 +57,7 @@ fun MainScreen( myPageNavGraph() signInNavGraph(navHostController = navigator.navController) signUpNavGraph() - searchProcessNavGraph() + searchProcessNavGraph(navHostController = navigator.navController) } } } diff --git a/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt b/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt index 220b5b096..2c56b12f9 100644 --- a/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt +++ b/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt @@ -16,25 +16,31 @@ import androidx.compose.ui.focus.FocusRequester import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.res.stringResource -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import androidx.navigation.NavHostController import com.terning.core.designsystem.component.textfield.SearchTextField import com.terning.core.designsystem.component.topappbar.BackButtonTopAppBar -import com.terning.core.designsystem.theme.Grey500 -import com.terning.core.designsystem.theme.TerningPointTheme +import com.terning.core.designsystem.theme.TerningMain import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.extension.addFocusCleaner import com.terning.feature.R @Composable -fun SearchProcessRoute() { - SearchProcessScreen() +fun SearchProcessRoute( + navController: NavHostController, +) { + SearchProcessScreen( + navController = navController + + ) } @Composable fun SearchProcessScreen( modifier: Modifier = Modifier, -) { + navController: NavHostController, + + ) { var text by remember { mutableStateOf("") } val focusRequester = remember { FocusRequester() } @@ -49,7 +55,7 @@ fun SearchProcessScreen( topBar = { BackButtonTopAppBar( title = stringResource(id = R.string.search_process_top_bar_title), - onBackButtonClick = { }, + onBackButtonClick = { navController.popBackStack() }, modifier = Modifier ) } @@ -64,7 +70,7 @@ fun SearchProcessScreen( Text( text = stringResource(id = R.string.search_process_question_text), style = TerningTheme.typography.heading2, - color = Grey500, + color = TerningMain, modifier = Modifier.padding( vertical = 16.dp ) @@ -84,11 +90,3 @@ fun SearchProcessScreen( } } } - -@Preview(showBackground = true) -@Composable -fun SearchProcessScreenPreview() { - TerningPointTheme { - SearchProcessScreen() - } -} diff --git a/feature/src/main/java/com/terning/feature/searchprocess/navigation/SearchProcessNavigation.kt b/feature/src/main/java/com/terning/feature/searchprocess/navigation/SearchProcessNavigation.kt index 091ee44ed..517508c06 100644 --- a/feature/src/main/java/com/terning/feature/searchprocess/navigation/SearchProcessNavigation.kt +++ b/feature/src/main/java/com/terning/feature/searchprocess/navigation/SearchProcessNavigation.kt @@ -2,6 +2,7 @@ package com.terning.feature.searchprocess.navigation import androidx.navigation.NavController import androidx.navigation.NavGraphBuilder +import androidx.navigation.NavHostController import androidx.navigation.NavOptions import androidx.navigation.compose.composable import com.terning.core.navigation.MainTabRoute @@ -15,9 +16,13 @@ fun NavController.navigateSearchProcess(navOptions: NavOptions? = null) { ) } -fun NavGraphBuilder.searchProcessNavGraph() { +fun NavGraphBuilder.searchProcessNavGraph( + navHostController: NavHostController +) { composable { - SearchProcessRoute() + SearchProcessRoute( + navController = navHostController + ) } } From a4673e251dfc443769e6657f0614ab09df1a6e0c Mon Sep 17 00:00:00 2001 From: arinming Date: Thu, 11 Jul 2024 02:09:20 +0900 Subject: [PATCH 07/10] =?UTF-8?q?[FEAT/#41]=20=ED=85=8D=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=20=ED=95=84=EB=93=9C=20=EC=99=84=EB=A3=8C=20=EB=B2=84=ED=8A=BC?= =?UTF-8?q?=20=ED=84=B0=EC=B9=98=EC=8B=9C=20=EA=B2=80=EC=83=89=20=EA=B2=B0?= =?UTF-8?q?=EA=B3=BC=20=ED=99=94=EB=A9=B4=EC=9C=BC=EB=A1=9C=20=EC=9D=B4?= =?UTF-8?q?=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/textfield/SearchTextField.kt | 2 + .../textfield/TerningBasicTextField.kt | 2 + .../com/terning/feature/main/MainNavigator.kt | 4 +- .../com/terning/feature/main/MainScreen.kt | 2 + .../searchprocess/SearchProcessRoute.kt | 6 +- .../feature/searchresult/SearchResultRoute.kt | 80 +++++++++++++++++++ .../navigation/SearchResultNavigation.kt | 30 +++++++ feature/src/main/res/values/strings.xml | 3 + 8 files changed, 126 insertions(+), 3 deletions(-) create mode 100644 feature/src/main/java/com/terning/feature/searchresult/SearchResultRoute.kt create mode 100644 feature/src/main/java/com/terning/feature/searchresult/navigation/SearchResultNavigation.kt diff --git a/core/src/main/java/com/terning/core/designsystem/component/textfield/SearchTextField.kt b/core/src/main/java/com/terning/core/designsystem/component/textfield/SearchTextField.kt index 88349f1b9..e540c905c 100644 --- a/core/src/main/java/com/terning/core/designsystem/component/textfield/SearchTextField.kt +++ b/core/src/main/java/com/terning/core/designsystem/component/textfield/SearchTextField.kt @@ -17,6 +17,7 @@ fun SearchTextField( leftIcon: Int, enabled: Boolean = true, readOnly: Boolean = false, + onDoneAction: (() -> Unit)? = null, ) { TerningBasicTextField( value = text, @@ -33,5 +34,6 @@ fun SearchTextField( leftIconColor = TerningMain, enabled = enabled, readOnly = readOnly, + onDoneAction = onDoneAction ) } \ No newline at end of file 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 ce8b2063a..45feb21b6 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 @@ -54,6 +54,7 @@ fun TerningBasicTextField( helperColor: Color = TerningMain, enabled: Boolean = true, readOnly: Boolean = false, + onDoneAction: (() -> Unit)? = null, ) { val keyboardController = LocalSoftwareKeyboardController.current val focusManager = LocalFocusManager.current @@ -69,6 +70,7 @@ fun TerningBasicTextField( onDone = { keyboardController?.hide() focusManager.clearFocus() + onDoneAction?.invoke() } ), 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 beb7b7920..a6e7a1de5 100644 --- a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt +++ b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt @@ -12,8 +12,8 @@ import androidx.navigation.navOptions import com.terning.feature.calendar.navigation.navigateCalendar import com.terning.feature.home.navigation.navigateHome import com.terning.feature.mypage.navigation.navigateMyPage -import com.terning.feature.onboarding.signin.navigation.SignIn import com.terning.feature.search.navigation.navigateSearch +import com.terning.feature.searchprocess.navigation.SearchProcess class MainNavigator( val navController: NavHostController, @@ -22,7 +22,7 @@ class MainNavigator( @Composable get() = navController .currentBackStackEntryAsState().value?.destination - val startDestination = SignIn + val startDestination = SearchProcess val currentTab: MainTab? @Composable get() = MainTab.find { tab -> diff --git a/feature/src/main/java/com/terning/feature/main/MainScreen.kt b/feature/src/main/java/com/terning/feature/main/MainScreen.kt index ded0535d4..1a4ce54ac 100644 --- a/feature/src/main/java/com/terning/feature/main/MainScreen.kt +++ b/feature/src/main/java/com/terning/feature/main/MainScreen.kt @@ -27,6 +27,7 @@ import com.terning.feature.onboarding.signin.navigation.signInNavGraph import com.terning.feature.onboarding.signup.navigation.signUpNavGraph import com.terning.feature.search.navigation.searchNavGraph import com.terning.feature.searchprocess.navigation.searchProcessNavGraph +import com.terning.feature.searchresult.navigation.searchResultNavGraph @Composable fun MainScreen( @@ -58,6 +59,7 @@ fun MainScreen( signInNavGraph(navHostController = navigator.navController) signUpNavGraph() searchProcessNavGraph(navHostController = navigator.navController) + searchResultNavGraph(navHostController = navigator.navController) } } } diff --git a/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt b/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt index 2c56b12f9..8544d1984 100644 --- a/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt +++ b/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt @@ -24,6 +24,7 @@ import com.terning.core.designsystem.theme.TerningMain import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.extension.addFocusCleaner import com.terning.feature.R +import com.terning.feature.searchresult.navigation.navigateSearchResult @Composable fun SearchProcessRoute( @@ -85,7 +86,10 @@ fun SearchProcessScreen( modifier = Modifier .padding(top = 8.dp) .focusRequester(focusRequester) - .addFocusCleaner(focusManager) + .addFocusCleaner(focusManager), + onDoneAction = { + navController.navigateSearchResult() + } ) } } diff --git a/feature/src/main/java/com/terning/feature/searchresult/SearchResultRoute.kt b/feature/src/main/java/com/terning/feature/searchresult/SearchResultRoute.kt new file mode 100644 index 000000000..a0eaee1f8 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/searchresult/SearchResultRoute.kt @@ -0,0 +1,80 @@ +package com.terning.feature.searchresult + +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Scaffold +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.focus.FocusRequester +import androidx.compose.ui.focus.focusRequester +import androidx.compose.ui.platform.LocalFocusManager +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import androidx.navigation.NavHostController +import com.terning.core.designsystem.component.textfield.SearchTextField +import com.terning.core.designsystem.component.topappbar.BackButtonTopAppBar +import com.terning.core.extension.addFocusCleaner +import com.terning.feature.R + +@Composable +fun SearchResultRoute( + navController: NavHostController, +) { + SearchResultScreen( + navController = navController + + ) +} + +@Composable +fun SearchResultScreen( + modifier: Modifier = Modifier, + navController: NavHostController, +) { + var text by remember { mutableStateOf("") } + + val focusRequester = remember { FocusRequester() } + val focusManager = LocalFocusManager.current + + LaunchedEffect(Unit) { + focusRequester.requestFocus() + } + + Scaffold( + modifier = modifier, + topBar = { + BackButtonTopAppBar( + title = stringResource(id = R.string.search_result_top_bar_title), + onBackButtonClick = { navController.popBackStack() }, + modifier = Modifier + ) + } + ) { paddingValues -> + Column( + modifier = Modifier + .fillMaxSize() + .padding(paddingValues) + .padding(horizontal = 24.dp) + .addFocusCleaner(focusManager) + ) { + SearchTextField( + text = text, + onValueChange = { newText -> + text = newText + }, + hint = stringResource(R.string.search_text_field_hint), + leftIcon = R.drawable.ic_nav_search, + modifier = Modifier + .padding(top = 8.dp) + .focusRequester(focusRequester) + .addFocusCleaner(focusManager) + ) + } + } +} diff --git a/feature/src/main/java/com/terning/feature/searchresult/navigation/SearchResultNavigation.kt b/feature/src/main/java/com/terning/feature/searchresult/navigation/SearchResultNavigation.kt new file mode 100644 index 000000000..f4543428e --- /dev/null +++ b/feature/src/main/java/com/terning/feature/searchresult/navigation/SearchResultNavigation.kt @@ -0,0 +1,30 @@ +package com.terning.feature.searchresult.navigation + +import androidx.navigation.NavController +import androidx.navigation.NavGraphBuilder +import androidx.navigation.NavHostController +import androidx.navigation.NavOptions +import androidx.navigation.compose.composable +import com.terning.core.navigation.MainTabRoute +import com.terning.feature.searchresult.SearchResultRoute +import kotlinx.serialization.Serializable + +fun NavController.navigateSearchResult(navOptions: NavOptions? = null) { + navigate( + route = SearchResult, + navOptions = navOptions + ) +} + +fun NavGraphBuilder.searchResultNavGraph( + navHostController: NavHostController, +) { + composable { + SearchResultRoute( + navController = navHostController + ) + } +} + +@Serializable +data object SearchResult : MainTabRoute \ No newline at end of file diff --git a/feature/src/main/res/values/strings.xml b/feature/src/main/res/values/strings.xml index 5ea0e5feb..46634be16 100644 --- a/feature/src/main/res/values/strings.xml +++ b/feature/src/main/res/values/strings.xml @@ -37,6 +37,9 @@ 검색 어떤 공고를\n찾고 계시나요? + + 검색 결과 + From bbddbbefd8faede4510a5981924adc492114f043 Mon Sep 17 00:00:00 2001 From: arinming Date: Thu, 11 Jul 2024 02:35:50 +0900 Subject: [PATCH 08/10] =?UTF-8?q?[FEAT/#41]=20=EA=B2=80=EC=83=89=20?= =?UTF-8?q?=EA=B2=B0=EA=B3=BC=20=ED=99=94=EB=A9=B4=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EB=B0=8F=20ProcessScreen=EC=97=90=EC=84=9C=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/terning/feature/main/MainScreen.kt | 2 - .../searchprocess/SearchProcessRoute.kt | 24 +++--- .../feature/searchresult/SearchResultRoute.kt | 80 ------------------- .../navigation/SearchResultNavigation.kt | 30 ------- feature/src/main/res/values/strings.xml | 4 +- 5 files changed, 15 insertions(+), 125 deletions(-) delete mode 100644 feature/src/main/java/com/terning/feature/searchresult/SearchResultRoute.kt delete mode 100644 feature/src/main/java/com/terning/feature/searchresult/navigation/SearchResultNavigation.kt diff --git a/feature/src/main/java/com/terning/feature/main/MainScreen.kt b/feature/src/main/java/com/terning/feature/main/MainScreen.kt index 1a4ce54ac..ded0535d4 100644 --- a/feature/src/main/java/com/terning/feature/main/MainScreen.kt +++ b/feature/src/main/java/com/terning/feature/main/MainScreen.kt @@ -27,7 +27,6 @@ import com.terning.feature.onboarding.signin.navigation.signInNavGraph import com.terning.feature.onboarding.signup.navigation.signUpNavGraph import com.terning.feature.search.navigation.searchNavGraph import com.terning.feature.searchprocess.navigation.searchProcessNavGraph -import com.terning.feature.searchresult.navigation.searchResultNavGraph @Composable fun MainScreen( @@ -59,7 +58,6 @@ fun MainScreen( signInNavGraph(navHostController = navigator.navController) signUpNavGraph() searchProcessNavGraph(navHostController = navigator.navController) - searchResultNavGraph(navHostController = navigator.navController) } } } diff --git a/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt b/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt index 8544d1984..dbcb98135 100644 --- a/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt +++ b/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt @@ -24,7 +24,6 @@ import com.terning.core.designsystem.theme.TerningMain import com.terning.core.designsystem.theme.TerningTheme import com.terning.core.extension.addFocusCleaner import com.terning.feature.R -import com.terning.feature.searchresult.navigation.navigateSearchResult @Composable fun SearchProcessRoute( @@ -43,6 +42,7 @@ fun SearchProcessScreen( ) { var text by remember { mutableStateOf("") } + var showSearchResults by remember { mutableStateOf(false) } val focusRequester = remember { FocusRequester() } val focusManager = LocalFocusManager.current @@ -55,7 +55,8 @@ fun SearchProcessScreen( modifier = modifier, topBar = { BackButtonTopAppBar( - title = stringResource(id = R.string.search_process_top_bar_title), + title = if (showSearchResults) stringResource(id = R.string.search_process_result_top_bar_title) + else stringResource(id = R.string.search_process_top_bar_title), onBackButtonClick = { navController.popBackStack() }, modifier = Modifier ) @@ -68,14 +69,17 @@ fun SearchProcessScreen( .padding(horizontal = 24.dp) .addFocusCleaner(focusManager) ) { - Text( - text = stringResource(id = R.string.search_process_question_text), - style = TerningTheme.typography.heading2, - color = TerningMain, - modifier = Modifier.padding( - vertical = 16.dp + if (!showSearchResults) { + Text( + text = stringResource(id = R.string.search_process_question_text), + style = TerningTheme.typography.heading2, + color = TerningMain, + modifier = Modifier.padding( + vertical = 16.dp + ) ) - ) + } + SearchTextField( text = text, onValueChange = { newText -> @@ -88,7 +92,7 @@ fun SearchProcessScreen( .focusRequester(focusRequester) .addFocusCleaner(focusManager), onDoneAction = { - navController.navigateSearchResult() + showSearchResults = true } ) } diff --git a/feature/src/main/java/com/terning/feature/searchresult/SearchResultRoute.kt b/feature/src/main/java/com/terning/feature/searchresult/SearchResultRoute.kt deleted file mode 100644 index a0eaee1f8..000000000 --- a/feature/src/main/java/com/terning/feature/searchresult/SearchResultRoute.kt +++ /dev/null @@ -1,80 +0,0 @@ -package com.terning.feature.searchresult - -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding -import androidx.compose.material3.Scaffold -import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.Modifier -import androidx.compose.ui.focus.FocusRequester -import androidx.compose.ui.focus.focusRequester -import androidx.compose.ui.platform.LocalFocusManager -import androidx.compose.ui.res.stringResource -import androidx.compose.ui.unit.dp -import androidx.navigation.NavHostController -import com.terning.core.designsystem.component.textfield.SearchTextField -import com.terning.core.designsystem.component.topappbar.BackButtonTopAppBar -import com.terning.core.extension.addFocusCleaner -import com.terning.feature.R - -@Composable -fun SearchResultRoute( - navController: NavHostController, -) { - SearchResultScreen( - navController = navController - - ) -} - -@Composable -fun SearchResultScreen( - modifier: Modifier = Modifier, - navController: NavHostController, -) { - var text by remember { mutableStateOf("") } - - val focusRequester = remember { FocusRequester() } - val focusManager = LocalFocusManager.current - - LaunchedEffect(Unit) { - focusRequester.requestFocus() - } - - Scaffold( - modifier = modifier, - topBar = { - BackButtonTopAppBar( - title = stringResource(id = R.string.search_result_top_bar_title), - onBackButtonClick = { navController.popBackStack() }, - modifier = Modifier - ) - } - ) { paddingValues -> - Column( - modifier = Modifier - .fillMaxSize() - .padding(paddingValues) - .padding(horizontal = 24.dp) - .addFocusCleaner(focusManager) - ) { - SearchTextField( - text = text, - onValueChange = { newText -> - text = newText - }, - hint = stringResource(R.string.search_text_field_hint), - leftIcon = R.drawable.ic_nav_search, - modifier = Modifier - .padding(top = 8.dp) - .focusRequester(focusRequester) - .addFocusCleaner(focusManager) - ) - } - } -} diff --git a/feature/src/main/java/com/terning/feature/searchresult/navigation/SearchResultNavigation.kt b/feature/src/main/java/com/terning/feature/searchresult/navigation/SearchResultNavigation.kt deleted file mode 100644 index f4543428e..000000000 --- a/feature/src/main/java/com/terning/feature/searchresult/navigation/SearchResultNavigation.kt +++ /dev/null @@ -1,30 +0,0 @@ -package com.terning.feature.searchresult.navigation - -import androidx.navigation.NavController -import androidx.navigation.NavGraphBuilder -import androidx.navigation.NavHostController -import androidx.navigation.NavOptions -import androidx.navigation.compose.composable -import com.terning.core.navigation.MainTabRoute -import com.terning.feature.searchresult.SearchResultRoute -import kotlinx.serialization.Serializable - -fun NavController.navigateSearchResult(navOptions: NavOptions? = null) { - navigate( - route = SearchResult, - navOptions = navOptions - ) -} - -fun NavGraphBuilder.searchResultNavGraph( - navHostController: NavHostController, -) { - composable { - SearchResultRoute( - navController = navHostController - ) - } -} - -@Serializable -data object SearchResult : MainTabRoute \ No newline at end of file diff --git a/feature/src/main/res/values/strings.xml b/feature/src/main/res/values/strings.xml index 46634be16..2386460fc 100644 --- a/feature/src/main/res/values/strings.xml +++ b/feature/src/main/res/values/strings.xml @@ -36,9 +36,7 @@ 검색 어떤 공고를\n찾고 계시나요? - - - 검색 결과 + 검색 결과 From 1d22fc0220e413300a3477cc8090c5689c541c56 Mon Sep 17 00:00:00 2001 From: arinming Date: Thu, 11 Jul 2024 02:54:18 +0900 Subject: [PATCH 09/10] =?UTF-8?q?[FEAT/#41]=20=EA=B2=80=EC=83=89=20?= =?UTF-8?q?=EA=B2=B0=EA=B3=BC=EA=B0=80=20=EC=97=86=EC=9D=84=20=EB=95=8C?= =?UTF-8?q?=EC=9D=98=20=ED=99=94=EB=A9=B4=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../searchprocess/SearchProcessRoute.kt | 56 +++++++++++++++++++ feature/src/main/res/drawable/ic_nosearch.xml | 10 ++++ feature/src/main/res/values/strings.xml | 1 + 3 files changed, 67 insertions(+) create mode 100644 feature/src/main/res/drawable/ic_nosearch.xml diff --git a/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt b/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt index dbcb98135..eace1c22e 100644 --- a/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt +++ b/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt @@ -1,6 +1,8 @@ package com.terning.feature.searchprocess +import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.material3.Scaffold @@ -11,16 +13,22 @@ import androidx.compose.runtime.getValue 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 import androidx.compose.ui.focus.focusRequester import androidx.compose.ui.platform.LocalFocusManager +import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.navigation.NavHostController +import androidx.navigation.compose.rememberNavController import com.terning.core.designsystem.component.textfield.SearchTextField import com.terning.core.designsystem.component.topappbar.BackButtonTopAppBar +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.feature.R @@ -42,6 +50,7 @@ fun SearchProcessScreen( ) { var text by remember { mutableStateOf("") } + var query by remember { mutableStateOf("") } var showSearchResults by remember { mutableStateOf(false) } val focusRequester = remember { FocusRequester() } @@ -92,9 +101,56 @@ fun SearchProcessScreen( .focusRequester(focusRequester) .addFocusCleaner(focusManager), onDoneAction = { + query = text showSearchResults = true } ) + + if (showSearchResults) { + + Column( + modifier = Modifier + .fillMaxSize() + .padding(top = 87.dp), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Image( + painter = painterResource(id = R.drawable.ic_nosearch), + contentDescription = stringResource( + id = R.string.search_process_no_result_icon + ) + ) + // TODO 네이버와 / 터닝과 / 영어 검색어 등 -> 디자인 쌤들 문의 + Row( + modifier = Modifier.padding(vertical = 16.dp) + ) { + Text( + text = query, + style = TerningTheme.typography.body1, + color = TerningMain, + ) + Text( + text = "와 일치하는 검색 결과가 없어요", + style = TerningTheme.typography.body1, + color = Grey400, + ) + } + } + + } } + + } } + + +@Preview(showBackground = true) +@Composable +fun SearchProcessScreenPreview() { + TerningPointTheme { + SearchProcessScreen( + navController = rememberNavController() + ) + } +} \ No newline at end of file diff --git a/feature/src/main/res/drawable/ic_nosearch.xml b/feature/src/main/res/drawable/ic_nosearch.xml new file mode 100644 index 000000000..c63bd8fb7 --- /dev/null +++ b/feature/src/main/res/drawable/ic_nosearch.xml @@ -0,0 +1,10 @@ + + + diff --git a/feature/src/main/res/values/strings.xml b/feature/src/main/res/values/strings.xml index 2386460fc..7256ef7c0 100644 --- a/feature/src/main/res/values/strings.xml +++ b/feature/src/main/res/values/strings.xml @@ -37,6 +37,7 @@ 검색 어떤 공고를\n찾고 계시나요? 검색 결과 + 검색 결과 없을 때 아이콘 From 9c1620e8278134522d7a35c0c566a46fbc93ebdf Mon Sep 17 00:00:00 2001 From: arinming Date: Thu, 11 Jul 2024 03:06:48 +0900 Subject: [PATCH 10/10] =?UTF-8?q?[FEAT/#41]=20SearchProcessViewModel=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/terning/feature/main/MainNavigator.kt | 4 +- .../searchprocess/SearchProcessRoute.kt | 49 +++++++++---------- .../searchprocess/SearchProcessViewModel.kt | 28 +++++++++++ .../models/SearchProcessState.kt | 8 +++ feature/src/main/res/values/strings.xml | 2 + 5 files changed, 62 insertions(+), 29 deletions(-) create mode 100644 feature/src/main/java/com/terning/feature/searchprocess/SearchProcessViewModel.kt create mode 100644 feature/src/main/java/com/terning/feature/searchprocess/models/SearchProcessState.kt 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 a6e7a1de5..e67b04927 100644 --- a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt +++ b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt @@ -12,8 +12,8 @@ import androidx.navigation.navOptions import com.terning.feature.calendar.navigation.navigateCalendar import com.terning.feature.home.navigation.navigateHome import com.terning.feature.mypage.navigation.navigateMyPage +import com.terning.feature.search.navigation.Search import com.terning.feature.search.navigation.navigateSearch -import com.terning.feature.searchprocess.navigation.SearchProcess class MainNavigator( val navController: NavHostController, @@ -22,7 +22,7 @@ class MainNavigator( @Composable get() = navController .currentBackStackEntryAsState().value?.destination - val startDestination = SearchProcess + val startDestination = Search val currentTab: MainTab? @Composable get() = MainTab.find { tab -> diff --git a/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt b/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt index eace1c22e..3c1ebc624 100644 --- a/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt +++ b/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt @@ -10,9 +10,7 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.getValue -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 @@ -22,6 +20,8 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +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.textfield.SearchTextField @@ -38,8 +38,7 @@ fun SearchProcessRoute( navController: NavHostController, ) { SearchProcessScreen( - navController = navController - + navController = navController, ) } @@ -47,11 +46,9 @@ fun SearchProcessRoute( fun SearchProcessScreen( modifier: Modifier = Modifier, navController: NavHostController, - - ) { - var text by remember { mutableStateOf("") } - var query by remember { mutableStateOf("") } - var showSearchResults by remember { mutableStateOf(false) } + viewModel: SearchProcessViewModel = hiltViewModel(), +) { + val state by viewModel.state.collectAsStateWithLifecycle() val focusRequester = remember { FocusRequester() } val focusManager = LocalFocusManager.current @@ -64,8 +61,11 @@ fun SearchProcessScreen( modifier = modifier, topBar = { BackButtonTopAppBar( - title = if (showSearchResults) stringResource(id = R.string.search_process_result_top_bar_title) - else stringResource(id = R.string.search_process_top_bar_title), + title = stringResource( + id = + if (state.showSearchResults) R.string.search_process_result_top_bar_title + else R.string.search_process_top_bar_title + ), onBackButtonClick = { navController.popBackStack() }, modifier = Modifier ) @@ -78,7 +78,7 @@ fun SearchProcessScreen( .padding(horizontal = 24.dp) .addFocusCleaner(focusManager) ) { - if (!showSearchResults) { + if (!state.showSearchResults) { Text( text = stringResource(id = R.string.search_process_question_text), style = TerningTheme.typography.heading2, @@ -90,9 +90,9 @@ fun SearchProcessScreen( } SearchTextField( - text = text, + text = state.text, onValueChange = { newText -> - text = newText + viewModel.updateText(newText) }, hint = stringResource(R.string.search_text_field_hint), leftIcon = R.drawable.ic_nav_search, @@ -101,13 +101,12 @@ fun SearchProcessScreen( .focusRequester(focusRequester) .addFocusCleaner(focusManager), onDoneAction = { - query = text - showSearchResults = true + viewModel.updateQuery(state.text) + viewModel.updateShowSearchResults(true) } ) - if (showSearchResults) { - + if (state.showSearchResults) { Column( modifier = Modifier .fillMaxSize() @@ -120,31 +119,27 @@ fun SearchProcessScreen( id = R.string.search_process_no_result_icon ) ) - // TODO 네이버와 / 터닝과 / 영어 검색어 등 -> 디자인 쌤들 문의 Row( - modifier = Modifier.padding(vertical = 16.dp) + modifier = Modifier.padding(vertical = 16.dp), + verticalAlignment = Alignment.CenterVertically ) { Text( - text = query, + text = state.query, style = TerningTheme.typography.body1, color = TerningMain, ) Text( - text = "와 일치하는 검색 결과가 없어요", + text = stringResource(id = R.string.search_process_no_result_text), style = TerningTheme.typography.body1, color = Grey400, ) } } - } } - - } } - @Preview(showBackground = true) @Composable fun SearchProcessScreenPreview() { @@ -153,4 +148,4 @@ fun SearchProcessScreenPreview() { navController = rememberNavController() ) } -} \ No newline at end of file +} diff --git a/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessViewModel.kt b/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessViewModel.kt new file mode 100644 index 000000000..cd201085a --- /dev/null +++ b/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessViewModel.kt @@ -0,0 +1,28 @@ +package com.terning.feature.searchprocess + +import androidx.lifecycle.ViewModel +import com.terning.feature.searchprocess.models.SearchProcessState +import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import javax.inject.Inject + +@HiltViewModel +class SearchProcessViewModel @Inject constructor() : ViewModel() { + private val _state: MutableStateFlow = + MutableStateFlow(SearchProcessState()) + + val state: StateFlow get() = _state + + fun updateText(newText: String) { + _state.value = _state.value.copy(text = newText) + } + + fun updateQuery(query: String) { + _state.value = _state.value.copy(query = query) + } + + fun updateShowSearchResults(show: Boolean) { + _state.value = _state.value.copy(showSearchResults = show) + } +} diff --git a/feature/src/main/java/com/terning/feature/searchprocess/models/SearchProcessState.kt b/feature/src/main/java/com/terning/feature/searchprocess/models/SearchProcessState.kt new file mode 100644 index 000000000..c66defbce --- /dev/null +++ b/feature/src/main/java/com/terning/feature/searchprocess/models/SearchProcessState.kt @@ -0,0 +1,8 @@ +package com.terning.feature.searchprocess.models + + +data class SearchProcessState( + val text: String = "", + val query: String = "", + val showSearchResults: Boolean = false, +) \ No newline at end of file diff --git a/feature/src/main/res/values/strings.xml b/feature/src/main/res/values/strings.xml index 7256ef7c0..54b8f98d8 100644 --- a/feature/src/main/res/values/strings.xml +++ b/feature/src/main/res/values/strings.xml @@ -38,6 +38,8 @@ 어떤 공고를\n찾고 계시나요? 검색 결과 검색 결과 없을 때 아이콘 + 와 일치하는 검색 결과가 없어요 +