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 29dc5cf87..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 @@ -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 @@ -9,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), @@ -27,6 +32,8 @@ fun SearchTextField( hintColor = Grey300, leftIcon = leftIcon, 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 a9045ef5e..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 @@ -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, @@ -51,7 +52,9 @@ fun TerningBasicTextField( helperMessage: String = "", helperIcon: Int? = null, helperColor: Color = TerningMain, + enabled: Boolean = true, 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..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 a5088099f..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,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,6 @@ fun TerningBasicTopAppBar( } }, colors = TopAppBarDefaults.topAppBarColors(White), - modifier = Modifier.padding(horizontal = 16.dp) + 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/MainNavigator.kt b/feature/src/main/java/com/terning/feature/main/MainNavigator.kt index 68d33fb38..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 @@ -23,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..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,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,21 +26,13 @@ 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( 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(), @@ -64,29 +53,16 @@ fun MainScreen( ) { homeNavGraph() calendarNavGraph() - searchNavGraph() + searchNavGraph(navHostController = navigator.navController) myPageNavGraph() signInNavGraph(navHostController = navigator.navController) signUpNavGraph() + 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/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 dc075791f..2702e3c3a 100644 --- a/feature/src/main/java/com/terning/feature/search/SearchRoute.kt +++ b/feature/src/main/java/com/terning/feature/search/SearchRoute.kt @@ -1,21 +1,22 @@ 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 +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.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.component.topappbar.LogoTopAppBar import com.terning.core.designsystem.theme.Black import com.terning.core.designsystem.theme.Grey100 import com.terning.core.designsystem.theme.TerningTheme @@ -23,64 +24,79 @@ 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 @Composable -fun SearchRoute() { - SearchScreen() +fun SearchRoute( + navController: NavHostController, +) { + SearchScreen( + navController = navController + ) } @Composable -fun SearchScreen() { - var text by remember { mutableStateOf("") } +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, ) - 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, - ) + 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 - ) + 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) + } } -} \ No newline at end of file + +} 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..3c1ebc624 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/searchprocess/SearchProcessRoute.kt @@ -0,0 +1,151 @@ +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 +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/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/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..517508c06 --- /dev/null +++ b/feature/src/main/java/com/terning/feature/searchprocess/navigation/SearchProcessNavigation.kt @@ -0,0 +1,30 @@ +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 +import com.terning.feature.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 : MainTabRoute \ 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 9594d9aa8..54b8f98d8 100644 --- a/feature/src/main/res/values/strings.xml +++ b/feature/src/main/res/values/strings.xml @@ -33,6 +33,14 @@ 지금 조회수가 많은 공고들이에요 지금 스크랩 수가 많은 공고들이에요 + + 검색 + 어떤 공고를\n찾고 계시나요? + 검색 결과 + 검색 결과 없을 때 아이콘 + 와 일치하는 검색 결과가 없어요 + +