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 19336ee0a..8a6d8ced0 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 @@ -21,6 +22,7 @@ fun NameTextField( TerningBasicTextField( value = value, onValueChange = onValueChange, + modifier = Modifier, textStyle = TerningTheme.typography.detail1, textColor = Black, drawLineColor = drawLineColor, 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 4fa00b512..21d181551 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,7 +1,7 @@ package com.terning.core.designsystem.component.textfield import androidx.compose.runtime.Composable -import androidx.compose.ui.graphics.Color +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 @@ -10,15 +10,19 @@ import com.terning.core.designsystem.theme.TerningTheme @Composable fun SearchTextField( - text: String, - onValueChange: (String) -> Unit, + text: String = "", + onValueChange: (String) -> Unit = {}, + modifier: Modifier, hint: String, leftIcon: Int, + enabled: Boolean = true, readOnly: Boolean = false, + onDoneAction: (() -> Unit)? = null, ) { TerningBasicTextField( value = text, onValueChange = onValueChange, + modifier = modifier, textStyle = TerningTheme.typography.button3, textColor = Grey400, cursorBrush = SolidColor(Grey300), @@ -28,7 +32,9 @@ fun SearchTextField( hintColor = Grey300, leftIcon = leftIcon, leftIconColor = TerningMain, + enabled = enabled, readOnly = readOnly, + onDoneAction = onDoneAction, helperColor = TerningMain ) } \ 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 788827f4c..e73c1a3d5 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,9 @@ import com.terning.core.designsystem.theme.White @Composable fun TerningBasicTextField( - value: String, - onValueChange: (String) -> Unit, + value: String = "", + onValueChange: (String) -> Unit = {}, + modifier: Modifier, textStyle: TextStyle, textColor: Color, hintColor: Color, @@ -50,8 +51,10 @@ fun TerningBasicTextField( hint: String = "", helperMessage: String = "", helperIcon: Int? = null, + enabled: Boolean = true, helperColor: Color, readOnly: Boolean = false, + onDoneAction: (() -> Unit)? = null, ) { val keyboardController = LocalSoftwareKeyboardController.current val focusManager = LocalFocusManager.current @@ -67,10 +70,11 @@ fun TerningBasicTextField( onDone = { keyboardController?.hide() focusManager.clearFocus() + onDoneAction?.invoke() } ), - modifier = Modifier + modifier = modifier .fillMaxWidth() .background(White) .drawWithContent { @@ -124,6 +128,8 @@ fun TerningBasicTextField( } } }, + + enabled = enabled, readOnly = readOnly, ) 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..6cab1601d 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 = 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 a5088099f..2f6e297ad 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,14 +37,17 @@ fun TerningBasicTopAppBar( ) }, + modifier = modifier, 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 +60,11 @@ fun TerningBasicTopAppBar( } }, colors = TopAppBarDefaults.topAppBarColors(White), - modifier = Modifier.padding(horizontal = 16.dp) + windowInsets = WindowInsets( + left = 0, + top = 0, + right = 0, + bottom = 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/MainNavigator.kt b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt index beb7b7920..859ae0c3a 100644 --- a/feature/src/main/java/com/terning/feature/main/MainNavigator.kt +++ b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt @@ -13,7 +13,7 @@ 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.search.search.navigation.navigateSearch class MainNavigator( val navController: NavHostController, 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 28b119120..305ed227c 100644 --- a/feature/src/main/java/com/terning/feature/main/MainScreen.kt +++ b/feature/src/main/java/com/terning/feature/main/MainScreen.kt @@ -16,9 +16,6 @@ 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 @@ -29,22 +26,14 @@ import com.terning.feature.mypage.navigation.myPageNavGraph import com.terning.feature.onboarding.filtering.navigation.filteringNavGraph 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.search.search.navigation.searchNavGraph +import com.terning.feature.search.searchprocess.navigation.searchProcessNavGraph @Composable fun MainScreen( navigator: MainNavigator = rememberMainNavigator(), ) { Scaffold( - topBar = { - when (navigator.currentTab) { - MainTab.HOME -> LogoTopAppBar() - MainTab.CALENDAR -> TerningBasicTopAppBar() - MainTab.SEARCH -> LogoTopAppBar() - MainTab.MY_PAGE -> MyPageTopAppBar() - null -> TerningBasicTopAppBar() - } - }, bottomBar = { MainBottomBar( isVisible = navigator.showBottomBar(), @@ -65,30 +54,17 @@ fun MainScreen( ) { homeNavGraph() calendarNavGraph() - searchNavGraph() + searchNavGraph(navHostController = navigator.navController) myPageNavGraph() signInNavGraph(navHostController = navigator.navController) signUpNavGraph(navHostController = navigator.navController) filteringNavGraph(navHostController = navigator.navController) + searchProcessNavGraph(navHostController = navigator.navController) } } } } - -@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/main/MainTab.kt b/feature/src/main/java/com/terning/feature/main/MainTab.kt index 4273117a2..01d8c8518 100644 --- a/feature/src/main/java/com/terning/feature/main/MainTab.kt +++ b/feature/src/main/java/com/terning/feature/main/MainTab.kt @@ -9,7 +9,7 @@ import com.terning.feature.R import com.terning.feature.calendar.navigation.Calendar import com.terning.feature.home.navigation.Home import com.terning.feature.mypage.navigation.MyPage -import com.terning.feature.search.navigation.Search +import com.terning.feature.search.search.navigation.Search enum class MainTab( @DrawableRes val icon: Int, 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/onboarding/signup/SignUpViewModel.kt b/feature/src/main/java/com/terning/feature/onboarding/signup/SignUpViewModel.kt index 1afd647bb..a01379d30 100644 --- a/feature/src/main/java/com/terning/feature/onboarding/signup/SignUpViewModel.kt +++ b/feature/src/main/java/com/terning/feature/onboarding/signup/SignUpViewModel.kt @@ -45,7 +45,7 @@ class SignUpViewModel @Inject constructor() : ViewModel() { name = trimmedName, drawLineColor = TerningMain, helper = HELPER_AVAILABLE, - helperIcon = R.drawable.ic_sign_up_available, + helperIcon = R.drawable.ic_check, helperColor = TerningMain, isButtonValid = true ) diff --git a/feature/src/main/java/com/terning/feature/search/SearchRoute.kt b/feature/src/main/java/com/terning/feature/search/SearchRoute.kt deleted file mode 100644 index 2d78d33c7..000000000 --- a/feature/src/main/java/com/terning/feature/search/SearchRoute.kt +++ /dev/null @@ -1,86 +0,0 @@ -package com.terning.feature.search - -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxWidth -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 com.terning.core.designsystem.component.textfield.SearchTextField -import com.terning.core.designsystem.theme.Black -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 - -@Composable -fun SearchRoute() { - SearchScreen() -} - -@Composable -fun SearchScreen() { - var text by remember { mutableStateOf("") } - val images = listOf( - R.drawable.ic_nav_search, - R.drawable.ic_sign_up_available, - R.drawable.ic_nav_my_page, - ) - - Column( - modifier = Modifier - .fillMaxWidth() - ) { - Box( - modifier = Modifier.padding( - horizontal = 24.dp, - vertical = 16.dp - ) - ) { - SearchTextField( - text = text, - onValueChange = { newText -> - text = newText - }, - hint = stringResource(R.string.search_text_field_hint), - leftIcon = R.drawable.ic_nav_search, - readOnly = true, - ) - } - - ImageSlider( - images = images - ) - - 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 - ) - - SearchInternList(type = InternListType.VIEW) - HorizontalDivider( - thickness = 4.dp, - modifier = Modifier.padding(vertical = 8.dp), - color = Grey100, - ) - SearchInternList(type = InternListType.SCRAP) - } -} \ No newline at end of file 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 new file mode 100644 index 000000000..bdda144ec --- /dev/null +++ b/feature/src/main/java/com/terning/feature/search/search/SearchRoute.kt @@ -0,0 +1,102 @@ +package com.terning.feature.search.search + +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 +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 +import com.terning.feature.R +import com.terning.feature.search.search.component.ImageSlider +import com.terning.feature.search.search.component.InternListType +import com.terning.feature.search.search.component.SearchInternList +import com.terning.feature.search.searchprocess.navigation.navigateSearchProcess + +@Composable +fun SearchRoute( + navController: NavHostController, +) { + SearchScreen( + navController = navController + ) +} + +@Composable +fun SearchScreen( + modifier: Modifier = Modifier, + navController: NavHostController, +) { + val images = listOf( + R.drawable.ic_nav_search, + R.drawable.ic_check, + R.drawable.ic_nav_my_page, + ) + + Scaffold( + modifier = modifier, + topBar = { + LogoTopAppBar() + } + ) { paddingValues -> + Column( + modifier = Modifier + .fillMaxSize() + .padding(paddingValues) + ) { + 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 + ) + + 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 + ) + + 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/search/component/DotsIndicator.kt b/feature/src/main/java/com/terning/feature/search/search/component/DotsIndicator.kt similarity index 93% rename from feature/src/main/java/com/terning/feature/search/component/DotsIndicator.kt rename to feature/src/main/java/com/terning/feature/search/search/component/DotsIndicator.kt index 908eb460e..561e5870e 100644 --- a/feature/src/main/java/com/terning/feature/search/component/DotsIndicator.kt +++ b/feature/src/main/java/com/terning/feature/search/search/component/DotsIndicator.kt @@ -1,4 +1,4 @@ -package com.terning.feature.search.component +package com.terning.feature.search.search.component import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row diff --git a/feature/src/main/java/com/terning/feature/search/component/ImageSlider.kt b/feature/src/main/java/com/terning/feature/search/search/component/ImageSlider.kt similarity index 97% rename from feature/src/main/java/com/terning/feature/search/component/ImageSlider.kt rename to feature/src/main/java/com/terning/feature/search/search/component/ImageSlider.kt index ddfb8c0bf..3eb84743b 100644 --- a/feature/src/main/java/com/terning/feature/search/component/ImageSlider.kt +++ b/feature/src/main/java/com/terning/feature/search/search/component/ImageSlider.kt @@ -1,4 +1,4 @@ -package com.terning.feature.search.component +package com.terning.feature.search.search.component import androidx.compose.foundation.Image import androidx.compose.foundation.background diff --git a/feature/src/main/java/com/terning/feature/search/component/IndicatorDots.kt b/feature/src/main/java/com/terning/feature/search/search/component/IndicatorDots.kt similarity index 93% rename from feature/src/main/java/com/terning/feature/search/component/IndicatorDots.kt rename to feature/src/main/java/com/terning/feature/search/search/component/IndicatorDots.kt index dc91d16e5..f8d75475e 100644 --- a/feature/src/main/java/com/terning/feature/search/component/IndicatorDots.kt +++ b/feature/src/main/java/com/terning/feature/search/search/component/IndicatorDots.kt @@ -1,4 +1,4 @@ -package com.terning.feature.search.component +package com.terning.feature.search.search.component import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box diff --git a/feature/src/main/java/com/terning/feature/search/component/InternListType.kt b/feature/src/main/java/com/terning/feature/search/search/component/InternListType.kt similarity index 62% rename from feature/src/main/java/com/terning/feature/search/component/InternListType.kt rename to feature/src/main/java/com/terning/feature/search/search/component/InternListType.kt index 9caae356d..ba32e936d 100644 --- a/feature/src/main/java/com/terning/feature/search/component/InternListType.kt +++ b/feature/src/main/java/com/terning/feature/search/search/component/InternListType.kt @@ -1,4 +1,4 @@ -package com.terning.feature.search.component +package com.terning.feature.search.search.component enum class InternListType(val type: String) { VIEW("view"), diff --git a/feature/src/main/java/com/terning/feature/search/component/SearchIntern.kt b/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt similarity index 97% rename from feature/src/main/java/com/terning/feature/search/component/SearchIntern.kt rename to feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt index 89ba2c0db..e2b6109f5 100644 --- a/feature/src/main/java/com/terning/feature/search/component/SearchIntern.kt +++ b/feature/src/main/java/com/terning/feature/search/search/component/SearchIntern.kt @@ -1,4 +1,4 @@ -package com.terning.feature.search.component +package com.terning.feature.search.search.component import androidx.compose.foundation.Image import androidx.compose.foundation.background diff --git a/feature/src/main/java/com/terning/feature/search/component/SearchInternList.kt b/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt similarity index 96% rename from feature/src/main/java/com/terning/feature/search/component/SearchInternList.kt rename to feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt index 8c0eafa80..0060685c0 100644 --- a/feature/src/main/java/com/terning/feature/search/component/SearchInternList.kt +++ b/feature/src/main/java/com/terning/feature/search/search/component/SearchInternList.kt @@ -1,4 +1,4 @@ -package com.terning.feature.search.component +package com.terning.feature.search.search.component import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column diff --git a/feature/src/main/java/com/terning/feature/search/navigation/SearchNavigation.kt b/feature/src/main/java/com/terning/feature/search/search/navigation/SearchNavigation.kt similarity index 61% rename from feature/src/main/java/com/terning/feature/search/navigation/SearchNavigation.kt rename to feature/src/main/java/com/terning/feature/search/search/navigation/SearchNavigation.kt index 26e2036b6..8daeea54b 100644 --- a/feature/src/main/java/com/terning/feature/search/navigation/SearchNavigation.kt +++ b/feature/src/main/java/com/terning/feature/search/search/navigation/SearchNavigation.kt @@ -1,11 +1,12 @@ -package com.terning.feature.search.navigation +package com.terning.feature.search.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 -import com.terning.feature.search.SearchRoute +import com.terning.feature.search.search.SearchRoute import kotlinx.serialization.Serializable fun NavController.navigateSearch(navOptions: NavOptions? = null) { @@ -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/search/searchprocess/SearchProcessRoute.kt b/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessRoute.kt new file mode 100644 index 000000000..3736f0516 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessRoute.kt @@ -0,0 +1,151 @@ +package com.terning.feature.search.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 +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.getValue +import androidx.compose.runtime.remember +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.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 +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 + +@Composable +fun SearchProcessRoute( + navController: NavHostController, +) { + SearchProcessScreen( + navController = navController, + ) +} + +@Composable +fun SearchProcessScreen( + modifier: Modifier = Modifier, + navController: NavHostController, + viewModel: SearchProcessViewModel = hiltViewModel(), +) { + val state by viewModel.state.collectAsStateWithLifecycle() + + val focusRequester = remember { FocusRequester() } + val focusManager = LocalFocusManager.current + + LaunchedEffect(Unit) { + focusRequester.requestFocus() + } + + Scaffold( + modifier = modifier, + topBar = { + BackButtonTopAppBar( + 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 + ) + } + ) { paddingValues -> + Column( + modifier = Modifier + .fillMaxSize() + .padding(paddingValues) + .padding(horizontal = 24.dp) + .addFocusCleaner(focusManager) + ) { + if (!state.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 = state.text, + onValueChange = { newText -> + viewModel.updateText(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), + onDoneAction = { + viewModel.updateQuery(state.text) + viewModel.updateShowSearchResults(true) + } + ) + + if (state.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 + ) + ) + Row( + modifier = Modifier.padding(vertical = 16.dp), + verticalAlignment = Alignment.CenterVertically + ) { + Text( + text = state.query, + style = TerningTheme.typography.body1, + color = TerningMain, + ) + Text( + text = stringResource(id = R.string.search_process_no_result_text), + style = TerningTheme.typography.body1, + color = Grey400, + ) + } + } + } + } + } +} + +@Preview(showBackground = true) +@Composable +fun SearchProcessScreenPreview() { + TerningPointTheme { + SearchProcessScreen( + navController = rememberNavController() + ) + } +} 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 new file mode 100644 index 000000000..a88196b52 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/search/searchprocess/SearchProcessViewModel.kt @@ -0,0 +1,28 @@ +package com.terning.feature.search.searchprocess + +import androidx.lifecycle.ViewModel +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 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/search/searchprocess/models/SearchProcessState.kt b/feature/src/main/java/com/terning/feature/search/searchprocess/models/SearchProcessState.kt new file mode 100644 index 000000000..2f55b7287 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/search/searchprocess/models/SearchProcessState.kt @@ -0,0 +1,8 @@ +package com.terning.feature.search.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/java/com/terning/feature/search/searchprocess/navigation/SearchProcessNavigation.kt b/feature/src/main/java/com/terning/feature/search/searchprocess/navigation/SearchProcessNavigation.kt new file mode 100644 index 000000000..fa6a4b7a2 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/search/searchprocess/navigation/SearchProcessNavigation.kt @@ -0,0 +1,30 @@ +package com.terning.feature.search.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.Route +import com.terning.feature.search.searchprocess.SearchProcessRoute +import kotlinx.serialization.Serializable + +fun NavController.navigateSearchProcess(navOptions: NavOptions? = null) { + navigate( + route = SearchProcess, + navOptions = navOptions + ) +} + +fun NavGraphBuilder.searchProcessNavGraph( + navHostController: NavHostController, +) { + composable { + SearchProcessRoute( + navController = navHostController + ) + } +} + +@Serializable +data object SearchProcess : Route \ No newline at end of file diff --git a/feature/src/main/res/drawable/ic_check.xml b/feature/src/main/res/drawable/ic_check.xml new file mode 100644 index 000000000..6c2547e9d --- /dev/null +++ b/feature/src/main/res/drawable/ic_check.xml @@ -0,0 +1,18 @@ + + + + \ 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/drawable/ic_sign_up_available.xml b/feature/src/main/res/drawable/ic_sign_up_available.xml deleted file mode 100644 index 3982b4d78..000000000 --- a/feature/src/main/res/drawable/ic_sign_up_available.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - diff --git a/feature/src/main/res/values/strings.xml b/feature/src/main/res/values/strings.xml index 0cb029fe5..ea012c692 100644 --- a/feature/src/main/res/values/strings.xml +++ b/feature/src/main/res/values/strings.xml @@ -35,6 +35,14 @@ 지금 조회수가 많은 공고들이에요 지금 스크랩 수가 많은 공고들이에요 + + 검색 + 어떤 공고를\n찾고 계시나요? + 검색 결과 + 검색 결과 없을 때 아이콘 + 와 일치하는 검색 결과가 없어요 + +